with a reduced set of buttons and axis.
So, I finally went ahead and ported my Joystick code from way back in my Arduino Leonardo Custom Joystick project to recent versions of the Arduino IDE. As a result, it can be added to the Libraries folder and used in any sketch for a fully USB-capable Arduino (such as Leonardo and Due). I am aware of the existing ArduinoJoystickLibrary, but that provides a rather large 'kitchen sink' HID descriptor, whereas this one is intentionally reduced to the number of buttons needed for my projects.
The source for this library is available in the Github project. At present, there are two branches:
- master is the same as the original Arduino Leonardo Joystick project, supporting 2 axis and 10 buttons.
- twobutton is a simplified library for my more recent Arduboy Joystick firmware project, which supports 2 axis and a mere 2 buttons.
The following is a screenshot of the twobutton variant, as it appears in jstest-gtk:
Both branches also include the descriptor source file (basicjoystick.hid), which can be used in the USB HID Descriptor Tool to define other configurations, if needed. The USB web site also has additional information on USB HID devices, which can be of use.