Jump to content
  • Advertisement
Sign in to follow this  
chessgeek

DirectInput Keyboard Errors

This topic is 3585 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'm making an expandable engine that keeps giving me errors when I input a key code into it.
void GetKeys(UCHAR* KeyState)
{
	dinkeyboard->Acquire();
	
	dinkeyboard->GetDeviceState(sizeof(UCHAR[256]), (LPVOID)keystate);

	for(int Index = 0; Index < 256; Index++)
		*(KeyState + Index) &= 0x80;

	return;
}

	if (GetKeys(DIK_ESCAPE) & 0x80)
	{
		PostMessage(hWnd, WM_DESTROY, 0, 0);
	}


those are obviously in separate .cpp files. However it keeps giving me an error that states: error C2664: 'GetKeys' : cannot convert parameter 1 from 'int' to 'UCHAR *'

Share this post


Link to post
Share on other sites
Advertisement
1. Your GetKeys function takes a keyboard state as a parameter, but you're passing in a single character.
2. What is your keystate variable declared as? It has different case from KeyState, and is a different variable.
3. PostMessage() is not the correct way to destroy your window for a large number of reasons. The best case is that your code crashes on your machine. The worst case is that your code crashes on some future version of Windows which doesn't expect you to be breaking things in that way. The correct thing to do is to call DestroyWindow().
4. As rip-off said, DirectInput for keyboard input is a brilliant way of wasting hours of your life, infuriating users, and stopping your app from running correctly on any keyboard layout apart from the one you happen to be using.

Share this post


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

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