Jump to content
  • Advertisement

Archived

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

omegasyphon

mouse input exception handling error

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

alright i have a problem with my windows handleing code and not sure why. when i debug it it goes to the follow line
    
     	lpdi->CreateDevice(GUID_SysMouse,&lpdimouse,NULL);
  

here are the functions i use for init main shutdown for the mouse input. and the game main where it calls the functions.
      

LPDIRECTINPUTDEVICE lpdimouse	= NULL;
LPDIRECTINPUT		lpdi		= NULL;
DIMOUSESTATE		dimouse;
bool				clickhandle;


HWND main_window_handle = NULL; // save the window handle

HINSTANCE main_instance      = NULL; // globally track hinstance




int initcontrols()
{
DirectInputCreate(main_instance,DIRECTINPUT_VERSION,&lpdi,NULL);
	lpdi->CreateDevice(GUID_SysMouse,&lpdimouse,NULL);
	lpdimouse->SetCooperativeLevel(main_window_handle,DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);
	lpdimouse->SetDataFormat(&c_dfDIMouse);
	lpdimouse->Acquire();
	mstate=1;
	return 0;
}

int mcontrol()
{

	if (lpdimouse->GetDeviceState(sizeof(dimouse),&dimouse ) == DI_OK)
	{
		if (dimouse.rgbButtons[0]	& 0x80)
		{
			if (!clickhandle)
			{
				MessageBeep(0);
				clickhandle = TRUE;
			}
		}
		else
			clickhandle = FALSE;
		bx += dimouse.lX;
		by += dimouse.lY;
	}

	return 0;
}

int killmouse()
{
	// first unacquire the mouse

lpdimouse->Unacquire();

// now release the mouse

lpdimouse->Release();

// release directinput

lpdi->Release();
return 0;
}

void main()
{
	if (mstate==0)
	initcontrols();
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutCreateWindow("game engine console");
	glutReshapeFunc(ChangeSize);
	glutDisplayFunc(renderscene);
	setuprc();
	mcontrol();
	glutMainLoop();
	killmouse();
}

    

Share this post


Link to post
Share on other sites
Advertisement

  • 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!