Joystick HID API for Arduino.
Go to file
2021-12-22 22:08:26 +00:00
example Add the ability to use a custom delay time for button presses. 2021-12-22 22:07:57 +00:00
.gitignore Rename variables for clarity, fix enumeration bug. 2021-11-01 22:09:11 +00:00
Button.cpp Add the ability to use a custom delay time for button presses. 2021-12-22 22:07:57 +00:00
Button.h Add the ability to use a custom delay time for button presses. 2021-12-22 22:07:57 +00:00
Joystick.cpp Add the ability to use a custom delay time for button presses. 2021-12-22 22:07:57 +00:00
Joystick.h Change default delay to 50 ms 2021-12-22 22:08:26 +00:00
Matrix.cpp Fix pulsed buttons and remove unnecessary delay from matrix buttons. 2021-11-24 16:39:00 +00:00
Matrix.h Bug fixes. 2021-11-24 05:40:28 +00:00
Reader.cpp Another bugfix, improve header documentation a bit. 2021-11-24 05:57:41 +00:00
Reader.h Rework example code, fix bugs and get to compiling state. Also introduce missing logic for the Matrix code to keep track of what column is active. 2021-11-22 20:10:08 +00:00
Readme.md Update documentation. 2021-11-24 06:04:21 +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.

Compiling and running the example code via SimulIDE

  1. Run make from the example directory.
  2. Load example.simu in SimulIDE.
  3. Right-click on the Arduino component, and click "load firmware". Select the .hex file created in the example/ directory.
  4. Click the red Power Circuit icon at the top of the SimulIDE window.

Usage

  1. In your arduino sketch, add the include: #include <Joystick.h>
  2. Create a Joystick object: Joystick joystick(true);
  3. Add buttons and axes in setup() with the Add* functions from Joystick.h. Call joystick.Update() in your loop() function. Also call joystick.Init() during setup().
  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, matrices

If you need more buttons than your board has pins, this library supports keyboard-style scan matrices as well as multiplexers. (FIXME: multiplexers aren't working yet) See the example sketch in the example/ directory for usage details. Note that, for matrices, the rows are the inputs that will be read, and the columns are the outputs that will sink the current. Current should flow (via diodes) from the rows to the columns. See the example.simu SimulIDE file for an example circuit.