diff --git a/src/SingleReport/BootKeyboard.cpp b/src/SingleReport/BootKeyboard.cpp index 05dd7a2..d29b2d8 100644 --- a/src/SingleReport/BootKeyboard.cpp +++ b/src/SingleReport/BootKeyboard.cpp @@ -70,7 +70,7 @@ static const uint8_t _hidReportDescriptorKeyboard[] PROGMEM = { 0xc0 /* END_COLLECTION */ }; -BootKeyboard_::BootKeyboard_(void) : PluggableUSBModule(1, 1, epType), protocol(1), idle(1), leds(0) +BootKeyboard_::BootKeyboard_(void) : PluggableUSBModule(1, 1, epType), protocol(HID_REPORT_PROTOCOL), idle(1), leds(0) { epType[0] = EP_TYPE_INTERRUPT_IN; PluggableUSB().plug(this); @@ -96,6 +96,10 @@ int BootKeyboard_::getDescriptor(USBSetup& setup) // In a HID Class Descriptor wIndex cointains the interface number if (setup.wIndex != pluggedInterface) { return 0; } + // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol + // due to the USB specs, but Windows and Linux just assumes its in report mode. + protocol = HID_REPORT_PROTOCOL; + return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorKeyboard, sizeof(_hidReportDescriptorKeyboard)); } diff --git a/src/SingleReport/BootMouse.cpp b/src/SingleReport/BootMouse.cpp index 470c5cd..27aee63 100644 --- a/src/SingleReport/BootMouse.cpp +++ b/src/SingleReport/BootMouse.cpp @@ -54,7 +54,7 @@ static const uint8_t _hidReportDescriptorMouse[] PROGMEM = { 0xc0 /* END_COLLECTION */ }; -BootMouse_::BootMouse_(void) : PluggableUSBModule(1, 1, epType), protocol(1), idle(1) +BootMouse_::BootMouse_(void) : PluggableUSBModule(1, 1, epType), protocol(HID_REPORT_PROTOCOL), idle(1) { epType[0] = EP_TYPE_INTERRUPT_IN; PluggableUSB().plug(this); @@ -80,6 +80,10 @@ int BootMouse_::getDescriptor(USBSetup& setup) // In a HID Class Descriptor wIndex cointains the interface number if (setup.wIndex != pluggedInterface) { return 0; } + // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol + // due to the USB specs, but Windows and Linux just assumes its in report mode. + protocol = HID_REPORT_PROTOCOL; + return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorMouse, sizeof(_hidReportDescriptorMouse)); } diff --git a/src/SingleReport/RawHID.cpp b/src/SingleReport/RawHID.cpp index 8be96f9..03e854b 100644 --- a/src/SingleReport/RawHID.cpp +++ b/src/SingleReport/RawHID.cpp @@ -47,7 +47,7 @@ static const uint8_t _hidReportDescriptorRawHID[] PROGMEM = { 0xC0 /* end collection */ }; -RawHID_::RawHID_(void) : PluggableUSBModule(1, 1, epType), protocol(1), idle(1), dataLength(0) +RawHID_::RawHID_(void) : PluggableUSBModule(1, 1, epType), protocol(HID_REPORT_PROTOCOL), idle(1), dataLength(0) { epType[0] = EP_TYPE_INTERRUPT_IN; PluggableUSB().plug(this); @@ -75,6 +75,10 @@ int RawHID_::getDescriptor(USBSetup& setup) // In a HID Class Descriptor wIndex cointains the interface number if (setup.wIndex != pluggedInterface) { return 0; } + // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol + // due to the USB specs, but Windows and Linux just assumes its in report mode. + protocol = HID_REPORT_PROTOCOL; + return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorRawHID, sizeof(_hidReportDescriptorRawHID)); } diff --git a/src/SingleReport/SingleGamepad.cpp b/src/SingleReport/SingleGamepad.cpp index 0791f42..acb86de 100644 --- a/src/SingleReport/SingleGamepad.cpp +++ b/src/SingleReport/SingleGamepad.cpp @@ -70,7 +70,7 @@ static const uint8_t _hidReportDescriptorGamepad[] PROGMEM = { 0xc0 /* END_COLLECTION */ }; -SingleGamepad_::SingleGamepad_(void) : PluggableUSBModule(1, 1, epType), protocol(1), idle(1) +SingleGamepad_::SingleGamepad_(void) : PluggableUSBModule(1, 1, epType), protocol(HID_REPORT_PROTOCOL), idle(1) { epType[0] = EP_TYPE_INTERRUPT_IN; PluggableUSB().plug(this); @@ -96,6 +96,10 @@ int SingleGamepad_::getDescriptor(USBSetup& setup) // In a HID Class Descriptor wIndex cointains the interface number if (setup.wIndex != pluggedInterface) { return 0; } + // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol + // due to the USB specs, but Windows and Linux just assumes its in report mode. + protocol = HID_REPORT_PROTOCOL; + return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorGamepad, sizeof(_hidReportDescriptorGamepad)); } diff --git a/src/SingleReport/SingleNKROKeyboard.cpp b/src/SingleReport/SingleNKROKeyboard.cpp index f88118c..bfb37a6 100644 --- a/src/SingleReport/SingleNKROKeyboard.cpp +++ b/src/SingleReport/SingleNKROKeyboard.cpp @@ -75,7 +75,7 @@ static const uint8_t _hidReportDescriptorNKRO[] PROGMEM = { 0xC0 /* End Collection */ }; -SingleNKROKeyboard_::SingleNKROKeyboard_(void) : PluggableUSBModule(1, 1, epType), protocol(1), idle(1), leds(0) +SingleNKROKeyboard_::SingleNKROKeyboard_(void) : PluggableUSBModule(1, 1, epType), protocol(HID_REPORT_PROTOCOL), idle(1), leds(0) { epType[0] = EP_TYPE_INTERRUPT_IN; PluggableUSB().plug(this); @@ -101,6 +101,10 @@ int SingleNKROKeyboard_::getDescriptor(USBSetup& setup) // In a HID Class Descriptor wIndex cointains the interface number if (setup.wIndex != pluggedInterface) { return 0; } + // Reset the protocol on reenumeration. Normally the host should not assume the state of the protocol + // due to the USB specs, but Windows and Linux just assumes its in report mode. + protocol = HID_REPORT_PROTOCOL; + return USB_SendControl(TRANSFER_PGM, _hidReportDescriptorNKRO, sizeof(_hidReportDescriptorNKRO)); }