Skip to content
Snippets Groups Projects
Commit 80e2710e authored by Byron Lathi's avatar Byron Lathi
Browse files

add shift support

finally get rid of the defined but not used warning.
parent 527c3116
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,9 @@ static irq_callback_t kbd_callback;
static volatile int flag = 0;
static uint8_t last_key;
static uint8_t lshift_flag = 0;
static uint8_t rshift_flag = 0;
// The normal letters numbers and punctuation symbols in scan set 1
static const char normal_map[] = {
......@@ -62,9 +65,26 @@ uint32_t keyboard_handle_irq()
uint8_t scancode = inb(0x60);
if (!(scancode & 0x80)) {
flag = 1;
last_key = normal_map[scancode];
printf("%c", last_key);
if (scancode == LSHIFT) {
lshift_flag = 1;
} else if (scancode == RSHIFT) {
rshift_flag = 1;
} else {
if (lshift_flag || rshift_flag) {
last_key = shift_map[scancode];
} else {
last_key = normal_map[scancode];
}
flag = 1;
printf("%c", last_key);
}
} else {
scancode &= ~0x80;
if (scancode == LSHIFT) {
lshift_flag = 0;
} else if (scancode == RSHIFT) {
rshift_flag = 0;
}
}
i8259_send_eoi(KEYBOARD_IRQ);
......
......@@ -5,6 +5,9 @@
#define KEYBOARD_IRQ 1
#define LSHIFT 0x2a
#define RSHIFT 0x36
uint32_t keyboard_init();
uint32_t keyboard_handle_irq();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment