MHeironimus / ArduinoJoystickLibrary

An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.
GNU Lesser General Public License v3.0
2.06k stars 403 forks source link

Trying to wrap my head around this #268

Closed Thick8 closed 1 year ago

Thick8 commented 1 year ago

Would it be possible to have a joystick example in addition to the joystick test? I'm trying to gain an understanding of the structure of the basic inputs but am overwhelmed by all the demo code. Just trying to make a flight simulator rudder with brakes, and I'm getting lost. This is as far as I've gotten.

 #include "Joystick.h"

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK, 0, 0, true, true, true, false, false, false, false, false, false, false, false);                 

int xAxis;
int yAxis;
int zAxis;

void setup() {
 //Axis inputs
 Joystick.setXAxis(A0); //Rudder 
 Joystick.setYAxis(A1); //Right brake
 Joystick.setZAxis(A2); //Left brake

 Joystick.begin();
 Joystick.setXAxisRange(-512, 512);
 Joystick.setYAxisRange(0, 1023);
 Joystick.setZAxisRange(0, 1023);
}

void loop() {
}
MHeironimus commented 1 year ago

There are a few examples included in the library in addition to the test scripts. There are some additional examples on the following wiki page: https://github.com/MHeironimus/ArduinoJoystickLibrary/wiki/Examples.