Skip to content

Commit febc212

Browse files
committed
Add update function to PedalsJoystick
Matching the layout of the ShiftJoystick example, this only sends the Joystick USB packet if the pedals have actually changed position. This should avoid issues with the pedals "spamming" inputs and stealing a game's input priority even when they're constantly 0.
1 parent 3eb0f29 commit febc212

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

examples/Pedals/PedalsJoystick/PedalsJoystick.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ void setup() {
6666
void loop() {
6767
pedals.update();
6868

69+
if (pedals.positionChanged()) {
70+
updatePedals();
71+
}
72+
}
73+
74+
void updatePedals() {
6975
if (pedals.hasPedal(SimRacing::Gas)) {
7076
int gasPedal = pedals.getPosition(SimRacing::Gas, 0, ADC_Max);
7177
Joystick.setRyAxis(gasPedal);

0 commit comments

Comments
 (0)