GetAsyncKeyState and x64 compiler
Posted: Wed Jul 08, 2015 8:58 pm
EDIT:
Solved, I was originally using Integers when I should have been using Words.
[Original Post]
I have a procedure for collecting key strokes which seems to work correctly on the 5.3(x86) compiler.
Sadly, on the 64 compiler it won't return any key releases.
I have very little knowledge when it comes to windows api.
So, I'm hoping someone can enlighten me on the proper way of collecting keystrokes using GetAsyncKeyState on the 86 and 64 compilers.
Any help is very much appreciated.
Solved, I was originally using Integers when I should have been using Words.
[Original Post]
I have a procedure for collecting key strokes which seems to work correctly on the 5.3(x86) compiler.
Sadly, on the 64 compiler it won't return any key releases.
I have very little knowledge when it comes to windows api.
So, I'm hoping someone can enlighten me on the proper way of collecting keystrokes using GetAsyncKeyState on the 86 and 64 compilers.
Any help is very much appreciated.
Code: Select all
Structure KeyData
OldKey.w
NewKey.w
EndStructure
Global.KeyData KEY_KeyA
#KEY_KeyA_UP = 1
#KEY_KeyA_DOWN = 2
Declare KEY_KeyboardButton(WindowHandle.i, Type.i)
If OpenWindow(0, 0, 0, 400, 300, "A Key Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
If KEY_KeyboardButton(0, #KEY_KeyA_DOWN) = #True
Debug "Down"
EndIf
If KEY_KeyboardButton(0, #KEY_KeyA_UP) = #True
Debug "Up"
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
Procedure KEY_KeyboardButton(WindowHandle.i, Type.i)
If WindowHandle >= 0
If GetActiveWindow() <> WindowHandle
ProcedureReturn #False
EndIf
EndIf
Select Type
Case #KEY_KeyA_DOWN
KEY_KeyA\NewKey = GetAsyncKeyState_(#VK_A) & 32768
If KEY_KeyA\NewKey <> 0
KEY_KeyA\OldKey = KEY_KeyA\NewKey
ProcedureReturn #True
EndIf
Case #KEY_KeyA_UP
KEY_KeyA\NewKey = GetAsyncKeyState_(#VK_A)
If KEY_KeyA\OldKey <> 0 And KEY_KeyA\NewKey = 0
KEY_KeyA\OldKey = 0
ProcedureReturn #True
EndIf
EndSelect
ProcedureReturn #False
EndProcedure