Joystick HID API for Arduino.
Go to file
2021-11-13 22:48:12 +00:00
examples Refactor code substantially, moving buttons into separate classes and using a lot more pointers to conserve memory until it is needed. 2021-11-08 01:37:30 +00:00
.gitignore Rename variables for clarity, fix enumeration bug. 2021-11-01 22:09:11 +00:00
Button.cpp For pulsed buttons, implement per-button 'timers' that independently end the pulse instead of having a 250ms delay between every single update... 2021-11-13 22:48:12 +00:00
Button.h For pulsed buttons, implement per-button 'timers' that independently end the pulse instead of having a 250ms delay between every single update... 2021-11-13 22:48:12 +00:00
Joystick.cpp For pulsed buttons, implement per-button 'timers' that independently end the pulse instead of having a 250ms delay between every single update... 2021-11-13 22:48:12 +00:00
Joystick.h For pulsed buttons, implement per-button 'timers' that independently end the pulse instead of having a 250ms delay between every single update... 2021-11-13 22:48:12 +00:00
Readme.md Fix compile-time errors, which necessitated some refactoring of the interface. 2021-11-02 23:17:25 +00:00

Arduino Joystick library

This is a library that builds and sends USB HID Joystick reports, making it easy to build USB Joysticks with Arduino.

Dependencies

Installation

  1. Install dependencies as above, or if using arduino-cli, with: arduino-cli lib install Bounce2 arduino-cli lib install "Analog-Digital Multiplexers"
  2. Put the arduino-joystick directory into your Arduino libraries directory.

Usage

  1. In your arduino sketch, add the includes: #include <Joystick.h>
  2. Create a Joystick object: Joystick joystick(true);
  3. Add buttons and axes in setup() with Joystick::AddButton(), and call Joystick::Update() in loop().
  4. Upload the sketch, connect to the serial monitor (at 115200 baud) and test the buttons.
  5. Set the joystick's debug parameter to false and re-upload the sketch. The arduino will NOT work in joystick mode with debug set to true!
  6. Flash the arduino-big-joystick firmware onto the USB Controller.

Advanced usage: multiplexers

If you need more buttons than your board has pins, multiplexers (such as this one and this one) are a popular solution. This library supports multiplexers! To use them, you need to do some extra work.

Call the AddMux() method and pass it the pins the multiplexer is connected to. You'll need to #include <Mux.h> to access admux::Pinset. AddMux() will return a mux_id for subsequently passing to AddButton(). The pin parameter for all multiplexed buttons should be the same as the multiplexer's signal_pin.