Skip to content

Commit 9f7ce0d

Browse files
committed
Add internal setJoystickDirect function
For setting the joystick values without rescaling them first
1 parent 9dde6a6 commit 9f7ce0d

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/XInput.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ void XInputController::setJoystick(XInputControl joy, int32_t x, int32_t y) {
274274
x = rescaleInput(x, *getRangeFromEnum(joy), joyData->range);
275275
y = rescaleInput(y, *getRangeFromEnum(joy), joyData->range);
276276

277+
setJoystickDirect(joy, x, y);
278+
}
279+
280+
void XInputController::setJoystickDirect(XInputControl joy, int16_t x, int16_t y) {
281+
const XInputMap_Joystick * joyData = getJoyFromEnum(joy);
282+
if (joyData == nullptr) return; // Not a joystick
283+
277284
if (getJoystickX(joy) == x && getJoystickY(joy) == y) return; // Joy hasn't changed
278285

279286
tx[joyData->x_low] = lowByte(x);

src/XInput.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class XInputController {
140140
uint8_t tx[20]; // USB transmit data
141141
boolean newData; // Flag for tx data changed
142142
boolean autoSendOption; // Flag for automatically sending data
143+
144+
void setJoystickDirect(XInputControl joy, int16_t x, int16_t y);
143145

144146
void inline autosend() {
145147
if (autoSendOption) { send(); }

0 commit comments

Comments
 (0)