]> git.gir.st - tmk_keyboard.git/blob - common/report.h
Fix action of system and consumer usage.
[tmk_keyboard.git] / common / report.h
1 /*
2 Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef REPORT_H
19 #define REPORT_H
20
21 #include <stdint.h>
22 #include "keycode.h"
23
24
25 /* report id */
26 #define REPORT_ID_MOUSE 1
27 #define REPORT_ID_SYSTEM 2
28 #define REPORT_ID_CONSUMER 3
29
30 /* mouse buttons */
31 #define MOUSE_BTN1 (1<<0)
32 #define MOUSE_BTN2 (1<<1)
33 #define MOUSE_BTN3 (1<<2)
34 #define MOUSE_BTN4 (1<<3)
35 #define MOUSE_BTN5 (1<<4)
36
37 /* Consumer Page(0x0C)
38 * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx
39 */
40 #define AUDIO_MUTE 0x00E2
41 #define AUDIO_VOL_UP 0x00E9
42 #define AUDIO_VOL_DOWN 0x00EA
43 #define TRANSPORT_NEXT_TRACK 0x00B5
44 #define TRANSPORT_PREV_TRACK 0x00B6
45 #define TRANSPORT_STOP 0x00B7
46 #define TRANSPORT_PLAY_PAUSE 0x00CD
47 /* application launch */
48 #define AL_CC_CONFIG 0x0183
49 #define AL_EMAIL 0x018A
50 #define AL_CALCULATOR 0x0192
51 #define AL_LOCAL_BROWSER 0x0194
52 /* application control */
53 #define AC_SEARCH 0x0221
54 #define AC_HOME 0x0223
55 #define AC_BACK 0x0224
56 #define AC_FORWARD 0x0225
57 #define AC_STOP 0x0226
58 #define AC_REFRESH 0x0227
59 #define AC_BOOKMARKS 0x022A
60 /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
61 #define AL_LOCK 0x019E
62 #define TRANSPORT_RECORD 0x00B2
63 #define TRANSPORT_REWIND 0x00B4
64 #define TRANSPORT_EJECT 0x00B8
65 #define AC_MINIMIZE 0x0206
66
67 /* Generic Desktop Page(0x01) - system power control */
68 #define SYSTEM_POWER_DOWN 0x0081
69 #define SYSTEM_SLEEP 0x0082
70 #define SYSTEM_WAKE_UP 0x0083
71
72
73 /* key report size(NKRO or boot mode) */
74 #if defined(HOST_PJRC)
75 # include "usb.h"
76 # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
77 # define REPORT_KEYS KBD2_REPORT_KEYS
78 # else
79 # define REPORT_KEYS KBD_REPORT_KEYS
80 # endif
81 #else
82 # define REPORT_KEYS 6
83 #endif
84
85
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89
90 typedef struct {
91 uint8_t mods;
92 uint8_t rserved;
93 uint8_t keys[REPORT_KEYS];
94 } __attribute__ ((packed)) report_keyboard_t;
95
96 typedef struct {
97 uint8_t buttons;
98 int8_t x;
99 int8_t y;
100 int8_t v;
101 int8_t h;
102 } __attribute__ ((packed)) report_mouse_t;
103
104
105 /* keycode to system usage */
106 #define KEYCODE2SYSTEM(key) \
107 (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
108 (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
109 (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
110
111 /* keycode to consumer usage */
112 #define KEYCODE2CONSUMER(key) \
113 (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \
114 (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \
115 (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
116 (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
117 (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
118 (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
119 (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
120 (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \
121 (key == KC_MAIL ? AL_EMAIL : \
122 (key == KC_CALCULATOR ? AL_CALCULATOR : \
123 (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \
124 (key == KC_WWW_SEARCH ? AC_SEARCH : \
125 (key == KC_WWW_HOME ? AC_HOME : \
126 (key == KC_WWW_BACK ? AC_BACK : \
127 (key == KC_WWW_FORWARD ? AC_FORWARD : \
128 (key == KC_WWW_STOP ? AC_STOP : \
129 (key == KC_WWW_REFRESH ? AC_REFRESH : \
130 (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))
131
132 #ifdef __cplusplus
133 }
134 #endif
135
136 #endif
Imprint / Impressum