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


Using GetDeviceState

Recommended Posts

ManaStone    148
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