diff options
Diffstat (limited to 'tmk_core/protocol')
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index d7d2227687..3502d9e644 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -48,16 +48,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 48 | # include "os_detection.h" | 48 | # include "os_detection.h" |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | #define NEXT_INTERFACE __COUNTER__ | ||
| 52 | |||
| 53 | /* | 51 | /* |
| 54 | * Interface indexes | 52 | * Interface indexes |
| 55 | */ | 53 | */ |
| 56 | enum usb_interfaces { | 54 | enum usb_interfaces { |
| 57 | #ifndef KEYBOARD_SHARED_EP | 55 | #ifndef KEYBOARD_SHARED_EP |
| 58 | KEYBOARD_INTERFACE = NEXT_INTERFACE, | 56 | KEYBOARD_INTERFACE, |
| 59 | #else | 57 | #else |
| 60 | SHARED_INTERFACE = NEXT_INTERFACE, | 58 | SHARED_INTERFACE, |
| 61 | # define KEYBOARD_INTERFACE SHARED_INTERFACE | 59 | # define KEYBOARD_INTERFACE SHARED_INTERFACE |
| 62 | #endif | 60 | #endif |
| 63 | 61 | ||
| @@ -65,32 +63,30 @@ enum usb_interfaces { | |||
| 65 | // interface number, to support Linux/OSX platforms and chrome.hid | 63 | // interface number, to support Linux/OSX platforms and chrome.hid |
| 66 | // If Raw HID is enabled, let it be always 1. | 64 | // If Raw HID is enabled, let it be always 1. |
| 67 | #ifdef RAW_ENABLE | 65 | #ifdef RAW_ENABLE |
| 68 | RAW_INTERFACE = NEXT_INTERFACE, | 66 | RAW_INTERFACE, |
| 69 | #endif | 67 | #endif |
| 70 | 68 | ||
| 71 | #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) | 69 | #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP) |
| 72 | SHARED_INTERFACE = NEXT_INTERFACE, | 70 | SHARED_INTERFACE, |
| 73 | #endif | 71 | #endif |
| 74 | 72 | ||
| 75 | #ifdef CONSOLE_ENABLE | 73 | #ifdef CONSOLE_ENABLE |
| 76 | CONSOLE_INTERFACE = NEXT_INTERFACE, | 74 | CONSOLE_INTERFACE, |
| 77 | #endif | 75 | #endif |
| 78 | 76 | ||
| 79 | TOTAL_INTERFACES = NEXT_INTERFACE | 77 | TOTAL_INTERFACES |
| 80 | }; | 78 | }; |
| 81 | 79 | ||
| 82 | #define MAX_INTERFACES 3 | 80 | #define MAX_INTERFACES 3 |
| 83 | 81 | ||
| 84 | #if (NEXT_INTERFACE - 1) > MAX_INTERFACES | 82 | _Static_assert(TOTAL_INTERFACES <= MAX_INTERFACES, "There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console."); |
| 85 | # error There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console | ||
| 86 | #endif | ||
| 87 | 83 | ||
| 88 | #if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE | 84 | #if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE |
| 89 | # error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two. | 85 | # error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two. |
| 90 | #endif | 86 | #endif |
| 91 | 87 | ||
| 92 | static uint8_t keyboard_led_state = 0; | 88 | static uint8_t keyboard_led_state = 0; |
| 93 | static uint8_t vusb_idle_rate = 0; | 89 | uint8_t keyboard_idle = 0; |
| 94 | uint8_t keyboard_protocol = 1; | 90 | uint8_t keyboard_protocol = 1; |
| 95 | 91 | ||
| 96 | /* Keyboard report send buffer */ | 92 | /* Keyboard report send buffer */ |
| @@ -335,7 +331,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
| 335 | break; | 331 | break; |
| 336 | case USBRQ_HID_GET_IDLE: | 332 | case USBRQ_HID_GET_IDLE: |
| 337 | dprint("GET_IDLE:"); | 333 | dprint("GET_IDLE:"); |
| 338 | usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate; | 334 | usbMsgPtr = (usbMsgPtr_t)&keyboard_idle; |
| 339 | return 1; | 335 | return 1; |
| 340 | case USBRQ_HID_GET_PROTOCOL: | 336 | case USBRQ_HID_GET_PROTOCOL: |
| 341 | dprint("GET_PROTOCOL:"); | 337 | dprint("GET_PROTOCOL:"); |
| @@ -351,8 +347,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { | |||
| 351 | } | 347 | } |
| 352 | return USB_NO_MSG; // to get data in usbFunctionWrite | 348 | return USB_NO_MSG; // to get data in usbFunctionWrite |
| 353 | case USBRQ_HID_SET_IDLE: | 349 | case USBRQ_HID_SET_IDLE: |
| 354 | vusb_idle_rate = rq->wValue.bytes[1]; | 350 | keyboard_idle = (rq->wValue.word & 0xFF00) >> 8; |
| 355 | dprintf("SET_IDLE: %02X", vusb_idle_rate); | 351 | dprintf("SET_IDLE: %02X", keyboard_idle); |
| 356 | break; | 352 | break; |
| 357 | case USBRQ_HID_SET_PROTOCOL: | 353 | case USBRQ_HID_SET_PROTOCOL: |
| 358 | if (rq->wIndex.word == KEYBOARD_INTERFACE) { | 354 | if (rq->wIndex.word == KEYBOARD_INTERFACE) { |
| @@ -1044,7 +1040,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 1044 | #endif | 1040 | #endif |
| 1045 | break; | 1041 | break; |
| 1046 | case USBDESCR_HID: | 1042 | case USBDESCR_HID: |
| 1047 | switch (rq->wValue.bytes[0]) { | 1043 | switch (rq->wIndex.word) { |
| 1048 | #ifndef KEYBOARD_SHARED_EP | 1044 | #ifndef KEYBOARD_SHARED_EP |
| 1049 | case KEYBOARD_INTERFACE: | 1045 | case KEYBOARD_INTERFACE: |
| 1050 | usbMsgPtr = (usbMsgPtr_t)&usbConfigurationDescriptor.keyboardHID; | 1046 | usbMsgPtr = (usbMsgPtr_t)&usbConfigurationDescriptor.keyboardHID; |
