aboutsummaryrefslogtreecommitdiff
path: root/common/report.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/report.h')
-rw-r--r--common/report.h121
1 files changed, 36 insertions, 85 deletions
diff --git a/common/report.h b/common/report.h
index e8582d81f..0995189b3 100644
--- a/common/report.h
+++ b/common/report.h
@@ -1,5 +1,5 @@
1/* 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
3 3
4This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#define REPORT_H 19#define REPORT_H
20 20
21#include <stdint.h> 21#include <stdint.h>
22#include <keycode.h> 22#include "keycode.h"
23 23
24 24
25/* report id */ 25/* report id */
@@ -34,8 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
34#define MOUSE_BTN4 (1<<3) 34#define MOUSE_BTN4 (1<<3)
35#define MOUSE_BTN5 (1<<4) 35#define MOUSE_BTN5 (1<<4)
36 36
37// Consumer Page(0x0C) 37/* Consumer Page(0x0C)
38// following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx 38 * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx
39 */
39#define AUDIO_MUTE 0x00E2 40#define AUDIO_MUTE 0x00E2
40#define AUDIO_VOL_UP 0x00E9 41#define AUDIO_VOL_UP 0x00E9
41#define AUDIO_VOL_DOWN 0x00EA 42#define AUDIO_VOL_DOWN 0x00EA
@@ -43,10 +44,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
43#define TRANSPORT_PREV_TRACK 0x00B6 44#define TRANSPORT_PREV_TRACK 0x00B6
44#define TRANSPORT_STOP 0x00B7 45#define TRANSPORT_STOP 0x00B7
45#define TRANSPORT_PLAY_PAUSE 0x00CD 46#define TRANSPORT_PLAY_PAUSE 0x00CD
47/* application launch */
46#define AL_CC_CONFIG 0x0183 48#define AL_CC_CONFIG 0x0183
47#define AL_EMAIL 0x018A 49#define AL_EMAIL 0x018A
48#define AL_CALCULATOR 0x0192 50#define AL_CALCULATOR 0x0192
49#define AL_LOCAL_BROWSER 0x0194 51#define AL_LOCAL_BROWSER 0x0194
52/* application control */
50#define AC_SEARCH 0x0221 53#define AC_SEARCH 0x0221
51#define AC_HOME 0x0223 54#define AC_HOME 0x0223
52#define AC_BACK 0x0224 55#define AC_BACK 0x0224
@@ -54,20 +57,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
54#define AC_STOP 0x0226 57#define AC_STOP 0x0226
55#define AC_REFRESH 0x0227 58#define AC_REFRESH 0x0227
56#define AC_BOOKMARKS 0x022A 59#define AC_BOOKMARKS 0x022A
57// supplement for Bluegiga iWRAP HID(not supported by Windows?) 60/* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
58#define AL_LOCK 0x019E 61#define AL_LOCK 0x019E
59#define TRANSPORT_RECORD 0x00B2 62#define TRANSPORT_RECORD 0x00B2
60#define TRANSPORT_REWIND 0x00B4 63#define TRANSPORT_REWIND 0x00B4
61#define TRANSPORT_EJECT 0x00B8 64#define TRANSPORT_EJECT 0x00B8
62#define AC_MINIMIZE 0x0206 65#define AC_MINIMIZE 0x0206
63 66
64// Generic Desktop Page(0x01) 67/* Generic Desktop Page(0x01) - system power control */
65#define SYSTEM_POWER_DOWN 0x0081 68#define SYSTEM_POWER_DOWN 0x0081
66#define SYSTEM_SLEEP 0x0082 69#define SYSTEM_SLEEP 0x0082
67#define SYSTEM_WAKE_UP 0x0083 70#define SYSTEM_WAKE_UP 0x0083
68 71
69 72
70// key report size(NKRO or boot mode) 73/* key report size(NKRO or boot mode) */
71#if defined(HOST_PJRC) 74#if defined(HOST_PJRC)
72# include "usb.h" 75# include "usb.h"
73# if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS 76# if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
@@ -99,84 +102,32 @@ typedef struct {
99} __attribute__ ((packed)) report_mouse_t; 102} __attribute__ ((packed)) report_mouse_t;
100 103
101 104
102static uint16_t key2system(uint8_t key) 105/* keycode to system usage */
103{ 106#define KEYCODE2SYSTEM(key) \
104 uint16_t usage = 0; 107 (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \
105 switch (key) { 108 (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \
106 case KC_SYSTEM_POWER: 109 (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
107 usage = SYSTEM_POWER_DOWN; 110
108 break; 111/* keycode to consumer usage */
109 case KC_SYSTEM_SLEEP: 112#define KEYCODE2CONSUMER(key) \
110 usage = SYSTEM_SLEEP; 113 (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \
111 break; 114 (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \
112 case KC_SYSTEM_WAKE: 115 (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \
113 usage = SYSTEM_WAKE_UP; 116 (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \
114 break; 117 (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \
115 } 118 (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \
116 return usage; 119 (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \
117} 120 (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \
118 121 (key == KC_MAIL ? AL_EMAIL : \
119static uint16_t key2consumer(uint8_t key) 122 (key == KC_CALCULATOR ? AL_CALCULATOR : \
120{ 123 (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \
121 uint16_t usage = 0; 124 (key == KC_WWW_SEARCH ? AC_SEARCH : \
122 switch (key) { 125 (key == KC_WWW_HOME ? AC_HOME : \
123 case KC_AUDIO_MUTE: 126 (key == KC_WWW_BACK ? AC_BACK : \
124 usage = AUDIO_MUTE; 127 (key == KC_WWW_FORWARD ? AC_FORWARD : \
125 break; 128 (key == KC_WWW_STOP ? AC_STOP : \
126 case KC_AUDIO_VOL_UP: 129 (key == KC_WWW_REFRESH ? AC_REFRESH : \
127 usage = AUDIO_VOL_UP; 130 (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))
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 131
181#ifdef __cplusplus 132#ifdef __cplusplus
182} 133}