X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=protocol%2Fpjrc%2Fusb.c;h=1e6ba8719a2a124ef687e63916bc30dd037df120;hb=c1ac7f159f12626aaef68e6caab0423b6bd00114;hp=a9fbc4638efbedb8a07ee14c512343f090891df3;hpb=969cc4f812e3f86213f97adf340e3c7160fc639e;p=max%2Ftmk_keyboard.git diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index a9fbc463..1e6ba871 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c @@ -31,10 +31,15 @@ #include "usb_mouse.h" #include "usb_debug.h" #include "usb_extra.h" +#include "led.h" #include "print.h" #include "util.h" +#ifdef SLEEP_LED_ENABLE #include "sleep_led.h" +#endif #include "suspend.h" +#include "action.h" +#include "action_util.h" /************************************************************************** @@ -102,7 +107,11 @@ static const uint8_t PROGMEM endpoint_config_table[] = { #else 0, // 2 #endif +#ifdef CONSOLE_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3 +#else + 0, +#endif #ifdef EXTRAKEY_ENABLE 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 #else @@ -331,8 +340,12 @@ static const uint8_t PROGMEM extra_hid_report_desc[] = { # define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 0) #endif +#ifdef CONSOLE_ENABLE #define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 1) #define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*DEBUG_HID_DESC_NUM+9) +#else +# define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 0) +#endif #ifdef EXTRAKEY_ENABLE # define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 1) @@ -423,6 +436,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = { 1, // bInterval #endif +#ifdef CONSOLE_ENABLE // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 9, // bLength 4, // bDescriptorType @@ -449,6 +463,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = { 0x03, // bmAttributes (0x03=intr) DEBUG_TX_SIZE, 0, // wMaxPacketSize 1, // bInterval +#endif #ifdef EXTRAKEY_ENABLE // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 @@ -552,8 +567,10 @@ static const struct descriptor_list_struct { {0x2100, MOUSE_INTERFACE, config1_descriptor+MOUSE_HID_DESC_OFFSET, 9}, {0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)}, #endif +#ifdef CONSOLE_ENABLE {0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9}, {0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)}, +#endif #ifdef EXTRAKEY_ENABLE {0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9}, {0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)}, @@ -612,6 +629,7 @@ uint8_t usb_configured(void) void usb_remote_wakeup(void) { UDCON |= (1<mods; UEDATX = 0; - uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6; + uint8_t keys = keyboard_protocol ? KBD_REPORT_KEYS : 6; for (uint8_t i=0; ikeys[i]; } @@ -884,13 +903,13 @@ ISR(USB_COM_vect) } if (bRequest == HID_GET_IDLE) { usb_wait_in_ready(); - UEDATX = usb_keyboard_idle_config; + UEDATX = keyboard_idle; usb_send_in(); return; } if (bRequest == HID_GET_PROTOCOL) { usb_wait_in_ready(); - UEDATX = usb_keyboard_protocol; + UEDATX = keyboard_protocol; usb_send_in(); return; } @@ -904,14 +923,18 @@ ISR(USB_COM_vect) return; } if (bRequest == HID_SET_IDLE) { - usb_keyboard_idle_config = (wValue >> 8); + keyboard_idle = (wValue >> 8); usb_keyboard_idle_count = 0; //usb_wait_in_ready(); usb_send_in(); return; } if (bRequest == HID_SET_PROTOCOL) { - usb_keyboard_protocol = wValue; + keyboard_protocol = wValue; +#ifdef NKRO_ENABLE + keyboard_nkro = !!keyboard_protocol; +#endif + clear_keyboard(); //usb_wait_in_ready(); usb_send_in(); return;