aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2011-02-13 00:15:51 +0900
committertmk <nobody@nowhere>2011-02-22 03:09:05 +0900
commit9a938eecbd2b70c970992583b5c16da717d8e254 (patch)
tree22ac37491f88aa60d917a18696c93f61a429d43c
parent2b8cd88ab142068eed0a3f230a3de79deb567536 (diff)
downloadqmk_firmware-9a938eecbd2b70c970992583b5c16da717d8e254.tar.gz
qmk_firmware-9a938eecbd2b70c970992583b5c16da717d8e254.zip
host interface for pjrc
-rw-r--r--Makefile.common19
-rw-r--r--Makefile.pjrc19
-rw-r--r--Makefile.rules16
-rw-r--r--Makefile.vusb10
-rw-r--r--command.c184
-rw-r--r--command.h6
-rw-r--r--hhkb/Makefile1
-rw-r--r--hhkb/config.h5
-rw-r--r--hhkb/led.c9
-rw-r--r--host.h21
-rw-r--r--keyboard.c13
-rw-r--r--keyboard.h5
-rw-r--r--layer.c1
-rw-r--r--mousekey.c42
-rw-r--r--pjrc/host.c135
-rwxr-xr-xpjrc/usb.c8
-rw-r--r--pjrc/usb.h21
-rw-r--r--pjrc/usb_keyboard.c183
-rw-r--r--pjrc/usb_keyboard.h68
-rw-r--r--ps2_vusb/Makefile1
-rw-r--r--ps2_vusb/README12
-rw-r--r--ps2_vusb/config.h14
-rw-r--r--vusb/host.c (renamed from ps2_vusb/host_vusb.c)8
-rw-r--r--vusb/host_vusb.h (renamed from ps2_vusb/host_vusb.h)0
24 files changed, 472 insertions, 329 deletions
diff --git a/Makefile.common b/Makefile.common
index ae2a562ce..1922def00 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -1,18 +1,35 @@
1SRC += keyboard.c \ 1SRC += host.c \
2 keyboard.c \
2 command.c \ 3 command.c \
3 layer.c \ 4 layer.c \
4 timer.c \ 5 timer.c \
5 print.c \ 6 print.c \
6 util.c 7 util.c
7 8
9
8# Option modules 10# Option modules
9ifdef MOUSEKEY_ENABLE 11ifdef MOUSEKEY_ENABLE
10 SRC += mousekey.c 12 SRC += mousekey.c
13 OPT_DEFS += -DMOUSEKEY_ENABLE
11endif 14endif
12 15
13ifdef PS2_MOUSE_ENABLE 16ifdef PS2_MOUSE_ENABLE
14 SRC += ps2.c \ 17 SRC += ps2.c \
15 ps2_mouse.c 18 ps2_mouse.c
19 OPT_DEFS += -DPS2_MOUSE_ENABLE
20endif
21
22ifdef USB_EXTRA_ENABLE
23 OPT_DEFS += -DUSB_EXTRA_ENABLE
24endif
25
26ifdef USB_NKRO_ENABLE
27 OPT_DEFS += -DUSB_NKRO_ENABLE
28endif
29
30ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
31 OPT_DEFS += -DUSB_MOUSE_ENABLE
16endif 32endif
17 33
34
18include $(COMMON_DIR)/Makefile.rules 35include $(COMMON_DIR)/Makefile.rules
diff --git a/Makefile.pjrc b/Makefile.pjrc
index 4c0e83504..894d4dcee 100644
--- a/Makefile.pjrc
+++ b/Makefile.pjrc
@@ -1,19 +1,16 @@
1# Following variables need to be set in <target>/Makefile: 1OPT_DEFS += -DHOST_PJRC
2# TARGET
3# COMMON_DIR
4# TARGET_DIR
5# TARGET_SRC
6# MCU
7# F_CPU
8 2
9
10# List C source files here. (C dependencies are automatically generated.)
11SRC = usb_keyboard.c \ 3SRC = usb_keyboard.c \
12 usb_debug.c \ 4 usb_debug.c \
13 usb.c \ 5 usb.c \
14 jump_bootloader.c 6 jump_bootloader.c
15SRC += $(TARGET_SRC) 7SRC += $(TARGET_SRC)
16 8
9
10# C source file search path
11VPATH = $(TARGET_DIR):$(COMMON_DIR):$(COMMON_DIR)/pjrc
12
13
17# Option modules 14# Option modules
18ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) 15ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
19 SRC += usb_mouse.c 16 SRC += usb_mouse.c
@@ -22,7 +19,3 @@ endif
22ifdef USB_EXTRA_ENABLE 19ifdef USB_EXTRA_ENABLE
23 SRC += usb_extra.c 20 SRC += usb_extra.c
24endif 21endif
25
26
27# C source file search path
28VPATH = $(TARGET_DIR):$(COMMON_DIR):$(COMMON_DIR)/pjrc
diff --git a/Makefile.rules b/Makefile.rules
index 3de1c0def..77bdf8846 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -78,22 +78,6 @@ EXTRAINCDIRS = $(subst :, ,$(VPATH))
78CSTANDARD = -std=gnu99 78CSTANDARD = -std=gnu99
79 79
80 80
81ifdef MOUSEKEY_ENABLE
82 OPT_DEFS += -DMOUSEKEY_ENABLE
83endif
84ifdef PS2_MOUSE_ENABLE
85 OPT_DEFS += -DPS2_MOUSE_ENABLE
86endif
87ifdef USB_EXTRA_ENABLE
88 OPT_DEFS += -DUSB_EXTRA_ENABLE
89endif
90ifdef USB_NKRO_ENABLE
91 OPT_DEFS += -DUSB_NKRO_ENABLE
92endif
93ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
94 OPT_DEFS += -DUSB_MOUSE_ENABLE
95endif
96
97# Place -D or -U options here for C sources 81# Place -D or -U options here for C sources
98CDEFS = -DF_CPU=$(F_CPU)UL 82CDEFS = -DF_CPU=$(F_CPU)UL
99CDEFS += $(OPT_DEFS) 83CDEFS += $(OPT_DEFS)
diff --git a/Makefile.vusb b/Makefile.vusb
index 1d92d13bc..0ef1b1155 100644
--- a/Makefile.vusb
+++ b/Makefile.vusb
@@ -1,13 +1,5 @@
1# Following variables need to be set in <target>/Makefile: 1OPT_DEFS += -DHOST_VUSB
2# TARGET
3# COMMON_DIR
4# TARGET_DIR
5# TARGET_SRC
6# MCU
7# F_CPU
8 2
9
10# List C source files here. (C dependencies are automatically generated.)
11SRC = usbdrv.c \ 3SRC = usbdrv.c \
12 usbdrvasm.S \ 4 usbdrvasm.S \
13 oddebug.c 5 oddebug.c
diff --git a/command.c b/command.c
new file mode 100644
index 000000000..a31a4007b
--- /dev/null
+++ b/command.c
@@ -0,0 +1,184 @@
1#include <stdint.h>
2#include <stdbool.h>
3#include <util/delay.h>
4#include "usb_keycodes.h"
5#include "host.h"
6#include "print.h"
7#include "debug.h"
8#include "util.h"
9#include "timer.h"
10#include "layer.h"
11#include "matrix_skel.h"
12#include "command.h"
13
14#ifdef HOST_PJRC
15# include "jump_bootloader.h"
16# include "usb_keyboard.h"
17# ifdef USB_EXTRA_ENABLE
18# include "usb_extra.h"
19# endif
20#endif
21
22
23static void help(void);
24static void switch_layer(uint8_t layer);
25
26
27uint8_t command_proc(void)
28{
29 if (!IS_COMMAND())
30 return 0;
31
32 uint8_t processed = 1;
33 bool last_print_enable = print_enable;
34 print_enable = true;
35 switch (keyboard_report->keys[0]) {
36 case KB_H:
37 help();
38 break;
39 case KB_B:
40#ifdef HOST_PJRC
41 host_clear_keyboard_report();
42 host_send_keyboard_report();
43 print("jump to bootloader...\n");
44 _delay_ms(1000);
45 jump_bootloader(); // not return
46#endif
47 break;
48 case KB_D:
49 debug_enable = !debug_enable;
50 if (debug_enable) {
51 last_print_enable = true;
52 print("debug enabled.\n");
53 debug_matrix = true;
54 debug_keyboard = true;
55 debug_mouse = true;
56 } else {
57 print("debug disabled.\n");
58 last_print_enable = false;
59 debug_matrix = false;
60 debug_keyboard = false;
61 debug_mouse = false;
62 }
63 break;
64 case KB_X: // debug matrix toggle
65 debug_matrix = !debug_matrix;
66 if (debug_matrix)
67 print("debug matrix enabled.\n");
68 else
69 print("debug matrix disabled.\n");
70 break;
71 case KB_K: // debug keyboard toggle
72 debug_keyboard = !debug_keyboard;
73 if (debug_keyboard)
74 print("debug keyboard enabled.\n");
75 else
76 print("debug keyboard disabled.\n");
77 break;
78 case KB_M: // debug mouse toggle
79 debug_mouse = !debug_mouse;
80 if (debug_mouse)
81 print("debug mouse enabled.\n");
82 else
83 print("debug mouse disabled.\n");
84 break;
85 case KB_V: // print version & information
86 print(STR(DESCRIPTION) "\n");
87 break;
88 case KB_T: // print timer
89 print("timer: "); phex16(timer_count); print("\n");
90 break;
91 case KB_P: // print toggle
92 if (print_enable) {
93 print("print disabled.\n");
94 last_print_enable = false;
95 } else {
96 last_print_enable = true;
97 print("print enabled.\n");
98 }
99 break;
100 case KB_S:
101#ifdef HOST_PJRC
102 print("UDCON: "); phex(UDCON); print("\n");
103 print("UDIEN: "); phex(UDIEN); print("\n");
104 print("UDINT: "); phex(UDINT); print("\n");
105 print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n");
106#endif
107 break;
108#ifdef USB_NKRO_ENABLE
109 case KB_N:
110 keyboard_nkro = !keyboard_nkro;
111 if (keyboard_nkro)
112 print("USB_NKRO: enabled\n");
113 else
114 print("USB_NKRO: disabled\n");
115 break;
116#endif
117#ifdef USB_EXTRA_ENABLE
118 case KB_ESC:
119 if (suspend && remote_wakeup) {
120 usb_remote_wakeup();
121 } else {
122 usb_extra_system_send(SYSTEM_POWER_DOWN);
123 }
124 break;
125#endif
126 case KB_BSPC:
127 matrix_init();
128 print("clear matrix\n");
129 break;
130 case KB_0:
131 switch_layer(0);
132 break;
133 case KB_1:
134 switch_layer(1);
135 break;
136 case KB_2:
137 switch_layer(2);
138 break;
139 case KB_3:
140 switch_layer(3);
141 break;
142 case KB_4:
143 switch_layer(4);
144 break;
145 default:
146 processed = 0;
147 }
148 if (processed)
149 _delay_ms(500);
150 print_enable = last_print_enable;
151 return processed;
152}
153
154static void help(void)
155{
156 print("b: jump to bootloader\n");
157 print("d: toggle debug enable\n");
158 print("x: toggle matrix debug\n");
159 print("k: toggle keyboard debug\n");
160 print("m: toggle mouse debug\n");
161 print("p: toggle print enable\n");
162 print("v: print version\n");
163 print("t: print timer count\n");
164 print("s: print status\n");
165#ifdef USB_NKRO_ENABLE
166 print("n: toggle USB_NKRO\n");
167#endif
168 print("Backspace: clear matrix\n");
169 print("ESC: power down/wake up\n");
170 print("0: switch to Layer0 \n");
171 print("1: switch to Layer1 \n");
172 print("2: switch to Layer2 \n");
173 print("3: switch to Layer3 \n");
174 print("4: switch to Layer4 \n");
175}
176
177static void switch_layer(uint8_t layer)
178{
179 print("current_layer: "); phex(current_layer); print("\n");
180 print("default_layer: "); phex(default_layer); print("\n");
181 current_layer = layer;
182 default_layer = layer;
183 print("switch to Layer: "); phex(layer); print("\n");
184}
diff --git a/command.h b/command.h
new file mode 100644
index 000000000..e83aec625
--- /dev/null
+++ b/command.h
@@ -0,0 +1,6 @@
1#ifndef COMMAND_H
2#define COMMAND
3
4uint8_t command_proc(void);
5
6#endif
diff --git a/hhkb/Makefile b/hhkb/Makefile
index 8e771d955..7c7ed0ee2 100644
--- a/hhkb/Makefile
+++ b/hhkb/Makefile
@@ -9,7 +9,6 @@ TARGET_DIR = .
9 9
10# keyboard dependent files 10# keyboard dependent files
11TARGET_SRC = tmk.c \ 11TARGET_SRC = tmk.c \
12 host_pjrc.c \
13 keymap.c \ 12 keymap.c \
14 matrix.c \ 13 matrix.c \
15 led.c 14 led.c
diff --git a/hhkb/config.h b/hhkb/config.h
index cc86e55ca..b8392aa8e 100644
--- a/hhkb/config.h
+++ b/hhkb/config.h
@@ -13,9 +13,14 @@
13/* matrix size */ 13/* matrix size */
14#define MATRIX_ROWS 8 14#define MATRIX_ROWS 8
15#define MATRIX_COLS 8 15#define MATRIX_COLS 8
16
16/* define if matrix has ghost */ 17/* define if matrix has ghost */
17//#define MATRIX_HAS_GHOST 18//#define MATRIX_HAS_GHOST
18 19
20/* key combination for command */
21#define IS_COMMAND() (keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT))
22
23
19/* USB NKey Rollover */ 24/* USB NKey Rollover */
20#ifdef USB_NKRO_ENABLE 25#ifdef USB_NKRO_ENABLE
21#endif 26#endif
diff --git a/hhkb/led.c b/hhkb/led.c
new file mode 100644
index 000000000..a96176859
--- /dev/null
+++ b/hhkb/led.c
@@ -0,0 +1,9 @@
1#include "stdint.h"
2#include "led.h"
3
4
5/* HHKB has no LEDs */
6void led_set(uint8_t usb_led)
7{
8}
9
diff --git a/host.h b/host.h
index f2c8085c3..5764e02c3 100644
--- a/host.h
+++ b/host.h
@@ -26,7 +26,17 @@
26#define MOUSE_BTN5 (1<<4) 26#define MOUSE_BTN5 (1<<4)
27 27
28 28
29#define REPORT_KEYS 6 29#if defined(HOST_PJRC)
30# include "usb.h"
31# if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
32# define REPORT_KEYS KBD2_REPORT_KEYS
33# else
34# define REPORT_KEYS KBD_REPORT_KEYS
35# endif
36#elif defined(HOST_VUSB)
37# define REPORT_KEYS 6
38#endif
39
30typedef struct { 40typedef struct {
31 uint8_t mods; 41 uint8_t mods;
32 uint8_t rserved; 42 uint8_t rserved;
@@ -37,17 +47,21 @@ typedef struct {
37 uint8_t buttons; 47 uint8_t buttons;
38 int8_t x; 48 int8_t x;
39 int8_t y; 49 int8_t y;
40/*
41 int8_t v; 50 int8_t v;
42 int8_t h; 51 int8_t h;
43 */
44} report_mouse_t; 52} report_mouse_t;
45 53
46 54
55#ifdef USB_NKRO_ENABLE
56extern bool keyboard_nkro;
57#endif
58
47extern report_keyboard_t *keyboard_report; 59extern report_keyboard_t *keyboard_report;
48extern report_keyboard_t *keyboard_report_prev; 60extern report_keyboard_t *keyboard_report_prev;
49 61
50 62
63uint8_t host_keyboard_leds(void);
64
51/* keyboard report operations */ 65/* keyboard report operations */
52void host_add_key(uint8_t key); 66void host_add_key(uint8_t key);
53void host_add_mod_bit(uint8_t mod); 67void host_add_mod_bit(uint8_t mod);
@@ -61,7 +75,6 @@ uint8_t host_get_mods(void);
61 75
62 76
63void host_send_keyboard_report(void); 77void host_send_keyboard_report(void);
64void host_send_mouse_report(void);
65void host_mouse_send(report_mouse_t *report); 78void host_mouse_send(report_mouse_t *report);
66 79
67#endif 80#endif
diff --git a/keyboard.c b/keyboard.c
index cb1c745e2..1a025bd01 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -13,7 +13,7 @@
13#endif 13#endif
14 14
15 15
16static uint8_t last_led = 0; 16static uint8_t last_leds = 0;
17 17
18 18
19void keyboard_init(void) 19void keyboard_init(void)
@@ -125,8 +125,13 @@ void keyboard_proc(void)
125 ps2_mouse_usb_send(); 125 ps2_mouse_usb_send();
126#endif 126#endif
127 127
128 if (last_led != host_keyboard_led()) { 128 if (last_leds != host_keyboard_leds()) {
129 led_set(host_keyboard_led()); 129 keyboard_set_leds(host_keyboard_leds());
130 last_led = host_keyboard_led(); 130 last_leds = host_keyboard_leds();
131 } 131 }
132} 132}
133
134void keyboard_set_leds(uint8_t leds)
135{
136 led_set(leds);
137}
diff --git a/keyboard.h b/keyboard.h
index 5d269e963..01ec72a06 100644
--- a/keyboard.h
+++ b/keyboard.h
@@ -1,10 +1,11 @@
1#ifndef KEYBOARD_H 1#ifndef KEYBOARD_H
2#define KEYBOARD_H 2#define KEYBOARD_H
3 3
4#include <stdint.h>
5
4 6
5void keyboard_init(void); 7void keyboard_init(void);
6void keyboard_proc(void); 8void keyboard_proc(void);
9void keyboard_set_leds(uint8_t leds);
7 10
8#endif 11#endif
9
10
diff --git a/layer.c b/layer.c
index 7138c0ed1..0fe06a456 100644
--- a/layer.c
+++ b/layer.c
@@ -4,6 +4,7 @@
4#include "timer.h" 4#include "timer.h"
5#include "layer.h" 5#include "layer.h"
6 6
7
7/* 8/*
8 * Parameters: 9 * Parameters:
9 * ENTER_DELAY |=======| 10 * ENTER_DELAY |=======|
diff --git a/mousekey.c b/mousekey.c
index 2e9b8cb1a..0c1436b0c 100644
--- a/mousekey.c
+++ b/mousekey.c
@@ -24,11 +24,15 @@ static void mousekey_debug(void);
24# define MOUSEKEY_DELAY_TIME 255 24# define MOUSEKEY_DELAY_TIME 255
25#endif 25#endif
26 26
27// acceleration parameters
28uint8_t mousekey_move_unit = 2;
29uint8_t mousekey_resolution = 5;
30
27 31
28static inline uint8_t move_unit(void) 32static inline uint8_t move_unit(void)
29{ 33{
30 uint16_t unit = 10 + (mousekey_repeat); 34 uint16_t unit = 5 + mousekey_repeat*2;
31 return (unit > 127 ? 127 : unit); 35 return (unit > 63 ? 63 : unit);
32} 36}
33 37
34void mousekey_decode(uint8_t code) 38void mousekey_decode(uint8_t code)
@@ -40,23 +44,18 @@ void mousekey_decode(uint8_t code)
40 else if (code == KB_MS_BTN1) report.buttons |= MOUSE_BTN1; 44 else if (code == KB_MS_BTN1) report.buttons |= MOUSE_BTN1;
41 else if (code == KB_MS_BTN2) report.buttons |= MOUSE_BTN2; 45 else if (code == KB_MS_BTN2) report.buttons |= MOUSE_BTN2;
42 else if (code == KB_MS_BTN3) report.buttons |= MOUSE_BTN3; 46 else if (code == KB_MS_BTN3) report.buttons |= MOUSE_BTN3;
43/*
44 else if (code == KB_MS_BTN4) report.buttons |= MOUSE_BTN4; 47 else if (code == KB_MS_BTN4) report.buttons |= MOUSE_BTN4;
45 else if (code == KB_MS_BTN5) report.buttons |= MOUSE_BTN5; 48 else if (code == KB_MS_BTN5) report.buttons |= MOUSE_BTN5;
46 else if (code == KB_MS_WH_UP) report.v += 1; 49 else if (code == KB_MS_WH_UP) report.v += 1;
47 else if (code == KB_MS_WH_DOWN) report.v -= 1; 50 else if (code == KB_MS_WH_DOWN) report.v -= 1;
48 else if (code == KB_MS_WH_LEFT) report.h -= 1; 51 else if (code == KB_MS_WH_LEFT) report.h -= 1;
49 else if (code == KB_MS_WH_RIGHT)report.h += 1; 52 else if (code == KB_MS_WH_RIGHT)report.h += 1;
50*/
51} 53}
52 54
53bool mousekey_changed(void) 55bool mousekey_changed(void)
54{ 56{
55 return (report.buttons != report_prev.buttons || 57 return (report.buttons != report_prev.buttons ||
56 report.x != report_prev.x || 58 report.x || report.y || report.v || report.h);
57 report.y != report_prev.y ||
58 report.x || report.y);
59 //return (report.buttons != report_prev.buttons || report.x || report.y);
60} 59}
61 60
62void mousekey_send(void) 61void mousekey_send(void)
@@ -65,36 +64,30 @@ void mousekey_send(void)
65 64
66 if (!mousekey_changed()) { 65 if (!mousekey_changed()) {
67 mousekey_repeat = 0; 66 mousekey_repeat = 0;
67 mousekey_clear_report();
68 return; 68 return;
69 } 69 }
70 70
71 // send immediately when buttun state is changed 71 // send immediately when buttun state is changed
72 if (report.buttons == report_prev.buttons) { 72 if (report.buttons == report_prev.buttons) {
73 // TODO: delay parameter setting 73 if (timer_elapsed(last_timer) < 5) {
74 if ((timer_elapsed(last_timer) < (mousekey_repeat == 1 ? 20 : 5))) { 74 mousekey_clear_report();
75 return; 75 return;
76 } 76 }
77 } 77 }
78 78
79 if (mousekey_repeat != 0xFF) {
80 mousekey_repeat++;
81 }
82
79 if (report.x && report.y) { 83 if (report.x && report.y) {
80 report.x *= 0.7; 84 report.x *= 0.7;
81 report.y *= 0.7; 85 report.y *= 0.7;
82 } 86 }
83 87
84 /*
85 print("mousekey_repeat: "); phex(mousekey_repeat); print("\n");
86 print("timer: "); phex16(timer_read()); print("\n");
87 print("last_timer: "); phex16(last_timer); print("\n");
88 print("mousekey: "); phex(report.buttons); print(" "); phex(report.x); print(" "); phex(report.y); print("\n");
89 */
90
91 mousekey_debug(); 88 mousekey_debug();
92
93 host_mouse_send(&report); 89 host_mouse_send(&report);
94 report_prev.buttons = report.buttons; 90 report_prev = report;
95 report_prev.x = report.x;
96 report_prev.y = report.y;
97 if (mousekey_repeat != 0xFF) mousekey_repeat++;
98 last_timer = timer_read(); 91 last_timer = timer_read();
99 mousekey_clear_report(); 92 mousekey_clear_report();
100} 93}
@@ -104,6 +97,8 @@ void mousekey_clear_report(void)
104 report.buttons = 0; 97 report.buttons = 0;
105 report.x = 0; 98 report.x = 0;
106 report.y = 0; 99 report.y = 0;
100 report.v = 0;
101 report.h = 0;
107} 102}
108 103
109static void mousekey_debug(void) 104static void mousekey_debug(void)
@@ -113,9 +108,8 @@ static void mousekey_debug(void)
113 phex(report.buttons); print("|"); 108 phex(report.buttons); print("|");
114 phex(report.x); print(" "); 109 phex(report.x); print(" ");
115 phex(report.y); print(" "); 110 phex(report.y); print(" ");
116/*
117 phex(report.v); print(" "); 111 phex(report.v); print(" ");
118 phex(report.h); 112 phex(report.h);
119*/ 113 phex(mousekey_repeat);
120 print("\n"); 114 print("\n");
121} 115}
diff --git a/pjrc/host.c b/pjrc/host.c
new file mode 100644
index 000000000..7247288bd
--- /dev/null
+++ b/pjrc/host.c
@@ -0,0 +1,135 @@
1#include <stdint.h>
2#include "usb_keycodes.h"
3#include "usb_keyboard.h"
4#include "usb_mouse.h"
5#include "debug.h"
6#include "host.h"
7
8
9#ifdef USB_NKRO_ENABLE
10bool keyboard_nkro = false;
11#endif
12
13static report_keyboard_t report0;
14static report_keyboard_t report1;
15report_keyboard_t *keyboard_report = &report0;
16report_keyboard_t *keyboard_report_prev = &report1;
17
18static inline void add_key_byte(uint8_t code);
19static inline void add_key_bit(uint8_t code);
20
21
22uint8_t host_keyboard_leds(void)
23{
24 return usb_keyboard_leds;
25}
26
27/* keyboard report operations */
28void host_add_key(uint8_t key)
29{
30#ifdef USB_NKRO_ENABLE
31 if (keyboard_nkro) {
32 add_key_bit(key);
33 return;
34 }
35#endif
36 add_key_byte(key);
37}
38
39void host_add_mod_bit(uint8_t mod)
40{
41 keyboard_report->mods |= mod;
42}
43
44void host_set_mods(uint8_t mods)
45{
46 keyboard_report->mods = mods;
47}
48
49void host_add_code(uint8_t code)
50{
51 if (IS_MOD(code)) {
52 host_add_mod_bit(MOD_BIT(code));
53 } else {
54 host_add_key(code);
55 }
56}
57
58void host_swap_keyboard_report(void)
59{
60 report_keyboard_t *tmp = keyboard_report_prev;
61 keyboard_report_prev = keyboard_report;
62 keyboard_report = tmp;
63}
64
65void host_clear_keyboard_report(void)
66{
67 keyboard_report->mods = 0;
68 for (int8_t i = 0; i < REPORT_KEYS; i++) {
69 keyboard_report->keys[i] = 0;
70 }
71}
72
73uint8_t host_has_anykey(void)
74{
75 uint8_t cnt = 0;
76 for (int i = 0; i < REPORT_KEYS; i++) {
77 if (keyboard_report->keys[i])
78 cnt++;
79 }
80 return cnt;
81}
82
83uint8_t *host_get_keys(void)
84{
85 return keyboard_report->keys;
86}
87
88uint8_t host_get_mods(void)
89{
90 return keyboard_report->mods;
91}
92
93
94void host_send_keyboard_report(void)
95{
96 usb_keyboard_send_report(keyboard_report);
97}
98
99void host_mouse_send(report_mouse_t *report)
100{
101 usb_mouse_send(report->x, report->y, report->v, report->h, report->buttons);
102}
103
104
105static inline void add_key_byte(uint8_t code)
106{
107 // TODO: fix ugly code
108 int8_t i = 0;
109 int8_t empty = -1;
110 for (; i < REPORT_KEYS; i++) {
111 if (keyboard_report_prev->keys[i] == code) {
112 keyboard_report->keys[i] = code;
113 break;
114 }
115 if (empty == -1 &&
116 keyboard_report_prev->keys[i] == 0 &&
117 keyboard_report->keys[i] == 0) {
118 empty = i;
119 }
120 }
121 if (i == REPORT_KEYS) {
122 if (empty != -1) {
123 keyboard_report->keys[empty] = code;
124 }
125 }
126}
127
128static inline void add_key_bit(uint8_t code)
129{
130 if ((code>>3) < REPORT_KEYS) {
131 keyboard_report->keys[code>>3] |= 1<<(code&7);
132 } else {
133 debug("add_key_bit: can't add: "); phex(code); debug("\n");
134 }
135}
diff --git a/pjrc/usb.c b/pjrc/usb.c
index 845b00bea..9fd30dee3 100755
--- a/pjrc/usb.c
+++ b/pjrc/usb.c
@@ -687,10 +687,10 @@ ISR(USB_GEN_vect)
687 usb_keyboard_idle_count++; 687 usb_keyboard_idle_count++;
688 if (usb_keyboard_idle_count == usb_keyboard_idle_config) { 688 if (usb_keyboard_idle_count == usb_keyboard_idle_config) {
689 usb_keyboard_idle_count = 0; 689 usb_keyboard_idle_count = 0;
690 UEDATX = usb_keyboard_mods; 690 UEDATX = keyboard_report->mods;
691 UEDATX = 0; 691 UEDATX = 0;
692 for (i=0; i<6; i++) { 692 for (i=0; i<6; i++) {
693 UEDATX = usb_keyboard_keys[i]; 693 UEDATX = keyboard_report->keys[i];
694 } 694 }
695 UEINTX = 0x3A; 695 UEINTX = 0x3A;
696 } 696 }
@@ -873,10 +873,10 @@ ISR(USB_COM_vect)
873 if (bmRequestType == 0xA1) { 873 if (bmRequestType == 0xA1) {
874 if (bRequest == HID_GET_REPORT) { 874 if (bRequest == HID_GET_REPORT) {
875 usb_wait_in_ready(); 875 usb_wait_in_ready();
876 UEDATX = usb_keyboard_mods; 876 UEDATX = keyboard_report->mods;
877 UEDATX = 0; 877 UEDATX = 0;
878 for (i=0; i<6; i++) { 878 for (i=0; i<6; i++) {
879 UEDATX = usb_keyboard_keys[i]; 879 UEDATX = keyboard_report->keys[i];
880 } 880 }
881 usb_send_in(); 881 usb_send_in();
882 return; 882 return;
diff --git a/pjrc/usb.h b/pjrc/usb.h
index ee72a1e39..4f0fd8f1e 100644
--- a/pjrc/usb.h
+++ b/pjrc/usb.h
@@ -14,8 +14,6 @@ uint8_t usb_configured(void); // is the USB port configured
14void usb_remote_wakeup(void); 14void usb_remote_wakeup(void);
15 15
16 16
17
18
19#define EP_TYPE_CONTROL 0x00 17#define EP_TYPE_CONTROL 0x00
20#define EP_TYPE_BULK_IN 0x81 18#define EP_TYPE_BULK_IN 0x81
21#define EP_TYPE_BULK_OUT 0x80 19#define EP_TYPE_BULK_OUT 0x80
@@ -88,4 +86,23 @@ void usb_remote_wakeup(void);
88#define ENDPOINT_HALT 0 86#define ENDPOINT_HALT 0
89#define TEST_MODE 2 87#define TEST_MODE 2
90 88
89
90/*------------------------------------------------------------------*
91 * Keyboard descriptor setting
92 *------------------------------------------------------------------*/
93#define KBD_INTERFACE 0
94#define KBD_ENDPOINT 1
95#define KBD_SIZE 8
96#define KBD_BUFFER EP_DOUBLE_BUFFER
97#define KBD_REPORT_KEYS (KBD_SIZE - 2)
98
99// secondary keyboard
100#ifdef USB_NKRO_ENABLE
101#define KBD2_INTERFACE 4
102#define KBD2_ENDPOINT 5
103#define KBD2_SIZE 16
104#define KBD2_BUFFER EP_DOUBLE_BUFFER
105#define KBD2_REPORT_KEYS (KBD2_SIZE - 1)
106#endif
107
91#endif 108#endif
diff --git a/pjrc/usb_keyboard.c b/pjrc/usb_keyboard.c
index 57e23d5fc..e29c5c9e9 100644
--- a/pjrc/usb_keyboard.c
+++ b/pjrc/usb_keyboard.c
@@ -5,14 +5,9 @@
5#include "print.h" 5#include "print.h"
6#include "debug.h" 6#include "debug.h"
7#include "util.h" 7#include "util.h"
8#include "host.h"
8 9
9 10
10// keyboard report.
11static usb_keyboard_report_t _report0 = { {0}, 0, false };
12static usb_keyboard_report_t _report1 = { {0}, 0, false };
13usb_keyboard_report_t *usb_keyboard_report = &_report0;
14usb_keyboard_report_t *usb_keyboard_report_prev = &_report1;
15
16// protocol setting from the host. We use exactly the same report 11// protocol setting from the host. We use exactly the same report
17// either way, so this variable only stores the setting since we 12// either way, so this variable only stores the setting since we
18// are required to be able to report which setting is in use. 13// are required to be able to report which setting is in use.
@@ -28,167 +23,42 @@ uint8_t usb_keyboard_idle_count=0;
28// 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana 23// 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana
29volatile uint8_t usb_keyboard_leds=0; 24volatile uint8_t usb_keyboard_leds=0;
30 25
31// enable USB NKRO
32bool usb_keyboard_nkro = false;
33 26
27static inline int8_t send_report(report_keyboard_t *report, uint8_t endpoint, uint8_t keys_start, uint8_t keys_end);
34 28
35int8_t usb_keyboard_send(void)
36{
37 return usb_keyboard_send_report(usb_keyboard_report);
38}
39 29
40static inline int8_t _send_report(usb_keyboard_report_t *report, uint8_t endpoint, uint8_t keys_start, uint8_t keys_end); 30int8_t usb_keyboard_send_report(report_keyboard_t *report)
41int8_t usb_keyboard_send_report(usb_keyboard_report_t *report)
42{ 31{
43 int8_t result = 0; 32 int8_t result = 0;
44 33
45#ifdef USB_NKRO_ENABLE 34#ifdef USB_NKRO_ENABLE
46 if (usb_keyboard_nkro) 35 if (keyboard_nkro)
47 result = _send_report(report, KBD2_ENDPOINT, 0, KBD2_REPORT_KEYS); 36 result = send_report(report, KBD2_ENDPOINT, 0, KBD2_REPORT_KEYS);
48 else 37 else
49#endif 38#endif
50 { 39 {
51 if (usb_keyboard_protocol) 40 if (usb_keyboard_protocol)
52 result = _send_report(report, KBD_ENDPOINT, 0, KBD_REPORT_KEYS); 41 result = send_report(report, KBD_ENDPOINT, 0, KBD_REPORT_KEYS);
53 else 42 else
54 result = _send_report(report, KBD_ENDPOINT, 0, 6); 43 result = send_report(report, KBD_ENDPOINT, 0, 6);
55 } 44 }
56 45
57 if (result) return result; 46 if (result) return result;
58 usb_keyboard_idle_count = 0; 47 usb_keyboard_idle_count = 0;
59 report->is_sent =true;
60 usb_keyboard_print_report(report); 48 usb_keyboard_print_report(report);
61 return 0; 49 return 0;
62} 50}
63 51
64void usb_keyboard_swap_report(void) { 52void usb_keyboard_print_report(report_keyboard_t *report)
65 usb_keyboard_report_t *tmp = usb_keyboard_report_prev;
66 usb_keyboard_report_prev = usb_keyboard_report;
67 usb_keyboard_report = tmp;
68}
69
70void usb_keyboard_clear_report(void) {
71 usb_keyboard_clear_keys();
72 usb_keyboard_clear_mods();
73 usb_keyboard_report->is_sent = false;
74}
75
76void usb_keyboard_clear_keys(void) {
77 for (int i = 0; i < KEYS_MAX; i++) usb_keyboard_report->keys[i] = 0;
78}
79
80void usb_keyboard_clear_mods(void)
81{
82 usb_keyboard_report->mods = 0;
83}
84
85void usb_keyboard_set_keys(uint8_t *keys)
86{
87 for (int i = 0; i < KEYS_MAX; i++)
88 usb_keyboard_report->keys[i] = keys[i];
89}
90
91void usb_keyboard_set_mods(uint8_t mods)
92{
93 usb_keyboard_report->mods = mods;
94}
95
96void usb_keyboard_add_code(uint8_t code)
97{
98 if (IS_MOD(code)) {
99 usb_keyboard_add_mod(code);
100 } else {
101 usb_keyboard_add_key(code);
102 }
103}
104
105static inline void _add_key_byte(uint8_t code);
106static inline void _add_key_bit(uint8_t code);
107void usb_keyboard_add_key(uint8_t code)
108{
109#ifdef USB_NKRO_ENABLE
110 if (usb_keyboard_nkro) {
111 _add_key_bit(code);
112 return;
113 }
114#endif
115 _add_key_byte(code);
116}
117
118void usb_keyboard_add_mod(uint8_t code)
119{
120 usb_keyboard_report->mods |= MOD_BIT(code);
121}
122
123void usb_keyboard_del_code(uint8_t code)
124{
125 if (IS_MOD(code)) {
126 usb_keyboard_del_mod(code);
127 } else {
128 usb_keyboard_del_key(code);
129 }
130}
131
132void usb_keyboard_del_key(uint8_t code)
133{
134#ifdef USB_NKRO_ENABLE
135 if ((code>>3) < KEYS_MAX) {
136 usb_keyboard_keys[code>>3] &= ~(1<<(code&7));
137 }
138#else
139 for (int i = 0; i < KEYS_MAX; i++) {
140 if (usb_keyboard_report->keys[i] == code) {
141 usb_keyboard_report->keys[i] = KB_NO;
142 return;
143 }
144 }
145#endif
146}
147
148void usb_keyboard_del_mod(uint8_t code)
149{
150 usb_keyboard_report->mods &= ~MOD_BIT(code);
151}
152
153bool usb_keyboard_is_sent(void)
154{
155 return usb_keyboard_report->is_sent;
156}
157
158bool usb_keyboard_has_key(void)
159{
160 uint8_t keys = 0;
161 for (int i = 0; i < KEYS_MAX; i++) keys |= usb_keyboard_report->keys[i];
162 return keys ? true : false;
163}
164
165bool usb_keyboard_has_mod(void)
166{
167 return usb_keyboard_report->mods ? true : false;
168}
169
170uint8_t usb_keyboard_get_key(void)
171{
172#ifdef USB_NKRO_ENABLE
173 if (usb_keyboard_nkro) {
174 uint8_t i = 0;
175 for (; i < KEYS_MAX && !usb_keyboard_keys[i]; i++);
176 return i<<3 | biton(usb_keyboard_keys[i]);
177 }
178#endif
179 return usb_keyboard_keys[0];
180}
181
182void usb_keyboard_print_report(usb_keyboard_report_t *report)
183{ 53{
184 if (!debug_keyboard) return; 54 if (!debug_keyboard) return;
185 print("keys: "); 55 print("keys: ");
186 for (int i = 0; i < KEYS_MAX; i++) { phex(report->keys[i]); print(" "); } 56 for (int i = 0; i < REPORT_KEYS; i++) { phex(report->keys[i]); print(" "); }
187 print(" mods: "); phex(report->mods); print("\n"); 57 print(" mods: "); phex(report->mods); print("\n");
188} 58}
189 59
190 60
191static inline int8_t _send_report(usb_keyboard_report_t *report, uint8_t endpoint, uint8_t keys_start, uint8_t keys_end) 61static inline int8_t send_report(report_keyboard_t *report, uint8_t endpoint, uint8_t keys_start, uint8_t keys_end)
192{ 62{
193 uint8_t intr_state, timeout; 63 uint8_t intr_state, timeout;
194 64
@@ -211,7 +81,7 @@ static inline int8_t _send_report(usb_keyboard_report_t *report, uint8_t endpoin
211 UENUM = endpoint; 81 UENUM = endpoint;
212 } 82 }
213 UEDATX = report->mods; 83 UEDATX = report->mods;
214 if (!usb_keyboard_nkro) 84 if (!keyboard_nkro)
215 UEDATX = 0; 85 UEDATX = 0;
216 for (uint8_t i = keys_start; i < keys_end; i++) { 86 for (uint8_t i = keys_start; i < keys_end; i++) {
217 UEDATX = report->keys[i]; 87 UEDATX = report->keys[i];
@@ -220,34 +90,3 @@ static inline int8_t _send_report(usb_keyboard_report_t *report, uint8_t endpoin
220 SREG = intr_state; 90 SREG = intr_state;
221 return 0; 91 return 0;
222} 92}
223
224static inline void _add_key_byte(uint8_t code)
225{
226 // TODO: fix ugly code
227 int8_t i = 0;
228 int8_t empty = -1;
229 for (; i < KEYS_MAX; i++) {
230 if (usb_keyboard_keys_prev[i] == code) {
231 usb_keyboard_keys[i] = code;
232 break;
233 }
234 if (empty == -1 &&
235 usb_keyboard_keys_prev[i] == 0 &&
236 usb_keyboard_keys[i] == 0) {
237 empty = i;
238 }
239 }
240 if (i == KEYS_MAX) {
241 if (empty != -1) {
242 usb_keyboard_keys[empty] = code;
243 }
244 }
245}
246
247static inline void _add_key_bit(uint8_t code)
248{
249 if ((code>>3) < KEYS_MAX) {
250 usb_keyboard_keys[code>>3] |= 1<<(code&7);
251 }
252}
253
diff --git a/pjrc/usb_keyboard.h b/pjrc/usb_keyboard.h
index 53de4336d..22287a056 100644
--- a/pjrc/usb_keyboard.h
+++ b/pjrc/usb_keyboard.h
@@ -4,78 +4,16 @@
4#include <stdint.h> 4#include <stdint.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include "usb.h" 6#include "usb.h"
7#include "host.h"
7 8
8 9
9#define KBD_INTERFACE 0
10#define KBD_ENDPOINT 1
11#define KBD_SIZE 8
12#define KBD_BUFFER EP_DOUBLE_BUFFER
13#define KBD_REPORT_KEYS (KBD_SIZE - 2)
14
15// secondary keyboard
16#ifdef USB_NKRO_ENABLE
17#define KBD2_INTERFACE 4
18#define KBD2_ENDPOINT 5
19#define KBD2_SIZE 16
20#define KBD2_BUFFER EP_DOUBLE_BUFFER
21#define KBD2_REPORT_KEYS (KBD2_SIZE - 1)
22#endif
23
24#if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
25#define KEYS_MAX KBD2_REPORT_KEYS
26#else
27#define KEYS_MAX KBD_REPORT_KEYS
28#endif
29
30
31typedef struct report {
32 uint8_t keys[KEYS_MAX];
33 uint8_t mods;
34 bool is_sent;
35} usb_keyboard_report_t;
36
37
38#define usb_keyboard_keys usb_keyboard_report->keys
39#define usb_keyboard_mods usb_keyboard_report->mods
40#define usb_keyboard_keys_prev usb_keyboard_report_prev->keys
41#define usb_keyboard_mods_prev usb_keyboard_report_prev->mods
42
43
44extern usb_keyboard_report_t *usb_keyboard_report;
45extern usb_keyboard_report_t *usb_keyboard_report_prev;
46extern uint8_t usb_keyboard_protocol; 10extern uint8_t usb_keyboard_protocol;
47extern uint8_t usb_keyboard_idle_config; 11extern uint8_t usb_keyboard_idle_config;
48extern uint8_t usb_keyboard_idle_count; 12extern uint8_t usb_keyboard_idle_count;
49extern volatile uint8_t usb_keyboard_leds; 13extern volatile uint8_t usb_keyboard_leds;
50extern bool usb_keyboard_nkro;
51
52
53int8_t usb_keyboard_send(void);
54int8_t usb_keyboard_send_report(usb_keyboard_report_t *report);
55
56void usb_keyboard_swap_report(void);
57
58void usb_keyboard_clear_report(void);
59void usb_keyboard_clear_keys(void);
60void usb_keyboard_clear_mods(void);
61
62void usb_keyboard_set_keys(uint8_t *keys);
63void usb_keyboard_set_mods(uint8_t mods);
64
65void usb_keyboard_add_code(uint8_t code);
66void usb_keyboard_add_key(uint8_t code);
67void usb_keyboard_add_mod(uint8_t code);
68
69void usb_keyboard_del_code(uint8_t code);
70void usb_keyboard_del_key(uint8_t code);
71void usb_keyboard_del_mod(uint8_t code);
72
73bool usb_keyboard_is_sent(void);
74bool usb_keyboard_has_key(void);
75bool usb_keyboard_has_mod(void);
76 14
77uint8_t usb_keyboard_get_key(void);
78 15
79void usb_keyboard_print_report(usb_keyboard_report_t *report); 16int8_t usb_keyboard_send_report(report_keyboard_t *report);
17void usb_keyboard_print_report(report_keyboard_t *report);
80 18
81#endif 19#endif
diff --git a/ps2_vusb/Makefile b/ps2_vusb/Makefile
index e4872fb6d..406008d84 100644
--- a/ps2_vusb/Makefile
+++ b/ps2_vusb/Makefile
@@ -13,7 +13,6 @@ TARGET_SRC = main.c \
13 matrix.c \ 13 matrix.c \
14 led.c \ 14 led.c \
15 ps2.c \ 15 ps2.c \
16 host_vusb.c \
17 usart_print.c 16 usart_print.c
18 17
19OPT_DEFS = -DDEBUG_LEVEL=0 18OPT_DEFS = -DDEBUG_LEVEL=0
diff --git a/ps2_vusb/README b/ps2_vusb/README
new file mode 100644
index 000000000..7d4512a48
--- /dev/null
+++ b/ps2_vusb/README
@@ -0,0 +1,12 @@
1PS/2 to USB keyboard converter with V-USB
2=========================================
32011/02/07
4
5NOT COMPLETED
6development was suspended.
7
8TODO:
9PS/2 library: losts data from keyboard occasionally,
10 should use interrupt thoroughly for communication.
11
12Code cleaning: merge code changed here to other subprojects and common modules.
diff --git a/ps2_vusb/config.h b/ps2_vusb/config.h
index b037bbe9c..858fe883f 100644
--- a/ps2_vusb/config.h
+++ b/ps2_vusb/config.h
@@ -11,8 +11,13 @@
11/* matrix size */ 11/* matrix size */
12#define MATRIX_ROWS 32 // keycode bit: 3-0 12#define MATRIX_ROWS 32 // keycode bit: 3-0
13#define MATRIX_COLS 8 // keycode bit: 6-4 13#define MATRIX_COLS 8 // keycode bit: 6-4
14/* define if matrix has ghost */ 14
15//#define MATRIX_HAS_GHOST 15/* key combination for command */
16#define IS_COMMAND() ( \
17 keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
18 keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
19)
20
16 21
17/* USB NKey Rollover */ 22/* USB NKey Rollover */
18#ifdef USB_NKRO_ENABLE 23#ifdef USB_NKRO_ENABLE
@@ -23,11 +28,6 @@
23# define MOUSEKEY_DELAY_TIME 255 28# define MOUSEKEY_DELAY_TIME 255
24#endif 29#endif
25 30
26#define IS_COMMAND() ( \
27 keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
28 keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
29)
30
31 31
32/* PS/2 lines */ 32/* PS/2 lines */
33#define PS2_CLOCK_PORT PORTD 33#define PS2_CLOCK_PORT PORTD
diff --git a/ps2_vusb/host_vusb.c b/vusb/host.c
index 8b89aa195..a32a1b17e 100644
--- a/ps2_vusb/host_vusb.c
+++ b/vusb/host.c
@@ -12,12 +12,12 @@ static report_keyboard_t report1;
12report_keyboard_t *keyboard_report = &report0; 12report_keyboard_t *keyboard_report = &report0;
13report_keyboard_t *keyboard_report_prev = &report1; 13report_keyboard_t *keyboard_report_prev = &report1;
14 14
15static uint8_t keyboard_led = 0; 15static uint8_t keyboard_leds = 0;
16static uchar idleRate = 0; 16static uchar idleRate = 0;
17 17
18uint8_t host_keyboard_led(void) 18uint8_t host_keyboard_leds(void)
19{ 19{
20 return keyboard_led; 20 return keyboard_leds;
21} 21}
22 22
23 23
@@ -190,7 +190,7 @@ uchar usbFunctionWrite(uchar *data, uchar len)
190 switch (last_req.kind) { 190 switch (last_req.kind) {
191 case SET_LED: 191 case SET_LED:
192 //debug("SET_LED\n"); 192 //debug("SET_LED\n");
193 keyboard_led = data[0]; 193 keyboard_leds = data[0];
194 last_req.len = 0; 194 last_req.len = 0;
195 return 1; 195 return 1;
196 break; 196 break;
diff --git a/ps2_vusb/host_vusb.h b/vusb/host_vusb.h
index f09ad5822..f09ad5822 100644
--- a/ps2_vusb/host_vusb.h
+++ b/vusb/host_vusb.h