Page 1 of 1

Keyboard support

Posted: Tue Nov 10, 2009 2:46 pm
by Auraomega
I've got the basics of keyboard covered, however I was wondering if anyone could advise me on how to make clean support, such as storing the typed letter and passing it onto the currently running program. I've tried the search function, but it's doing nothing (just sitting loading for the past 10 minutes).

Re: Keyboard support

Posted: Tue Nov 10, 2009 4:45 pm
by NickJohnson
I'm guessing what you're looking for is a way to make the keyboard act more like a text stream, so it can be read from by a user process asynchronously. The key here is to make a queue (probably from a linked list) that buffers the input characters. When the process makes a system call to read from the keyboard, just fill its buffer with the output end of the queue.

You may also want to couple the keyboard and screen drivers, because it is often easiest to just echo keystrokes to the screen, regardless of if and how many processes are reading them. Then you get a device that you can both read and write to, and makes sense too.

Re: Keyboard support

Posted: Wed Nov 11, 2009 2:47 am
by AJ
NickJohnson wrote:The key here is to make a queue (probably from a linked list) that buffers the input characters.
I'd be tempted to implement a Ring Buffer (wikipedia calls this a Circular Buffer).
You may also want to couple the keyboard and screen drivers, because it is often easiest to just echo keystrokes to the screen, regardless of if and how many processes are reading them. Then you get a device that you can both read and write to, and makes sense too.
Great idea in the early stages of development, but remember to leave yourself a way to easily remove this feature without breaking anything when you get to the point of adding a window manager / multiple virtual consoles.

Cheers,
Adam