From 0ea82d6b4d90315270f4b4e552a786429d05918d Mon Sep 17 00:00:00 2001 From: starnakin Date: Sun, 8 Sep 2024 19:47:31 +0200 Subject: [PATCH] support caps with shift but not with caps lock --- headers/keyboard.h | 3 +++ src/terminal/get.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/headers/keyboard.h b/headers/keyboard.h index f88687f..66b31e5 100644 --- a/headers/keyboard.h +++ b/headers/keyboard.h @@ -93,3 +93,6 @@ static const char *keymap[128] = { #define KEY_RIGHT 0x4D #define KEY_SPACE 0x39 #define KEY_UP 0x48 +#define KET_LEFT_SHIFT 0x2A +#define KEY_RIGHT_SHIFT 0x36 +#define KEY_CAPSLOCK 0x3A \ No newline at end of file diff --git a/src/terminal/get.c b/src/terminal/get.c index 5f7adbf..ddba96f 100644 --- a/src/terminal/get.c +++ b/src/terminal/get.c @@ -1,3 +1,5 @@ +#include + #include "keyboard.h" #include "kprintf.h" #include "sys/io.h" @@ -5,13 +7,18 @@ uint8_t terminal_getkey(void) { + static bool caps = false; static uint8_t prev_scan_code = 0; uint8_t scan_code; scan_code = inb(KEYBOARD_PORT); - if (scan_code != prev_scan_code && prev_scan_code != 0) { + if (scan_code == KEY_RIGHT_SHIFT || scan_code == KET_LEFT_SHIFT) // || scan_code == KEY_CAPSLOCK) + caps = true; + else if (scan_code == KEY_RIGHT_SHIFT + 128 || scan_code == KET_LEFT_SHIFT + 128) // || scan_code == KEY_CAPSLOCK + 128) + caps = 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][0]); + kprintf(0, "%c", keymap[scan_code][caps]); if (scan_code >= KEY_F1 && scan_code <= KEY_F10) terminal_set_screen(scan_code - KEY_F1); }