From 41e3953d2ca15e801fb6f84fe17145e8792d7ae3 Mon Sep 17 00:00:00 2001 From: Robbe Van Herck Date: Thu, 9 Jan 2020 16:53:06 +0100 Subject: [PATCH] Add newline and backspace --- kernel/drivers/keyboard/keycodes.c | 3 +++ kernel/drivers/keyboard/keymaps/DUMMY_azerty.c | 4 ++++ kernel/terminal.c | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/kernel/drivers/keyboard/keycodes.c b/kernel/drivers/keyboard/keycodes.c index 545dda1..c18d288 100644 --- a/kernel/drivers/keyboard/keycodes.c +++ b/kernel/drivers/keyboard/keycodes.c @@ -31,6 +31,9 @@ typedef enum keycode_enum { KEYCODE_SPACE = ' ', + KEYCODE_BACKSPACE = 0x08, + KEYCODE_NEWLINE = '\n', + KEYCODE_SHIFT_UP, KEYCODE_SHIFT_DOWN, KEYCODE_CAPS_UP, diff --git a/kernel/drivers/keyboard/keymaps/DUMMY_azerty.c b/kernel/drivers/keyboard/keymaps/DUMMY_azerty.c index 1665995..6d9fa6d 100644 --- a/kernel/drivers/keyboard/keymaps/DUMMY_azerty.c +++ b/kernel/drivers/keyboard/keymaps/DUMMY_azerty.c @@ -72,6 +72,10 @@ keycode get_keycode(unsigned char scancode) { return KEYCODE_CAPS_DOWN; case 0xba: return KEYCODE_CAPS_UP; + case 0x0e: + return KEYCODE_BACKSPACE; + case 0x1c: + return KEYCODE_NEWLINE; default: return KEYCODE_UNKNOWN; } diff --git a/kernel/terminal.c b/kernel/terminal.c index 1b242f9..40e51e3 100644 --- a/kernel/terminal.c +++ b/kernel/terminal.c @@ -76,6 +76,18 @@ void terminal_putchar(char c) { terminal_row++; return; } + if (c == 0x08) { + if (terminal_column == 0) { + if(terminal_row != 0) { + terminal_row--; + terminal_column = VGA_WIDTH - 1; + } + } else { + terminal_column--; + } + terminal_putentryat(' ', terminal_color, terminal_column, terminal_row); + return; + } terminal_putentryat(c, terminal_color, terminal_column, terminal_row); if (++terminal_column == VGA_WIDTH) {