Archived

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

Using GetDeviceState

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

I wrote a function to process direct input for the keyboard. But when I tried to check if the escape key was down it would always go through the condition as if it was down. Then I tried adding the ! operator to it and it did the same thing. Then I went to check to see if GetDeviceState FAILED or not and when I tested it, it apparently failed because it went through the condition. But then I replaced FAILED with SUCCEEDED and it also apparently succeeded because it still went through the condition. I don’t understand. How can it succeed and fail at the same time? Here is the function I ended up with. What did I do wrong. VOID KBProcess() { #define KEYDOWN(name, key) (name[key] & 0x80) DWORD buffer[256]; if((FAILED(g_lpkeyboard->GetDeviceState(sizeof(buffer),(LPVOID)&buffer))); { MessageBox(hWnd,"blah","df",MB_OK); PostMessage(hWnd,WM_DESTROY,0,0); } if((KEYDOWN(buffer,DIK_ESCAPE)) { //MessageBox(hWnd,"blah","df",MB_OK); //PostMessage(hWnd,WM_DESTROY,0,0); } } Edited by - ManaStone on January 3, 2002 1:59:11 PM

Share this post


Link to post
Share on other sites