aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-12-17 03:06:21 +0900
committertmk <nobody@nowhere>2012-12-17 03:06:21 +0900
commit4324e163360db4c6ebd25cab74d09d42b3021278 (patch)
treee5bfc84926b09d6f9234effc7e07f87e51645ec4 /common
parent8a709c2750eab09ec0f83450410a13640931d48e (diff)
downloadqmk_firmware-4324e163360db4c6ebd25cab74d09d42b3021278.tar.gz
qmk_firmware-4324e163360db4c6ebd25cab74d09d42b3021278.zip
Fix action of system and consumer usage.
Diffstat (limited to 'common')
-rw-r--r--common/action.c97
-rw-r--r--common/report.h121
2 files changed, 36 insertions, 182 deletions
diff --git a/common/action.c b/common/action.c
index d4aae207f..45e2276e7 100644
--- a/common/action.c
+++ b/common/action.c
@@ -415,89 +415,6 @@ static void register_code(uint8_t code)
415 host_add_mods(MOD_BIT(code)); 415 host_add_mods(MOD_BIT(code));
416 host_send_keyboard_report(); 416 host_send_keyboard_report();
417 } 417 }
418#ifdef MOUSEKEY_ENABLE
419 else if IS_MOUSEKEY(code) {
420 mousekey_on(code);
421 mousekey_send();
422 }
423#endif
424#ifdef EXTRAKEY_ENABLE
425 else if IS_CONSUMER(code) {
426 uint16_t usage = 0;
427 switch (code) {
428 case KC_AUDIO_MUTE:
429 usage = AUDIO_MUTE;
430 break;
431 case KC_AUDIO_VOL_UP:
432 usage = AUDIO_VOL_UP;
433 break;
434 case KC_AUDIO_VOL_DOWN:
435 usage = AUDIO_VOL_DOWN;
436 break;
437 case KC_MEDIA_NEXT_TRACK:
438 usage = TRANSPORT_NEXT_TRACK;
439 break;
440 case KC_MEDIA_PREV_TRACK:
441 usage = TRANSPORT_PREV_TRACK;
442 break;
443 case KC_MEDIA_STOP:
444 usage = TRANSPORT_STOP;
445 break;
446 case KC_MEDIA_PLAY_PAUSE:
447 usage = TRANSPORT_PLAY_PAUSE;
448 break;
449 case KC_MEDIA_SELECT:
450 usage = AL_CC_CONFIG;
451 break;
452 case KC_MAIL:
453 usage = AL_EMAIL;
454 break;
455 case KC_CALCULATOR:
456 usage = AL_CALCULATOR;
457 break;
458 case KC_MY_COMPUTER:
459 usage = AL_LOCAL_BROWSER;
460 break;
461 case KC_WWW_SEARCH:
462 usage = AC_SEARCH;
463 break;
464 case KC_WWW_HOME:
465 usage = AC_HOME;
466 break;
467 case KC_WWW_BACK:
468 usage = AC_BACK;
469 break;
470 case KC_WWW_FORWARD:
471 usage = AC_FORWARD;
472 break;
473 case KC_WWW_STOP:
474 usage = AC_STOP;
475 break;
476 case KC_WWW_REFRESH:
477 usage = AC_REFRESH;
478 break;
479 case KC_WWW_FAVORITES:
480 usage = AC_BOOKMARKS;
481 break;
482 }
483 host_consumer_send(usage);
484 }
485 else if IS_SYSTEM(code) {
486 uint16_t usage = 0;
487 switch (code) {
488 case KC_SYSTEM_POWER:
489 usage = SYSTEM_POWER_DOWN;
490 break;
491 case KC_SYSTEM_SLEEP:
492 usage = SYSTEM_SLEEP;
493 break;
494 case KC_SYSTEM_WAKE:
495 usage = SYSTEM_WAKE_UP;
496 break;
497 }
498 host_system_send(usage);
499 }
500#endif
501} 418}
502 419
503static void unregister_code(uint8_t code) 420static void unregister_code(uint8_t code)
@@ -510,20 +427,6 @@ static void unregister_code(uint8_t code)
510 host_del_mods(MOD_BIT(code)); 427 host_del_mods(MOD_BIT(code));
511 host_send_keyboard_report(); 428 host_send_keyboard_report();
512 } 429 }
513#ifdef MOUSEKEY_ENABLE
514 else if IS_MOUSEKEY(code) {
515 mousekey_off(code);
516 mousekey_send();
517 }
518#endif
519#ifdef EXTRAKEY_ENABLE
520 else if IS_CONSUMER(code) {
521 host_consumer_send(0x0000);
522 }
523 else if IS_SYSTEM(code) {
524 host_system_send(0x0000);
525 }
526#endif
527} 430}
528 431
529static void register_mods(uint8_t mods) 432static void register_mods(uint8_t mods)
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}