Skip to content

feat: add pygame keyboard input with intuitive key bindings#397

Open
mrosseel wants to merge 1 commit intobrickbots:mainfrom
mrosseel:feature/pygame-keymap
Open

feat: add pygame keyboard input with intuitive key bindings#397
mrosseel wants to merge 1 commit intobrickbots:mainfrom
mrosseel:feature/pygame-keymap

Conversation

@mrosseel
Copy link
Collaborator

Summary

  • Add pygame-based keyboard input support for development/testing without hardware keypad
  • Map intuitive key bindings (arrow keys, enter, escape, etc.) to PiFinder button events
  • Enable with --keyboard local flag

Test plan

  • Run with --keyboard local --camera debug and verify all key bindings work
  • Verify no impact when using hardware keypad (default mode)

🤖 Generated with Claude Code

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>
@jscheidtmann
Copy link
Collaborator

jscheidtmann commented Mar 17, 2026

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

@mrosseel
Copy link
Collaborator Author

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.

@jscheidtmann
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants