kbd.c (1113B)
1 #include "extern.h" 2 #include "idt.h" 3 #include "port.h" 4 5 static void kbd_callback(struct reg *); 6 7 static unsigned char kbdus[128] = { 8 0, /* Error */ 9 27, /* Escape */ 10 '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 11 '-', '=', '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 12 '[', ']', '\n', 13 0, /* Control */ 14 'a', 's', 'd', 'f', 'g', 15 'h', 'j', 'k', 'l', ';', '\'', '`', 16 0, /* Left Shift */ 17 '\\', 'z', 'x', 18 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 19 0, /* Right Shift */ 20 '*', 21 0, /* Alt */ 22 ' ', 23 0, /* Caps Lock */ 24 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F1-F10 */ 25 0, /* Num Lock */ 26 0, /* Scroll Lock */ 27 0, /* Home Key */ 28 0, /* Up Arrow */ 29 0, /* Page Up */ 30 '-', 31 0, /* Left Arrow */ 32 0, 33 0, /* Right Arrow */ 34 '+', 35 0, /* End Key */ 36 0, /* Down Arrow */ 37 0, /* Page Down */ 38 0, /* Insert Key */ 39 0, /* Delete Key */ 40 0, 0, 0, 41 0, 0, /* F11, F12 */ 42 0, /* The rest are undefined */ 43 }; 44 45 static void 46 kbd_callback(struct reg *r) 47 { 48 uint8_t sc; 49 50 if ((sc = inb(P_KBD)) & 0x80) { 51 } else { 52 tty_putc(kbdus[sc]); 53 } 54 (void)r; 55 } 56 57 void 58 kbd_init(void) 59 { 60 int_add_handler(1, kbd_callback); 61 }