Problems with a command buffer
Posted: Sun Aug 02, 2009 1:23 am
Hello,
There're some problems with my command buffer.
For example: I type about in my Command Line, then press Backspace and then t and Enter, so there's "about' in my CLI.
But CLI can't found this command.
What's wrong with it?
--Andrew
There're some problems with my command buffer.
Code: Select all
unsigned shift_state = 0;
char kbd_buffer[128];
unsigned i;
bool bufchar;
/* Handles the keyboard interrupt */
void keyboard_handler(struct regs *r)
{
unsigned char scan_code;
/* Read from the keyboard's data buffer */
scan_code = inportb(0x60);
switch(scan_code)
{
case 0x2A:
shift_state = 1;
break;
case 0xAA:
shift_state = 0;
break;
default:
if (scan_code & 0x80)
{
bufchar = false;
}
else
{
if (kbdus[scan_code] == '\b')
{
bufchar = false;
if (i > 0)
{
i--;
putch(0);
move_csr(i, csr_y);
}
}
else if (kbdus[scan_code] == '\n')
{
putch('\n');
kbd_buffer[i++] = '\0';
exec_command(kbd_buffer);
bufchar = false;
i = 0;
}
else
{
putch((shift_state ? kbdus_shift:kbdus)[scan_code]);
bufchar = true;
}
}
break;
}
if (bufchar == true)
{
i++;
kbd_buffer[i] = ((shift_state ? kbdus_shift:kbdus)[scan_code]);
}
outportb(0x20,0x20);
}
But CLI can't found this command.
What's wrong with it?
--Andrew