summaryrefslogtreecommitdiff
path: root/kernel/src/devices
diff options
context:
space:
mode:
authorAleksa Vuckovic <aleksav013@gmail.com>2022-08-08 21:25:55 +0200
committerAleksa Vuckovic <aleksav013@gmail.com>2022-08-08 21:26:37 +0200
commite11298e56be560de64bbccfe74fef7ff85c623d1 (patch)
treed8323a711d0887bd1ef0c55025d93a9b551cc7aa /kernel/src/devices
parent0162997df4ae7769bd4fc055b2c03b473846d1f5 (diff)
stdio.h; gcc $(WARNINGS)
Diffstat (limited to 'kernel/src/devices')
-rw-r--r--kernel/src/devices/keyboard.c55
1 files changed, 8 insertions, 47 deletions
diff --git a/kernel/src/devices/keyboard.c b/kernel/src/devices/keyboard.c
index f873a29..76c12c7 100644
--- a/kernel/src/devices/keyboard.c
+++ b/kernel/src/devices/keyboard.c
@@ -1,53 +1,17 @@
#include <types.h>
+#include <keyboard.h>
#include <pic.h>
#include <io.h>
-#include <graphics.h>
-#include <debug.h>
#include <keymap.h>
-#include <libk/string.h>
+#include <libk/stdio.h>
+#include <libk/math.h>
#define KEYBOARD_DATA_PORT 0x60
#define KEYBOARD_STATUS_PORT 0x64
-static uint32_t x;
-static uint32_t y;
bool is_pressed[128];
-void print_char(char c)
-{
-
- if (c == '\n') {
- x = 0;
- y++;
- return;
- }
- if (x * 8 >= fb.width) {
- x = 0;
- y++;
- }
- if (y * 16 >= fb.height) {
- x = 0;
- y = 0;
- }
- fb_draw_character(fb, c, x * 8, y * 16, WHITE, BLACK);
- x++;
-}
-
-void print_string(char* s)
-{
- for (size_t i = 0; i < strlen(s); i++) {
- print_char(s[i]);
- }
-}
-
-void print_int(uint64_t num)
-{
- char a[100];
- itos(num, a);
- print_string(a);
-}
-
void keyboard_handler(void)
{
uint8_t status = inb(KEYBOARD_STATUS_PORT);
@@ -58,21 +22,18 @@ void keyboard_handler(void)
if (keycode < keymap_len) {
is_pressed[keycode] = true;
if (keycode == KEY_SPACE) {
- print_char(' ');
+ printf(" ");
} else if (keycode == KEY_BACKSPACE) {
- if (!x) return;
- x--;
- print_char(' ');
- x--;
+ printf("\b \b");
} else if (keycode == KEY_ENTER) {
- print_char(keymap[keycode]);
+ printf("%c", keymap[keycode]);
} else {
if (keymap[keycode] == ' ') return;
if (is_pressed[KEY_LSHIFT] || is_pressed[KEY_RSHIFT])
- print_char(shift_keymap[keycode]);
+ printf("%c", shift_keymap[keycode]);
else
- print_char(keymap[keycode]);
+ printf("%c", keymap[keycode]);
}
} else {
is_pressed[keycode - 128] = false;