File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ XInputGamepad KEYWORD1
1414
1515# Enums
1616XInputControl KEYWORD1
17+ XInputReceiveType KEYWORD1
1718XInputLEDPattern KEYWORD1
1819
1920#######################################
@@ -89,6 +90,10 @@ TRIGGER_RIGHT LITERAL1
8990JOY_LEFT LITERAL1
9091JOY_RIGHT LITERAL1
9192
93+ # USB Receive Packet Types
94+ Rumble LITERAL1
95+ LEDs LITERAL1
96+
9297# LED Patterns
9398Off LITERAL1
9499Blinking LITERAL1
Original file line number Diff line number Diff line change @@ -347,14 +347,16 @@ size_t XInputGamepad::receive() {
347347 // Grab packet and store it in rx array
348348 uint8_t rx[8 ];
349349 size_t bytesRecv = XInputUSB::recv (rx, USB_Timeout);
350+
351+ const uint8_t PacketType = rx[0 ];
350352
351353 // Rumble Packet
352- if ((rx[ 0 ] == 0x00 ) & (rx[ 1 ] == 0x08 ) ) {
354+ if (PacketType == ( uint8_t ) XInputReceiveType::Rumble ) {
353355 rumble[RumbleLeft.bufferIndex ] = rx[RumbleLeft.rxIndex ]; // Big weight (Left grip)
354356 rumble[RumbleRight.bufferIndex ] = rx[RumbleRight.rxIndex ]; // Small weight (Right grip)
355357 }
356358 // LED Packet
357- else if (rx[ 0 ] == 0x01 ) {
359+ else if (PacketType == ( uint8_t ) XInputReceiveType::LEDs ) {
358360 parseLED (rx[2 ]);
359361 }
360362 return bytesRecv;
Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ enum XInputControl {
5151 JOY_RIGHT,
5252};
5353
54+ enum class XInputReceiveType {
55+ Rumble = 0x00 ,
56+ LEDs = 0x01 ,
57+ };
58+
5459enum class XInputLEDPattern {
5560 Off = 0x00 ,
5661 Blinking = 0x01 ,
You can’t perform that action at this time.
0 commit comments