ArduinoGamepad
A GamePad HID library for Arduino Pro Micro/Leonardo (ATMega32u4)
Install / Use
/learn @gamelaster/ArduinoGamepadREADME
ArduinoGamepad
A GamePad HID library for Arduino Pro Micro/Leonardo (ATMega32u4) This library works only on Arduino IDE 1.6.6 or higher!
How to install
Create a new directory named "Gamepad" in Documents > Arduino > libraries, and copy all files from repository into that directory
How to make a Gamepad
http://www.instructables.com/id/Arduino-LeonardoMicroATMega32u4-As-GamepadGame-Con/
Small example
//Including a library
#include <Gamepad.h>
//Initializing a Gamepad
Gamepad gp;
int buttonIndex = 0;
bool setState = true;
void setup() {
}
void loop() {
gp.setButtonState(buttonIndex++, setState);
if(buttonIndex == 16)
{
setState = !setState; //negate the value
buttonIndex = 0;
}
delay(500);
}
How to test gamepad
- Just try a game what supports a normal GamePad (not X360, if you want to play game whats support only X360, use X360CE)
- Or use a Windows Devices "Tester" (where is option to calibrate a GamePad, but I recommending a Arduinos calibration in example project): Go to Control Panel > Devices and Printers and search your device (for me its a Arduino Leonardo) > Right click > Settings of game device > Properties > Test
Functions reference
Gamepad(bool useZRx = false)
Initializing a USB HID Descriptor
booleanuseZRx (defaultfalse): Z is used to represent the right stick’s X axis, Rx is used to represent the right stick’s Y axis. This doesn’t make sense but this is how most existing USB game pads work. I have tested this using Battlefield Bad Company 2, it works. SOURCE
sendUpdate()
Sending a update report, its not needed to use, its executed automatically
setButtonState(uint8_t button, bool state)
Setting a Button State
uint8_tbutton - Number of button (0 - 15), Button #1 is 0, Button #2 is 1 etc...boolstate -trueis pressed,falseis released
setLeftXaxis(uint8_t axis)
Setting an "axis" for Left Thumbstick X Axis
uint8_taxis - a value from -127 to 127, when 0 means center (you must format a values from real Thumbsticks to this ranges)
setLeftYaxis(uint8_t axis)
Setting an "axis" for Left Thumbstick Y Axis
uint8_taxis - a value from -127 to 127, when 0 means center (you must format a values from real Thumbsticks to this ranges)
setRightXaxis(uint8_t axis)
Setting an "axis" for Right Thumbstick X Axis
uint8_taxis - a value from -127 to 127, when 0 means center (you must format a values from real Thumbsticks to this ranges)
setRightYaxis(uint8_t axis)
Setting an "axis" for Right Thumbstick Y Axis
uint8_taxis - a value from -127 to 127, when 0 means center (you must format a values from real Thumbsticks to this ranges)
Related Skills
node-connect
338.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.4kCommit, push, and open a PR
