aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/report.h
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/report.h')
-rw-r--r--tmk_core/common/report.h52
1 files changed, 38 insertions, 14 deletions
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 6c27eb9dc..eb9afb727 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)
@@ -36,6 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
36 38
37/* Consumer Page(0x0C) 39/* Consumer Page(0x0C)
38 * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx 40 * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx
41 * see also https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/display-brightness-control
39 */ 42 */
40#define AUDIO_MUTE 0x00E2 43#define AUDIO_MUTE 0x00E2
41#define AUDIO_VOL_UP 0x00E9 44#define AUDIO_VOL_UP 0x00E9
@@ -45,6 +48,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
45#define TRANSPORT_STOP 0x00B7 48#define TRANSPORT_STOP 0x00B7
46#define TRANSPORT_STOP_EJECT 0x00CC 49#define TRANSPORT_STOP_EJECT 0x00CC
47#define TRANSPORT_PLAY_PAUSE 0x00CD 50#define TRANSPORT_PLAY_PAUSE 0x00CD
51#define BRIGHTNESSUP 0x006F
52#define BRIGHTNESSDOWN 0x0070
48/* application launch */ 53/* application launch */
49#define AL_CC_CONFIG 0x0183 54#define AL_CC_CONFIG 0x0183
50#define AL_EMAIL 0x018A 55#define AL_EMAIL 0x018A
@@ -72,27 +77,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
72#define SYSTEM_WAKE_UP 0x0083 77#define SYSTEM_WAKE_UP 0x0083
73 78
74 79
80#define NKRO_SHARED_EP
75/* key report size(NKRO or boot mode) */ 81/* key report size(NKRO or boot mode) */
76#if defined(NKRO_ENABLE) 82#if defined(NKRO_ENABLE)
77 #if defined(PROTOCOL_PJRC) 83 #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" 84 #include "protocol/usb_descriptor.h"
84 #define KEYBOARD_REPORT_SIZE NKRO_EPSIZE 85 #define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2)
85 #define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2) 86 #elif defined(PROTOCOL_ARM_ATSAM)
87 #include "protocol/arm_atsam/usb/udi_device_epsize.h"
86 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) 88 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
89 #undef NKRO_SHARED_EP
90 #undef MOUSE_SHARED_EP
87 #else 91 #else
88 #error "NKRO not supported with this protocol" 92 #error "NKRO not supported with this protocol"
93 #endif
89#endif 94#endif
90 95
96#ifdef KEYBOARD_SHARED_EP
97# define KEYBOARD_REPORT_SIZE 9
91#else 98#else
92# define KEYBOARD_REPORT_SIZE 8 99# define KEYBOARD_REPORT_SIZE 8
93# define KEYBOARD_REPORT_KEYS 6
94#endif 100#endif
95 101
102#define KEYBOARD_REPORT_KEYS 6
103
104/* VUSB hardcodes keyboard and mouse+extrakey only */
105#if defined(PROTOCOL_VUSB)
106 #undef KEYBOARD_SHARED_EP
107 #undef MOUSE_SHARED_EP
108#endif
96 109
97#ifdef __cplusplus 110#ifdef __cplusplus
98extern "C" { 111extern "C" {
@@ -121,12 +134,18 @@ extern "C" {
121typedef union { 134typedef union {
122 uint8_t raw[KEYBOARD_REPORT_SIZE]; 135 uint8_t raw[KEYBOARD_REPORT_SIZE];
123 struct { 136 struct {
137#ifdef KEYBOARD_SHARED_EP
138 uint8_t report_id;
139#endif
124 uint8_t mods; 140 uint8_t mods;
125 uint8_t reserved; 141 uint8_t reserved;
126 uint8_t keys[KEYBOARD_REPORT_KEYS]; 142 uint8_t keys[KEYBOARD_REPORT_KEYS];
127 }; 143 };
128#ifdef NKRO_ENABLE 144#ifdef NKRO_ENABLE
129 struct { 145 struct nkro_report {
146#ifdef NKRO_SHARED_EP
147 uint8_t report_id;
148#endif
130 uint8_t mods; 149 uint8_t mods;
131 uint8_t bits[KEYBOARD_REPORT_BITS]; 150 uint8_t bits[KEYBOARD_REPORT_BITS];
132 } nkro; 151 } nkro;
@@ -134,6 +153,9 @@ typedef union {
134} __attribute__ ((packed)) report_keyboard_t; 153} __attribute__ ((packed)) report_keyboard_t;
135 154
136typedef struct { 155typedef struct {
156#ifdef MOUSE_SHARED_EP
157 uint8_t report_id;
158#endif
137 uint8_t buttons; 159 uint8_t buttons;
138 int8_t x; 160 int8_t x;
139 int8_t y; 161 int8_t y;
@@ -170,7 +192,9 @@ typedef struct {
170 (key == KC_WWW_FORWARD ? AC_FORWARD : \ 192 (key == KC_WWW_FORWARD ? AC_FORWARD : \
171 (key == KC_WWW_STOP ? AC_STOP : \ 193 (key == KC_WWW_STOP ? AC_STOP : \
172 (key == KC_WWW_REFRESH ? AC_REFRESH : \ 194 (key == KC_WWW_REFRESH ? AC_REFRESH : \
173 (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))) 195 (key == KC_BRIGHTNESS_UP ? BRIGHTNESSUP : \
196 (key == KC_BRIGHTNESS_DOWN ? BRIGHTNESSDOWN : \
197 (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))))
174 198
175uint8_t has_anykey(report_keyboard_t* keyboard_report); 199uint8_t has_anykey(report_keyboard_t* keyboard_report);
176uint8_t get_first_key(report_keyboard_t* keyboard_report); 200uint8_t get_first_key(report_keyboard_t* keyboard_report);