Skip to content

Commit 48dbca2

Browse files
authored
Flush receive buffer on construction (#50)
On certain platforms this was causing a problem where the library was always one or two packets behind because USB packets were received and buffered by the hardware controller before the library object was constructed and could set its callback. Flushing the receive buffer when the object is constructed appears to solve this issue.
1 parent ee48580 commit 48dbca2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/XInput.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ XInputController::XInputController() :
200200
reset();
201201
#ifdef USB_XINPUT
202202
XInputUSB::setRecvCallback(XInputLib_Receive_Callback);
203+
while(this->receive()); // flush USB OUT buffer
203204
#endif
204205
}
205206

0 commit comments

Comments
 (0)