blob: bccd47a611ef87cdfc71b9033ff477be91ed78c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
keycodes are 32-bit integers.
the low byte indicates the key itself. for printable characters (and keys with
reasonable translations to ascii control codes), this is the ascii code. for
other ones, something in the range of 0x80 to 0xef is used, seen in table 1.
the top 24 bits indicate several flags. these are seen in table 2, where bit 0
is the lowest bit of the second lowest byte of the keycode, and bit 23 is the
highest bit of the highest byte of the keycode.
the "get key" system call returns 0 if there is not a key available. it is
recommended to make the system call and, if it returns 0, yield to the scheduler
and then loop back to making the system call. this way your task does not block
the cpu while waiting for keyboard input. see the "get_key_char" function in
user.c of the "knob" library for an example of this.
table 1:
code | key
------|---------------
0x80 | left shift
0x81 | right shift
0x82 | left control
0x83 | right control
0x84 | left alt
0x85 | right alt
0x86 | left win
0x87 | right win
0x88 | caps lock
0x89 | num lock
0x8a | scroll lock
0x8b | insert
0x8c | reserved
.... | reserved
0x97 | reserved
0x98 | unassigned
.... | unassigned
0x9f | unassigned
0xa0 | F1
0xa1 | F2
0xa2 | F3
0xa3 | F4
0xa4 | F5
0xa5 | F6
0xa6 | F7
0xa7 | F8
0xa8 | F9
0xa9 | F10
0xaa | F11
0xab | F12
0xac | unassigned
.... | unassigned
0xaf | unassigned
0xb0 | numpad 0
0xb1 | numpad 1
0xb2 | numpad 2
0xb3 | numpad 3
0xb4 | numpad 4
0xb5 | numpad 5
0xb6 | numpad 6
0xb7 | numpad 7
0xb8 | numpad 8
0xb9 | numpad 9
0xba | numpad *
0xbb | numpad +
0xbc | numpad Enter
0xbd | numpad -
0xbe | numpad .
0xbf | numpad /
0xc0 | unassigned
0xc1 | delete
0xc2 | home
0xc3 | end
0xc4 | page up
0xc5 | page down
0xc6 | up
0xc7 | down
0xc8 | left
0xc9 | right
0xca | escape
0xcb | menu
0xcc | pause
0xcd | print screen
0xce | unassigned
.... | unassigned
0xef | unassigned
table 2:
bit 0: left shift
bit 1: right shift
bit 2: caps lock
bit 3: insert
bit 4: num lock
bit 5: scroll lock
bit 6: left alt
bit 7: right alt
bit 8: left control
bit 9: right control
bit 10: left meta
bit 11: right meta
bits 12-23 are reserved for future versions. in this version, they should be set
to zero when giving a keycode, and should be ignored when recieving a keycode.
|