]> git.gir.st - tmk_keyboard.git/blob - common/report.h
Add initial fix for new keymap.
[tmk_keyboard.git] / common / report.h
1 /*
2 Copyright 2011 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 #define AUDIO_MUTE 0x00E2
40 #define AUDIO_VOL_UP 0x00E9
41 #define AUDIO_VOL_DOWN 0x00EA
42 #define TRANSPORT_NEXT_TRACK 0x00B5
43 #define TRANSPORT_PREV_TRACK 0x00B6
44 #define TRANSPORT_STOP 0x00B7
45 #define TRANSPORT_PLAY_PAUSE 0x00CD
46 #define AL_CC_CONFIG 0x0183
47 #define AL_EMAIL 0x018A
48 #define AL_CALCULATOR 0x0192
49 #define AL_LOCAL_BROWSER 0x0194
50 #define AC_SEARCH 0x0221
51 #define AC_HOME 0x0223
52 #define AC_BACK 0x0224
53 #define AC_FORWARD 0x0225
54 #define AC_STOP 0x0226
55 #define AC_REFRESH 0x0227
56 #define AC_BOOKMARKS 0x022A
57 // supplement for Bluegiga iWRAP HID(not supported by Windows?)
58 #define AL_LOCK 0x019E
59 #define TRANSPORT_RECORD 0x00B2
60 #define TRANSPORT_REWIND 0x00B4
61 #define TRANSPORT_EJECT 0x00B8
62 #define AC_MINIMIZE 0x0206
63
64 // Generic Desktop Page(0x01)
65 #define SYSTEM_POWER_DOWN 0x0081
66 #define SYSTEM_SLEEP 0x0082
67 #define SYSTEM_WAKE_UP 0x0083
68
69
70 // key report size(NKRO or boot mode)
71 #if defined(HOST_PJRC)
72 # include "usb.h"
73 # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
74 # define REPORT_KEYS KBD2_REPORT_KEYS
75 # else
76 # define REPORT_KEYS KBD_REPORT_KEYS
77 # endif
78 #else
79 # define REPORT_KEYS 6
80 #endif
81
82
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86
87 typedef struct {
88 uint8_t mods;
89 uint8_t rserved;
90 uint8_t keys[REPORT_KEYS];
91 } __attribute__ ((packed)) report_keyboard_t;
92
93 typedef struct {
94 uint8_t buttons;
95 int8_t x;
96 int8_t y;
97 int8_t v;
98 int8_t h;
99 } __attribute__ ((packed)) report_mouse_t;
100
101
102 static uint16_t key2system(uint8_t key)
103 {
104 uint16_t usage = 0;
105 switch (key) {
106 case KC_SYSTEM_POWER:
107 usage = SYSTEM_POWER_DOWN;
108 break;
109 case KC_SYSTEM_SLEEP:
110 usage = SYSTEM_SLEEP;
111 break;
112 case KC_SYSTEM_WAKE:
113 usage = SYSTEM_WAKE_UP;
114 break;
115 }
116 return usage;
117 }
118
119 static uint16_t key2consumer(uint8_t key)
120 {
121 uint16_t usage = 0;
122 switch (key) {
123 case KC_AUDIO_MUTE:
124 usage = AUDIO_MUTE;
125 break;
126 case KC_AUDIO_VOL_UP:
127 usage = AUDIO_VOL_UP;
128 break;
129 case KC_AUDIO_VOL_DOWN:
130 usage = AUDIO_VOL_DOWN;
131 break;
132 case KC_MEDIA_NEXT_TRACK:
133 usage = TRANSPORT_NEXT_TRACK;
134 break;
135 case KC_MEDIA_PREV_TRACK:
136 usage = TRANSPORT_PREV_TRACK;
137 break;
138 case KC_MEDIA_STOP:
139 usage = TRANSPORT_STOP;
140 break;
141 case KC_MEDIA_PLAY_PAUSE:
142 usage = TRANSPORT_PLAY_PAUSE;
143 break;
144 case KC_MEDIA_SELECT:
145 usage = AL_CC_CONFIG;
146 break;
147 case KC_MAIL:
148 usage = AL_EMAIL;
149 break;
150 case KC_CALCULATOR:
151 usage = AL_CALCULATOR;
152 break;
153 case KC_MY_COMPUTER:
154 usage = AL_LOCAL_BROWSER;
155 break;
156 case KC_WWW_SEARCH:
157 usage = AC_SEARCH;
158 break;
159 case KC_WWW_HOME:
160 usage = AC_HOME;
161 break;
162 case KC_WWW_BACK:
163 usage = AC_BACK;
164 break;
165 case KC_WWW_FORWARD:
166 usage = AC_FORWARD;
167 break;
168 case KC_WWW_STOP:
169 usage = AC_STOP;
170 break;
171 case KC_WWW_REFRESH:
172 usage = AC_REFRESH;
173 break;
174 case KC_WWW_FAVORITES:
175 usage = AC_BOOKMARKS;
176 break;
177 }
178 return usage;
179 }
180
181 #ifdef __cplusplus
182 }
183 #endif
184
185 #endif
Imprint / Impressum