This patch set adds support for USB mice.
There is a bug in qemu's USB mouse support that prevents this from working on qemu. Otherwise, it runs fine. I'll send a separate patch with a fix for qemu.
I've also tested this on my epia-cn machine with coreboot.
-Kevin
Kevin O'Connor (3): Document usb-hid.c functions. When USB keyboard active, don't send keyboard commands to ps2 port. Add support for USB mice.
src/clock.c | 4 +- src/config.h | 2 + src/kbd.c | 11 +++- src/mouse.c | 29 +++++--- src/ps2port.c | 36 +++++----- src/ps2port.h | 4 +- src/usb-hid.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/usb-hid.h | 12 ++- src/usb.c | 12 ++-- 9 files changed, 265 insertions(+), 58 deletions(-)
--- src/usb-hid.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/usb-hid.c b/src/usb-hid.c index 67b5e54..f82965d 100644 --- a/src/usb-hid.c +++ b/src/usb-hid.c @@ -17,6 +17,7 @@ struct usb_pipe *keyboard_pipe VAR16VISIBLE; * Setup ****************************************************************/
+// Send USB HID protocol message. static int set_protocol(struct usb_pipe *pipe, u16 val) { @@ -29,6 +30,7 @@ set_protocol(struct usb_pipe *pipe, u16 val) return send_default_control(pipe, &req, NULL); }
+// Send USB HID SetIdle request. static int set_idle(struct usb_pipe *pipe, int ms) { @@ -93,6 +95,7 @@ usb_keyboard_setup(void) * Keyboard events ****************************************************************/
+// Mapping from USB key id to ps2 key sequence. static u16 KeyToScanCode[] VAR16 = { 0x0000, 0x0000, 0x0000, 0x0000, 0x001e, 0x0030, 0x002e, 0x0020, 0x0012, 0x0021, 0x0022, 0x0023, 0x0017, 0x0024, 0x0025, 0x0026, @@ -109,6 +112,7 @@ static u16 KeyToScanCode[] VAR16 = { 0x0048, 0x0049, 0x0052, 0x0053 };
+// Mapping from USB modifier id to ps2 key sequence. static u16 ModifierToScanCode[] VAR16 = { //lcntl, lshift, lalt, lgui, rcntl, rshift, ralt, rgui 0x001d, 0x002a, 0x0038, 0xe05b, 0xe01d, 0x0036, 0xe038, 0xe05c @@ -116,12 +120,14 @@ static u16 ModifierToScanCode[] VAR16 = {
#define RELEASEBIT 0x80
+// Format of USB event data struct keyevent { u8 modifiers; u8 reserved; u8 keys[6]; };
+// Translate data from KeyToScanCode[] to calls to process_key(). static void prockeys(u16 keys) { @@ -139,6 +145,7 @@ prockeys(u16 keys) process_key(keys); }
+// Handle a USB key press/release event. static void procscankey(u8 key, u8 flags) { @@ -149,6 +156,7 @@ procscankey(u8 key, u8 flags) prockeys(keys | flags); }
+// Handle a USB modifier press/release event. static void procmodkey(u8 mods, u8 flags) { @@ -161,6 +169,7 @@ procmodkey(u8 mods, u8 flags) } }
+// Process USB keyboard data. static void noinline handle_key(struct keyevent *data) { @@ -225,6 +234,7 @@ handle_key(struct keyevent *data) SET_EBDA2(ebda_seg, usbkey_last.data, old.data); }
+// Check for USB events pending - called periodically from timer interrupt. void usb_check_key(void) {
Route keyboard commands to a USB handler when USB keyboard is active.
Add a GETID handler for USB keyboards. --- src/kbd.c | 11 ++++++++++- src/mouse.c | 26 ++++++++++++++++---------- src/ps2port.c | 36 +++++++++++++++++++----------------- src/ps2port.h | 4 ++-- src/usb-hid.c | 23 +++++++++++++++++++++++ src/usb-hid.h | 2 ++ 6 files changed, 72 insertions(+), 30 deletions(-)
diff --git a/src/kbd.c b/src/kbd.c index 36c89fc..1977c5d 100644 --- a/src/kbd.c +++ b/src/kbd.c @@ -9,7 +9,8 @@ #include "util.h" // debug_enter #include "config.h" // CONFIG_* #include "bregs.h" // struct bregs -#include "ps2port.h" // kbd_command +#include "ps2port.h" // ps2_kbd_command +#include "usb-hid.h" // usb_kbd_command
// Bit definitions for BDA kbd_flag[012] #define KF0_RSHIFT (1<<0) @@ -109,6 +110,14 @@ dequeue_key(struct bregs *regs, int incr, int extended) SET_BDA(kbd_buf_head, buffer_head); }
+static inline int +kbd_command(int command, u8 *param) +{ + if (usb_kbd_active()) + return usb_kbd_command(command, param); + return ps2_kbd_command(command, param); +} + // read keyboard input static void handle_1600(struct bregs *regs) diff --git a/src/mouse.c b/src/mouse.c index aba12ad..cc6c4d2 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -9,7 +9,7 @@ #include "util.h" // debug_isr #include "pic.h" // eoi_pic2 #include "bregs.h" // struct bregs -#include "ps2port.h" // aux_command +#include "ps2port.h" // ps2_mouse_command
void mouse_setup(void) @@ -21,6 +21,12 @@ mouse_setup(void) SETBITS_BDA(equipment_list_flags, 0x04); }
+static inline int +mouse_command(int command, u8 *param) +{ + return ps2_mouse_command(command, param); +} + #define RET_SUCCESS 0x00 #define RET_EINVFUNCTION 0x01 #define RET_EINVINPUT 0x02 @@ -36,7 +42,7 @@ disable_mouse(u16 ebda_seg) ps2ctr &= ~I8042_CTR_AUXINT; SET_EBDA2(ebda_seg, ps2ctr, ps2ctr);
- return aux_command(PSMOUSE_CMD_DISABLE, NULL); + return mouse_command(PSMOUSE_CMD_DISABLE, NULL); }
// Disable Mouse @@ -67,7 +73,7 @@ mouse_15c20001(struct bregs *regs) ps2ctr |= I8042_CTR_AUXINT; SET_EBDA2(ebda_seg, ps2ctr, ps2ctr);
- int ret = aux_command(PSMOUSE_CMD_ENABLE, NULL); + int ret = mouse_command(PSMOUSE_CMD_ENABLE, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -96,7 +102,7 @@ static void mouse_15c201(struct bregs *regs) { u8 param[2]; - int ret = aux_command(PSMOUSE_CMD_RESET_BAT, param); + int ret = mouse_command(PSMOUSE_CMD_RESET_BAT, param); if (ret) { set_code_invalid(regs, RET_ENEEDRESEND); return; @@ -116,7 +122,7 @@ mouse_15c202(struct bregs *regs) return; } u8 mouse_data1 = GET_GLOBAL(sample_rates[regs->bh]); - int ret = aux_command(PSMOUSE_CMD_SETRATE, &mouse_data1); + int ret = mouse_command(PSMOUSE_CMD_SETRATE, &mouse_data1); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -137,7 +143,7 @@ mouse_15c203(struct bregs *regs) return; } u8 param = regs->bh; - int ret = aux_command(PSMOUSE_CMD_SETRES, ¶m); + int ret = mouse_command(PSMOUSE_CMD_SETRES, ¶m); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -149,7 +155,7 @@ static void mouse_15c204(struct bregs *regs) { u8 param[2]; - int ret = aux_command(PSMOUSE_CMD_GETID, param); + int ret = mouse_command(PSMOUSE_CMD_GETID, param); if (ret) { set_code_invalid(regs, RET_ENEEDRESEND); return; @@ -179,7 +185,7 @@ static void mouse_15c20600(struct bregs *regs) { u8 param[3]; - int ret = aux_command(PSMOUSE_CMD_GETINFO, param); + int ret = mouse_command(PSMOUSE_CMD_GETINFO, param); if (ret) { set_code_invalid(regs, RET_ENEEDRESEND); return; @@ -194,7 +200,7 @@ mouse_15c20600(struct bregs *regs) static void mouse_15c20601(struct bregs *regs) { - int ret = aux_command(PSMOUSE_CMD_SETSCALE11, NULL); + int ret = mouse_command(PSMOUSE_CMD_SETSCALE11, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else @@ -205,7 +211,7 @@ mouse_15c20601(struct bregs *regs) static void mouse_15c20602(struct bregs *regs) { - int ret = aux_command(PSMOUSE_CMD_SETSCALE21, NULL); + int ret = mouse_command(PSMOUSE_CMD_SETSCALE21, NULL); if (ret) set_code_invalid(regs, RET_ENEEDRESEND); else diff --git a/src/ps2port.c b/src/ps2port.c index 47dfd49..f379eb3 100644 --- a/src/ps2port.c +++ b/src/ps2port.c @@ -8,7 +8,7 @@ #include "ioport.h" // inb #include "util.h" // dprintf #include "biosvar.h" // GET_EBDA -#include "ps2port.h" // kbd_command +#include "ps2port.h" // ps2_kbd_command #include "pic.h" // eoi_pic1
@@ -194,7 +194,7 @@ ps2_sendbyte(int aux, u8 command, int timeout) }
static int -ps2_command(int aux, int command, u8 *param) +__ps2_command(int aux, int command, u8 *param) { int ret2; int receive = (command >> 8) & 0xf; @@ -296,24 +296,26 @@ fail: return ret; }
-int -kbd_command(int command, u8 *param) +static int +ps2_command(int aux, int command, u8 *param) { - dprintf(7, "kbd_command cmd=%x\n", command); - int ret = ps2_command(0, command, param); + dprintf(7, "ps2_command aux=%d cmd=%x\n", aux, command); + int ret = __ps2_command(aux, command, param); if (ret) - dprintf(2, "keyboard command %x failed\n", command); + dprintf(2, "ps2 command %x failed (aux=%d)\n", command, aux); return ret; }
int -aux_command(int command, u8 *param) +ps2_kbd_command(int command, u8 *param) { - dprintf(7, "aux_command cmd=%x\n", command); - int ret = ps2_command(1, command, param); - if (ret) - dprintf(2, "mouse command %x failed\n", command); - return ret; + return ps2_command(0, command, param); +} + +int +ps2_mouse_command(int command, u8 *param) +{ + return ps2_command(1, command, param); }
@@ -413,7 +415,7 @@ keyboard_init(void *data)
/* ------------------- keyboard side ------------------------*/ /* reset keyboard and self test (keyboard side) */ - ret = kbd_command(ATKBD_CMD_RESET_BAT, param); + ret = ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); if (ret) return; if (param[0] != 0xaa) { @@ -422,13 +424,13 @@ keyboard_init(void *data) }
/* Disable keyboard */ - ret = kbd_command(ATKBD_CMD_RESET_DIS, NULL); + ret = ps2_kbd_command(ATKBD_CMD_RESET_DIS, NULL); if (ret) return;
// Set scancode command (mode 2) param[0] = 0x02; - ret = kbd_command(ATKBD_CMD_SSCANSET, param); + ret = ps2_kbd_command(ATKBD_CMD_SSCANSET, param); if (ret) return;
@@ -436,7 +438,7 @@ keyboard_init(void *data) SET_EBDA(ps2ctr, I8042_CTR_AUXDIS | I8042_CTR_XLATE | I8042_CTR_KBDINT);
/* Enable keyboard */ - ret = kbd_command(ATKBD_CMD_ENABLE, NULL); + ret = ps2_kbd_command(ATKBD_CMD_ENABLE, NULL); if (ret) return;
diff --git a/src/ps2port.h b/src/ps2port.h index bc04903..afb0e78 100644 --- a/src/ps2port.h +++ b/src/ps2port.h @@ -57,8 +57,8 @@ // functions int i8042_flush(void); int i8042_command(int command, u8 *param); -int kbd_command(int command, u8 *param); -int aux_command(int command, u8 *param); +int ps2_kbd_command(int command, u8 *param); +int ps2_mouse_command(int command, u8 *param); void ps2port_setup(void);
#endif // ps2port.h diff --git a/src/usb-hid.c b/src/usb-hid.c index f82965d..bffd81c 100644 --- a/src/usb-hid.c +++ b/src/usb-hid.c @@ -9,6 +9,7 @@ #include "config.h" // CONFIG_* #include "usb.h" // usb_ctrlrequest #include "biosvar.h" // GET_GLOBAL +#include "ps2port.h" // ATKBD_CMD_GETID
struct usb_pipe *keyboard_pipe VAR16VISIBLE;
@@ -252,3 +253,25 @@ usb_check_key(void) handle_key(&data); } } + +// Test if USB keyboard is active. +inline int +usb_kbd_active(void) +{ + return GET_GLOBAL(keyboard_pipe) != NULL; +} + +// Handle a ps2 style keyboard command. +inline int +usb_kbd_command(int command, u8 *param) +{ + switch (command) { + case ATKBD_CMD_GETID: + // Return the id of a standard AT keyboard. + param[0] = 0xab; + param[1] = 0x83; + return 0; + default: + return -1; + } +} diff --git a/src/usb-hid.h b/src/usb-hid.h index 1c75560..6af4da2 100644 --- a/src/usb-hid.h +++ b/src/usb-hid.h @@ -7,7 +7,9 @@ struct usb_pipe; int usb_keyboard_init(struct usb_pipe *pipe , struct usb_interface_descriptor *iface, int imax); void usb_keyboard_setup(void); +inline int usb_kbd_active(void); void usb_check_key(void); +inline int usb_kbd_command(int command, u8 *param);
/****************************************************************
Initial support for USB mice that follow the "boot" protocol. --- src/clock.c | 4 +- src/config.h | 2 + src/mouse.c | 3 + src/usb-hid.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++----- src/usb-hid.h | 10 ++- src/usb.c | 12 ++-- 6 files changed, 185 insertions(+), 30 deletions(-)
diff --git a/src/clock.c b/src/clock.c index 4756ea8..c79f392 100644 --- a/src/clock.c +++ b/src/clock.c @@ -12,7 +12,7 @@ #include "pic.h" // eoi_pic1 #include "bregs.h" // struct bregs #include "biosvar.h" // GET_GLOBAL -#include "usb-hid.h" // usb_check_key +#include "usb-hid.h" // usb_check_event
// RTC register flags #define RTC_A_UIP 0x80 @@ -452,7 +452,7 @@ handle_08(void)
SET_BDA(timer_counter, counter);
- usb_check_key(); + usb_check_event();
// chain to user timer tick INT #0x1c u32 eax=0, flags; diff --git a/src/config.h b/src/config.h index e762435..b101174 100644 --- a/src/config.h +++ b/src/config.h @@ -44,6 +44,8 @@ #define CONFIG_USB_HUB 1 // Support USB keyboards #define CONFIG_USB_KEYBOARD 1 +// Support USB mice +#define CONFIG_USB_MOUSE 1 // Support PS2 ports (keyboard and mouse) #define CONFIG_PS2PORT 1 // Support for IDE disk code diff --git a/src/mouse.c b/src/mouse.c index cc6c4d2..09273b0 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -10,6 +10,7 @@ #include "pic.h" // eoi_pic2 #include "bregs.h" // struct bregs #include "ps2port.h" // ps2_mouse_command +#include "usb-hid.h" // usb_mouse_command
void mouse_setup(void) @@ -24,6 +25,8 @@ mouse_setup(void) static inline int mouse_command(int command, u8 *param) { + if (usb_mouse_active()) + return usb_mouse_command(command, param); return ps2_mouse_command(command, param); }
diff --git a/src/usb-hid.c b/src/usb-hid.c index bffd81c..2a95228 100644 --- a/src/usb-hid.c +++ b/src/usb-hid.c @@ -12,6 +12,7 @@ #include "ps2port.h" // ATKBD_CMD_GETID
struct usb_pipe *keyboard_pipe VAR16VISIBLE; +struct usb_pipe *mouse_pipe VAR16VISIBLE;
/**************************************************************** @@ -47,24 +48,17 @@ set_idle(struct usb_pipe *pipe, int ms) #define KEYREPEATWAITMS 500 #define KEYREPEATMS 33
-int -usb_keyboard_init(struct usb_pipe *pipe - , struct usb_interface_descriptor *iface, int imax) +static int +usb_kbd_init(struct usb_pipe *pipe, struct usb_endpoint_descriptor *epdesc) { if (! CONFIG_USB_KEYBOARD) return -1; if (keyboard_pipe) // XXX - this enables the first found keyboard (could be random) return -1; - dprintf(2, "usb_keyboard_setup %p\n", pipe);
- // Find intr in endpoint. - struct usb_endpoint_descriptor *epdesc = findEndPointDesc( - iface, imax, USB_ENDPOINT_XFER_INT, USB_DIR_IN); - if (!epdesc || epdesc->wMaxPacketSize != 8) { - dprintf(1, "No keyboard intr in?\n"); + if (epdesc->wMaxPacketSize != 8) return -1; - }
// Enable "boot" protocol. int ret = set_protocol(pipe, 1); @@ -83,12 +77,66 @@ usb_keyboard_init(struct usb_pipe *pipe return 0; }
+static int +usb_mouse_init(struct usb_pipe *pipe, struct usb_endpoint_descriptor *epdesc) +{ + if (! CONFIG_USB_MOUSE) + return -1; + if (mouse_pipe) + // XXX - this enables the first found mouse (could be random) + return -1; + + if (epdesc->wMaxPacketSize < 3 || epdesc->wMaxPacketSize > 8) + return -1; + + // Enable "boot" protocol. + int ret = set_protocol(pipe, 1); + if (ret) + return -1; + + mouse_pipe = alloc_intr_pipe(pipe, epdesc); + if (!mouse_pipe) + return -1; + + dprintf(1, "USB mouse initialized\n"); + return 0; +} + +// Initialize a found USB HID device (if applicable). +int +usb_hid_init(struct usb_pipe *pipe + , struct usb_interface_descriptor *iface, int imax) +{ + if (! CONFIG_USB_KEYBOARD || ! CONFIG_USB_MOUSE) + return -1; + dprintf(2, "usb_hid_init %p\n", pipe); + + if (iface->bInterfaceSubClass != USB_INTERFACE_SUBCLASS_BOOT) + // Doesn't support boot protocol. + return -1; + + // Find intr in endpoint. + struct usb_endpoint_descriptor *epdesc = findEndPointDesc( + iface, imax, USB_ENDPOINT_XFER_INT, USB_DIR_IN); + if (!epdesc) { + dprintf(1, "No usb hid intr in?\n"); + return -1; + } + + if (iface->bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD) + return usb_kbd_init(pipe, epdesc); + if (iface->bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) + return usb_mouse_init(pipe, epdesc); + return -1; +} + void -usb_keyboard_setup(void) +usb_hid_setup(void) { - if (! CONFIG_USB_KEYBOARD) - return; - keyboard_pipe = NULL; + if (CONFIG_USB_KEYBOARD) + keyboard_pipe = NULL; + if (CONFIG_USB_MOUSE) + mouse_pipe = NULL; }
@@ -121,7 +169,7 @@ static u16 ModifierToScanCode[] VAR16 = {
#define RELEASEBIT 0x80
-// Format of USB event data +// Format of USB keyboard event data struct keyevent { u8 modifiers; u8 reserved; @@ -235,8 +283,8 @@ handle_key(struct keyevent *data) SET_EBDA2(ebda_seg, usbkey_last.data, old.data); }
-// Check for USB events pending - called periodically from timer interrupt. -void +// Check if a USB keyboard event is pending and process it if so. +static void usb_check_key(void) { if (! CONFIG_USB_KEYBOARD) @@ -258,6 +306,8 @@ usb_check_key(void) inline int usb_kbd_active(void) { + if (! CONFIG_USB_KEYBOARD) + return 0; return GET_GLOBAL(keyboard_pipe) != NULL; }
@@ -265,6 +315,9 @@ usb_kbd_active(void) inline int usb_kbd_command(int command, u8 *param) { + if (! CONFIG_USB_KEYBOARD) + return -1; + dprintf(9, "usb keyboard cmd=%x\n", command); switch (command) { case ATKBD_CMD_GETID: // Return the id of a standard AT keyboard. @@ -275,3 +328,100 @@ usb_kbd_command(int command, u8 *param) return -1; } } + + +/**************************************************************** + * Mouse events + ****************************************************************/ + +// Format of USB mouse event data +struct mouseevent { + u8 buttons; + u8 x, y; + u8 reserved[5]; +}; + +// Process USB mouse data. +static void +handle_mouse(struct mouseevent *data) +{ + dprintf(9, "Got mouse b=%x x=%x y=%x\n", data->buttons, data->x, data->y); + + s8 x = data->x, y = -data->y; + u8 flag = ((data->buttons & 0x7) | (1<<3) + | (x & 0x80 ? (1<<4) : 0) | (y & 0x80 ? (1<<5) : 0)); + process_mouse(flag); + process_mouse(x); + process_mouse(y); +} + +// Check if a USB mouse event is pending and process it if so. +static void +usb_check_mouse(void) +{ + if (! CONFIG_USB_MOUSE) + return; + struct usb_pipe *pipe = GET_GLOBAL(mouse_pipe); + if (!pipe) + return; + + for (;;) { + struct mouseevent data; + int ret = usb_poll_intr(pipe, &data); + if (ret) + break; + handle_mouse(&data); + } +} + +// Test if USB mouse is active. +inline int +usb_mouse_active(void) +{ + if (! CONFIG_USB_MOUSE) + return 0; + return GET_GLOBAL(mouse_pipe) != NULL; +} + +// Handle a ps2 style mouse command. +inline int +usb_mouse_command(int command, u8 *param) +{ + if (! CONFIG_USB_MOUSE) + return -1; + dprintf(9, "usb mouse cmd=%x\n", command); + switch (command) { + case PSMOUSE_CMD_ENABLE: + case PSMOUSE_CMD_DISABLE: + case PSMOUSE_CMD_SETSCALE11: + return 0; + case PSMOUSE_CMD_SETSCALE21: + case PSMOUSE_CMD_SETRATE: + case PSMOUSE_CMD_SETRES: + // XXX + return 0; + case PSMOUSE_CMD_RESET_BAT: + case PSMOUSE_CMD_GETID: + // Return the id of a standard AT mouse. + param[0] = 0xaa; + param[1] = 0x00; + return 0; + + case PSMOUSE_CMD_GETINFO: + param[0] = 0x00; + param[1] = 4; + param[2] = 100; + return 0; + + default: + return -1; + } +} + +// Check for USB events pending - called periodically from timer interrupt. +void +usb_check_event(void) +{ + usb_check_key(); + usb_check_mouse(); +} diff --git a/src/usb-hid.h b/src/usb-hid.h index 6af4da2..d8199b9 100644 --- a/src/usb-hid.h +++ b/src/usb-hid.h @@ -4,12 +4,14 @@ // usb-hid.c struct usb_interface_descriptor; struct usb_pipe; -int usb_keyboard_init(struct usb_pipe *pipe - , struct usb_interface_descriptor *iface, int imax); -void usb_keyboard_setup(void); +int usb_hid_init(struct usb_pipe *pipe + , struct usb_interface_descriptor *iface, int imax); +void usb_hid_setup(void); inline int usb_kbd_active(void); -void usb_check_key(void); inline int usb_kbd_command(int command, u8 *param); +inline int usb_mouse_active(void); +inline int usb_mouse_command(int command, u8 *param); +void usb_check_event(void);
/**************************************************************** diff --git a/src/usb.c b/src/usb.c index 694ea28..7e6a18b 100644 --- a/src/usb.c +++ b/src/usb.c @@ -325,11 +325,9 @@ configure_usb_device(struct usb_pipe *pipe) // Determine if a driver exists for this device - only look at the // first interface of the first configuration. struct usb_interface_descriptor *iface = (void*)(&config[1]); - if ((iface->bInterfaceClass != USB_CLASS_HID - || iface->bInterfaceSubClass != USB_INTERFACE_SUBCLASS_BOOT - || iface->bInterfaceProtocol != USB_INTERFACE_PROTOCOL_KEYBOARD) - && (iface->bInterfaceClass != USB_CLASS_MASS_STORAGE) - && (iface->bInterfaceClass != USB_CLASS_HUB)) + if (iface->bInterfaceClass != USB_CLASS_HID + && iface->bInterfaceClass != USB_CLASS_MASS_STORAGE + && iface->bInterfaceClass != USB_CLASS_HUB) // Not a supported device. goto fail;
@@ -345,7 +343,7 @@ configure_usb_device(struct usb_pipe *pipe) else if (iface->bInterfaceClass == USB_CLASS_MASS_STORAGE) ret = usb_msc_init(pipe, iface, imax); else - ret = usb_keyboard_init(pipe, iface, imax); + ret = usb_hid_init(pipe, iface, imax); if (ret) goto fail;
@@ -425,7 +423,7 @@ usb_setup(void)
dprintf(3, "init usb\n");
- usb_keyboard_setup(); + usb_hid_setup();
// Look for USB controllers int ehcibdf = -1;