Skip to content

Commit 7e0aa6b

Browse files
committed
Separate X and Y for setJoystickDirect
Minor change, but prevents rewriting both axes if only one changes
1 parent 4613ca7 commit 7e0aa6b

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/XInput.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,18 @@ void XInputController::setJoystickDirect(XInputControl joy, int16_t x, int16_t y
341341
const XInputMap_Joystick * joyData = getJoyFromEnum(joy);
342342
if (joyData == nullptr) return; // Not a joystick
343343

344-
if (getJoystickX(joy) == x && getJoystickY(joy) == y) return; // Joy hasn't changed
345-
346-
tx[joyData->x_low] = lowByte(x);
347-
tx[joyData->x_high] = highByte(x);
344+
if (getJoystickX(joy) != x) {
345+
tx[joyData->x_low] = lowByte(x);
346+
tx[joyData->x_high] = highByte(x);
347+
newData = true;
348+
}
348349

349-
tx[joyData->y_low] = lowByte(y);
350-
tx[joyData->y_high] = highByte(y);
350+
if (getJoystickY(joy) != y) {
351+
tx[joyData->y_low] = lowByte(y);
352+
tx[joyData->y_high] = highByte(y);
353+
newData = true;
354+
}
351355

352-
newData = true;
353356
autosend();
354357
}
355358

0 commit comments

Comments
 (0)