diff options
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r-- | cores/arduino/USBCore.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 8794250..f2a2365 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -360,6 +360,9 @@ void InitEndpoints() UERST = 0x7E; // Reset endpoints UERST = 0; // End reset + + SetEP(XINPUT_RX_ENDPOINT); // Select XInput RX endpoint (OUT) + UEIENX |= (1 << RXOUTE); // Enable received "OUT" interrupt } static int _cmark; @@ -506,9 +509,17 @@ bool SendDescriptor(USBSetup& setup) return true; } -// Endpoint 0 interrupt +// Endpoint interrupt ISR(USB_COM_vect) { + SetEP(XINPUT_RX_ENDPOINT); // Select XInput RX endpoint (OUT) + if (UEINTX & (1 << RXOUTI)) { // If data received... + UEINTX &= ~(1 << RXOUTI); // Clear interrupt flag + if (XInputUSB::RecvCallback != nullptr) { + XInputUSB::RecvCallback(); // Call callback function if it exists + } + } + SetEP(0); if (!ReceivedSetupInt()) return; |