This is the code I use on the left hand joystick/mouse/keyboard from Lynx Workshop I printed and built.
Many props to him for such a great idea and the wonderful design. I use this controller for most of my gaming sessions now!
On the hardware level, the only thing I changed was adding simple diodes on the matrix to eliminate ghosting and support pressing multiple keys simultaneously.
I started from the original template from Lynx Workshop, but I suppose there is not much left from it. However I reused most of the logic from the excellent Arduino Keypad library.
The 3 buttons under the pinky finger are dedicated to switching modes. One click on one of these buttons select the related emulation mode (Keyboard, Joystick, Mouse) or switch key mapping if this mode is already active.
TODO / WIP:
- Keyboard emulation
- Joystick emulation
- Mouse emulation
- Add assembly pictures (showing diodes and my poor soldering skills)
- Implement scroll wheel using joystick (and modifier key) and maybe prev/next buttons