Keyboard support
Keyboard support
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.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Keyboard support
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.
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
I'd be tempted to implement a Ring Buffer (wikipedia calls this a Circular Buffer).NickJohnson wrote:The key here is to make a queue (probably from a linked list) that buffers the input characters.
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.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.
Cheers,
Adam