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.
Hello there,
I am making my own OS from scratch, as many of you here, and I have programmed my isr's, the gdt and the idt, irq's, etc. and I have come across a hurdle which I cant get past. I have a keyboard handler which is full of stuff to handle for the interface. I need to program a get string function, which basically adds the pressed letter from the keyboard buffer to a string until the user presses enter, when the keyboard handler exits. Then my kernel calls the get function which returns the string from get_string. I tried using flag variables to signal to the handler to add the letter to the get_string buffer, instead of going through the normal procedure or if the user pressed enter, disable the flag. However, I cannot have getsbuf=kblayout
; because that will truncate the old value of the file. How can I have it so the old value does not get overwritten, but the the new key gets added?
Hope you understood the long post and thanks in advance,
t6q4
Last edited by t6q4 on Sat Apr 11, 2009 6:30 am, edited 1 time in total.
The same method (global variable) i am also using for my keyboard driver.
When a key pressed, driver adds the key at the end of the buffer/queue.
When the OS handles the pressed keys, it removes characters from the queue.
Think about that your OS maybe multitasking in the future.
Let the driver only saves the characters (key presses).
Make a kernel part that handles these keys/characters with a way that can be dynamic (passes keys at the active window/process).
@t0xic - Thanks, I didnt use your code, I made my own using your principles. Thanks again, for showing me how to append stuff to variables!
@Jef - I may add multitasking in the future, though thats quite far down on my todo list. Thanks for your ideas, I may use your method instead of cramming all my keyboard shortcut stuff into the keyboard handler.
void keyboard_isr()
{
Get Raw Key Data...
Add it to the Buffer
Send a "wake up" message to the keyboard driver
}
The idea behind this is that the keyboard driver will get a notice saying that there are some keys pressed, and the Keyboard Driver, NOT THE ISR, will decode the state flags (ctrl/alt/shift/caps/num/etc etc) and send the key to the waiting app.
Granted I understand that this requires a multi-tasking model. But imho, I think you should have a simple round-robin task scheduling before trying to implement a driver.
Good luck either way!
-Rich
Mouse Pad - Coming in the distant future... Kernel: Indigo Kernel - v0.0.1
Thanks to JamesM and BrokenThorn for there tutorials!