keyboard

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.
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Post by codemastersnake »

jal wrote:
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.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

And don't flame back, because both myself and jal could cook up exactly what you have in less than a day.
I think your knowledge is so limited, you have no chance to succeed making anything even close to an OS.
Whoa, I know you guys are right, but is the excessively rude and elite attitude necessary?
C8H10N4O2 | #446691 | Trust the nodes.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

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).
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

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.


JAL
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post by White-spirit »

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 ;)
Working on multi-tasking support ...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

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?

That is why a circular buffer was suggested.

Cheers,

James
Post Reply