Jump to content
  • Advertisement


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


Buffred mouse, HELP PLZ

This topic is 5355 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

int		     xPos, yPos;
DWORD		     numofelements;


my setup code


                             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",

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);

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",

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

	MessageBox(Window, "Acqurie mouse failed", "Error", 

my buffred input code


numofelements = 0;

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

	if(hr != DI_OK) {

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



	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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!