I'm having problems with GetKeyWait. This allows you to check for keys non-blocking. However, when it tells me a key is pressed (KEYREP_KEYEVENT returned), the keycode is not set, just left at zero. This is not what the docs say.
take a look at this code snippet:
[codebox]void mainloop()
{
unsigned int k;
for (;
{
int changed = 0;
int v;
k = 0;
v = GetKeyWait(KEYWAIT_HALTOFF_TIMEROFF, 0, 1, &k); // nonblocking
if (v == KEYREP_KEYEVENT)
{
if (k)
{
// !!! this never happens despite KEYEVENT signal
changed = keyhandler(k);
}
}
else
{
changed = idlehandler();
}
if (changed)
Bdisp_PutDisp_DD();
Sleep(10);
}
}[/codebox]
What happens is that i'm told a key is pressed, but `k' is never set! I'm wondering if there's another call i should make here to actually retrieve the key. note GetKey(&k) is no good because it waits again for another key.
Either i've made a silly mistake or this call is broken. Does anyone know how to inspect the keybuffer another way?
any help most appreciated. thanks,
-- hugh.
Edited by Hugh, 15 February 2009 - 05:30 PM.