joystick_keys
eventsys.joystick_keys ¶
Optional eventsys mapper: joystick hat/buttons → held key-code state.
JoystickKeys is not a :class:~eventsys.JoystickDevice and not a keypad.
It does not poll hardware, enqueue events, or synthesize KEYDOWN /
KEYUP. It subscribes to a :class:~eventsys.Runtime and updates an internal
held-key map from JOYHATMOTION / JOYBUTTON* using a joymap.
Import explicitly (not loaded by import eventsys)::
from eventsys.joystick_keys import JoystickKeys
from eventsys import Keys
joymap = {
1: { # joystick instance_id
"hats": {
# hat index → [left, right, down, up] key codes
0: [Keys.K_LEFT, Keys.K_RIGHT, Keys.K_DOWN, Keys.K_UP],
},
"buttons": {
0: Keys.K_RETURN,
1: Keys.K_d,
2: Keys.K_f,
},
}
}
joy = JoystickKeys(runtime, joymap)
while True:
runtime.poll()
if held := joy.read():
print(held)