views:

188

answers:

1

Hello Guys,

I am desperately looking for a solution that enables me to read keyboard events in a non blocking way. These Keyboard events are generated by a VIRTUAL KEYBOARD that comes with the WinCE device. I have a console application running in C++, where the user is asked to navigate via 'ESC', 'U' and other characters through the menu. I first tried to use fread and stdin and realised that it is blocking call and waits for a carriage return. Then I tried to hook up to the windows message WM_KEYUP, but I never recieve this windows message. Furthermore I tried to use QtGUI together with the event QKeyEvent, but I never recieve any event. I wonder if it is in general possible to recieve non-blocking keyboard events on a WinCE device. I would be glad if you have any suggestions!

Cheers, Jan

+1  A: 

GetAynchKeyState will read the state of the entire (virtual) keyboard. Alternatively, you can pass a handle to the console to WaitForSingleObject, with timeout of 0 milliseconds. This will always return immediately, but the return value will tell you whether the keyboard has input waiting -- if it returns with the timeout expired, there's not. If it returns WAIT_OBJECT_0, there is input waiting to be read. As yet another alternative, there's also GetNumberOfConsoleInputEvents, which tells you how much input is waiting to be read.

Jerry Coffin