Rev 1353 | Rev 1560 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1353 | Rev 1451 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ |
28 | */ |
29 | 29 | ||
30 | #include <arch/kbd.h> |
30 | #include <arch/kbd.h> |
31 | #include <key_buffer.h> |
- | |
32 | #include <ipc/ipc.h> |
31 | #include <ipc/ipc.h> |
33 | 32 | ||
34 | #define SPECIAL '?' |
33 | #define SPECIAL '?' |
35 | #define KEY_RELEASE 0x80 |
34 | #define KEY_RELEASE 0x80 |
36 | 35 | ||
Line 77... | Line 76... | ||
77 | SPECIAL, /* 0x36 - RShift */ |
76 | SPECIAL, /* 0x36 - RShift */ |
78 | '*', |
77 | '*', |
79 | SPECIAL, /* 0x38 - LAlt */ |
78 | SPECIAL, /* 0x38 - LAlt */ |
80 | ' ', |
79 | ' ', |
81 | SPECIAL, /* 0x3a - CapsLock */ |
80 | SPECIAL, /* 0x3a - CapsLock */ |
- | 81 | 0x3b, /* 0x3b - F1 */ |
|
82 | SPECIAL, /* 0x3b - F1 */ |
82 | // SPECIAL, /* 0x3b - F1 */ |
- | 83 | 0x3c, /* 0x3c - F2 */ |
|
83 | SPECIAL, /* 0x3c - F2 */ |
84 | // SPECIAL, /* 0x3c - F2 */ |
- | 85 | 0x3d, /* 0x3d - F3 */ |
|
84 | SPECIAL, /* 0x3d - F3 */ |
86 | // SPECIAL, /* 0x3d - F3 */ |
- | 87 | 0x3e, /* 0x3e - F4 */ |
|
85 | SPECIAL, /* 0x3e - F4 */ |
88 | // SPECIAL, /* 0x3e - F4 */ |
86 | SPECIAL, /* 0x3f - F5 */ |
89 | // SPECIAL, /* 0x3f - F5 */ |
- | 90 | 0x3f, /* 0x3f - F5 */ |
|
87 | SPECIAL, /* 0x40 - F6 */ |
91 | // SPECIAL, /* 0x40 - F6 */ |
- | 92 | 0x40, /* 0x40 - F6 */ |
|
88 | SPECIAL, /* 0x41 - F7 */ |
93 | // SPECIAL, /* 0x41 - F7 */ |
- | 94 | 0x41, /* 0x41 - F7 */ |
|
89 | SPECIAL, /* 0x42 - F8 */ |
95 | // SPECIAL, /* 0x42 - F8 */ |
- | 96 | 0x42, /* 0x42 - F8 */ |
|
90 | SPECIAL, /* 0x43 - F9 */ |
97 | // SPECIAL, /* 0x43 - F9 */ |
- | 98 | 0x43, /* 0x43 - F9 */ |
|
91 | SPECIAL, /* 0x44 - F10 */ |
99 | // SPECIAL, /* 0x44 - F10 */ |
- | 100 | 0x44, /* 0x44 - F10 */ |
|
92 | SPECIAL, /* 0x45 - NumLock */ |
101 | SPECIAL, /* 0x45 - NumLock */ |
93 | SPECIAL, /* 0x46 - ScrollLock */ |
102 | SPECIAL, /* 0x46 - ScrollLock */ |
94 | '7', '8', '9', '-', |
103 | '7', '8', '9', '-', |
95 | '4', '5', '6', '+', |
104 | '4', '5', '6', '+', |
96 | '1', '2', '3', |
105 | '1', '2', '3', |
Line 157... | Line 166... | ||
157 | SPECIAL, /* 0x36 - RShift */ |
166 | SPECIAL, /* 0x36 - RShift */ |
158 | '*', |
167 | '*', |
159 | SPECIAL, /* 0x38 - LAlt */ |
168 | SPECIAL, /* 0x38 - LAlt */ |
160 | ' ', |
169 | ' ', |
161 | SPECIAL, /* 0x3a - CapsLock */ |
170 | SPECIAL, /* 0x3a - CapsLock */ |
- | 171 | 0x3b, /* 0x3b - F1 */ |
|
- | 172 | 0x3c, /* 0x3c - F2 */ |
|
- | 173 | 0x3d, /* 0x3d - F3 */ |
|
- | 174 | 0x3e, /* 0x3e - F4 */ |
|
- | 175 | 0x3f, /* 0x3f - F5 */ |
|
- | 176 | 0x40, /* 0x40 - F6 */ |
|
- | 177 | 0x41, /* 0x41 - F7 */ |
|
- | 178 | 0x42, /* 0x42 - F8 */ |
|
- | 179 | 0x43, /* 0x43 - F9 */ |
|
- | 180 | 0x44, /* 0x44 - F10 */ |
|
162 | SPECIAL, /* 0x3b - F1 */ |
181 | // SPECIAL, /* 0x3b - F1 */ |
163 | SPECIAL, /* 0x3c - F2 */ |
182 | // SPECIAL, /* 0x3c - F2 */ |
164 | SPECIAL, /* 0x3d - F3 */ |
183 | // SPECIAL, /* 0x3d - F3 */ |
165 | SPECIAL, /* 0x3e - F4 */ |
184 | // SPECIAL, /* 0x3e - F4 */ |
166 | SPECIAL, /* 0x3f - F5 */ |
185 | // SPECIAL, /* 0x3f - F5 */ |
167 | SPECIAL, /* 0x40 - F6 */ |
186 | // SPECIAL, /* 0x40 - F6 */ |
168 | SPECIAL, /* 0x41 - F7 */ |
187 | // SPECIAL, /* 0x41 - F7 */ |
169 | SPECIAL, /* 0x42 - F8 */ |
188 | // SPECIAL, /* 0x42 - F8 */ |
170 | SPECIAL, /* 0x43 - F9 */ |
189 | // SPECIAL, /* 0x43 - F9 */ |
171 | SPECIAL, /* 0x44 - F10 */ |
190 | // SPECIAL, /* 0x44 - F10 */ |
172 | SPECIAL, /* 0x45 - NumLock */ |
191 | SPECIAL, /* 0x45 - NumLock */ |
173 | SPECIAL, /* 0x46 - ScrollLock */ |
192 | SPECIAL, /* 0x46 - ScrollLock */ |
174 | '7', '8', '9', '-', |
193 | '7', '8', '9', '-', |
175 | '4', '5', '6', '+', |
194 | '4', '5', '6', '+', |
176 | '1', '2', '3', |
195 | '1', '2', '3', |
Line 228... | Line 247... | ||
228 | irq_code_t i8042_kbd = { |
247 | irq_code_t i8042_kbd = { |
229 | 1, |
248 | 1, |
230 | i8042_cmds |
249 | i8042_cmds |
231 | }; |
250 | }; |
232 | 251 | ||
233 | static int key_released(unsigned char key) |
252 | static int key_released(keybuffer_t *keybuffer, unsigned char key) |
234 | { |
253 | { |
235 | switch (key) { |
254 | switch (key) { |
236 | case SC_LSHIFT: |
255 | case SC_LSHIFT: |
237 | case SC_RSHIFT: |
256 | case SC_RSHIFT: |
238 | keyflags &= ~PRESSED_SHIFT; |
257 | keyflags &= ~PRESSED_SHIFT; |
Line 247... | Line 266... | ||
247 | default: |
266 | default: |
248 | break; |
267 | break; |
249 | } |
268 | } |
250 | } |
269 | } |
251 | 270 | ||
252 | static int key_pressed(unsigned char key) |
271 | static int key_pressed(keybuffer_t *keybuffer, unsigned char key) |
253 | { |
272 | { |
254 | char *map = sc_primary_map; |
273 | char *map = sc_primary_map; |
255 | char ascii = sc_primary_map[key]; |
274 | char ascii = sc_primary_map[key]; |
256 | char shift, capslock; |
275 | char shift, capslock; |
257 | char letter = 0; |
276 | char letter = 0; |
Line 265... | Line 284... | ||
265 | keyflags |= PRESSED_CAPSLOCK; |
284 | keyflags |= PRESSED_CAPSLOCK; |
266 | break; |
285 | break; |
267 | case SC_SPEC_ESCAPE: |
286 | case SC_SPEC_ESCAPE: |
268 | break; |
287 | break; |
269 | case SC_LEFTARR: |
288 | case SC_LEFTARR: |
270 | if (key_buffer_available() >= 3) { |
289 | if (keybuffer_available(keybuffer) >= 3) { |
271 | key_buffer_push(0x1b); |
290 | keybuffer_push(keybuffer, 0x1b); |
272 | key_buffer_push(0x5b); |
291 | keybuffer_push(keybuffer, 0x5b); |
273 | key_buffer_push(0x44); |
292 | keybuffer_push(keybuffer, 0x44); |
274 | } |
293 | } |
275 | break; |
294 | break; |
276 | case SC_RIGHTARR: |
295 | case SC_RIGHTARR: |
277 | if (key_buffer_available() >= 3) { |
296 | if (keybuffer_available(keybuffer) >= 3) { |
278 | key_buffer_push(0x1b); |
297 | keybuffer_push(keybuffer, 0x1b); |
279 | key_buffer_push(0x5b); |
298 | keybuffer_push(keybuffer, 0x5b); |
280 | key_buffer_push(0x43); |
299 | keybuffer_push(keybuffer, 0x43); |
281 | } |
300 | } |
282 | break; |
301 | break; |
283 | case SC_UPARR: |
302 | case SC_UPARR: |
284 | if (key_buffer_available() >= 3) { |
303 | if (keybuffer_available(keybuffer) >= 3) { |
285 | key_buffer_push(0x1b); |
304 | keybuffer_push(keybuffer, 0x1b); |
286 | key_buffer_push(0x5b); |
305 | keybuffer_push(keybuffer, 0x5b); |
287 | key_buffer_push(0x41); |
306 | keybuffer_push(keybuffer, 0x41); |
288 | } |
307 | } |
289 | break; |
308 | break; |
290 | case SC_DOWNARR: |
309 | case SC_DOWNARR: |
291 | if (key_buffer_available() >= 3) { |
310 | if (keybuffer_available(keybuffer) >= 3) { |
292 | key_buffer_push(0x1b); |
311 | keybuffer_push(keybuffer, 0x1b); |
293 | key_buffer_push(0x5b); |
312 | keybuffer_push(keybuffer, 0x5b); |
294 | key_buffer_push(0x42); |
313 | keybuffer_push(keybuffer, 0x42); |
295 | } |
314 | } |
296 | break; |
315 | break; |
297 | case SC_HOME: |
316 | case SC_HOME: |
298 | if (key_buffer_available() >= 3) { |
317 | if (keybuffer_available(keybuffer) >= 3) { |
299 | key_buffer_push(0x1b); |
318 | keybuffer_push(keybuffer, 0x1b); |
300 | key_buffer_push(0x4f); |
319 | keybuffer_push(keybuffer, 0x4f); |
301 | key_buffer_push(0x48); |
320 | keybuffer_push(keybuffer, 0x48); |
302 | } |
321 | } |
303 | break; |
322 | break; |
304 | case SC_END: |
323 | case SC_END: |
305 | if (key_buffer_available() >= 3) { |
324 | if (keybuffer_available(keybuffer) >= 3) { |
306 | key_buffer_push(0x1b); |
325 | keybuffer_push(keybuffer, 0x1b); |
307 | key_buffer_push(0x4f); |
326 | keybuffer_push(keybuffer, 0x4f); |
308 | key_buffer_push(0x46); |
327 | keybuffer_push(keybuffer, 0x46); |
309 | } |
328 | } |
310 | break; |
329 | break; |
311 | case SC_DELETE: |
330 | case SC_DELETE: |
312 | if (key_buffer_available() >= 4) { |
331 | if (keybuffer_available(keybuffer) >= 4) { |
313 | key_buffer_push(0x1b); |
332 | keybuffer_push(keybuffer, 0x1b); |
314 | key_buffer_push(0x5b); |
333 | keybuffer_push(keybuffer, 0x5b); |
315 | key_buffer_push(0x33); |
334 | keybuffer_push(keybuffer, 0x33); |
316 | key_buffer_push(0x7e); |
335 | keybuffer_push(keybuffer, 0x7e); |
317 | } |
336 | } |
318 | break; |
337 | break; |
319 | default: |
338 | default: |
320 | letter = ((ascii >= 'a') && (ascii <= 'z')); |
339 | letter = ((ascii >= 'a') && (ascii <= 'z')); |
321 | capslock = (keyflags & PRESSED_CAPSLOCK) || (lockflags & LOCKED_CAPSLOCK); |
340 | capslock = (keyflags & PRESSED_CAPSLOCK) || (lockflags & LOCKED_CAPSLOCK); |
322 | shift = keyflags & PRESSED_SHIFT; |
341 | shift = keyflags & PRESSED_SHIFT; |
323 | if (letter && capslock) |
342 | if (letter && capslock) |
324 | shift = !shift; |
343 | shift = !shift; |
325 | if (shift) |
344 | if (shift) |
326 | map = sc_secondary_map; |
345 | map = sc_secondary_map; |
327 | key_buffer_push(map[key]); |
346 | keybuffer_push(keybuffer, map[key]); |
328 | break; |
347 | break; |
329 | } |
348 | } |
330 | } |
349 | } |
331 | 350 | ||
332 | /** Register uspace irq handler |
351 | /** Register uspace irq handler |
Line 335... | Line 354... | ||
335 | int kbd_arch_init(void) |
354 | int kbd_arch_init(void) |
336 | { |
355 | { |
337 | return !(ipc_register_irq(1, &i8042_kbd)); |
356 | return !(ipc_register_irq(1, &i8042_kbd)); |
338 | } |
357 | } |
339 | 358 | ||
340 | int kbd_arch_process(int scan_code) |
359 | int kbd_arch_process(keybuffer_t *keybuffer, int scan_code) |
341 | { |
360 | { |
342 | if (scan_code != IGNORE_CODE) { |
361 | if (scan_code != IGNORE_CODE) { |
343 | if (scan_code & KEY_RELEASE) |
362 | if (scan_code & KEY_RELEASE) |
344 | key_released(scan_code ^ KEY_RELEASE); |
363 | key_released(keybuffer, scan_code ^ KEY_RELEASE); |
345 | else |
364 | else |
346 | key_pressed(scan_code); |
365 | key_pressed(keybuffer, scan_code); |
347 | } |
366 | } |
348 | return 1; |
367 | return 1; |
349 | } |
368 | } |