I am making some mini-spaceshooter-game like Galaga. My problem are the simultaneously pressed keys - the controls are: WSAD for ship movement and SPACE for fire. Alternative contorls for ship movement are the arrowkeys. If i am using WSAD and SPACE it is all right - you can "fly" and fire. But with the arrowkeys i have some problems: i can "fly" and fire when pressing UP and RHIGHT (and SPACE of course), but not pressing UP+LEFT oder DOWN+LEFT/RIGHT. Searching google and some forums (win32asm and masm forum) for hours and days, i variate my code - from "GetKeyState" about "GetAsyncKeyState" until processing WM_KEYUP/DOWN in the WinMsgProc. At last, i wanted to use DirectInput and see this example: http://www.wasm.ru/forum/viewtopic.php?id=15166. This small program shows me the pressed keys - and getting the input throught DirectInput. But there i can not press all the keys (the below keys) - so my question: is this DirectInput example correkt and my keyboard is the problem (hardware)? I mean if i use the Control-Key insteat the space-key, it is all right. Using numpadkeys (8,4,5,6 +SPACE) - the same problem. Using numpadkeys (8,4,2,6) works too. or have i some error in reasoning? You can answer me in russian, too - i can read it (but not type it down ) Some code (the Msg Loop): Код (Text): StartLoop: invoke TranslateMessage, ADDR msg ; translate any keystrokes invoke GetAsyncKeyState,VK_SPACE test eax, 80000000h lea esi,keystate .if eax mov byte ptr [esi+VK_SPACE],TRUE .else mov byte ptr [esi+VK_SPACE],FALSE .endif ; and so on - i cut this piece of code ;this ist another variation: keystate ist a 256 Byte Buffer comment $ .if msg.message==WM_KEYDOWN lea esi,keystate add esi,msg.wParam mov byte ptr [esi],TRUE .elseif msg.message==WM_KEYUP lea esi,keystate add esi,msg.wParam mov byte ptr [esi],FALSE .endif $ invoke DispatchMessage, ADDR msg ; dispatch the message to the WndProc jumpin: invoke GetMessage,ADDR msg,NULL,0,0 ; fill the MSG structure test eax, eax ; test its return value jne StartLoop ; loop back if its not ZERO
I almost on 100 % am confident that Dinput example is correct. Different keyboards have hardware restrictions on the certain combinations of keys pressed simultaneously. It is desirable to not use such combinations.