feat: add pygame keyboard input with intuitive key bindings#397
feat: add pygame keyboard input with intuitive key bindings#397mrosseel wants to merge 5 commits into
Conversation
When using a pygame display (-fh), capture keyboard events directly in the main event loop instead of relying on PyHotKey/pynput, which cannot access the keyboard on Wayland. Key mapping: - +/= and - for PLUS/MINUS (intuitive, matches the button labels) - Enter/Space/Z for SQUARE (select) - Ctrl+key for ALT_ variants (emulates SQUARE+key on hardware keypad) - Arrow keys, number keys, M for LNG_SQUARE unchanged When pygame display is active with --keyboard local, uses keyboard_none since the main loop handles key capture directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Is that a display keyboard (that shows the keyboard binding in a UI)? I created already some extensive keybindings, see the comment at the top of keyboard_local.py |
hi, no it's not a visualisation, pyhotkey does not work on wayland so I figured a pygame approach to steer the pygame window might be cleaner. I am working on some visualisation though, but that's not something expected to be checked in. |
|
Maybe this fixes my woes with website testing: pyhotkey on Mac delivers keypresses, even if the window is not focused. Hmm, need to look into a null display. |
@jscheidtmann I've just checked in #435 which may be of interest to you! Probably a good base for web testing and includes some shutdown logic |
Extract the pygame key-map construction into a module-level _build_pygame_keymaps() helper so main()'s event loop stays readable. The per-iteration pygame.event.get() poll and the QUIT->KeyboardInterrupt shutdown path are unchanged. Add a comment at the setup site and ADR-0004 explaining why pygame keys are captured in the main process at all: pygame can only read events from the window-owning process and pynput/PyHotKey can't reach the keyboard under Wayland, so the keyboard process stays the no-op keyboard_none. The preceding origin/main merge supplies keyboard_none's bloom_remap arg (from brickbots#435), fixing the crash where main.py passed a 4th arg the branch's keyboard_none didn't accept. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@mrosseel I've merged main into this branch and re-organized the initialization out of the main loop code. I've tested it and its very nice to not have it pickup stray keystrokes when the PyGame window is not focused 🙌 I'm ready to merge this if you are! |
Summary
--keyboard localflagTest plan
--keyboard local --camera debugand verify all key bindings work🤖 Generated with Claude Code