Using GetDeviceState

Started by
-1 comments, last by ManaStone 22 years, 3 months ago
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
-----------------------------Download my real time 3D RPG.

This topic is closed to new replies.

Advertisement