This is Arduino code for making a gamepad using an ATmega32U4- based board.
Tested with an Arduino Pro Micro clone, works out of the box with at least PC (and supposedly PS3).
This fork is made primarily for This not-so-slimbox 3d print project, which you should check out ;)
Why this one instead of jfedor2's?
- Blazing fast!
- On
Arduino Pro Micro 8Mhz @3.3Ventire update loop takes only230 μsie0.230 ms. - Note: you will most likely be bottlenecked by USB update rate (max. 1000 updates a second, ie fastest update time possible is
1ms)
- On
- OOP style: reliable and trivial to extend
- Like the functionality but not the imlementation? Just inherit and override!
- Per-button debouncing with possibility for per-button custom timings
- Just edit respective
DEBOUNCE_BUT_XXXdefinitions with whatever timings you want!
- Just edit respective
- S.O.C.D. (Simultanious Opposing Cordinal Directions) cleaning strategies:
TournamentLegal(default):- left + right = neutral
- up + down = up
AllNeutral:- left + right = neutral
- up + down = neutral
LastInputPriority- left + right = right
- right + left = left
- up + down = down
- down + up = up
None:- No cleaning
- Possibility to add your own as simple or as complex as you'd like!
- D-pad mode switch to make it act as left stick
Switching of S.O.C.D. strategy on the fly
- ATmega32U4- based board (mine was a Arduino Pro Micro clone)
- Arduino IDE or Platform.io plugin for VSCode
- For
Arduino IDE:- rename
main.cppintomain.inoand flash
- rename
- For
Platform.io:- Open directory using Platform.io plugin and flash
Should compile in about 2 seconds with no errors
- By default is
TournamentLegal(resets on every reconnection) - To cycle between types press buttons defined by
SOCD_STRATEGY_CYCLE_BUTTONSPS+Startby default- Order of key presses doesn't matter
- To change button combination for SOCD type cycling:
- Navigate to line
69that says#define SOCD_STRATEGY_CYCLE_BUTTONS &PS, &Start - List the buttons you'd like instead in similar fasion (see comment in code for more info)
- Example new line
69:#define SOCD_STRATEGY_CYCLE_BUTTONS &Select, &Start
- Example new line
- Navigate to line
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Originally forked from jfedor2/gamepad repo, but departed heavliy from it.