Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Now heres the question: Im a writing a basic command line. How do I use this driver to get a string of input when I want it? I somehow need a readline function that returns a string(char*) of input, but how can I make the driver send the readline function keys? Hope you get what I mean.
Hazza
Last edited by RharryR on Fri Feb 12, 2016 2:45 am, edited 1 time in total.
Start with get_char before get_string.
Anyway, your keyboard driver has to store the pressed keys in some sort of buffer, and your get_char function should read from that buffer and remove the character from it.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
omarrx024 wrote:Start with get_char before get_string.
Anyway, your keyboard driver has to store the pressed keys in some sort of buffer, and your get_char function should read from that buffer and remove the character from it.
Thanks for the reply. Could you demonstrate how I could do this? Im having a bit of trouble. Thanks again!!
void keyboard_irq_handler()
{
char scancode = inportb(0x60);
// get ASCII char from scancode and put it in last_char
last_char = get_ascii_char(scancode); // psuedo-code
kbd_irq = 1; // notify that an IRQ has occured
}
char get_char()
{
while(kbd_irq != 1); // wait for an IRQ
// now we know an IRQ occured
// so just read the key
kbd_irq = 0;
return last_char;
}
You know your OS is advanced when you stop using the Intel programming guide as a reference.
That's a good question. I would like to share my own keyboard code with you. Its highly modular and easy to port though I wont suggest you to port my code into yours as I don't know what you have in your kernel. just go throw my code for any help. making a keyboard driver was a delicate task for me. you can use my scancodes and the basic idea from my keyboard driver which is get the scancode by quering the keyboard encoder/controller and match it with different cases. then use it to make a getch() func and then a getline func. if you want to use the backspace thing, you would have to write a code especially using your VGA I/O operations. Here are my code : (Not for just copy paste :3 )