diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 9c3425b4..f8e6f4cf 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -75,6 +75,10 @@ ifeq (yes,$(strip $(NKRO_ENABLE))) OPT_DEFS += -DNKRO_ENABLE endif +ifeq (yes,$(strip $(NKRO_6KRO_ENABLE))) + OPT_DEFS += -DNKRO_6KRO_ENABLE +endif + ifeq (yes,$(strip $(USB_6KRO_ENABLE))) OPT_DEFS += -DUSB_6KRO_ENABLE endif diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index f81877dd..7324bb27 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c @@ -22,7 +22,7 @@ along with this program. If not, see . static inline void add_key_byte(uint8_t code); static inline void del_key_byte(uint8_t code); -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) static inline void add_key_bit(uint8_t code); static inline void del_key_bit(uint8_t code); #endif @@ -75,7 +75,7 @@ void send_keyboard_report(void) { /* key */ void add_key(uint8_t key) { -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) if (keyboard_protocol && keyboard_nkro) { add_key_bit(key); return; @@ -86,7 +86,7 @@ void add_key(uint8_t key) void del_key(uint8_t key) { -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) if (keyboard_protocol && keyboard_nkro) { del_key_bit(key); return; @@ -159,7 +159,7 @@ uint8_t has_anymod(void) uint8_t get_first_key(void) { -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) if (keyboard_protocol && keyboard_nkro) { uint8_t i = 0; for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) @@ -286,7 +286,7 @@ static inline void del_key_byte(uint8_t code) #endif } -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) static inline void add_key_bit(uint8_t code) { if ((code>>3) < KEYBOARD_REPORT_BITS) { diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c index eb06d787..220eb14f 100644 --- a/tmk_core/common/bootmagic.c +++ b/tmk_core/common/bootmagic.c @@ -88,7 +88,7 @@ void bootmagic(void) } eeconfig_write_keymap(keymap_config.raw); -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) keyboard_nkro = keymap_config.nkro; #endif diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 54050bd9..74255736 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -134,7 +134,7 @@ static void command_common_help(void) "e: eeprom\n" #endif -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) "n: NKRO\n" #endif @@ -314,7 +314,7 @@ static bool command_common(uint8_t code) #ifdef COMMAND_ENABLE " COMMAND" #endif -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) " NKRO" #endif #ifdef KEYMAP_SECTION_ENABLE @@ -336,7 +336,7 @@ static bool command_common(uint8_t code) print_val_hex8(host_keyboard_leds()); print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_idle); -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) print_val_hex8(keyboard_nkro); #endif print_val_hex32(timer_read32()); @@ -355,7 +355,7 @@ static bool command_common(uint8_t code) # endif #endif break; -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) case KC_N: clear_keyboard(); //Prevents stuck keys. keyboard_nkro = !keyboard_nkro; diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index 27aa44a2..1f40aa49 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c @@ -23,7 +23,7 @@ along with this program. If not, see . #include "debug.h" -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) bool keyboard_nkro = true; #endif diff --git a/tmk_core/common/host.h b/tmk_core/common/host.h index fefb8141..e1359782 100644 --- a/tmk_core/common/host.h +++ b/tmk_core/common/host.h @@ -28,7 +28,7 @@ along with this program. If not, see . extern "C" { #endif -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) extern bool keyboard_nkro; #endif diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 5f91550a..fcafbd5f 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -94,7 +94,7 @@ along with this program. If not, see . # define KEYBOARD_REPORT_KEYS (KBD2_SIZE - 2) # define KEYBOARD_REPORT_BITS (KBD2_SIZE - 1) -#elif defined(PROTOCOL_LUFA) && defined(NKRO_ENABLE) +#elif defined(PROTOCOL_LUFA) && (defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE)) # include "protocol/lufa/descriptor.h" # define KEYBOARD_REPORT_SIZE NKRO_EPSIZE # define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2) @@ -142,7 +142,7 @@ typedef union { uint8_t reserved; uint8_t keys[KEYBOARD_REPORT_KEYS]; }; -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) struct { uint8_t mods; uint8_t bits[KEYBOARD_REPORT_BITS]; diff --git a/tmk_core/protocol/lufa/descriptor.c b/tmk_core/protocol/lufa/descriptor.c index 77d86e55..1dbaac03 100644 --- a/tmk_core/protocol/lufa/descriptor.c +++ b/tmk_core/protocol/lufa/descriptor.c @@ -46,6 +46,8 @@ ******************************************************************************/ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = { +#ifndef NKRO_ENABLE + /* 6KRO - Boot protocol */ HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ HID_RI_USAGE(8, 0x06), /* Keyboard */ HID_RI_COLLECTION(8, 0x01), /* Application */ @@ -81,17 +83,54 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = HID_RI_REPORT_SIZE(8, 0x08), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), HID_RI_END_COLLECTION(0), +#else + /* NKRO - Report protocol */ + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x06), /* Keyboard */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ + HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ + HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, 0x08), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + + HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ + HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ + HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ + HID_RI_REPORT_COUNT(8, 0x05), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x03), + HID_RI_OUTPUT(8, HID_IOF_CONSTANT), + + HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ + HID_RI_USAGE_MINIMUM(8, 0x00), /* Keyboard 0 */ + HID_RI_USAGE_MAXIMUM(8, (NKRO_EPSIZE-1)*8-1), /* Keyboard Right GUI */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, (NKRO_EPSIZE-1)*8), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_END_COLLECTION(0), +#endif }; -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = { +#ifdef MOUSE_ENABLE HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ HID_RI_USAGE(8, 0x02), /* Mouse */ HID_RI_COLLECTION(8, 0x01), /* Application */ HID_RI_USAGE(8, 0x01), /* Pointer */ HID_RI_COLLECTION(8, 0x00), /* Physical */ + HID_RI_REPORT_ID(8, REPORT_ID_MOUSE), + HID_RI_USAGE_PAGE(8, 0x09), /* Button */ HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */ HID_RI_USAGE_MAXIMUM(8, 0x08), /* Button 8 */ @@ -147,12 +186,9 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0), -}; #endif #ifdef EXTRAKEY_ENABLE -const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = -{ HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ HID_RI_USAGE(8, 0x80), /* System Control */ HID_RI_COLLECTION(8, 0x01), /* Application */ @@ -178,6 +214,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = HID_RI_REPORT_COUNT(8, 1), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), HID_RI_END_COLLECTION(0), +#endif }; #endif @@ -203,7 +240,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = }; #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] = { HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ @@ -322,14 +359,19 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), +#ifdef NKRO_ENABLE + .EndpointSize = NKRO_EPSIZE, + .PollingIntervalMS = 0x01 +#else .EndpointSize = KEYBOARD_EPSIZE, .PollingIntervalMS = 0x0A +#endif }, /* * Mouse */ -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) .Mouse_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -340,8 +382,13 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .TotalEndpoints = 1, .Class = HID_CSCP_HIDClass, +#if defined(MOUSE_ENABLE) .SubClass = HID_CSCP_BootSubclass, .Protocol = HID_CSCP_MouseBootProtocol, +#else + .SubClass = HID_CSCP_NonBootSubclass, + .Protocol = HID_CSCP_NonBootProtocol, +#endif .InterfaceStrIndex = NO_DESCRIPTOR }, @@ -364,49 +411,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = MOUSE_EPSIZE, - .PollingIntervalMS = 0x0A - }, -#endif - - /* - * Extra - */ -#ifdef EXTRAKEY_ENABLE - .Extrakey_Interface = - { - .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - - .InterfaceNumber = EXTRAKEY_INTERFACE, - .AlternateSetting = 0x00, - - .TotalEndpoints = 1, - - .Class = HID_CSCP_HIDClass, - .SubClass = HID_CSCP_NonBootSubclass, - .Protocol = HID_CSCP_NonBootProtocol, - - .InterfaceStrIndex = NO_DESCRIPTOR - }, - - .Extrakey_HID = - { - .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, - - .HIDSpec = VERSION_BCD(1,1,1), - .CountryCode = 0x00, - .TotalReportDescriptors = 1, - .HIDReportType = HID_DTYPE_Report, - .HIDReportLength = sizeof(ExtrakeyReport) - }, - - .Extrakey_INEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM), - .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = EXTRAKEY_EPSIZE, - .PollingIntervalMS = 0x0A + .PollingIntervalMS = 0x01 }, #endif @@ -465,7 +470,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = /* * NKRO */ -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE .NKRO_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -582,25 +587,19 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Address = &ConfigurationDescriptor.Keyboard_HID; Size = sizeof(USB_HID_Descriptor_HID_t); break; -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) case MOUSE_INTERFACE: Address = &ConfigurationDescriptor.Mouse_HID; Size = sizeof(USB_HID_Descriptor_HID_t); break; #endif -#ifdef EXTRAKEY_ENABLE - case EXTRAKEY_INTERFACE: - Address = &ConfigurationDescriptor.Extrakey_HID; - Size = sizeof(USB_HID_Descriptor_HID_t); - break; -#endif #ifdef CONSOLE_ENABLE case CONSOLE_INTERFACE: Address = &ConfigurationDescriptor.Console_HID; Size = sizeof(USB_HID_Descriptor_HID_t); break; #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE case NKRO_INTERFACE: Address = &ConfigurationDescriptor.NKRO_HID; Size = sizeof(USB_HID_Descriptor_HID_t); @@ -614,25 +613,19 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Address = &KeyboardReport; Size = sizeof(KeyboardReport); break; -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) case MOUSE_INTERFACE: Address = &MouseReport; Size = sizeof(MouseReport); break; #endif -#ifdef EXTRAKEY_ENABLE - case EXTRAKEY_INTERFACE: - Address = &ExtrakeyReport; - Size = sizeof(ExtrakeyReport); - break; -#endif #ifdef CONSOLE_ENABLE case CONSOLE_INTERFACE: Address = &ConsoleReport; Size = sizeof(ConsoleReport); break; #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE case NKRO_INTERFACE: Address = &NKROReport; Size = sizeof(NKROReport); diff --git a/tmk_core/protocol/lufa/descriptor.h b/tmk_core/protocol/lufa/descriptor.h index ed58f21e..5c09be30 100644 --- a/tmk_core/protocol/lufa/descriptor.h +++ b/tmk_core/protocol/lufa/descriptor.h @@ -57,20 +57,13 @@ typedef struct USB_HID_Descriptor_HID_t Keyboard_HID; USB_Descriptor_Endpoint_t Keyboard_INEndpoint; -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) // Mouse HID Interface USB_Descriptor_Interface_t Mouse_Interface; USB_HID_Descriptor_HID_t Mouse_HID; USB_Descriptor_Endpoint_t Mouse_INEndpoint; #endif -#ifdef EXTRAKEY_ENABLE - // Extrakey HID Interface - USB_Descriptor_Interface_t Extrakey_Interface; - USB_HID_Descriptor_HID_t Extrakey_HID; - USB_Descriptor_Endpoint_t Extrakey_INEndpoint; -#endif - #ifdef CONSOLE_ENABLE // Console HID Interface USB_Descriptor_Interface_t Console_Interface; @@ -79,7 +72,7 @@ typedef struct USB_Descriptor_Endpoint_t Console_OUTEndpoint; #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE // NKRO HID Interface USB_Descriptor_Interface_t NKRO_Interface; USB_HID_Descriptor_HID_t NKRO_HID; @@ -91,25 +84,19 @@ typedef struct /* index of interface */ #define KEYBOARD_INTERFACE 0 -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) # define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1) #else # define MOUSE_INTERFACE KEYBOARD_INTERFACE #endif -#ifdef EXTRAKEY_ENABLE -# define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1) -#else -# define EXTRAKEY_INTERFACE MOUSE_INTERFACE -#endif - #ifdef CONSOLE_ENABLE -# define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1) +# define CONSOLE_INTERFACE (MOUSE_INTERFACE + 1) #else -# define CONSOLE_INTERFACE EXTRAKEY_INTERFACE +# define CONSOLE_INTERFACE MOUSE_INTERFACE #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE # define NKRO_INTERFACE (CONSOLE_INTERFACE + 1) #else # define NKRO_INTERFACE CONSOLE_INTERFACE @@ -123,26 +110,20 @@ typedef struct // Endopoint number and size #define KEYBOARD_IN_EPNUM 1 -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) # define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1) #else # define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM #endif -#ifdef EXTRAKEY_ENABLE -# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1) -#else -# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM -#endif - #ifdef CONSOLE_ENABLE -# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) -# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1) +# define CONSOLE_IN_EPNUM (MOUSE_IN_EPNUM + 1) +# define CONSOLE_OUT_EPNUM (MOUSE_IN_EPNUM + 1) #else -# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM +# define CONSOLE_OUT_EPNUM MOUSE_IN_EPNUM #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE # define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) #else # define NKRO_IN_EPNUM CONSOLE_OUT_EPNUM @@ -150,13 +131,18 @@ typedef struct /* Check number of endpoints. ATmega32u2 has only four except for control endpoint. */ #if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 -# error "Endpoints are not available enough to support all functions. Disable some of build options in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" +# error "Endpoints are not available enough to support all functions. Disable some of build options in Makefile.(MOUSEKEY, CONSOLE, NKRO)" #endif #define KEYBOARD_EPSIZE 8 + +#if defined(MOUSE_EXT_REPORT) +#define MOUSE_EPSIZE 10 +#else #define MOUSE_EPSIZE 8 -#define EXTRAKEY_EPSIZE 8 +#endif + #define CONSOLE_EPSIZE 32 #define NKRO_EPSIZE 32 diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 54221591..e5077dfb 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -71,6 +71,7 @@ uint8_t keyboard_idle = 0; /* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; +uint8_t mouse_protocol = 1; static uint8_t keyboard_led_stats = 0; static report_keyboard_t keyboard_report_sent; @@ -329,20 +330,19 @@ void EVENT_USB_Device_ConfigurationChanged(void) /* Setup Keyboard HID Report Endpoints */ ConfigSuccess &= ENDPOINT_CONFIG(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, - KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE); +#ifdef NKRO_ENABLE + NKRO_EPSIZE, +#else + KEYBOARD_EPSIZE, +#endif + ENDPOINT_BANK_SINGLE); -#ifdef MOUSE_ENABLE +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) /* Setup Mouse HID Report Endpoint */ ConfigSuccess &= ENDPOINT_CONFIG(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE); #endif -#ifdef EXTRAKEY_ENABLE - /* Setup Extra HID Report Endpoint */ - ConfigSuccess &= ENDPOINT_CONFIG(EXTRAKEY_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, - EXTRAKEY_EPSIZE, ENDPOINT_BANK_SINGLE); -#endif - #ifdef CONSOLE_ENABLE /* Setup Console HID Report Endpoints */ ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, @@ -353,7 +353,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) #endif #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE /* Setup NKRO HID Report Endpoints */ ConfigSuccess &= ENDPOINT_CONFIG(NKRO_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, NKRO_EPSIZE, ENDPOINT_BANK_SINGLE); @@ -414,7 +414,7 @@ void EVENT_USB_Device_ControlRequest(void) // Interface switch (USB_ControlRequest.wIndex) { case KEYBOARD_INTERFACE: -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE case NKRO_INTERFACE: #endif Endpoint_ClearSETUP(); @@ -450,6 +450,13 @@ void EVENT_USB_Device_ControlRequest(void) print("[p]"); #endif } + if (USB_ControlRequest.wIndex == MOUSE_INTERFACE) { + Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(mouse_protocol); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } } break; @@ -466,6 +473,13 @@ void EVENT_USB_Device_ControlRequest(void) print("[P]"); #endif } + if (USB_ControlRequest.wIndex == MOUSE_INTERFACE) { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + mouse_protocol = (USB_ControlRequest.wValue & 0xFF); + clear_keyboard(); + } } break; @@ -515,10 +529,14 @@ static void send_keyboard(report_keyboard_t *report) return; /* Select the Keyboard Report Endpoint */ -#ifdef NKRO_ENABLE +#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE) if (keyboard_protocol && keyboard_nkro) { /* Report protocol - NKRO */ + #if defined(NKRO_6KRO_ENABLE) Endpoint_SelectEndpoint(NKRO_IN_EPNUM); + #else + Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); + #endif /* Check if write ready for a polling interval around 1ms */ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(8); @@ -563,7 +581,14 @@ static void send_mouse(report_mouse_t *report) if (!Endpoint_IsReadWriteAllowed()) return; /* Write Mouse Report Data */ - Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL); + if (mouse_protocol) { + // Report + Endpoint_Write_8(REPORT_ID_MOUSE); + Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL); + } else { + // Boot + Endpoint_Write_Stream_LE(report, 3, NULL); + } /* Finalize the stream transfer to send the last packet */ Endpoint_ClearIN(); @@ -582,7 +607,7 @@ static void send_system(uint16_t data) .report_id = REPORT_ID_SYSTEM, .usage = data - SYSTEM_POWER_DOWN + 1 }; - Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); + Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); /* Check if write ready for a polling interval around 10ms */ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); @@ -605,7 +630,7 @@ static void send_consumer(uint16_t data) .report_id = REPORT_ID_CONSUMER, .usage = data }; - Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); + Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); /* Check if write ready for a polling interval around 10ms */ while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);