Skip to content

Commit 36c114a

Browse files
committed
Add releaseAll function
1 parent 531ab66 commit 36c114a

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ setDpad KEYWORD2
2929
setTrigger KEYWORD2
3030
setJoystick KEYWORD2
3131

32+
releaseAll KEYWORD2
33+
3234
# Receive data
3335
getPlayer KEYWORD2
3436
getRumble KEYWORD2

src/XInput.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ void XInputGamepad::setJoystick(XInputControl joy, int16_t x, int16_t y) {
206206
tx[joyData->y_high] = highByte(y);
207207
}
208208

209+
void XInputGamepad::releaseAll() {
210+
const uint8_t offset = 2; // Skip message type and packet size
211+
memset(tx + offset, 0x00, sizeof(tx) - offset); // Clear TX array
212+
}
213+
209214
uint8_t XInputGamepad::getPlayer() const {
210215
return player;
211216
}

src/XInput.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class XInputGamepad {
8585

8686
void setJoystick(XInputControl joy, int16_t x, int16_t y);
8787

88+
void releaseAll();
89+
8890
// Received Data
8991
uint8_t getPlayer() const; // Player # assigned to the controller (0 is unassigned)
9092
uint16_t getRumble() const; // Rumble motors. MSB is large weight, LSB is small

0 commit comments

Comments
 (0)