Archived

This topic is now archived and is closed to further replies.

Buffred mouse, HELP PLZ

This topic is 5046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got buffered mouse code setup and i get no errors but i also get no response to from the mouse it doesn''t move or anything. my variables

LPDIRECTINPUT8       pDInput;
LPDIRECTINPUTDEVICE8 pMouse;
int		     xPos, yPos;
DIDEVICEOBJECTDATA   Mouse_Buffer[10];
DWORD		     numofelements;

 


my setup code

      

if(FAILED(DirectInput8Create(GetModuleHandle(NULL),       
                             DIRECTINPUT_VERSION, 					     IID_IDirectInput8, (VOID**) 
                             &pDInput, NULL))) {

	MessageBox(Window, "DirectInput8Create failed", 
                   "Error", MB_OK);

	}
	
if(FAILED(pDInput->CreateDevice(GUID_SysMouse, &pMouse, NULL))) {

	MessageBox(Window, "CreateDevice mouse failed", "Error",
                   MB_OK);

	}
	
if(FAILED(pMouse->SetDataFormat(&c_dfDIMouse))) {

	MessageBox(Window, "SetDataFormat mouse failed",
                   "Error", MB_OK);
	}

if(FAILED(pMouse->SetCooperativeLevel(Window, DISCL_EXCLUSIVE | 
                                      DISCL_FOREGROUND))) {

	MessageBox(Window, "SetCooperativeLevel mouse failed",
                   "Error", MB_OK);
	}

DIPROPDWORD blah
blah.diph.dwSize		= sizeof(DIPROPDWORD);
blah.diph.dwHeaderSize	= sizeof(DIPROPHEADER);
blah.diph.dwObj			= 0;
blah.diph.dwHow			= DIPH_DEVICE;
blah.dwData				= 10;

if(FAILED(pMouse->SetProperty(DIPROP_BUFFERSIZE, &blah.diph))) {

	MessageBox(Window, "SetPorperty mouse failed", "Error",
                   MB_OK);
	}

if(FAILED(pMouse->Acquire())) { 

	MessageBox(Window, "Acqurie mouse failed", "Error", 
                   MB_OK);
	}



my buffred input code

         

numofelements = 0;

hr = pMouse->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), 
                           Mouse_Buffer, &numofelements, 0);

	if(hr != DI_OK) {
		
		if(hr != DI_BUFFEROVERFLOW) {

		     MessageBox(NULL, "hr != DI_OK or 
                                DI_BUFFEROVERFLOW", "Error", 
                                MB_OK);

		}

	}

	
	for(DWORD i = 0; i < numofelements; i++){

		switch(Mouse_Buffer[i].dwOfs) {

			case DIMOFS_X:
				
				xPos += Mouse_Buffer[i].dwData;				

			case DIMOFS_Y:

				yPos += Mouse_Buffer[i].dwData;

							
		}	

	}

Any info on what I''m doing wrong would be nice

Share this post


Link to post
Share on other sites
I haven''t really worked with the mouse in buffered mode before, but I just want to make sure that you realize since you set the device up in exclusive mode, it will kill the windows mouse cursor while your application is in focus. Use DISCL_NONEXCLUSIVE if you want to keep the normal mouse cursor and still get input.

Also, your code is set up so that it updates your application mouse data whether the GetDeviceData function succeeded or not, you may want to put an else statement after your if(hr != DI_OK). The mouse may become unaquired if the user alt-tabs and you''ll be filling your mouse data with nonsense.

Share this post


Link to post
Share on other sites