aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2011-01-05 00:04:25 +0900
committertmk <nobody@nowhere>2011-01-05 00:19:43 +0900
commit6b0c939d72c11e404f84c926cf82f9501f8511ff (patch)
tree9df22c1991b8b293442b2f12fac08e910dc49d58
parent7272c65d3d24187487e7d38e332401002f5f233b (diff)
downloadqmk_firmware-6b0c939d72c11e404f84c926cf82f9501f8511ff.tar.gz
qmk_firmware-6b0c939d72c11e404f84c926cf82f9501f8511ff.zip
add a build option: USB_EXTRA_ENABLE
-rw-r--r--Makefile.common40
-rw-r--r--hhkb/Makefile12
-rw-r--r--key_process.c19
-rw-r--r--macway/Makefile13
-rw-r--r--macway/config.h2
-rwxr-xr-xusb.c60
-rw-r--r--usb_extra.h10
7 files changed, 121 insertions, 35 deletions
diff --git a/Makefile.common b/Makefile.common
index 9e995c908..795e7b999 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -53,15 +53,18 @@ SRC = tmk.c \
53 layer.c \ 53 layer.c \
54 key_process.c \ 54 key_process.c \
55 usb_keyboard.c \ 55 usb_keyboard.c \
56 usb_mouse.c \
57 usb_debug.c \ 56 usb_debug.c \
58 usb_extra.c \
59 usb.c \ 57 usb.c \
60 jump_bootloader.c \ 58 jump_bootloader.c \
61 print.c \ 59 print.c \
62 timer.c \ 60 timer.c \
63 util.c 61 util.c
64SRC += $(TARGET_SRC) 62SRC += $(TARGET_SRC)
63
64# Option modules
65ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
66 SRC += usb_mouse.c
67endif
65ifdef MOUSEKEY_ENABLE 68ifdef MOUSEKEY_ENABLE
66 SRC += mousekey.c 69 SRC += mousekey.c
67endif 70endif
@@ -69,6 +72,17 @@ ifdef PS2_MOUSE_ENABLE
69 SRC += ps2.c \ 72 SRC += ps2.c \
70 ps2_mouse.c 73 ps2_mouse.c
71endif 74endif
75ifdef USB_EXTRA_ENABLE
76 SRC += usb_extra.c
77endif
78
79ALL_SRC = $(SRC)
80ALL_SRC += usb_mouse.c \
81 mousekey.c \
82 ps2.c \
83 ps2_mouse.c \
84 usb_extra.c
85
72 86
73# C source file search path 87# C source file search path
74VPATH = $(TARGET_DIR):$(COMMON_DIR) 88VPATH = $(TARGET_DIR):$(COMMON_DIR)
@@ -127,15 +141,21 @@ CSTANDARD = -std=gnu99
127 141
128 142
129OPT_DEFS = 143OPT_DEFS =
130ifdef USB_NKRO_ENABLE
131 OPT_DEFS += -DUSB_NKRO_ENABLE
132endif
133ifdef MOUSEKEY_ENABLE 144ifdef MOUSEKEY_ENABLE
134 OPT_DEFS += -DMOUSEKEY_ENABLE 145 OPT_DEFS += -DMOUSEKEY_ENABLE
135endif 146endif
136ifdef PS2_MOUSE_ENABLE 147ifdef PS2_MOUSE_ENABLE
137 OPT_DEFS += -DPS2_MOUSE_ENABLE 148 OPT_DEFS += -DPS2_MOUSE_ENABLE
138endif 149endif
150ifdef USB_EXTRA_ENABLE
151 OPT_DEFS += -DUSB_EXTRA_ENABLE
152endif
153ifdef USB_NKRO_ENABLE
154 OPT_DEFS += -DUSB_NKRO_ENABLE
155endif
156ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
157 OPT_DEFS += -DUSB_MOUSE_ENABLE
158endif
139 159
140# Place -D or -U options here for C sources 160# Place -D or -U options here for C sources
141CDEFS = -DF_CPU=$(F_CPU)UL 161CDEFS = -DF_CPU=$(F_CPU)UL
@@ -622,11 +642,11 @@ clean_list :
622 $(REMOVE) $(TARGET).map 642 $(REMOVE) $(TARGET).map
623 $(REMOVE) $(TARGET).sym 643 $(REMOVE) $(TARGET).sym
624 $(REMOVE) $(TARGET).lss 644 $(REMOVE) $(TARGET).lss
625 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) 645 $(REMOVE) $(ALL_SRC:%.c=$(OBJDIR)/%.o)
626 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) 646 $(REMOVE) $(ALL_SRC:%.c=$(OBJDIR)/%.lst)
627 $(REMOVE) $(SRC:.c=.s) 647 $(REMOVE) $(ALL_SRC:.c=.s)
628 $(REMOVE) $(SRC:.c=.d) 648 $(REMOVE) $(ALL_SRC:.c=.d)
629 $(REMOVE) $(SRC:.c=.i) 649 $(REMOVE) $(ALL_SRC:.c=.i)
630 $(REMOVEDIR) .dep 650 $(REMOVEDIR) .dep
631 651
632 652
diff --git a/hhkb/Makefile b/hhkb/Makefile
index 943785fef..f2192888f 100644
--- a/hhkb/Makefile
+++ b/hhkb/Makefile
@@ -69,10 +69,12 @@ MCU = at90usb1286 # Teensy++ 2.0
69F_CPU = 16000000 69F_CPU = 16000000
70 70
71 71
72# Options 72# Build Options
73# comment out to disable 73# comment out to disable the options.
74USB_NKRO_ENABLE = yes 74MOUSEKEY_ENABLE = yes # Mouse keys
75MOUSEKEY_ENABLE = yes 75#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
76#PS2_MOUSE_ENABLE = yes 76USB_EXTRA_ENABLE = yes # Enhanced feature for Windows(Audio control and System control)
77USB_NKRO_ENABLE = yes # USB Nkey Rollover
78
77 79
78include $(COMMON_DIR)/Makefile.common 80include $(COMMON_DIR)/Makefile.common
diff --git a/key_process.c b/key_process.c
index e3bee02e3..2d4e78819 100644
--- a/key_process.c
+++ b/key_process.c
@@ -8,8 +8,6 @@
8#include "util.h" 8#include "util.h"
9#include "jump_bootloader.h" 9#include "jump_bootloader.h"
10#include "usb_keyboard.h" 10#include "usb_keyboard.h"
11#include "usb_mouse.h"
12#include "usb_extra.h"
13#include "usb_keycodes.h" 11#include "usb_keycodes.h"
14#include "usb.h" 12#include "usb.h"
15#include "layer.h" 13#include "layer.h"
@@ -22,6 +20,12 @@
22#ifdef PS2_MOUSE_ENABLE 20#ifdef PS2_MOUSE_ENABLE
23# include "ps2_mouse.h" 21# include "ps2_mouse.h"
24#endif 22#endif
23#ifdef USB_EXTRA_ENABLE
24# include "usb_extra.h"
25#endif
26#ifdef USB_MOUSE_ENABLE
27# include "usb_mouse.h"
28#endif
25 29
26 30
27// TODO: refactoring 31// TODO: refactoring
@@ -67,6 +71,7 @@ void proc_matrix(void) {
67#endif 71#endif
68 } 72 }
69 73
74#ifdef USB_EXTRA_ENABLE
70 // audio control & system control 75 // audio control & system control
71 else if (code == KB_MUTE) { 76 else if (code == KB_MUTE) {
72 usb_extra_audio_send(AUDIO_MUTE); 77 usb_extra_audio_send(AUDIO_MUTE);
@@ -88,6 +93,7 @@ void proc_matrix(void) {
88 } 93 }
89 _delay_ms(1000); 94 _delay_ms(1000);
90 } 95 }
96#endif
91 97
92 // normal keys 98 // normal keys
93 else { 99 else {
@@ -259,7 +265,9 @@ void proc_matrix(void) {
259 print("usb_keyboard_protocol:"); phex(usb_keyboard_protocol); print("\n"); 265 print("usb_keyboard_protocol:"); phex(usb_keyboard_protocol); print("\n");
260 print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n"); 266 print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n");
261 print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n"); 267 print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n");
268#ifdef USB_MOUSE_ENABLE
262 print("usb_mouse_protocol:"); phex(usb_mouse_protocol); print("\n"); 269 print("usb_mouse_protocol:"); phex(usb_mouse_protocol); print("\n");
270#endif
263 if (usb_keyboard_nkro) print("USB_NKRO: enabled\n"); else print("USB_NKRO: disabled\n"); 271 if (usb_keyboard_nkro) print("USB_NKRO: enabled\n"); else print("USB_NKRO: disabled\n");
264 _delay_ms(500); 272 _delay_ms(500);
265 break; 273 break;
@@ -267,13 +275,16 @@ void proc_matrix(void) {
267 usb_keyboard_clear_report(); 275 usb_keyboard_clear_report();
268 usb_keyboard_send(); 276 usb_keyboard_send();
269 usb_keyboard_protocol = !usb_keyboard_protocol; 277 usb_keyboard_protocol = !usb_keyboard_protocol;
270 usb_mouse_protocol = !usb_mouse_protocol;
271 print("keyboard protcol: "); 278 print("keyboard protcol: ");
272 if (usb_keyboard_protocol) print("report"); else print("boot"); 279 if (usb_keyboard_protocol) print("report"); else print("boot");
273 print("\n"); 280 print("\n");
281
282#ifdef USB_MOUSE_ENABLE
283 usb_mouse_protocol = !usb_mouse_protocol;
274 print("mouse protcol: "); 284 print("mouse protcol: ");
275 if (usb_mouse_protocol) print("report"); else print("boot"); 285 if (usb_mouse_protocol) print("report"); else print("boot");
276 print("\n"); 286 print("\n");
287#endif
277 _delay_ms(1000); 288 _delay_ms(1000);
278 break; 289 break;
279#ifdef USB_NKRO_ENABLE 290#ifdef USB_NKRO_ENABLE
@@ -285,6 +296,7 @@ void proc_matrix(void) {
285 _delay_ms(1000); 296 _delay_ms(1000);
286 break; 297 break;
287#endif 298#endif
299#ifdef USB_EXTRA_ENABLE
288 case KB_ESC: 300 case KB_ESC:
289 usb_keyboard_clear_report(); 301 usb_keyboard_clear_report();
290 usb_keyboard_send(); 302 usb_keyboard_send();
@@ -295,6 +307,7 @@ void proc_matrix(void) {
295 } 307 }
296 _delay_ms(1000); 308 _delay_ms(1000);
297 break; 309 break;
310#endif
298 } 311 }
299 } 312 }
300 313
diff --git a/macway/Makefile b/macway/Makefile
index fffe1ad54..49dba6746 100644
--- a/macway/Makefile
+++ b/macway/Makefile
@@ -69,10 +69,13 @@ MCU = atmega32u4 # Teensy 2.0
69F_CPU = 16000000 69F_CPU = 16000000
70 70
71 71
72# Options 72# Build Options
73# comment out to disable 73# comment out to disable the options.
74#USB_NKRO_ENABLE = yes 74#
75MOUSEKEY_ENABLE = yes 75MOUSEKEY_ENABLE = yes # Mouse keys
76PS2_MOUSE_ENABLE = yes 76PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
77USB_EXTRA_ENABLE = yes # Enhanced feature for Windows(Audio control and System control)
78#USB_NKRO_ENABLE = yes # USB Nkey Rollover
79
77 80
78include $(COMMON_DIR)/Makefile.common 81include $(COMMON_DIR)/Makefile.common
diff --git a/macway/config.h b/macway/config.h
index de9fc78b1..41bdc33de 100644
--- a/macway/config.h
+++ b/macway/config.h
@@ -2,7 +2,7 @@
2#define CONFIG_H 2#define CONFIG_H
3 3
4#define VENDOR_ID 0xFEED 4#define VENDOR_ID 0xFEED
5#define PRODUCT_ID 0xBEEF 5#define PRODUCT_ID 0xBEE0
6#define MANUFACTURER t.m.k. 6#define MANUFACTURER t.m.k.
7#define PRODUCT Macway mod 7#define PRODUCT Macway mod
8#define DESCRIPTION t.m.k. keyboard firmware for Macway mod 8#define DESCRIPTION t.m.k. keyboard firmware for Macway mod
diff --git a/usb.c b/usb.c
index 2ec20ca22..845b00bea 100755
--- a/usb.c
+++ b/usb.c
@@ -91,15 +91,23 @@ bool suspend = false;
91static const uint8_t PROGMEM endpoint_config_table[] = { 91static const uint8_t PROGMEM endpoint_config_table[] = {
92 // enable, UECFG0X(type, direction), UECFG1X(size, bank, allocation) 92 // enable, UECFG0X(type, direction), UECFG1X(size, bank, allocation)
93 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD_SIZE) | KBD_BUFFER, // 1 93 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD_SIZE) | KBD_BUFFER, // 1
94#ifdef USB_MOUSE_ENABLE
94 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, // 2 95 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, // 2
96#else
97 0, // 2
98#endif
95 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3 99 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3
100#ifdef USB_EXTRA_ENABLE
96 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 101 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4
102#else
103 0, // 4
104#endif
97#ifdef USB_NKRO_ENABLE 105#ifdef USB_NKRO_ENABLE
98 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD2_SIZE) | KBD2_BUFFER, // 5 106 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD2_SIZE) | KBD2_BUFFER, // 5
99#else 107#else
100 0, // 5 108 0, // 5
101#endif 109#endif
102 0, // 6 110 0, // 6
103}; 111};
104 112
105 113
@@ -205,6 +213,7 @@ static uint8_t PROGMEM keyboard2_hid_report_desc[] = {
205}; 213};
206#endif 214#endif
207 215
216#ifdef USB_MOUSE_ENABLE
208// Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension 217// Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
209// http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521 218// http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521
210// http://www.keil.com/forum/15671/ 219// http://www.keil.com/forum/15671/
@@ -281,6 +290,7 @@ static uint8_t PROGMEM mouse_hid_report_desc[] = {
281 0xc0, // END_COLLECTION 290 0xc0, // END_COLLECTION
282 0xc0 // END_COLLECTION 291 0xc0 // END_COLLECTION
283}; 292};
293#endif
284 294
285static uint8_t PROGMEM debug_hid_report_desc[] = { 295static uint8_t PROGMEM debug_hid_report_desc[] = {
286 0x06, 0x31, 0xFF, // Usage Page 0xFF31 (vendor defined) 296 0x06, 0x31, 0xFF, // Usage Page 0xFF31 (vendor defined)
@@ -295,6 +305,7 @@ static uint8_t PROGMEM debug_hid_report_desc[] = {
295 0xC0 // end collection 305 0xC0 // end collection
296}; 306};
297 307
308#ifdef USB_EXTRA_ENABLE
298// audio controls & system controls 309// audio controls & system controls
299// http://www.microsoft.com/whdc/archive/w2kbd.mspx 310// http://www.microsoft.com/whdc/archive/w2kbd.mspx
300static uint8_t PROGMEM extra_hid_report_desc[] = { 311static uint8_t PROGMEM extra_hid_report_desc[] = {
@@ -331,18 +342,37 @@ static uint8_t PROGMEM extra_hid_report_desc[] = {
331 0x81, 0x07, // INPUT (Cnst,Var,Rel) 342 0x81, 0x07, // INPUT (Cnst,Var,Rel)
332 0xc0 // END_COLLECTION 343 0xc0 // END_COLLECTION
333}; 344};
345#endif
346
347#define KBD_HID_DESC_NUM 0
348#define KBD_HID_DESC_OFFSET (9+(9+9+7)*KBD_HID_DESC_NUM+9)
349
350#ifdef USB_MOUSE_ENABLE
351# define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 1)
352# define MOUSE_HID_DESC_OFFSET (9+(9+9+7)*MOUSE_HID_DESC_NUM+9)
353#else
354# define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 0)
355#endif
356
357#define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 1)
358#define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*DEBUG_HID_DESC_NUM+9)
359
360#ifdef USB_EXTRA_ENABLE
361# define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 1)
362# define EXTRA_HID_DESC_OFFSET (9+(9+9+7)*EXTRA_HID_DESC_NUM+9)
363#else
364# define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 0)
365#endif
334 366
335#define KBD_HID_DESC_OFFSET (9+(9+9+7)*0+9)
336#define MOUSE_HID_DESC_OFFSET (9+(9+9+7)*1+9)
337#define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*2+9)
338#define EXTRA_HID_DESC_OFFSET (9+(9+9+7)*3+9)
339#ifdef USB_NKRO_ENABLE 367#ifdef USB_NKRO_ENABLE
340# define NUM_INTERFACES 5 368# define KBD2_HID_DESC_NUM (EXTRA_HID_DESC_NUM + 1)
341# define KBD2_HID_DESC_OFFSET (9+(9+9+7)*4+9) 369# define KBD2_HID_DESC_OFFSET (9+(9+9+7)*EXTRA_HID_DESC_NUM+9)
342#else 370#else
343# define NUM_INTERFACES 4 371# define KBD2_HID_DESC_NUM (EXTRA_HID_DESC_NUM + 0)
344#endif 372#endif
345#define CONFIG1_DESC_SIZE (9+(9+9+7)*NUM_INTERFACES) 373
374#define NUM_INTERFACES (KBD2_HID_DESC_NUM + 1)
375#define CONFIG1_DESC_SIZE (9+(9+9+7)*NUM_INTERFACES)
346static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = { 376static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
347 // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10 377 // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10
348 9, // bLength; 378 9, // bLength;
@@ -382,6 +412,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
382 KBD_SIZE, 0, // wMaxPacketSize 412 KBD_SIZE, 0, // wMaxPacketSize
383 10, // bInterval 413 10, // bInterval
384 414
415#ifdef USB_MOUSE_ENABLE
385 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 416 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
386 9, // bLength 417 9, // bLength
387 4, // bDescriptorType 418 4, // bDescriptorType
@@ -413,6 +444,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
413 0x03, // bmAttributes (0x03=intr) 444 0x03, // bmAttributes (0x03=intr)
414 MOUSE_SIZE, 0, // wMaxPacketSize 445 MOUSE_SIZE, 0, // wMaxPacketSize
415 1, // bInterval 446 1, // bInterval
447#endif
416 448
417 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 449 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
418 9, // bLength 450 9, // bLength
@@ -441,6 +473,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
441 DEBUG_TX_SIZE, 0, // wMaxPacketSize 473 DEBUG_TX_SIZE, 0, // wMaxPacketSize
442 1, // bInterval 474 1, // bInterval
443 475
476#ifdef USB_EXTRA_ENABLE
444 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 477 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
445 9, // bLength 478 9, // bLength
446 4, // bDescriptorType 479 4, // bDescriptorType
@@ -467,6 +500,7 @@ static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
467 0x03, // bmAttributes (0x03=intr) 500 0x03, // bmAttributes (0x03=intr)
468 EXTRA_SIZE, 0, // wMaxPacketSize 501 EXTRA_SIZE, 0, // wMaxPacketSize
469 10, // bInterval 502 10, // bInterval
503#endif
470 504
471#ifdef USB_NKRO_ENABLE 505#ifdef USB_NKRO_ENABLE
472 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 506 // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
@@ -537,12 +571,16 @@ static struct descriptor_list_struct {
537 // HID/REPORT descriptors 571 // HID/REPORT descriptors
538 {0x2100, KBD_INTERFACE, config1_descriptor+KBD_HID_DESC_OFFSET, 9}, 572 {0x2100, KBD_INTERFACE, config1_descriptor+KBD_HID_DESC_OFFSET, 9},
539 {0x2200, KBD_INTERFACE, keyboard_hid_report_desc, sizeof(keyboard_hid_report_desc)}, 573 {0x2200, KBD_INTERFACE, keyboard_hid_report_desc, sizeof(keyboard_hid_report_desc)},
574#ifdef USB_MOUSE_ENABLE
540 {0x2100, MOUSE_INTERFACE, config1_descriptor+MOUSE_HID_DESC_OFFSET, 9}, 575 {0x2100, MOUSE_INTERFACE, config1_descriptor+MOUSE_HID_DESC_OFFSET, 9},
541 {0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)}, 576 {0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)},
577#endif
542 {0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9}, 578 {0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9},
543 {0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)}, 579 {0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)},
580#ifdef USB_EXTRA_ENABLE
544 {0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9}, 581 {0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9},
545 {0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)}, 582 {0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)},
583#endif
546#ifdef USB_NKRO_ENABLE 584#ifdef USB_NKRO_ENABLE
547 {0x2100, KBD2_INTERFACE, config1_descriptor+KBD2_HID_DESC_OFFSET, 9}, 585 {0x2100, KBD2_INTERFACE, config1_descriptor+KBD2_HID_DESC_OFFSET, 9},
548 {0x2200, KBD2_INTERFACE, keyboard2_hid_report_desc, sizeof(keyboard2_hid_report_desc)}, 586 {0x2200, KBD2_INTERFACE, keyboard2_hid_report_desc, sizeof(keyboard2_hid_report_desc)},
@@ -879,6 +917,7 @@ ISR(USB_COM_vect)
879 } 917 }
880 } 918 }
881 } 919 }
920#ifdef USB_MOUSE_ENABLE
882 if (wIndex == MOUSE_INTERFACE) { 921 if (wIndex == MOUSE_INTERFACE) {
883 if (bmRequestType == 0xA1) { 922 if (bmRequestType == 0xA1) {
884 if (bRequest == HID_GET_REPORT) { 923 if (bRequest == HID_GET_REPORT) {
@@ -913,6 +952,7 @@ ISR(USB_COM_vect)
913 } 952 }
914 } 953 }
915 } 954 }
955#endif
916 if (wIndex == DEBUG_INTERFACE) { 956 if (wIndex == DEBUG_INTERFACE) {
917 if (bRequest == HID_GET_REPORT && bmRequestType == 0xA1) { 957 if (bRequest == HID_GET_REPORT && bmRequestType == 0xA1) {
918 len = wLength; 958 len = wLength;
diff --git a/usb_extra.h b/usb_extra.h
index 202f3223b..d6f9e8ba0 100644
--- a/usb_extra.h
+++ b/usb_extra.h
@@ -1,5 +1,11 @@
1#ifndef USB_EXTRA_H 1#ifndef USB_EXTRA_H
2#define USB_EXTRA_H 1 2#define USB_EXTRA_H 1
3/*
4 * Enhanced keyboard features for Windows:
5 * Audio control and System control
6 *
7 * http://www.microsoft.com/whdc/archive/w2kbd.mspx
8 */
3 9
4#include <stdint.h> 10#include <stdint.h>
5#include "usb.h" 11#include "usb.h"
@@ -10,11 +16,13 @@
10#define EXTRA_SIZE 2 16#define EXTRA_SIZE 2
11#define EXTRA_BUFFER EP_DOUBLE_BUFFER 17#define EXTRA_BUFFER EP_DOUBLE_BUFFER
12 18
13// http://www.microsoft.com/whdc/archive/w2kbd.mspx 19
20// Consumer Page(0x0C) Consumer Control(0x01)
14#define AUDIO_VOL_UP (1<<0) 21#define AUDIO_VOL_UP (1<<0)
15#define AUDIO_VOL_DOWN (1<<1) 22#define AUDIO_VOL_DOWN (1<<1)
16#define AUDIO_MUTE (1<<2) 23#define AUDIO_MUTE (1<<2)
17 24
25// Generic Desktop Page(0x01) System Control(0x80)
18#define SYSTEM_POWER_DOWN (1<<0) 26#define SYSTEM_POWER_DOWN (1<<0)
19#define SYSTEM_SLEEP (1<<1) 27#define SYSTEM_SLEEP (1<<1)
20#define SYSTEM_WAKE_UP (1<<2) 28#define SYSTEM_WAKE_UP (1<<2)