Rev 4343 | Rev 4346 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4343 | Rev 4344 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | #include <kbd.h> |
38 | #include <kbd.h> |
39 | #include <kbd/kbd.h> |
39 | #include <kbd/kbd.h> |
40 | #include <kbd/keycode.h> |
40 | #include <kbd/keycode.h> |
41 | #include <kbd_ctl.h> |
41 | #include <kbd_ctl.h> |
42 | 42 | ||
43 | static int scanmap_simple[]; |
- | |
44 | - | ||
45 | void kbd_ctl_parse_scancode(int scancode) |
- | |
46 | { |
- | |
47 | kbd_ev_type_t type; |
- | |
48 | unsigned int key; |
43 | enum dec_state { |
49 | - | ||
50 | if (scancode < 0 || scancode >= 0x100) |
- | |
51 | return; |
44 | ds_s, |
52 | - | ||
53 | if (scancode & 0x80) { |
- | |
54 | scancode &= ~0x80; |
- | |
55 | type = KE_RELEASE; |
- | |
56 | } else { |
45 | ds_e |
57 | type = KE_PRESS; |
- | |
58 | } |
46 | }; |
59 | 47 | ||
60 | key = scanmap_simple[scancode]; |
- | |
61 | if (key != 0) |
- | |
62 | kbd_push_ev(type, key, 0); |
48 | static enum dec_state ds = ds_s; |
63 | } |
- | |
64 | 49 | ||
65 | static int scanmap_simple[128] = { |
50 | static int scanmap_simple[] = { |
66 | 51 | ||
67 | [0x29] = KC_BACKTICK, |
52 | [0x29] = KC_BACKTICK, |
68 | 53 | ||
69 | [0x02] = KC_1, |
54 | [0x02] = KC_1, |
70 | [0x03] = KC_2, |
55 | [0x03] = KC_2, |
Line 148... | Line 133... | ||
148 | [0x44] = KC_F10, |
133 | [0x44] = KC_F10, |
149 | 134 | ||
150 | [0x57] = KC_F11, |
135 | [0x57] = KC_F11, |
151 | [0x58] = KC_F12, |
136 | [0x58] = KC_F12, |
152 | 137 | ||
- | 138 | [0x46] = KC_SCROLL_LOCK, |
|
- | 139 | ||
153 | [0x1c] = KC_ENTER |
140 | [0x1c] = KC_ENTER, |
154 | 141 | ||
- | 142 | [0x45] = KC_NUM_LOCK, |
|
- | 143 | [0x37] = KC_NTIMES, |
|
- | 144 | [0x4a] = KC_NMINUS, |
|
- | 145 | [0x4e] = KC_NPLUS, |
|
- | 146 | [0x47] = KC_N7, |
|
- | 147 | [0x48] = KC_N8, |
|
- | 148 | [0x49] = KC_N9, |
|
155 | /* |
149 | [0x4b] = KC_N4, |
156 | [0x1] = KC_PRNSCR, |
150 | [0x4c] = KC_N5, |
- | 151 | [0x4d] = KC_N6, |
|
- | 152 | [0x4f] = KC_N1, |
|
157 | [0x1] = KC_SCROLL_LOCK, |
153 | [0x50] = KC_N2, |
158 | [0x1] = KC_PAUSE, |
154 | [0x51] = KC_N3, |
159 | */ |
155 | [0x52] = KC_N0, |
- | 156 | [0x53] = KC_NPERIOD |
|
160 | }; |
157 | }; |
161 | 158 | ||
- | 159 | static int scanmap_e0[] = { |
|
- | 160 | [0x38] = KC_RALT, |
|
- | 161 | [0x1d] = KC_RSHIFT, |
|
- | 162 | ||
- | 163 | [0x37] = KC_PRTSCR, |
|
- | 164 | ||
- | 165 | [0x52] = KC_INSERT, |
|
- | 166 | [0x47] = KC_HOME, |
|
- | 167 | [0x49] = KC_PAGE_UP, |
|
- | 168 | ||
- | 169 | [0x53] = KC_DELETE, |
|
- | 170 | [0x4f] = KC_END, |
|
- | 171 | [0x51] = KC_PAGE_DOWN, |
|
- | 172 | ||
- | 173 | [0x48] = KC_UP, |
|
- | 174 | [0x4b] = KC_LEFT, |
|
- | 175 | [0x50] = KC_DOWN, |
|
- | 176 | [0x4d] = KC_RIGHT, |
|
- | 177 | ||
- | 178 | [0x35] = KC_NSLASH, |
|
- | 179 | [0x1c] = KC_NENTER |
|
- | 180 | }; |
|
- | 181 | ||
- | 182 | ||
- | 183 | void kbd_ctl_parse_scancode(int scancode) |
|
- | 184 | { |
|
- | 185 | kbd_ev_type_t type; |
|
- | 186 | unsigned int key; |
|
- | 187 | int *map; |
|
- | 188 | size_t map_length; |
|
- | 189 | ||
- | 190 | if (scancode == 0xe0) { |
|
- | 191 | ds = ds_e; |
|
- | 192 | return; |
|
- | 193 | } |
|
- | 194 | ||
- | 195 | switch (ds) { |
|
- | 196 | case ds_s: |
|
- | 197 | map = scanmap_simple; |
|
- | 198 | map_length = sizeof(scanmap_simple) / sizeof(int); |
|
- | 199 | break; |
|
- | 200 | case ds_e: |
|
- | 201 | map = scanmap_e0; |
|
- | 202 | map_length = sizeof(scanmap_e0) / sizeof(int); |
|
- | 203 | break; |
|
- | 204 | } |
|
- | 205 | ||
- | 206 | ds = ds_s; |
|
- | 207 | ||
- | 208 | if (scancode & 0x80) { |
|
- | 209 | scancode &= ~0x80; |
|
- | 210 | type = KE_RELEASE; |
|
- | 211 | } else { |
|
- | 212 | type = KE_PRESS; |
|
- | 213 | } |
|
- | 214 | ||
- | 215 | if (scancode < 0 || scancode >= map_length) |
|
- | 216 | return; |
|
- | 217 | ||
- | 218 | key = map[scancode]; |
|
- | 219 | if (key != 0) |
|
- | 220 | kbd_push_ev(type, key); |
|
- | 221 | } |
|
- | 222 | ||
162 | /** |
223 | /** |
163 | * @} |
224 | * @} |
164 | */ |
225 | */ |