summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2020-02-25 12:18:11 +1100
committerDrashna Jael're <drashna@live.com>2020-03-26 00:42:13 -0700
commitebb243aacee704cf5bbb63b65439c06703ba5bc1 (patch)
tree4a3df9e767d1497e07baa99147fbc8af30b05208
parentf4b460c20042b1d04abab1931f81513ac0031c37 (diff)
Improvements to extrakey HID descriptors (#8156)
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c1
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_conf.h4
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c56
-rw-r--r--tmk_core/protocol/chibios/usb_main.c20
-rw-r--r--tmk_core/protocol/lufa/lufa.c2
-rw-r--r--tmk_core/protocol/usb_descriptor.c16
-rw-r--r--tmk_core/protocol/vusb/vusb.c55
7 files changed, 87 insertions, 67 deletions
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index 9c8073dd9e..e952a427ef 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -130,7 +130,6 @@ void send_extra(uint8_t report_id, uint16_t data) {
void send_system(uint16_t data) {
#ifdef EXTRAKEY_ENABLE
- if (data != 0) data = data - SYSTEM_POWER_DOWN + 1;
send_extra(REPORT_ID_SYSTEM, data);
#endif // EXTRAKEY_ENABLE
}
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
index f22f5003ab..80556205f2 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
@@ -327,7 +327,7 @@ typedef struct {
} udi_hid_exk_desc_t;
typedef struct {
- uint8_t array[54];
+ uint8_t array[50];
} udi_hid_exk_report_desc_t;
# define UDI_HID_EXK_DESC \
@@ -429,7 +429,7 @@ typedef struct {
} udi_hid_raw_desc_t;
typedef struct {
- uint8_t array[27];
+ uint8_t array[26];
} udi_hid_raw_report_desc_t;
# define UDI_HID_RAW_DESC \
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
index c3952d50c8..45a432678b 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
@@ -373,35 +373,33 @@ static uint8_t udi_hid_exk_report_trans[UDI_HID_EXK_REPORT_SIZE];
COMPILER_WORD_ALIGNED
UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{
- // System Control Collection (8 bits)
-
- 0x05, 0x01, // Usage Page (Generic Desktop),
- 0x09, 0x80, // Usage (System Control),
- 0xA1, 0x01, // Collection (Application),
- 0x85, REPORT_ID_SYSTEM, // Report ID (2) (System),
- 0x16, 0x01, 0x00, // Logical Minimum (1),
- 0x26, 0x03, 0x00, // Logical Maximum (3),
- 0x1A, 0x81, 0x00, // Usage Minimum (81) (System Power Down),
- 0x2A, 0x83, 0x00, // Usage Maximum (83) (System Wake Up),
- 0x75, 0x10, // Report Size (16),
- 0x95, 0x01, // Report Count (1),
- 0x81, 0x00, // Input (Data, Array),
- 0xC0, // End Collection - System Control
-
- // Consumer Control Collection - Media Keys (16 bits)
-
- 0x05, 0x0C, // Usage Page (Consumer),
- 0x09, 0x01, // Usage (Consumer Control),
- 0xA1, 0x01, // Collection (Application),
- 0x85, REPORT_ID_CONSUMER, // Report ID (3) (Consumer),
- 0x16, 0x01, 0x00, // Logical Minimum (1),
- 0x26, 0x9C, 0x02, // Logical Maximum (668),
- 0x1A, 0x01, 0x00, // Usage Minimum (1),
- 0x2A, 0x9C, 0x02, // Usage Maximum (668),
- 0x75, 0x10, // Report Size (16),
- 0x95, 0x01, // Report Count (1),
- 0x81, 0x00, // Input (Data, Array),
- 0xC0, // End Collection - Consumer Control
+ // clang-format off
+ 0x05, 0x01, // Usage Page (Generic Desktop)
+ 0x09, 0x80, // Usage (System Control)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_SYSTEM, // Report ID
+ 0x19, 0x01, // Usage Minimum (Pointer)
+ 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xB7, 0x00, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0xC0, // End Collection
+
+ 0x05, 0x0C, // Usage Page (Consumer)
+ 0x09, 0x01, // Usage (Consumer Control)
+ 0xA1, 0x01, // Collection (Application)
+ 0x85, REPORT_ID_CONSUMER, // Report ID
+ 0x19, 0x01, // Usage Minimum (Consumer Control)
+ 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xA0, 0x02, // Logical Maximum
+ 0x95, 0x01, // Report Count (1)
+ 0x75, 0x10, // Report Size (16)
+ 0x81, 0x00, // Input (Data, Array, Absolute)
+ 0xC0 // End Collection
+ //clang-format on
}};
static bool udi_hid_exk_setreport(void);
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index e05c4c5055..6192baa4d2 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -783,7 +783,7 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) {
*/
#ifdef EXTRAKEY_ENABLE
-static void send_extra_report(uint8_t report_id, uint16_t data) {
+static void send_extra(uint8_t report_id, uint16_t data) {
osalSysLock();
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
osalSysUnlock();
@@ -795,15 +795,19 @@ static void send_extra_report(uint8_t report_id, uint16_t data) {
usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t));
osalSysUnlock();
}
+#endif
-void send_system(uint16_t data) { send_extra_report(REPORT_ID_SYSTEM, data); }
-
-void send_consumer(uint16_t data) { send_extra_report(REPORT_ID_CONSUMER, data); }
+void send_system(uint16_t data) {
+#ifdef EXTRAKEY_ENABLE
+ send_extra(REPORT_ID_SYSTEM, data);
+#endif
+}
-#else /* EXTRAKEY_ENABLE */
-void send_system(uint16_t data) { (void)data; }
-void send_consumer(uint16_t data) { (void)data; }
-#endif /* EXTRAKEY_ENABLE */
+void send_consumer(uint16_t data) {
+#ifdef EXTRAKEY_ENABLE
+ send_extra(REPORT_ID_CONSUMER, data);
+#endif
+}
/* ---------------------------------------------------------
* Console functions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 5059d78ae9..9ab1b8ae90 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -802,7 +802,7 @@ static void send_extra(uint8_t report_id, uint16_t data) {
*/
static void send_system(uint16_t data) {
#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1);
+ send_extra(REPORT_ID_SYSTEM, data);
#endif
}
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index c49edd2c3b..a03c318ca5 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -169,10 +169,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
HID_RI_USAGE(8, 0x80), // System Control
HID_RI_COLLECTION(8, 0x01), // Application
HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
- HID_RI_USAGE_MINIMUM(16, 0x0081), // System Power Down
- HID_RI_USAGE_MAXIMUM(16, 0x0083), // System Wake Up
- HID_RI_LOGICAL_MINIMUM(16, 0x0001),
- HID_RI_LOGICAL_MAXIMUM(16, 0x0003),
+ HID_RI_USAGE_MINIMUM(8, 0x01), // Pointer
+ HID_RI_USAGE_MAXIMUM(16, 0x00B7), // System Display LCD Autoscale
+ HID_RI_LOGICAL_MINIMUM(8, 0x01),
+ HID_RI_LOGICAL_MAXIMUM(16, 0x00B7),
HID_RI_REPORT_COUNT(8, 1),
HID_RI_REPORT_SIZE(8, 16),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
@@ -182,10 +182,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
HID_RI_USAGE(8, 0x01), // Consumer Control
HID_RI_COLLECTION(8, 0x01), // Application
HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER),
- HID_RI_USAGE_MINIMUM(16, 0x0001), // Consumer Control
- HID_RI_USAGE_MAXIMUM(16, 0x029C), // AC Distribute Vertically
- HID_RI_LOGICAL_MINIMUM(16, 0x0001),
- HID_RI_LOGICAL_MAXIMUM(16, 0x029C),
+ HID_RI_USAGE_MINIMUM(8, 0x01), // Consumer Control
+ HID_RI_USAGE_MAXIMUM(16, 0x02A0), // AC Desktop Show All Applications
+ HID_RI_LOGICAL_MINIMUM(8, 0x01),
+ HID_RI_LOGICAL_MAXIMUM(16, 0x02A0),
HID_RI_REPORT_COUNT(8, 1),
HID_RI_REPORT_SIZE(8, 16),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 081b48d44b..0b91bfb414 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -130,7 +130,7 @@ static void send_extra(uint8_t report_id, uint16_t data) {
static void send_system(uint16_t data) {
#ifdef EXTRAKEY_ENABLE
- send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1);
+ send_extra(REPORT_ID_SYSTEM, data);
#endif
}
@@ -262,7 +262,9 @@ const PROGMEM uchar keyboard_hid_report[] = {
0xC0 // End Collection
};
-const PROGMEM uchar mouse_hid_report[] = {
+#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
+const PROGMEM uchar mouse_extra_hid_report[] = {
+# ifdef MOUSE_ENABLE
// Mouse report descriptor
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
@@ -311,17 +313,18 @@ const PROGMEM uchar mouse_hid_report[] = {
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // End Collection
0xC0, // End Collection
+# endif
-#ifdef EXTRAKEY_ENABLE
+# ifdef EXTRAKEY_ENABLE
// Extrakeys report descriptor
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x80, // Usage (System Control)
0xA1, 0x01, // Collection (Application)
0x85, REPORT_ID_SYSTEM, // Report ID
- 0x1A, 0x81, 0x00, // Usage Minimum (System Power Down)
- 0x2A, 0x83, 0x00, // Usage Maximum (System Wake Up)
- 0x16, 0x01, 0x00, // Logical Minimum
- 0x26, 0x03, 0x00, // Logical Maximum
+ 0x19, 0x01, // Usage Minimum (Pointer)
+ 0x2A, 0xB7, 0x00, // Usage Maximum (System Display LCD Autoscale)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xB7, 0x00, // Logical Maximum
0x95, 0x01, // Report Count (1)
0x75, 0x10, // Report Size (16)
0x81, 0x00, // Input (Data, Array, Absolute)
@@ -331,16 +334,17 @@ const PROGMEM uchar mouse_hid_report[] = {
0x09, 0x01, // Usage (Consumer Control)
0xA1, 0x01, // Collection (Application)
0x85, REPORT_ID_CONSUMER, // Report ID
- 0x1A, 0x01, 0x00, // Usage Minimum (Consumer Control)
- 0x2A, 0x9C, 0x02, // Usage Maximum (AC Distribute Vertically)
- 0x16, 0x01, 0x00, // Logical Minimum
- 0x26, 0x9C, 0x02, // Logical Maximum
+ 0x19, 0x01, // Usage Minimum (Consumer Control)
+ 0x2A, 0xA0, 0x02, // Usage Maximum (AC Desktop Show All Applications)
+ 0x15, 0x01, // Logical Minimum
+ 0x26, 0xA0, 0x02, // Logical Maximum
0x95, 0x01, // Report Count (1)
0x75, 0x10, // Report Size (16)
0x81, 0x00, // Input (Data, Array, Absolute)
0xC0 // End Collection
-#endif
+# endif
};
+#endif
#ifndef USB_MAX_POWER_CONSUMPTION
# define USB_MAX_POWER_CONSUMPTION 500
@@ -361,10 +365,19 @@ const PROGMEM char usbDescriptorConfiguration[] = {
/* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */
- 9 + (9 + 9 + 7) + (9 + 9 + 7), 0,
+# if defined (MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
+ 59, // 9 + (9 + 9 + 7) + (9 + 9 + 7)
+#else
+ 34, // 9 + (9 + 9 + 7)
+# endif
+ 0,
// 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0,
/* total length of data returned (including inlined descriptors) */
+# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
2, /* number of interfaces in this configuration */
+# else
+ 1,
+#endif
1, /* index of this configuration */
0, /* configuration name string index */
# if USB_CFG_IS_SELF_POWERED
@@ -402,8 +415,9 @@ const PROGMEM char usbDescriptorConfiguration[] = {
USB_POLLING_INTERVAL_MS, /* in ms */
# endif
+# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
/*
- * Mouse interface
+ * Mouse/extrakeys interface
*/
/* Interface descriptor */
9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
@@ -422,8 +436,8 @@ const PROGMEM char usbDescriptorConfiguration[] = {
0x00, /* target country code */
0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
0x22, /* descriptor type: report */
- sizeof(mouse_hid_report), 0, /* total length of report descriptor */
-# if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */
+ sizeof(mouse_extra_hid_report), 0, /* total length of report descriptor */
+# if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */
/* Endpoint descriptor */
7, /* sizeof(usbDescrEndpoint) */
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
@@ -431,6 +445,7 @@ const PROGMEM char usbDescriptorConfiguration[] = {
0x03, /* attrib: Interrupt endpoint */
8, 0, /* maximum packet size */
USB_POLLING_INTERVAL_MS, /* in ms */
+# endif
# endif
};
#endif
@@ -459,10 +474,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + 9);
len = 9;
break;
+#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
case 1:
usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + (9 + 9 + 7) + 9);
len = 9;
break;
+#endif
}
break;
case USBDESCR_HID_REPORT:
@@ -472,10 +489,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
usbMsgPtr = (unsigned char *)keyboard_hid_report;
len = sizeof(keyboard_hid_report);
break;
+#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
case 1:
- usbMsgPtr = (unsigned char *)mouse_hid_report;
- len = sizeof(mouse_hid_report);
+ usbMsgPtr = (unsigned char *)mouse_extra_hid_report;
+ len = sizeof(mouse_extra_hid_report);
break;
+#endif
}
break;
}