blob: de7415cdb7b570d85a6652fce2cb5c95890b4d25 (
plain)
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
|
#include "asm.h"
#include "exceptions.h"
#include "print.h"
#include "str.h"
#include <stdint.h>
static uint8_t shift_held = 0;
static uint8_t capslock = 0;
void keyboard_handler() {
const char *scancodes =
"??1234567890-=?\tqwertyuiop[]\n?asdfghjkl;'`?\\zxcvbnm,./?*? ";
const char *SCANCODES =
"\?\?!@#$%^&*()_+?\tQWERTYUIOP{}\n?ASDFGHJKL:\"~?|ZXCVBNM<>??*? ";
unsigned char sc = inb(0x60);
uint8_t isheld = shift_held != 0;
char c = (isheld ^ capslock) ? SCANCODES[sc] : scancodes[sc];
if (capslock & (!isheld) && !isalpha(c))
c = scancodes[sc];
if (isheld && !isalpha(c))
c = SCANCODES[sc];
if (sc < 0x59 && scancodes[sc] != '?')
printf("%c", c);
switch (sc) {
case 0x2A:
shift_held |= 0b10;
break;
case 0x36:
shift_held |= 0b01;
break;
case 0xAA:
shift_held &= 0b01;
break;
case 0xB6:
shift_held &= 0b10;
break;
case 0x0E:
delete_char();
break;
case 0x3A:
capslock = !capslock;
break;
}
if (shift_held && sc == 0xE0)
panic("Test panic");
outb(0x20, 0x20);
}
|