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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to wrap my head around this

Thick8 opened this issue · comments

commented

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() {
}
 

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.