diff options
Diffstat (limited to 'firmware/usbstack')
-rw-r--r-- | firmware/usbstack/usb_hid.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c index 5885b60e32..885ae4c24a 100644 --- a/firmware/usbstack/usb_hid.c +++ b/firmware/usbstack/usb_hid.c | |||
@@ -785,27 +785,39 @@ bool usb_hid_control_request(struct usb_ctrlrequest *req, unsigned char *dest) | |||
785 | (req->bRequest == USB_HID_SET_IDLE) ? "set idle" : | 785 | (req->bRequest == USB_HID_SET_IDLE) ? "set idle" : |
786 | ((req->bRequest == USB_HID_SET_REPORT) ? "set report" : | 786 | ((req->bRequest == USB_HID_SET_REPORT) ? "set report" : |
787 | ((req->bRequest == USB_HID_GET_REPORT) ? "get report" : ""))); | 787 | ((req->bRequest == USB_HID_GET_REPORT) ? "get report" : ""))); |
788 | |||
789 | int rc; | ||
788 | switch (req->bRequest) | 790 | switch (req->bRequest) |
789 | { | 791 | { |
790 | case USB_HID_SET_REPORT: | 792 | case USB_HID_SET_REPORT: |
791 | if (usb_hid_set_report(req)) | 793 | rc = usb_hid_set_report(req); |
792 | break; | 794 | break; |
793 | case USB_HID_GET_REPORT: | 795 | case USB_HID_GET_REPORT: |
794 | if (usb_hid_get_report(req, &dest)) | 796 | rc = usb_hid_get_report(req, &dest); |
795 | break; | 797 | break; |
796 | case USB_HID_SET_IDLE: | 798 | case USB_HID_SET_IDLE: |
797 | if (dest != orig_dest) | 799 | rc = 0; |
798 | { | 800 | break; |
799 | usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */ | 801 | default: |
800 | usb_drv_send(EP_CONTROL, orig_dest, dest - orig_dest); | 802 | /* all other requests are errors */ |
801 | } | 803 | rc = -1; |
802 | else | 804 | break; |
803 | { | ||
804 | usb_drv_send(EP_CONTROL, NULL, 0); /* ack */ | ||
805 | } | ||
806 | return true; | ||
807 | } | 805 | } |
808 | break; | 806 | |
807 | if(rc != 0) | ||
808 | break; | ||
809 | |||
810 | if (dest != orig_dest) | ||
811 | { | ||
812 | usb_drv_recv(EP_CONTROL, NULL, 0); /* ack */ | ||
813 | usb_drv_send(EP_CONTROL, orig_dest, dest - orig_dest); | ||
814 | } | ||
815 | else | ||
816 | { | ||
817 | usb_drv_send(EP_CONTROL, NULL, 0); /* ack */ | ||
818 | } | ||
819 | |||
820 | return true; | ||
809 | } | 821 | } |
810 | 822 | ||
811 | case USB_TYPE_VENDOR: | 823 | case USB_TYPE_VENDOR: |