summaryrefslogtreecommitdiff
path: root/kernel/src/devices/keyboard.c
diff options
context:
space:
mode:
authorAleksa Vuckovic <aleksa@vuckovic.cc>2023-02-25 06:56:01 +0100
committerAleksa Vuckovic <aleksa@vuckovic.cc>2023-02-25 08:45:09 +0100
commit239900af293f192931391dc5579afab39a43e6c6 (patch)
tree72d7f87ee6adf5aa84b78436197e03e61fba8d97 /kernel/src/devices/keyboard.c
parentaaa23fffd02fb49cdbc56a480dbb5a8fa95bff38 (diff)
clang-format
Diffstat (limited to 'kernel/src/devices/keyboard.c')
-rw-r--r--kernel/src/devices/keyboard.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/kernel/src/devices/keyboard.c b/kernel/src/devices/keyboard.c
index 549a0ca..67c2f19 100644
--- a/kernel/src/devices/keyboard.c
+++ b/kernel/src/devices/keyboard.c
@@ -7,23 +7,23 @@
#include <libk/stdio.h>
#include <libk/math.h>
#include <libk/string.h>
+#include <stdbuff.h>
+#include <heap.h>
bool is_pressed[128];
-#include <stdbuff.h>
-#include <heap.h>
#define BUFFER_SIZE 10000
-stdbuff* keyboard_buffer;
+stdbuff *keyboard_buffer;
void init_keyboard()
{
-// outb(KEYBOARD_CMD_PORT, 0xF3);
-// io_wait();
-// outb(KEYBOARD_DATA_PORT, 0x00);
-// io_wait();
-// while (!(inb(KEYBOARD_STATUS_PORT) & 1)) {}
-// if (inb(KEYBOARD_DATA_PORT) == 0xFA)
-// printf("[keyboard init]\n");
+ // outb(KEYBOARD_CMD_PORT, 0xF3);
+ // io_wait();
+ // outb(KEYBOARD_DATA_PORT, 0x00);
+ // io_wait();
+ // while (!(inb(KEYBOARD_STATUS_PORT) & 1)) {}
+ // if (inb(KEYBOARD_DATA_PORT) == 0xFA)
+ // printf("[keyboard init]\n");
}
void keyboard_handler()
@@ -48,13 +48,14 @@ void keyboard_handler()
if (main_fb.x != 0)
write_buff(keyboard_buffer, "\b \b", 3);
} else if (keycode == KEY_ENTER) {
- char* output = kalloc(sizeof(char) + 1);
+ char *output = kalloc(sizeof(char) + 1);
output[0] = keymap[keycode];
write_buff(keyboard_buffer, output, 1);
kfree(output);
} else {
- char* output = kalloc(sizeof(char) + 1);
- if (keymap[keycode] == ' ') return;
+ char *output = kalloc(sizeof(char) + 1);
+ if (keymap[keycode] == ' ')
+ return;
if (is_pressed[KEY_LSHIFT] || is_pressed[KEY_RSHIFT])
output[0] = shift_keymap[keycode];
else
@@ -66,8 +67,13 @@ void keyboard_handler()
is_pressed[keycode - 128] = false;
}
- uint32_t len = (uint32_t)(keyboard_buffer->head >= keyboard_buffer->tail ? keyboard_buffer->head - keyboard_buffer->tail : BUFFER_SIZE + keyboard_buffer->head - keyboard_buffer->tail);
- char* print_buff = kalloc(len + 1);
+ uint32_t len =
+ (uint32_t)(keyboard_buffer->head >= keyboard_buffer->tail ?
+ keyboard_buffer->head -
+ keyboard_buffer->tail :
+ BUFFER_SIZE + keyboard_buffer->head -
+ keyboard_buffer->tail);
+ char *print_buff = kalloc(len + 1);
read_buff(keyboard_buffer, print_buff, len);
printf("%s", print_buff);
kfree(print_buff);