Keyboard support

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

Keyboard support

Post 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).
Windows: Just another pane in the glass.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Keyboard support

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Keyboard support

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