support caps with shift but not with caps lock

This commit is contained in:
starnakin 2024-09-08 19:47:31 +02:00
parent d0ddac4775
commit 0ea82d6b4d
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -1,3 +1,5 @@
#include <stdbool.h>
#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);
}