Primary Method: pygame -> ANSI -> SSH PTY Bridge
Status: PROVEN - Fully operational on RG via
herms_sdl_client.py
The herms_sdl_client.py (29,936 bytes, 877 lines)
running on RG40XXV captures gamepad input via pygame and converts it to
ANSI escape sequences, then sends them through an SSH PTY connection to
a remote herm process.
Architecture
RG40XXV Gamepad Input
↓ (evdev events)
pygame.JOYBUTTONDOWN / JOYHATMOTION / JOYAXISMOTION
↓ (button mapping)
ANSI Escape Sequences (e.g., \r, \x1b, \x1b[A, etc.)
↓ (PTY write)
SSH Connection to mehdifarah@192.168.1.46
↓
Remote herm Process (receives input as if typed locally)
Button Mappings (from herms_sdl_client.py lines 608-617)
| Gamepad Button | ANSI Sequence | Action |
|---|---|---|
| BTN_A | \r (Carriage Return) |
Enter/Confirm |
| BTN_B | \x1b (Escape) |
Escape/Back |
| BTN_X | (Space) |
Space |
| BTN_Y | \x7f (DEL) |
Backspace |
| BTN_L1 | \t (Tab) |
Tab |
| BTN_R1 | F2 key sequence | Function key |
| BTN_SELECT | F11 key sequence | Select |
| BTN_START | F12 key sequence | Start |
| D-pad UP | \x1b[A |
ANSI Up |
| D-pad DOWN | \x1b[B |
ANSI Down |
| D-pad RIGHT | \x1b[C |
ANSI Right |
| D-pad LEFT | \x1b[D |
ANSI Left |
Analog Stick Injection (lines 789-803)
- Joystick axis 0/1 (left stick) with thresholds at ±0.55
- Triggers direction sequences (
\x1b[A,\x1b[B,\x1b[C,\x1b[D) at 0.16s intervals - Provides smooth directional input
SSH Target
- Primary:
mehdifarah@192.168.1.46(LAN IP) - SSH Server: dropbear (confirmed from logs)
- RTT: ~10ms
- Connection: Persistent PTY session
Input Latency
- Gamepad event to ANSI conversion: <1ms
- SSH round-trip: ~10ms
- Total input latency: ~10-15ms