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.h158
1 files changed, 65 insertions, 93 deletions
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index e7c31bd37..ccc6d599b 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -21,90 +21,88 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <stdint.h> 21#include <stdint.h>
22#include "keycode.h" 22#include "keycode.h"
23 23
24
25/* report id */ 24/* report id */
26#define REPORT_ID_KEYBOARD 1 25#define REPORT_ID_KEYBOARD 1
27#define REPORT_ID_MOUSE 2 26#define REPORT_ID_MOUSE 2
28#define REPORT_ID_SYSTEM 3 27#define REPORT_ID_SYSTEM 3
29#define REPORT_ID_CONSUMER 4 28#define REPORT_ID_CONSUMER 4
30#define REPORT_ID_NKRO 5 29#define REPORT_ID_NKRO 5
31 30
32/* mouse buttons */ 31/* mouse buttons */
33#define MOUSE_BTN1 (1<<0) 32#define MOUSE_BTN1 (1 << 0)
34#define MOUSE_BTN2 (1<<1) 33#define MOUSE_BTN2 (1 << 1)
35#define MOUSE_BTN3 (1<<2) 34#define MOUSE_BTN3 (1 << 2)
36#define MOUSE_BTN4 (1<<3) 35#define MOUSE_BTN4 (1 << 3)
37#define MOUSE_BTN5 (1<<4) 36#define MOUSE_BTN5 (1 << 4)
38 37
39/* Consumer Page(0x0C) 38/* Consumer Page(0x0C)
40 * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx 39 * 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 40 * see also https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/display-brightness-control
42 */ 41 */
43#define AUDIO_MUTE 0x00E2 42#define AUDIO_MUTE 0x00E2
44#define AUDIO_VOL_UP 0x00E9 43#define AUDIO_VOL_UP 0x00E9
45#define AUDIO_VOL_DOWN 0x00EA 44#define AUDIO_VOL_DOWN 0x00EA
46#define TRANSPORT_NEXT_TRACK 0x00B5 45#define TRANSPORT_NEXT_TRACK 0x00B5
47#define TRANSPORT_PREV_TRACK 0x00B6 46#define TRANSPORT_PREV_TRACK 0x00B6
48#define TRANSPORT_STOP 0x00B7 47#define TRANSPORT_STOP 0x00B7
49#define TRANSPORT_STOP_EJECT 0x00CC 48#define TRANSPORT_STOP_EJECT 0x00CC
50#define TRANSPORT_PLAY_PAUSE 0x00CD 49#define TRANSPORT_PLAY_PAUSE 0x00CD
51#define BRIGHTNESS_UP 0x006F 50#define BRIGHTNESS_UP 0x006F
52#define BRIGHTNESS_DOWN 0x0070 51#define BRIGHTNESS_DOWN 0x0070
53/* application launch */ 52/* application launch */
54#define AL_CC_CONFIG 0x0183 53#define AL_CC_CONFIG 0x0183
55#define AL_EMAIL 0x018A 54#define AL_EMAIL 0x018A
56#define AL_CALCULATOR 0x0192 55#define AL_CALCULATOR 0x0192
57#define AL_LOCAL_BROWSER 0x0194 56#define AL_LOCAL_BROWSER 0x0194
58/* application control */ 57/* application control */
59#define AC_SEARCH 0x0221 58#define AC_SEARCH 0x0221
60#define AC_HOME 0x0223 59#define AC_HOME 0x0223
61#define AC_BACK 0x0224 60#define AC_BACK 0x0224
62#define AC_FORWARD 0x0225 61#define AC_FORWARD 0x0225
63#define AC_STOP 0x0226 62#define AC_STOP 0x0226
64#define AC_REFRESH 0x0227 63#define AC_REFRESH 0x0227
65#define AC_BOOKMARKS 0x022A 64#define AC_BOOKMARKS 0x022A
66/* supplement for Bluegiga iWRAP HID(not supported by Windows?) */ 65/* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
67#define AL_LOCK 0x019E 66#define AL_LOCK 0x019E
68#define TRANSPORT_RECORD 0x00B2 67#define TRANSPORT_RECORD 0x00B2
69#define TRANSPORT_FAST_FORWARD 0x00B3 68#define TRANSPORT_FAST_FORWARD 0x00B3
70#define TRANSPORT_REWIND 0x00B4 69#define TRANSPORT_REWIND 0x00B4
71#define TRANSPORT_EJECT 0x00B8 70#define TRANSPORT_EJECT 0x00B8
72#define AC_MINIMIZE 0x0206 71#define AC_MINIMIZE 0x0206
73 72
74/* Generic Desktop Page(0x01) - system power control */ 73/* Generic Desktop Page(0x01) - system power control */
75#define SYSTEM_POWER_DOWN 0x0081 74#define SYSTEM_POWER_DOWN 0x0081
76#define SYSTEM_SLEEP 0x0082 75#define SYSTEM_SLEEP 0x0082
77#define SYSTEM_WAKE_UP 0x0083 76#define SYSTEM_WAKE_UP 0x0083
78
79 77
80#define NKRO_SHARED_EP 78#define NKRO_SHARED_EP
81/* key report size(NKRO or boot mode) */ 79/* key report size(NKRO or boot mode) */
82#if defined(NKRO_ENABLE) 80#if defined(NKRO_ENABLE)
83 #if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS) 81# if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS)
84 #include "protocol/usb_descriptor.h" 82# include "protocol/usb_descriptor.h"
85 #define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2) 83# define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2)
86 #elif defined(PROTOCOL_ARM_ATSAM) 84# elif defined(PROTOCOL_ARM_ATSAM)
87 #include "protocol/arm_atsam/usb/udi_device_epsize.h" 85# include "protocol/arm_atsam/usb/udi_device_epsize.h"
88 #define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) 86# define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
89 #undef NKRO_SHARED_EP 87# undef NKRO_SHARED_EP
90 #undef MOUSE_SHARED_EP 88# undef MOUSE_SHARED_EP
91 #else 89# else
92 #error "NKRO not supported with this protocol" 90# error "NKRO not supported with this protocol"
93 #endif 91# endif
94#endif 92#endif
95 93
96#ifdef KEYBOARD_SHARED_EP 94#ifdef KEYBOARD_SHARED_EP
97# define KEYBOARD_REPORT_SIZE 9 95# define KEYBOARD_REPORT_SIZE 9
98#else 96#else
99# define KEYBOARD_REPORT_SIZE 8 97# define KEYBOARD_REPORT_SIZE 8
100#endif 98#endif
101 99
102#define KEYBOARD_REPORT_KEYS 6 100#define KEYBOARD_REPORT_KEYS 6
103 101
104/* VUSB hardcodes keyboard and mouse+extrakey only */ 102/* VUSB hardcodes keyboard and mouse+extrakey only */
105#if defined(PROTOCOL_VUSB) 103#if defined(PROTOCOL_VUSB)
106 #undef KEYBOARD_SHARED_EP 104# undef KEYBOARD_SHARED_EP
107 #undef MOUSE_SHARED_EP 105# undef MOUSE_SHARED_EP
108#endif 106#endif
109 107
110#ifdef __cplusplus 108#ifdef __cplusplus
@@ -143,58 +141,32 @@ typedef union {
143 }; 141 };
144#ifdef NKRO_ENABLE 142#ifdef NKRO_ENABLE
145 struct nkro_report { 143 struct nkro_report {
146#ifdef NKRO_SHARED_EP 144# ifdef NKRO_SHARED_EP
147 uint8_t report_id; 145 uint8_t report_id;
148#endif 146# endif
149 uint8_t mods; 147 uint8_t mods;
150 uint8_t bits[KEYBOARD_REPORT_BITS]; 148 uint8_t bits[KEYBOARD_REPORT_BITS];
151 } nkro; 149 } nkro;
152#endif 150#endif
153} __attribute__ ((packed)) report_keyboard_t; 151} __attribute__((packed)) report_keyboard_t;
154 152
155typedef struct { 153typedef struct {
156#ifdef MOUSE_SHARED_EP 154#ifdef MOUSE_SHARED_EP
157 uint8_t report_id; 155 uint8_t report_id;
158#endif 156#endif
159 uint8_t buttons; 157 uint8_t buttons;
160 int8_t x; 158 int8_t x;
161 int8_t y; 159 int8_t y;
162 int8_t v; 160 int8_t v;
163 int8_t h; 161 int8_t h;
164} __attribute__ ((packed)) report_mouse_t; 162} __attribute__((packed)) report_mouse_t;
165
166 163
167/* keycode to system usage */ 164/* keycode to system usage */
168#define KEYCODE2SYSTEM(key) \ 165#define KEYCODE2SYSTEM(key) (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
169 (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
170 (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
171 (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
172 166
173/* keycode to consumer usage */ 167/* keycode to consumer usage */
174#define KEYCODE2CONSUMER(key) \ 168#define KEYCODE2CONSUMER(key) \
175 (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \ 169 (key == KC_AUDIO_MUTE ? AUDIO_MUTE : (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : (key == KC_MEDIA_STOP ? TRANSPORT_STOP : (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : (key == KC_MAIL ? AL_EMAIL : (key == KC_CALCULATOR ? AL_CALCULATOR : (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : (key == KC_WWW_SEARCH ? AC_SEARCH : (key == KC_WWW_HOME ? AC_HOME : (key == KC_WWW_BACK ? AC_BACK : (key == KC_WWW_FORWARD ? AC_FORWARD : (key == KC_WWW_STOP ? AC_STOP : (key == KC_WWW_REFRESH ? AC_REFRESH : (key == KC_BRIGHTNESS_UP ? BRIGHTNESS_UP : (key == KC_BRIGHTNESS_DOWN ? BRIGHTNESS_DOWN : (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))))
176 (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \
177 (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
178 (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
179 (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
180 (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \
181 (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \
182 (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
183 (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \
184 (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
185 (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \
186 (key == KC_MAIL ? AL_EMAIL : \
187 (key == KC_CALCULATOR ? AL_CALCULATOR : \
188 (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \
189 (key == KC_WWW_SEARCH ? AC_SEARCH : \
190 (key == KC_WWW_HOME ? AC_HOME : \
191 (key == KC_WWW_BACK ? AC_BACK : \
192 (key == KC_WWW_FORWARD ? AC_FORWARD : \
193 (key == KC_WWW_STOP ? AC_STOP : \
194 (key == KC_WWW_REFRESH ? AC_REFRESH : \
195 (key == KC_BRIGHTNESS_UP ? BRIGHTNESS_UP : \
196 (key == KC_BRIGHTNESS_DOWN ? BRIGHTNESS_DOWN : \
197 (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))))
198 170
199uint8_t has_anykey(report_keyboard_t* keyboard_report); 171uint8_t has_anykey(report_keyboard_t* keyboard_report);
200uint8_t get_first_key(report_keyboard_t* keyboard_report); 172uint8_t get_first_key(report_keyboard_t* keyboard_report);