Keybourdinput (Windows): simultaneosly pressed keys

Тема в разделе "WASM.ENGLISH", создана пользователем CDW, 29 июл 2006.

  1. CDW

    CDW New Member

    Публикаций:
    0
    Регистрация:
    1 мар 2006
    Сообщения:
    5
    Адрес:
    Germany
    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):
    1. StartLoop:
    2.       invoke TranslateMessage, ADDR msg         ; translate any keystrokes
    3.        
    4.        invoke GetAsyncKeyState,VK_SPACE
    5.        test eax, 80000000h    
    6.        lea esi,keystate
    7.        .if eax        
    8.           mov byte ptr [esi+VK_SPACE],TRUE
    9.        .else
    10.             mov byte ptr [esi+VK_SPACE],FALSE
    11.        
    12.        .endif
    13.  
    14. ;   and so on - i cut this piece of code
    15. ;this ist another variation: keystate ist a 256 Byte Buffer  
    16.       comment $
    17.       .if msg.message==WM_KEYDOWN
    18.         lea esi,keystate
    19.        add esi,msg.wParam
    20.         mov byte ptr [esi],TRUE
    21.        
    22.        .elseif msg.message==WM_KEYUP   
    23.         lea esi,keystate
    24.         add esi,msg.wParam
    25.         mov byte ptr [esi],FALSE
    26.       .endif
    27.       $
    28.       invoke DispatchMessage,  ADDR msg         ; dispatch the message to the WndProc
    29.     jumpin:
    30.       invoke GetMessage,ADDR msg,NULL,0,0       ; fill the MSG structure
    31.       test eax, eax                             ; test its return value
    32.       jne StartLoop                             ; loop back if its not ZERO
     
  2. keYMax

    keYMax New Member

    Публикаций:
    0
    Регистрация:
    2 июл 2003
    Сообщения:
    276
    Адрес:
    Новоуральск
    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.