mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-09 12:50:17 +00:00
Currently the Keyboard _Devices entry on Windows does not report all the key presses and releases. This is due to missing some messages in the form of WM_SYSKEYDOWN and WM_SYSKEYUP. Additionally Windows is weird about report the state of the individual shift keys, so we add some logic using GetAsyncKeyState() to fix that up. Fixes: #333
29 lines
837 B
Text
29 lines
837 B
Text
|
|
Sub emulateScancode(scancode As Integer, isDown As Long)
|
|
Dim kbd As KbdInput
|
|
|
|
kbd.typ = INPUT_TYPE_KEYBOARD
|
|
kbd.scancode = scancode And &H7FFF ' Strip off extended flag
|
|
kbd.flags = KBD_FLAG_SCANCODE
|
|
If isDown = 0 Then kbd.flags = kbd.flags Or KBD_FLAG_UP
|
|
If scancode And &H8000 Then kbd.flags = kbd.flags Or KBD_FLAG_EXTENDED
|
|
|
|
e& = SendInput~&(1, _Offset(kbd), LEN(kbd))
|
|
|
|
If e& <> 1 Then Print "ERROR: e:"; e&; ", GetLastError:"; GetLastError
|
|
_Delay .05
|
|
End Sub
|
|
|
|
Sub emulateVirtualKey(vk As Integer, isDown As Long)
|
|
Dim kbd As KbdInput
|
|
|
|
kbd.typ = INPUT_TYPE_KEYBOARD
|
|
kbd.vk = vk
|
|
If isDown = 0 Then kbd.flags = kbd.flags Or KBD_FLAG_UP
|
|
|
|
e& = SendInput~&(1, _Offset(kbd), LEN(kbd))
|
|
|
|
If e& <> 1 Then Print "ERROR: e:"; e&; ", GetLastError:"; GetLastError
|
|
_Delay .05
|
|
End Sub
|
|
|