Jump to content
  • Advertisement

Archived

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

smitty1276

DInput... problem detecting keydown...

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

Every example I''ve ever seen checks to see if a key is down like so...
bool IsKeyUp( char key ) { return (m_Keys[key] & 0x80) ? true : false; }
bool IsKeyDown( char key ) { return (m_Keys[key] & 0x80) ? false: true;  }
Of course, if GetDeviceStatus() sets the high bit of the corresponding array element, this is the correct way. I was trying to test my class in a little simple windows program, with this code...
bool bFinished = false;
	while(!bFinished)
	{
		if(Input.IsKeyDown(DIK_RETURN))
			SetWindowText(g_hWnd, "Enter pressed!");

		PeekMessage(&msg, g_hWnd, NULL, NULL, PM_REMOVE);

		if(msg.message == WM_QUIT)
			bFinished = true;
		else
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	return msg.wParam;
}
THE PROBLEM... when I run my program the window text is set to "Enter pressed!" immediately and flickers as its refreshed repeatedly thereafter, even when I''m not pushing any keys. Anyone had this problem or have any ideas why it may be happening? It is very, very frustrating...

Share this post


Link to post
Share on other sites
Advertisement
OK, I''m an idiot... I had the function names backwards... when I switch them it doesn''t set the window title...

but NOW it won''t set the window text even if I *DO* press return.

Any idea why? I''m sure it could just be a win32 problem... am I doing something that would prevent it from setting the window''s caption? Or is it still not reading correctly?

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!