aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorMarvin Borner2019-11-25 22:36:11 +0100
committerMarvin Borner2019-11-25 22:36:11 +0100
commitac441fe297e937a8cd17f968e0644be6f485d573 (patch)
tree8a902c97196cc80994b5cb1e44d6865360c16caa /src/kernel
parentc5f8b04cdea44e5e5e0c208947b1f7ae44703a23 (diff)
Added basic control key support
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/input/ps2/keyboard.c41
-rw-r--r--src/kernel/kernel.c4
-rw-r--r--src/kernel/timer/timer.c1
3 files changed, 34 insertions, 12 deletions
diff --git a/src/kernel/input/ps2/keyboard.c b/src/kernel/input/ps2/keyboard.c
index 24802bd..1ca1a1b 100644
--- a/src/kernel/input/ps2/keyboard.c
+++ b/src/kernel/input/ps2/keyboard.c
@@ -3,11 +3,12 @@
#include <kernel/graphics/vesa.h>
int shift_pressed;
+int control_pressed;
char keymap[128] = {
0 /*E*/, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b',
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
- 0 /*C*/, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 14 /*LS*/,
+ 17 /*C*/, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 14 /*LS*/,
'\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 14 /*RS*/, '*',
0, // Alt key
' ', // Space bar
@@ -37,7 +38,7 @@ char keymap[128] = {
char shift_keymap[128] = {
0 /*E*/, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b',
'\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n',
- 0 /*C*/, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 14 /*LS*/,
+ 17 /*C*/, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 14 /*LS*/,
'|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 14 /*RS*/, '*',
0, // Alt key
' ', // Space bar
@@ -64,28 +65,48 @@ char shift_keymap[128] = {
0, // Other keys
};
-void keyboard_handler(struct regs *r)
+char *handle_shift(int scan_code)
{
- unsigned char scan_code;
char *current_keymap = keymap;
if (shift_pressed) current_keymap = shift_keymap;
- scan_code = inb(0x60);
-
if ((scan_code & 0x80) == 0) { // PRESS
- // TODO: Fix caps lock deactivation when pressing shift while shifted
+ // TODO: Fix caps lock deactivation when pressing shift while (locked) shifted
if (current_keymap[scan_code] == 14 || (current_keymap[scan_code] == 15 && !shift_pressed)) {
shift_pressed = 1;
- return;
} else if (current_keymap[scan_code] == 15 && shift_pressed) {
shift_pressed = 0;
- return;
}
- vesa_keyboard_char(current_keymap[scan_code]);
} else { // RELEASE
char key = current_keymap[scan_code];
if (key == 14) shift_pressed = 0;
}
+
+ return current_keymap;
+}
+
+void keyboard_handler(struct regs *r)
+{
+ unsigned char scan_code;
+
+ scan_code = inb(0x60);
+ char *current_keymap = handle_shift(scan_code);
+
+ if ((scan_code & 0x80) == 0) { // PRESS
+ if (current_keymap[scan_code] == 17)
+ control_pressed = 1;
+
+ if (control_pressed && current_keymap[scan_code] == 'l') {
+ vesa_clear();
+ return;
+ }
+
+ vesa_keyboard_char(current_keymap[scan_code]);
+ } else { // RELEASE
+ // TODO: Fix control release
+ if (current_keymap[scan_code] == 17)
+ control_pressed = 0;
+ }
}
void keyboard_acknowledge()
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index b717218..e3c5295 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -29,9 +29,9 @@ void kernel_main()
// Install drivers
asm ("cli");
+ timer_install();
mouse_install();
keyboard_install();
- timer_install();
asm ("sti");
// Get hardware information
@@ -42,7 +42,7 @@ void kernel_main()
uint8_t boot_drive_id = (uint8_t) (*((uint8_t *) 0x9000));
if (boot_drive_id == 0xE0) {
- install_melvix();
+ // install_melvix();
}
// User mode!
diff --git a/src/kernel/timer/timer.c b/src/kernel/timer/timer.c
index defb95d..dd4e165 100644
--- a/src/kernel/timer/timer.c
+++ b/src/kernel/timer/timer.c
@@ -39,4 +39,5 @@ void timer_install()
{
timer_phase(1000);
irq_install_handler(0, timer_handler);
+ info("Installed timer");
} \ No newline at end of file