diff --git a/tmk_core/protocol/lufa/descriptor.c b/tmk_core/protocol/lufa/descriptor.c index 77d86e55..0f188e29 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,6 +83,40 @@ 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 @@ -203,7 +239,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,8 +358,13 @@ 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 }, /* @@ -465,7 +506,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}, @@ -600,7 +641,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 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); @@ -632,7 +673,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 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..c7fa4ec1 100644 --- a/tmk_core/protocol/lufa/descriptor.h +++ b/tmk_core/protocol/lufa/descriptor.h @@ -79,7 +79,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; @@ -109,7 +109,7 @@ typedef struct # define CONSOLE_INTERFACE EXTRAKEY_INTERFACE #endif -#ifdef NKRO_ENABLE +#ifdef NKRO_6KRO_ENABLE # define NKRO_INTERFACE (CONSOLE_INTERFACE + 1) #else # define NKRO_INTERFACE CONSOLE_INTERFACE @@ -142,7 +142,7 @@ typedef struct # define CONSOLE_OUT_EPNUM EXTRAKEY_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 diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 54221591..2db0d6f1 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -329,7 +329,12 @@ 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 /* Setup Mouse HID Report Endpoint */ @@ -353,7 +358,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 +419,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(); @@ -515,10 +520,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);