Add: very very basic keyboard driver with shady keymap

This commit is contained in:
xamidev
2024-07-16 22:13:56 +02:00
parent af78ad21cd
commit ddbc549cb0
7 changed files with 70 additions and 4 deletions

Binary file not shown.

63
kb.c Normal file
View File

@@ -0,0 +1,63 @@
#include "io.h"
#include "stdio.h"
#include "system.h"
unsigned char kbdus[128] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
'9', '0', '-', '=', '\b', /* Backspace */
'\t', /* Tab */
'q', 'w', 'e', 'r', /* 19 */
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */
0, /* 29 - Control */
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */
'\'', '`', 0, /* Left shift */
'\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */
'm', ',', '.', '/', 0, /* Right shift */
'*',
0, /* Alt */
' ', /* Space bar */
0, /* Caps lock */
0, /* 59 - F1 key ... > */
0, 0, 0, 0, 0, 0, 0, 0,
0, /* < ... F10 */
0, /* 69 - Num lock*/
0, /* Scroll Lock */
0, /* Home key */
0, /* Up Arrow */
0, /* Page Up */
'-',
0, /* Left Arrow */
0,
0, /* Right Arrow */
'+',
0, /* 79 - End key*/
0, /* Down Arrow */
0, /* Page Down */
0, /* Insert Key */
0, /* Delete Key */
0, 0, 0,
0, /* F11 Key */
0, /* F12 Key */
0, /* All other keys are undefined */
};
void keyboard_handler()
{
unsigned char scancode;
scancode = inb(0x60);
if (scancode & 0x80)
{
}
else
{
putc(kbdus[scancode]);
}
}
void keyboard_install()
{
irq_install_handler(1, keyboard_handler);
}

Binary file not shown.

View File

@@ -25,11 +25,13 @@ int kmain(int retvalue)
colorputs("Blank OS version 1 iteration 3 minor 20\n", 10); colorputs("Blank OS version 1 iteration 3 minor 20\n", 10);
// TODO: Framebuffer upgrade: color output
// TODO: Serial printf to dump registers on kernel panic // TODO: Serial printf to dump registers on kernel panic
// TODO: Fix scrolling bug (framebuffer driver) // TODO: Fix scrolling bug (framebuffer driver)
// TODO: Fix keyboard driver bug (some keys mapped weirdly) + add suport for SHIFT and backspace (deleting character)
// TODO: Grub modules to load programs
// TODO: Folder and build process restructuration
timer_install(); //timer_install();
keyboard_install();
return retvalue; return retvalue;
} }

View File

@@ -1,4 +1,4 @@
OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o timer.o OBJECTS = loader.o kmain.o stdio.o io.o string.o serial.o gdt.o idt.o system.o isr.o irq.o timer.o kb.o
CC = gcc CC = gcc
CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra -c CFLAGS = -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra -c
LDFLAGS = -T link.ld -melf_i386 LDFLAGS = -T link.ld -melf_i386

BIN
os.iso

Binary file not shown.

View File

@@ -19,5 +19,6 @@ void irq_install_handler(int irq, void (*handler)(struct regs *r));
void irq_uninstall_handler(int irq); void irq_uninstall_handler(int irq);
void timer_install(); void timer_install();
void delay(int ticks); void delay(int ticks);
void keyboard_install();
#endif #endif