keyboard buffer

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.
Post Reply
elias

keyboard buffer

Post by elias »

i had a thought when reading about keyboard programming. if whenever a keystroke occurs, its translated to ASCII by the driver and stored in the keyboard buffer, and the keyboard buffer is circular, this means that if a program dosnt read from the kbd(the buffer in this case), the data is lost because it will be overwritten from too many keystrokes. is there any way around this? how big is the kbd buffer in most OSes?
stonedzealot

Re:keyboard buffer

Post by stonedzealot »

Well, the best way to handle this, in my opinion, is to give the character to the program that the user is typing into. For example, at the OS's command line, you'd pass the char to the command line handler, who'd then print the character to the screen (next to the command line) and then add the char onto the string/array of chars that holds the part of the command that has been typed so far.
DarylD

Re:keyboard buffer

Post by DarylD »

Yes, just use events or messages to send the keyboard command.

In my OS I have a RequestFocus module call which will tell the keyboard driver where to send the keystrokes.

Daryl.
Rico Sanchez

Re:keyboard buffer

Post by Rico Sanchez »

When a keyboard interrupt occurs. Do you all the keyboard handling, such as converting the keystroke to an ASCII character and sending it to the right program, in the ISR. Or do you only put the keystroke in a buffer as the ISR and that another part of the system (kernel or keyboard task) futher handles the keyboard handling. It seems to me that keeping the ISRs as short as possible is the best sollution so that other interrupts can be handled faster (at the ISR level), or would this be too much overhead?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:keyboard buffer

Post by distantvoices »

I have my keyboard Interrupt service routine put scancodes into a circular buffer, and from this buffer, another function which is called kbd_read, fetches the codes, translates them to characters or metakeys, and hands the characters over to the function which has requested them. Thus, I keep the ISR neat, short and simple.

I have learned to do it this way from tanenbaums os book.

stay safe
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
elias

Re:keyboard buffer

Post by elias »

this was what im planning to do too. but how big is your circular buffer? and my only prob is, wat happens if it overwrites itself?
Post Reply