diff --git a/Readme.md b/Readme.md index 3fcddc2..c3c92da 100644 --- a/Readme.md +++ b/Readme.md @@ -37,7 +37,7 @@ Use the [online Wiki](https://github.com/NicoHood/HID/wiki) to get the newest do * Download an offline version in [releases](https://github.com/NicoHood/HID/releases). It's a snapshot of the current stable release but might have missed some updates that the current master branch has included. This also includes an offline version of the wiki. Offline versions will be available after some time when the official release is out. -* Select [branch 'dev'](https://github.com/NicoHood/HID/tree/dev) to test the bleeding edge of this software. It might now work at all or has a lot of debugging stuff in it. +* Select [branch 'dev'](https://github.com/NicoHood/HID/tree/dev) to test the bleeding edge of this software. It might not work at all or has a lot of debugging stuff in it. If the dev version gets near to a new release a note will be placed here, that you can test the new dev beta. Currently there is no beta available. diff --git a/src/ImprovedKeyboard.cpp b/src/ImprovedKeyboard.cpp index df912d4..ba0f32b 100644 --- a/src/ImprovedKeyboard.cpp +++ b/src/ImprovedKeyboard.cpp @@ -116,7 +116,7 @@ void Keyboard_::send_now(void){ } #if defined(HID_KEYBOARD_LEDS_ENABLED) -void Keyboard_::setReportData(const void* data, uint8_t len){ +void Keyboard_::setReportData(void* &data, uint16_t len){ // Save led state if(len == 2) leds = *(uint8_t*)(data+1); diff --git a/src/ImprovedKeyboard.h b/src/ImprovedKeyboard.h index 496b9a6..efa2538 100644 --- a/src/ImprovedKeyboard.h +++ b/src/ImprovedKeyboard.h @@ -56,7 +56,7 @@ private: HID_KeyboardReport_Data_t _keyReport; void sendReport(HID_KeyboardReport_Data_t* keys); #if defined(HID_KEYBOARD_LEDS_ENABLED) - virtual void setReportData(const void* data, uint8_t len); + virtual void setReportData(void* &data, uint16_t len); uint8_t leds; #endif public: diff --git a/src/NKROKeyboard.cpp b/src/NKROKeyboard.cpp index 83a72f7..8dbd3e0 100644 --- a/src/NKROKeyboard.cpp +++ b/src/NKROKeyboard.cpp @@ -121,7 +121,7 @@ void NKROKeyboard_::send_now(void){ } #if defined(HID_KEYBOARD_LEDS_ENABLED) -void NKROKeyboard_::setReportData(const void* data, uint8_t len){ +void NKROKeyboard_::setReportData(void* &data, uint16_t len){ // Save led state if(len == 2) leds = *(uint8_t*)(data+1); diff --git a/src/NKROKeyboard.h b/src/NKROKeyboard.h index 0efb7ba..c5c960d 100644 --- a/src/NKROKeyboard.h +++ b/src/NKROKeyboard.h @@ -56,7 +56,7 @@ protected: HID_NKROKeyboardReport_Data_t _keyReport; void sendReport(HID_NKROKeyboardReport_Data_t* keys); #if defined(HID_KEYBOARD_LEDS_ENABLED) - virtual void setReportData(const void* data, uint8_t len); + virtual void setReportData(void* &data, uint16_t len); uint8_t leds; #endif public: diff --git a/src/PluggableHID/HID.cpp b/src/PluggableHID/HID.cpp index 6291416..97a9292 100644 --- a/src/PluggableHID/HID.cpp +++ b/src/PluggableHID/HID.cpp @@ -169,11 +169,22 @@ bool HID_::HID_Setup(USBSetup& setup, u8 i) // Get the data length information and the corresponding bytes // Assuming the host will never send more than 255 bytes uint8_t length = setup.wLength; - uint8_t data[length]; - USB_RecvControl(data, length); + void* data = malloc(length); + if(data){ + uint8_t recvLength = length; + //TODO loop can be improved maybe? Or does the compiler do this already? + while(recvLength > USB_EP_SIZE){ + USB_RecvControl(data + (length - recvLength), USB_EP_SIZE); + recvLength -= USB_EP_SIZE; + } + USB_RecvControl(data + (length - recvLength), recvLength); - // Data may contain the report ID again (Keyboard), maybe not (RawHID) - current->setReportData(data, length); + // Data may contain the report ID again (Keyboard), maybe not (RawHID) + current->setReportData(data, length); + } + + // Release data if the pointer still exists + free(data); // Dont search any further break; diff --git a/src/PluggableHID/HIDDevice.cpp b/src/PluggableHID/HIDDevice.cpp index f971f6d..926af13 100644 --- a/src/PluggableHID/HIDDevice.cpp +++ b/src/PluggableHID/HIDDevice.cpp @@ -20,7 +20,7 @@ void HIDDevice::SendRawReport(const void* data, int len){ HID.SendReport(HID_REPORTID_NONE, data, len); } -void HIDDevice::setReportData(const void* data, uint8_t len){ +void HIDDevice::setReportData(void* &data, uint16_t len){ // Discard this information if its not implemented by the HIDDevice } diff --git a/src/PluggableHID/HIDDevice.h b/src/PluggableHID/HIDDevice.h index 62f78ec..3997673 100644 --- a/src/PluggableHID/HIDDevice.h +++ b/src/PluggableHID/HIDDevice.h @@ -49,7 +49,7 @@ public: const uint16_t descriptorLength; const uint8_t reportID; - virtual void setReportData(const void* data, uint8_t len); + virtual void setReportData(void* &data, uint16_t len); protected: // Could be used and inherited public for custom, professional usage, like raw Keyboard diff --git a/src/TeensyKeyboard.cpp b/src/TeensyKeyboard.cpp index 992df32..05c9552 100644 --- a/src/TeensyKeyboard.cpp +++ b/src/TeensyKeyboard.cpp @@ -30,7 +30,7 @@ HIDDevice((uint8_t*)teensykeyboard_hid_report_desc, sizeof(teensykeyboard_hid_re } #if defined(HID_KEYBOARD_LEDS_ENABLED) -void usb_keyboard_class::setReportData(const void* data, uint8_t len){ +void usb_keyboard_class::setReportData(void* &data, uint16_t len){ // Save led state if(len == 2) leds = *(uint8_t*)(data+1); diff --git a/src/TeensyKeyboard.h b/src/TeensyKeyboard.h index 3db7299..e71ef2f 100644 --- a/src/TeensyKeyboard.h +++ b/src/TeensyKeyboard.h @@ -128,7 +128,7 @@ class usb_keyboard_class : public Print, private HIDDevice uint8_t keyboard_report_data[8]; #if defined(HID_KEYBOARD_LEDS_ENABLED) - virtual void setReportData(const void* data, uint8_t len); + virtual void setReportData(void* &data, uint16_t len); uint8_t leds; #endif };