add: capslock support

This commit is contained in:
starnakin 2024-09-08 20:06:44 +02:00
parent 662a75d233
commit d3aa5af23a

View File

@ -7,20 +7,22 @@
uint8_t terminal_getkey(void)
{
static bool caps = false;
static bool caps_mode = false;
static uint8_t prev_scan_code = 0;
uint8_t scan_code;
scan_code = inb(KEYBOARD_PORT);
if (scan_code == 0x3A || scan_code == 0x58)
caps = !caps;
if (scan_code == 0x3A || scan_code == 0x58) {
caps_mode = !caps_mode;
outb(0xED, (caps_mode << 2));
}
else if (scan_code == KEY_RIGHT_SHIFT || scan_code == KET_LEFT_SHIFT)
caps = true;
caps_mode = true;
else if (scan_code == KEY_RIGHT_SHIFT + 128 || scan_code == KET_LEFT_SHIFT + 128)
caps = false;
caps_mode = false;
else if (scan_code != prev_scan_code && prev_scan_code != 0) {
if (scan_code < 128 && keymap[scan_code])
kprintf(0, "%c", keymap[scan_code][caps]);
kprintf(0, "%c", keymap[scan_code][caps_mode]);
if (scan_code >= KEY_F1 && scan_code <= KEY_F10)
terminal_set_screen(scan_code - KEY_F1);
}