diff options
Diffstat (limited to 'tmk_core/common/report.h')
-rw-r--r-- | tmk_core/common/report.h | 46 |
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 |
103 | extern "C" { | 108 | extern "C" { |
@@ -126,12 +131,18 @@ extern "C" { | |||
126 | typedef union { | 131 | typedef 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 | ||
141 | typedef struct { | 152 | typedef 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; |