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.
Woellchen wrote:i just asked how to get the pressed buttons to the right "task" and i think i will do it like 01000101's suggestion by giving each "task" an own char buffer
And now the $100,000 question: where are you going to put that buffer? And who is going to manage it? How does the application extract key presses from it? Thought about locking access to it? Concurrency problems?
JAL
One could really use a circlar queue for that. You can initialize that buffer at a very initial stage of booting. write a getch() function and make it extract a character from the buffer.
And Locking is not that difficult. With lil' hardwork anyone can implement locks to avoid concurrency.
Alboin wrote:Whoa, I know you guys are right, but is the excessively rude and elite attitude necessary?
Probably not. But even us OS Gods *cough* have a bad day, now and then *cough*.
JAL
P.S. Please note the sarcasm, I do not consider myself an OS God at all, although JamesM is, of course (being one, not considering himself one, that is).
Snake wrote:One could really use a circlar queue for that. You can initialize that buffer at a very initial stage of booting. write a getch() function and make it extract a character from the buffer.
Yes, but as soon as you have multiple potential tasks wanting input, you're going to need more than that.
You just have to set a global variable with the name last_pressed_key, your keyboard handler puts the char there, and the getch function returns the value of that variable
White-spirit wrote:You want a getch() function as I see, no ?
You just have to set a global variable with the name last_pressed_key, your keyboard handler puts the char there, and the getch function returns the value of that variable
Hi,
That solution is unfortunately not reentrant and will only work for single tasking systems. The OP wanted to be able to dispatch the keys pressed to a particular "task" (although I was and still am confused about how much tasking the OP actually implements).
Unfortunately, that solution also suffers from a rather large problem - what if the user presses *two* keys before the getch() function is called? Where is the other keypress stored?