This repository contains the firmware for a custom Sim-Racing Buttonbox, built on an Arduino Leonardo (ATmega32u4).
The device presents itself to the PC as a USB keyboard (HID) and maps physical buttons and rotary encoders to configurable keyboard actions for different racing games.
The firmware includes:
- ➡️ 24 physical buttons (matrix-based)
- 🔄 4 rotary encoders
- 🖥️ 128×64 SSD1306 OLED display
- 🎮 Multiple game profiles (e.g., ACC, F1 23)
- 💾 Persistent profile storage via EEPROM
- ⌨️ Keyboard emulation via USB (Keyboard.h)
- Each supported game has its own configuration header (e.g.,
acc.h,f1_23.h) - Every profile defines:
- 24 button functions
- 4 encoder functions
- Switching games updates both the functional mappings and the OLED display.
Each of the four rotary encoders can trigger different actions depending on direction:
- Increase/Decrease in-game settings
- Navigate menus
- Operate MFD elements
Using the native USB capabilities of the Leonardo:
- Sends standard keys (
KEY_LEFT_ARROW,KEY_RIGHT_CTRL, …) - Supports key combinations
- Supports press/release logic and toggles
- Shows startup information
- Displays the currently selected game profile
- Acts as visual feedback layer for interactions (optional extension)
- Remembers last selected profile across reboots
Adding a new game only requires:
- New
<game>.hingame_configs/ - Adding it to the registration tables in
ButtonFunctions.h - Optional OLED naming update
Create a file in src/game_configs/<your_game>.h
Define:
namespace YourGame { void Button_1(); ... void Button_24(); void Encoder_1(Direction dir); ... void Encoder_4(Direction dir); }
Register your functions in ButtonFunctions.h
GAMES[] = { "Assetto Corsa Competizione", "F1 23", "Your Game" };
Add your mapping to:
buttonNamespaces[]
encoderNamespaces[]
Done. No other code changes required.
CC BY-NC-ND 4.0 DEED Attribution-NonCommercial-NoDerivs 4.0 International