Compare commits
7 commits
master
...
fix/get_re
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4a62ff5f9a | ||
![]() |
56ec2854a8 | ||
![]() |
e52eabe8fa | ||
![]() |
9917211afe | ||
![]() |
eb4793b188 | ||
![]() |
41ccca96b7 | ||
![]() |
d6cc57f0f1 |
1 changed files with 46 additions and 15 deletions
|
@ -73,12 +73,24 @@ static virtual_timer_t keyboard_idle_timer;
|
||||||
static void keyboard_idle_timer_cb(void *arg);
|
static void keyboard_idle_timer_cb(void *arg);
|
||||||
|
|
||||||
report_keyboard_t keyboard_report_sent = {{0}};
|
report_keyboard_t keyboard_report_sent = {{0}};
|
||||||
#ifdef MOUSE_ENABLE
|
report_mouse_t mouse_report_sent = {0};
|
||||||
report_mouse_t mouse_report_blank = {0};
|
|
||||||
#endif /* MOUSE_ENABLE */
|
union {
|
||||||
|
uint8_t report_id;
|
||||||
|
report_keyboard_t keyboard;
|
||||||
#ifdef EXTRAKEY_ENABLE
|
#ifdef EXTRAKEY_ENABLE
|
||||||
uint8_t extra_report_blank[3] = {0};
|
report_extra_t extra;
|
||||||
#endif /* EXTRAKEY_ENABLE */
|
#endif
|
||||||
|
#ifdef MOUSE_ENABLE
|
||||||
|
report_mouse_t mouse;
|
||||||
|
#endif
|
||||||
|
#ifdef DIGITIZER_ENABLE
|
||||||
|
report_digitizer_t digitizer;
|
||||||
|
#endif
|
||||||
|
#ifdef JOYSTICK_ENABLE
|
||||||
|
joystick_report_t joystick;
|
||||||
|
#endif
|
||||||
|
} universal_report_blank = {0};
|
||||||
|
|
||||||
/* ---------------------------------------------------------
|
/* ---------------------------------------------------------
|
||||||
* Descriptors and USB driver objects
|
* Descriptors and USB driver objects
|
||||||
|
@ -103,7 +115,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype
|
||||||
static USBDescriptor desc;
|
static USBDescriptor desc;
|
||||||
uint16_t wValue = ((uint16_t)dtype << 8) | dindex;
|
uint16_t wValue = ((uint16_t)dtype << 8) | dindex;
|
||||||
desc.ud_string = NULL;
|
desc.ud_string = NULL;
|
||||||
desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const) & desc.ud_string);
|
desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const)&desc.ud_string);
|
||||||
if (desc.ud_string == NULL)
|
if (desc.ud_string == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
|
@ -566,20 +578,38 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
|
||||||
switch (usbp->setup[1]) { /* bRequest */
|
switch (usbp->setup[1]) { /* bRequest */
|
||||||
case HID_GET_REPORT:
|
case HID_GET_REPORT:
|
||||||
switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0?) */
|
switch (usbp->setup[4]) { /* LSB(wIndex) (check MSB==0?) */
|
||||||
|
#ifndef KEYBOARD_SHARED_EP
|
||||||
case KEYBOARD_INTERFACE:
|
case KEYBOARD_INTERFACE:
|
||||||
usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent), NULL);
|
usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, KEYBOARD_REPORT_SIZE, NULL);
|
||||||
return TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
|
|
||||||
case MOUSE_INTERFACE:
|
|
||||||
usbSetupTransfer(usbp, (uint8_t *)&mouse_report_blank, sizeof(mouse_report_blank), NULL);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
|
||||||
|
case MOUSE_INTERFACE:
|
||||||
|
usbSetupTransfer(usbp, (uint8_t *)&mouse_report_sent, sizeof(mouse_report_sent), NULL);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef SHARED_EP_ENABLE
|
||||||
|
case SHARED_INTERFACE:
|
||||||
|
# ifdef KEYBOARD_SHARED_EP
|
||||||
|
if (usbp->setup[2] == REPORT_ID_KEYBOARD) {
|
||||||
|
usbSetupTransfer(usbp, (uint8_t *)&keyboard_report_sent, KEYBOARD_REPORT_SIZE, NULL);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# ifdef MOUSE_SHARED_EP
|
||||||
|
if (usbp->setup[2] == REPORT_ID_MOUSE) {
|
||||||
|
usbSetupTransfer(usbp, (uint8_t *)&mouse_report_sent, sizeof(mouse_report_sent), NULL);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif /* SHARED_EP_ENABLE */
|
||||||
default:
|
default:
|
||||||
usbSetupTransfer(usbp, NULL, 0, NULL);
|
universal_report_blank.report_id = usbp->setup[2];
|
||||||
|
usbSetupTransfer(usbp, (uint8_t *)&universal_report_blank, usbp->setup[6], NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -888,6 +918,7 @@ void send_mouse(report_mouse_t *report) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t));
|
usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t));
|
||||||
|
mouse_report_sent = *report;
|
||||||
osalSysUnlock();
|
osalSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue