|
|
@ -379,7 +379,6 @@ static void set_led_transfer_cb(USBDriver *usbp) {
|
|
|
|
/* Callback for SETUP request on the endpoint 0 (control) */
|
|
|
|
/* Callback for SETUP request on the endpoint 0 (control) */
|
|
|
|
static bool usb_request_hook_cb(USBDriver *usbp) {
|
|
|
|
static bool usb_request_hook_cb(USBDriver *usbp) {
|
|
|
|
const USBDescriptor *dp;
|
|
|
|
const USBDescriptor *dp;
|
|
|
|
int has_report_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* usbp->setup fields:
|
|
|
|
/* usbp->setup fields:
|
|
|
|
* 0: bmRequestType (bitmask)
|
|
|
|
* 0: bmRequestType (bitmask)
|
|
|
@ -432,26 +431,17 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
|
|
|
|
switch (usbp->setup[1]) { /* bRequest */
|
|
|
|
switch (usbp->setup[1]) { /* bRequest */
|
|
|
|
case HID_SET_REPORT:
|
|
|
|
case HID_SET_REPORT:
|
|
|
|
switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0 and wLength==1?) */
|
|
|
|
switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0 and wLength==1?) */
|
|
|
|
case KEYBOARD_INTERFACE:
|
|
|
|
|
|
|
|
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
|
|
|
|
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
|
|
|
|
case SHARED_INTERFACE:
|
|
|
|
case SHARED_INTERFACE:
|
|
|
|
|
|
|
|
usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case KEYBOARD_INTERFACE:
|
|
|
|
/* keyboard_led_stats = <read byte from next OUT report>
|
|
|
|
/* keyboard_led_stats = <read byte from next OUT report>
|
|
|
|
* keyboard_led_stats needs be word (or dword), otherwise we get an exception on F0 */
|
|
|
|
* keyboard_led_stats needs be word (or dword), otherwise we get an exception on F0 */
|
|
|
|
has_report_id = 0;
|
|
|
|
|
|
|
|
#if defined(SHARED_EP_ENABLE)
|
|
|
|
|
|
|
|
if (usbp->setup[4] == SHARED_INTERFACE) {
|
|
|
|
|
|
|
|
has_report_id = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (usbp->setup[4] == KEYBOARD_INTERFACE && !keyboard_protocol) {
|
|
|
|
|
|
|
|
has_report_id = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_report_id) {
|
|
|
|
|
|
|
|
usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL);
|
|
|
|
usbSetupTransfer(usbp, (uint8_t *)&keyboard_led_stats, 1, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|