Fix: backspace, shift (kb driver) + Add: doc + ascii art
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
|
||||
#define KEYBOARD_BUFFER_SIZE 256
|
||||
|
||||
#define LEFT_SHIFT_PRESSED 0x2A
|
||||
#define RIGHT_SHIFT_PRESSED 0x36
|
||||
#define LEFT_SHIFT_RELEASED 0xAA
|
||||
#define RIGHT_SHIFT_RELEASED 0xB6
|
||||
|
||||
unsigned char kbdus[128] =
|
||||
{
|
||||
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
|
||||
@@ -44,9 +49,50 @@ unsigned char kbdus[128] =
|
||||
0, /* All other keys are undefined */
|
||||
};
|
||||
|
||||
unsigned char kbdus_shift[128] =
|
||||
{
|
||||
0, 27, '!', '@', '#', '$', '%', '^', '&', '*', /* 9 */
|
||||
'(', ')', '_', '+', '\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 */
|
||||
};
|
||||
|
||||
static char keyboard_buffer[KEYBOARD_BUFFER_SIZE];
|
||||
static unsigned int keyboard_buffer_start = 0;
|
||||
static unsigned int keyboard_buffer_end = 0;
|
||||
static int shift_pressed = 0;
|
||||
|
||||
void keyboard_handler()
|
||||
{
|
||||
@@ -56,14 +102,27 @@ void keyboard_handler()
|
||||
|
||||
if (scancode & 0x80)
|
||||
{
|
||||
if (scancode == LEFT_SHIFT_RELEASED || scancode == RIGHT_SHIFT_RELEASED) {
|
||||
shift_pressed = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char c = kbdus[scancode];
|
||||
if (c)
|
||||
{
|
||||
keyboard_buffer[keyboard_buffer_end] = c;
|
||||
keyboard_buffer_end = (keyboard_buffer_end+1) % KEYBOARD_BUFFER_SIZE;
|
||||
if (scancode == LEFT_SHIFT_PRESSED || scancode == RIGHT_SHIFT_PRESSED) {
|
||||
shift_pressed = 1;
|
||||
} else {
|
||||
char c;
|
||||
if (shift_pressed) {
|
||||
c = kbdus_shift[scancode];
|
||||
} else {
|
||||
c = kbdus[scancode];
|
||||
}
|
||||
|
||||
if (c)
|
||||
{
|
||||
keyboard_buffer[keyboard_buffer_end] = c;
|
||||
keyboard_buffer_end = (keyboard_buffer_end+1) % KEYBOARD_BUFFER_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
#include "idt.h"
|
||||
#include "system.h"
|
||||
|
||||
char* ascii_title =
|
||||
"\n"
|
||||
" oooooooooo o888 oooo ooooooo oooooooo8\n"
|
||||
" 888 888 888 ooooooo oo oooooo 888 ooooo o888 888o 888 \n"
|
||||
" 888oooo88 888 ooooo888 888 888 888o888 888 888 888oooooo \n"
|
||||
" 888 888 888 888 888 888 888 8888 88o 888o o888 888\n"
|
||||
" o888ooo888 o888o 88ooo88 8o o888o o888o o888o o888o 88ooo88 o88oooo888\n\n"
|
||||
" --------------------------------- v0.3.31 --------------------------------\n\n";
|
||||
|
||||
int kmain(int retvalue)
|
||||
{
|
||||
|
||||
@@ -23,12 +32,10 @@ int kmain(int retvalue)
|
||||
|
||||
clear();
|
||||
|
||||
colorputs("Blank OS version 1 iteration 3 minor 20\n", 10);
|
||||
colorputs(ascii_title, 10);
|
||||
|
||||
// TODO: Serial printf to dump registers on kernel panic
|
||||
// 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
|
||||
|
||||
//timer_install();
|
||||
keyboard_install();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ void shell_install()
|
||||
printf("%d", 4/0);
|
||||
}
|
||||
else {
|
||||
puts("Unknown command\n");
|
||||
printf("Unknown command %s\n", input_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user