Code: Select all
#include <system.h>
unsigned char* input = "";
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(struct regs *r)
{
unsigned char scancode;
scancode = inportb(0x60);
if (scancode & 0x80)
{
}
else
{
char temp = kbdus[scancode];
if(scancode != 0)
{
if(temp == '\n')
{
runCommand(input);
input = "";
}
else
{
input = input + temp;
}
}
putch(temp);
}
}
void keyboard_install()
{
irq_install_handler(1, keyboard_handler);
}
Code: Select all
void runCommand(unsigned char * command)
{
if(command == "cls")
{
cls();
}
else if(command == "help")
{
puts("\nBrian Hoover's OS v. 0.01\n");
puts("\ncls - Clears Screen\n");
puts("help - Displays This Help Screen\n");
puts("exit - Exit The Shell\n");
}
else
{
puts("\nInvalid Command");
}
puts("\n");
puts(command);
puts("\n>");
return;
}
Something strange seems to be happening with the variable input.
I just need to be pointed in the right direction.
snapshot of bochs:
Code: Select all
- Clears Screen
>
1234
Invalid Command
>
123456789
Invalid Command
>
123
Invalid Command
- Clears Screen
>
12
Invalid Command
[Ãcls
>
cls
Invalid Command
>