Advertisement Jump to content
Sign in to follow this  
akira32

MFC project with DirectInput

This topic is 3829 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 create a MFC project in VS2008. And I want to use DirectInput in this project. But I met a problem of Unepected error encountered when I SetCooperativeLevel in keyboard and mouse. Can MFC project use the DirectInput? I should use what value of SetCooperativeLevel for keyboard and mouse.
void DirectInput::DirectInputInit(HINSTANCE AppInstance,HWND hWnd)
{
	ZeroMemory(mKeyboardState, sizeof(mKeyboardState));
	ZeroMemory(&mMouseState, sizeof(mMouseState));

	HR(DirectInput8Create(AfxGetInstanceHandle(), DIRECTINPUT_VERSION, 
		IID_IDirectInput8, (void**)&mDInput, 0));

	HR(mDInput->CreateDevice(GUID_SysKeyboard, &mKeyboard, 0));
	HR(mKeyboard->SetDataFormat(&c_dfDIKeyboard));
	HR(mKeyboard->SetCooperativeLevel(m_hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND));
	HR(mKeyboard->Acquire());

	HR(mDInput->CreateDevice(GUID_SysMouse, &mMouse, 0));
	HR(mMouse->SetDataFormat(&c_dfDIMouse2));
	HR(mMouse->SetCooperativeLevel(m_hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND));
	HR(mMouse->Acquire());
}
[Edited by - akira32 on July 29, 2008 2:32:52 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!