1
From 5718d5662d33355403e7aa62227acecac1755a4f Mon Sep 17 00:00:00 2001
2
From: Kevin O'Connor <kevin@koconnor.net>
3
Date: Sat, 1 May 2010 19:25:41 -0400
4
Subject: [PATCH 11/17] Document usb-hid.c functions.
7
src/usb-hid.c | 10 ++++++++++
8
1 files changed, 10 insertions(+), 0 deletions(-)
10
diff --git a/src/usb-hid.c b/src/usb-hid.c
11
index 67b5e54..f82965d 100644
14
@@ -17,6 +17,7 @@ struct usb_pipe *keyboard_pipe VAR16VISIBLE;
16
****************************************************************/
18
+// Send USB HID protocol message.
20
set_protocol(struct usb_pipe *pipe, u16 val)
22
@@ -29,6 +30,7 @@ set_protocol(struct usb_pipe *pipe, u16 val)
23
return send_default_control(pipe, &req, NULL);
26
+// Send USB HID SetIdle request.
28
set_idle(struct usb_pipe *pipe, int ms)
30
@@ -93,6 +95,7 @@ usb_keyboard_setup(void)
32
****************************************************************/
34
+// Mapping from USB key id to ps2 key sequence.
35
static u16 KeyToScanCode[] VAR16 = {
36
0x0000, 0x0000, 0x0000, 0x0000, 0x001e, 0x0030, 0x002e, 0x0020,
37
0x0012, 0x0021, 0x0022, 0x0023, 0x0017, 0x0024, 0x0025, 0x0026,
38
@@ -109,6 +112,7 @@ static u16 KeyToScanCode[] VAR16 = {
39
0x0048, 0x0049, 0x0052, 0x0053
42
+// Mapping from USB modifier id to ps2 key sequence.
43
static u16 ModifierToScanCode[] VAR16 = {
44
//lcntl, lshift, lalt, lgui, rcntl, rshift, ralt, rgui
45
0x001d, 0x002a, 0x0038, 0xe05b, 0xe01d, 0x0036, 0xe038, 0xe05c
46
@@ -116,12 +120,14 @@ static u16 ModifierToScanCode[] VAR16 = {
48
#define RELEASEBIT 0x80
50
+// Format of USB event data
57
+// Translate data from KeyToScanCode[] to calls to process_key().
61
@@ -139,6 +145,7 @@ prockeys(u16 keys)
65
+// Handle a USB key press/release event.
67
procscankey(u8 key, u8 flags)
69
@@ -149,6 +156,7 @@ procscankey(u8 key, u8 flags)
70
prockeys(keys | flags);
73
+// Handle a USB modifier press/release event.
75
procmodkey(u8 mods, u8 flags)
77
@@ -161,6 +169,7 @@ procmodkey(u8 mods, u8 flags)
81
+// Process USB keyboard data.
83
handle_key(struct keyevent *data)
85
@@ -225,6 +234,7 @@ handle_key(struct keyevent *data)
86
SET_EBDA2(ebda_seg, usbkey_last.data, old.data);
89
+// Check for USB events pending - called periodically from timer interrupt.