aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/report.h
diff options
context:
space:
mode:
authorJames Laird-Wah <james@laird-wah.net>2018-11-16 17:22:05 +1100
committerDrashna Jaelre <drashna@live.com>2018-11-15 22:22:05 -0800
commit39bd760faf2666e91d6dc5b199f02fa3206c6acd (patch)
tree12db265881a0d358bb0e186689a7b20a81c37bc6 /tmk_core/common/report.h
parent46cf8cc9b33a3c8bdbb0ce7df7f48f28e4d979a5 (diff)
downloadqmk_firmware-39bd760faf2666e91d6dc5b199f02fa3206c6acd.tar.gz
qmk_firmware-39bd760faf2666e91d6dc5b199f02fa3206c6acd.zip
Use a single endpoint for HID reports (#3951)
* Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
Diffstat (limited to 'tmk_core/common/report.h')
-rw-r--r--tmk_core/common/report.h46
1 files changed, 30 insertions, 16 deletions
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 167f38275..5a1a6b19c 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -23,9 +23,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23 23
24 24
25/* report id */ 25/* report id */
26#define REPORT_ID_MOUSE 1 26#define REPORT_ID_KEYBOARD 1
27#define REPORT_ID_SYSTEM 2 27#define REPORT_ID_MOUSE 2
28#define REPORT_ID_CONSUMER 3 28#define REPORT_ID_SYSTEM 3
29#define REPORT_ID_CONSUMER 4
30#define REPORT_ID_NKRO 5
29 31
30/* mouse buttons */ 32/* mouse buttons */
31#define MOUSE_BTN1 (1<<0) 33#define MOUSE_BTN1 (1<<0)
@@ -72,32 +74,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
72#define SYSTEM_WAKE_UP 0x0083 74#define SYSTEM_WAKE_UP 0x0083
73 75
74 76
77#define NKRO_SHARED_EP
75/* key report size(NKRO or boot mode) */ 78/* key report size(NKRO or boot mode) */
76#if defined(NKRO_ENABLE) 79#if defined(NKRO_ENABLE)
77 #if defined(PROTOCOL_PJRC) 80 #if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS)
78 #include "usb.h"
79 #define KEYBOARD_REPORT_SIZE KBD2_SIZE
80 #define KEYBOARD_REPORT_KEYS (KBD2_SIZE - 2)
81 #define KEYBOARD_REPORT_BITS (KBD2_SIZE - 1)
82 #elif defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS)
83 #include "protocol/usb_descriptor.h" 81 #include "protocol/usb_descriptor.h"
84 #define KEYBOARD_REPORT_SIZE NKRO_EPSIZE 82 #define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2)
85 #define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2)
86 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
87 #elif defined(PROTOCOL_ARM_ATSAM) 83 #elif defined(PROTOCOL_ARM_ATSAM)
88 #include "protocol/arm_atsam/usb/udi_device_epsize.h" 84 #include "protocol/arm_atsam/usb/udi_device_epsize.h"
89 #define KEYBOARD_REPORT_SIZE NKRO_EPSIZE
90 #define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2)
91 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) 85 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
86 #undef NKRO_SHARED_EP
87 #undef MOUSE_SHARED_EP
92 #else 88 #else
93 #error "NKRO not supported with this protocol" 89 #error "NKRO not supported with this protocol"
90 #endif
94#endif 91#endif
95 92
93#ifdef KEYBOARD_SHARED_EP
94# define KEYBOARD_REPORT_SIZE 9
96#else 95#else
97# define KEYBOARD_REPORT_SIZE 8 96# define KEYBOARD_REPORT_SIZE 8
98# define KEYBOARD_REPORT_KEYS 6
99#endif 97#endif
100 98
99#define KEYBOARD_REPORT_KEYS 6
100
101/* VUSB hardcodes keyboard and mouse+extrakey only */
102#if defined(PROTOCOL_VUSB)
103 #undef KEYBOARD_SHARED_EP
104 #undef MOUSE_SHARED_EP
105#endif
101 106
102#ifdef __cplusplus 107#ifdef __cplusplus
103extern "C" { 108extern "C" {
@@ -126,12 +131,18 @@ extern "C" {
126typedef union { 131typedef union {
127 uint8_t raw[KEYBOARD_REPORT_SIZE]; 132 uint8_t raw[KEYBOARD_REPORT_SIZE];
128 struct { 133 struct {
134#ifdef KEYBOARD_SHARED_EP
135 uint8_t report_id;
136#endif
129 uint8_t mods; 137 uint8_t mods;
130 uint8_t reserved; 138 uint8_t reserved;
131 uint8_t keys[KEYBOARD_REPORT_KEYS]; 139 uint8_t keys[KEYBOARD_REPORT_KEYS];
132 }; 140 };
133#ifdef NKRO_ENABLE 141#ifdef NKRO_ENABLE
134 struct { 142 struct nkro_report {
143#ifdef NKRO_SHARED_EP
144 uint8_t report_id;
145#endif
135 uint8_t mods; 146 uint8_t mods;
136 uint8_t bits[KEYBOARD_REPORT_BITS]; 147 uint8_t bits[KEYBOARD_REPORT_BITS];
137 } nkro; 148 } nkro;
@@ -139,6 +150,9 @@ typedef union {
139} __attribute__ ((packed)) report_keyboard_t; 150} __attribute__ ((packed)) report_keyboard_t;
140 151
141typedef struct { 152typedef struct {
153#ifdef MOUSE_SHARED_EP
154 uint8_t report_id;
155#endif
142 uint8_t buttons; 156 uint8_t buttons;
143 int8_t x; 157 int8_t x;
144 int8_t y; 158 int8_t y;