Created
June 26, 2021 20:57
-
-
Save RazerMoon/dd1112c660545814fee68667d8427c8a to your computer and use it in GitHub Desktop.
FSX custom throttle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Joystick.h" | |
// https://github.com/MHeironimus/ArduinoJoystickLibrary | |
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, | |
JOYSTICK_TYPE_GAMEPAD, 0, 0, // first no. is how many button there are | |
false , false, false, false, false, false, | |
true, true, false, false, false); | |
int throttle = A0; | |
int rudder = A1; | |
int throttleValue = 0; | |
int rudderValue = 0; | |
int prevrudValue = 0; | |
int prevthroValue = 0; | |
int sens = 5; | |
// init joystick libary | |
void setup() { | |
Joystick.begin(); | |
} | |
void loop() { | |
throttleValue = analogRead(throttle); | |
rudderValue = analogRead(rudder); | |
if (abs(throttleValue - prevthroValue) > sens) { | |
Joystick.setThrottle(throttleValue); | |
prevthroValue = throttleValue; | |
} | |
if (abs(rudderValue - prevrudValue) > sens) { | |
Joystick.setRudder(rudderValue); | |
prevrudValue = rudderValue; | |
} | |
delay(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment