Page 1 of 1
[SOLVED] How to get string of input with basic IRQ driver?
Posted: Thu Feb 11, 2016 1:26 am
by RharryR
Howdy!
I have written a IRQ keyboard driver, which works nice and dandy:
Code: Select all
// Generic Keyboard Driver
#include "include.h"
void kern_keyboard_int(struct regs* r)
{
unsigned char code;
code = inb(0x60);
if(code & 0x80)
{
}
else
{
}
}
void kern_setup_keyboard_driver()
{
kern_put_str("Setting up generic keyboard driver...\n");
kern_irq_place_handler(1, kern_keyboard_int);
}
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
Re: How to get string of input with basic IRQ driver?
Posted: Thu Feb 11, 2016 4:06 am
by BrightLight
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.
Re: How to get string of input with basic IRQ driver?
Posted: Thu Feb 11, 2016 6:22 pm
by RharryR
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!!
Re: [SOLVED] How to get string of input with basic IRQ drive
Posted: Fri Feb 12, 2016 3:54 pm
by BrightLight
Psuedo-code might look like this:
Code: Select all
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;
}
Re: [SOLVED] How to get string of input with basic IRQ drive
Posted: Sat Feb 13, 2016 12:42 am
by ashishkumar4
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 )
https://github.com/AshishKumar4/Aqeous/ ... s/Keyboard (keyboard)
https://github.com/AshishKumar4/Aqeous/ ... /console.c (my console code)
Re: [SOLVED] How to get string of input with basic IRQ drive
Posted: Sat Feb 13, 2016 6:16 pm
by RharryR
Thanks!! You guys are great!
Got my nice snazzy command line working