fix(input): keys are physical positions on every layout; Input.key_label names them
The Windows runtime keyed the held set by the character MapVirtualKeyA gave a virtual key, so a game's WASD belonged to whatever the active layout put there, and with an input method on every letter arrived as VK_PROCESSKEY. The typing block is now read from the scancode (the arrows, numpad and F-keys still by virtual key); macOS reads keyCode the same way. Input.key_label(key) names a key in the player's own layout (Windows) or as its US character elsewhere. Verified on Windows with SendInput into a live window: VK_Z carrying W's scancode holds 'w', VK_PROCESSKEY carrying A's holds 'a', Caps Lock changes nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2a2f463d5b
commit
619476ffed
14 changed files with 60552 additions and 60168 deletions
24
examples/library/input_key_label.ludic
Normal file
24
examples/library/input_key_label.ludic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# input_key_label.ludic — the name a player sees for a key. Letters, digits and
|
||||
# punctuation are physical positions named for the US layout; headless the label is that
|
||||
# character upper case, and the named keys and arrows are words. An unnamed code is "".
|
||||
#
|
||||
# Deterministic; a full run prints: W A ; 1 Space Esc Shift Left Right 0 1
|
||||
program InputKeyLabel {
|
||||
function bi(b: bool) -> int { if b { return 1 }; return 0 }
|
||||
|
||||
entry {
|
||||
print(Input.key_label('w'))
|
||||
print(Input.key_label('a'))
|
||||
print(Input.key_label(';'))
|
||||
print(Input.key_label('1'))
|
||||
print(Input.key_label(32))
|
||||
print(Input.key_label(27))
|
||||
print(Input.key_label(16))
|
||||
print(Input.key_label(Key.Left))
|
||||
print(Input.key_label(Key.Right))
|
||||
print(len(Input.key_label(200)))
|
||||
Input.press('a')
|
||||
Input.poll()
|
||||
print(bi(Input.key_down('a'))) # the held set is unchanged by naming
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue