Jump to content



Photo
- - - - -

Problem With Getkeywait


  • Please log in to reply
2 replies to this topic

#1 Hugh

Hugh

    Newbie

  • Members
  • Pip
  • 9 posts
  • Location:London, uk

  • Calculators:
    fx-9860g slim

Posted 15 February 2009 - 05:26 PM

Hi,

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.


#2 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 17 February 2009 - 11:54 PM

Hello,

You can try using the keyboard functions in Revolution-FX: http://sourceforge.n...s/revolution-fx & http://revolution-fx.sourceforge.net. It's pretty quick (and easy to use!) if speed is what you need as they communicate directly with the hardware.

#3 Hugh

Hugh

    Newbie

  • Members
  • Pip
  • 9 posts
  • Location:London, uk

  • Calculators:
    fx-9860g slim

Posted 19 February 2009 - 02:12 AM

Hi,

Thanks for your reply. I will download the revolution code and take a look.

cheers,
-- hugh.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users