diff --git a/Downstream/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c b/Downstream/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c index 19e6bea..557cc9f 100644 --- a/Downstream/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c +++ b/Downstream/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c @@ -614,7 +614,7 @@ USBH_StatusTypeDef USBH_HID_SetProtocol(USBH_HandleTypeDef *phost, phost->Control.setup.b.bRequest = USB_HID_SET_PROTOCOL; - phost->Control.setup.b.wValue.w = protocol != 0 ? 0 : 1; + phost->Control.setup.b.wValue.w = protocol == 0 ? 0 : 1; phost->Control.setup.b.wIndex.w = 0; phost->Control.setup.b.wLength.w = 0; diff --git a/Downstream/Src/downstream_hid.c b/Downstream/Src/downstream_hid.c index 9dd42dd..67dee40 100644 --- a/Downstream/Src/downstream_hid.c +++ b/Downstream/Src/downstream_hid.c @@ -17,8 +17,9 @@ -#define HID_MOUSE_DATA_LEN 4 -#define HID_KEYBOARD_DATA_LEN 0 +#define HID_REPORT_DATA_LEN 8 +#define HID_MOUSE_DATA_LEN 3 +#define HID_KEYBOARD_DATA_LEN 0 extern USBH_HandleTypeDef hUsbHostFS; //Hard-link ourselves to usb_host.c @@ -32,7 +33,7 @@ InterfaceCommandClassTypeDef Downstream_HID_ApproveConnectedDevice(void) if (HID_Handle->Protocol == HID_MOUSE_BOOT_CODE) { - if (HID_Handle->length == 8) + if ((HID_Handle->length >= HID_MOUSE_DATA_LEN) && (HID_Handle->length <= HID_REPORT_DATA_LEN)) { return COMMAND_CLASS_HID_MOUSE; } diff --git a/Upstream/Src/upstream_hid.c b/Upstream/Src/upstream_hid.c index 56212d6..3835fcd 100644 --- a/Upstream/Src/upstream_hid.c +++ b/Upstream/Src/upstream_hid.c @@ -17,8 +17,8 @@ #define HID_REPORT_DATA_LEN 8 -#define HID_MOUSE_DATA_LEN 4 - +#define HID_MOUSE_DATA_LEN 3 +#define HID_KEYBOARD_DATA_LEN 0 UpstreamPacketTypeDef* UpstreamHidPacket = NULL; @@ -138,7 +138,7 @@ void Upstream_HID_GetNextReportReceiveCallback(UpstreamPacketTypeDef* receivedPa return; } - for (i = dataLength; i > HID_REPORT_DATA_LEN; i++) + for (i = dataLength; i < HID_REPORT_DATA_LEN; i++) { receivedPacket->Data[i] = 0; //Zero out unused bytes before we send report upstream }