Original Post
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...