diff options
author | Nick Brassel <nick@tzarc.org> | 2020-05-21 20:31:42 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 20:31:42 +1000 |
commit | d1df576ece12a7627a18e1581eed482cda2dbed5 (patch) | |
tree | 8c8415ba527681ed9d453689c435c6f06a6daa64 | |
parent | 83ebbf57b349552038d9d9af994eb2e9528ecbc5 (diff) | |
download | qmk_firmware-d1df576ece12a7627a18e1581eed482cda2dbed5.tar.gz qmk_firmware-d1df576ece12a7627a18e1581eed482cda2dbed5.zip |
Allow for overriding RAW endpoint usage page and ID. (#8834)
* Allow for overriding RAW endpoint usage page and ID.
* Move usb_descriptor_common.h.
* Docs update.
-rw-r--r-- | docs/feature_rawhid.md | 6 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c | 5 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 5 | ||||
-rw-r--r-- | tmk_core/protocol/usb_descriptor_common.h | 31 | ||||
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 7 |
5 files changed, 46 insertions, 8 deletions
diff --git a/docs/feature_rawhid.md b/docs/feature_rawhid.md index ed848a4c7..01e215be4 100644 --- a/docs/feature_rawhid.md +++ b/docs/feature_rawhid.md | |||
@@ -44,7 +44,11 @@ To connect your host computer to your keyboard with raw HID you need four pieces | |||
44 | 3. Usage Page | 44 | 3. Usage Page |
45 | 4. Usage | 45 | 4. Usage |
46 | 46 | ||
47 | The first two can easily be found in your keyboard's `config.h` in the keyboard's main directory under `VENDOR_ID` and `PRODUCT_ID`. **Usage Page** is **`0xFF60`** and **Usage** is **`0x0061`**. | 47 | The first two can easily be found in your keyboard's `config.h` in the keyboard's main directory under `VENDOR_ID` and `PRODUCT_ID`. |
48 | |||
49 | The final two can be overridden in your keyboard's `config.h` in the keyboard's main directory by redefining the values: `#define RAW_USAGE_PAGE 0xFF60` and `#define RAW_USAGE_ID 0x61`. | ||
50 | |||
51 | By default, **Usage Page** is `0xFF60` and **Usage** is `0x61`. | ||
48 | 52 | ||
49 | ### Building your host | 53 | ### Building your host |
50 | 54 | ||
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 3e9fbfdbe..9ea4addcf 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include "udi_hid_kbd.h" | 55 | #include "udi_hid_kbd.h" |
56 | #include <string.h> | 56 | #include <string.h> |
57 | #include "report.h" | 57 | #include "report.h" |
58 | #include "usb_descriptor_common.h" | ||
58 | 59 | ||
59 | //*************************************************************************** | 60 | //*************************************************************************** |
60 | // KBD | 61 | // KBD |
@@ -641,8 +642,8 @@ static uint8_t udi_hid_raw_report_recv[UDI_HID_RAW_REPORT_SIZE]; | |||
641 | 642 | ||
642 | COMPILER_WORD_ALIGNED | 643 | COMPILER_WORD_ALIGNED |
643 | UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{ | 644 | UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{ |
644 | 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined) | 645 | 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined) |
645 | 0x09, 0x61, // Usage (Vendor Defined) | 646 | 0x09, RAW_USAGE_ID, // Usage (Vendor Defined) |
646 | 0xA1, 0x01, // Collection (Application) | 647 | 0xA1, 0x01, // Collection (Application) |
647 | 0x75, 0x08, // Report Size (8) | 648 | 0x75, 0x08, // Report Size (8) |
648 | 0x15, 0x00, // Logical Minimum (0) | 649 | 0x15, 0x00, // Logical Minimum (0) |
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index f2b91b099..8c71dd1dd 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "util.h" | 39 | #include "util.h" |
40 | #include "report.h" | 40 | #include "report.h" |
41 | #include "usb_descriptor.h" | 41 | #include "usb_descriptor.h" |
42 | #include "usb_descriptor_common.h" | ||
42 | 43 | ||
43 | // clang-format off | 44 | // clang-format off |
44 | 45 | ||
@@ -232,8 +233,8 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { | |||
232 | 233 | ||
233 | #ifdef RAW_ENABLE | 234 | #ifdef RAW_ENABLE |
234 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = { | 235 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = { |
235 | HID_RI_USAGE_PAGE(16, 0xFF60), // Vendor Defined | 236 | HID_RI_USAGE_PAGE(16, RAW_USAGE_PAGE), // Vendor Defined |
236 | HID_RI_USAGE(8, 0x61), // Vendor Defined | 237 | HID_RI_USAGE(8, RAW_USAGE_ID), // Vendor Defined |
237 | HID_RI_COLLECTION(8, 0x01), // Application | 238 | HID_RI_COLLECTION(8, 0x01), // Application |
238 | // Data to host | 239 | // Data to host |
239 | HID_RI_USAGE(8, 0x62), // Vendor Defined | 240 | HID_RI_USAGE(8, 0x62), // Vendor Defined |
diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h new file mode 100644 index 000000000..b1f602c82 --- /dev/null +++ b/tmk_core/protocol/usb_descriptor_common.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* Copyright 2020 Nick Brassel (tzarc) | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | ///////////////////// | ||
20 | // RAW Usage page and ID configuration | ||
21 | |||
22 | #ifndef RAW_USAGE_PAGE | ||
23 | # define RAW_USAGE_PAGE 0xFF60 | ||
24 | #endif | ||
25 | |||
26 | #ifndef RAW_USAGE_ID | ||
27 | # define RAW_USAGE_ID 0x61 | ||
28 | #endif | ||
29 | |||
30 | #define RAW_USAGE_PAGE_HI ((uint8_t)(RAW_USAGE_PAGE >> 8)) | ||
31 | #define RAW_USAGE_PAGE_LO ((uint8_t)(RAW_USAGE_PAGE & 0xFF)) | ||
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index a9f37c61b..4c8e6003f 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
@@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
26 | #include "vusb.h" | 26 | #include "vusb.h" |
27 | #include "print.h" | 27 | #include "print.h" |
28 | #include "debug.h" | 28 | #include "debug.h" |
29 | #include "usb_descriptor_common.h" | ||
29 | 30 | ||
30 | #ifdef RAW_ENABLE | 31 | #ifdef RAW_ENABLE |
31 | # include "raw_hid.h" | 32 | # include "raw_hid.h" |
@@ -409,9 +410,9 @@ const PROGMEM uchar keyboard_hid_report[] = { | |||
409 | 410 | ||
410 | #ifdef RAW_ENABLE | 411 | #ifdef RAW_ENABLE |
411 | const PROGMEM uchar raw_hid_report[] = { | 412 | const PROGMEM uchar raw_hid_report[] = { |
412 | 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined) | 413 | 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined) |
413 | 0x09, 0x61, // Usage (Vendor Defined) | 414 | 0x09, RAW_USAGE_ID, // Usage (Vendor Defined) |
414 | 0xA1, 0x01, // Collection (Application) | 415 | 0xA1, 0x01, // Collection (Application) |
415 | // Data to host | 416 | // Data to host |
416 | 0x09, 0x62, // Usage (Vendor Defined) | 417 | 0x09, 0x62, // Usage (Vendor Defined) |
417 | 0x15, 0x00, // Logical Minimum (0) | 418 | 0x15, 0x00, // Logical Minimum (0) |