This is a fancy name I made up (KDT) for handling keystrokes in the console of the test OS that I am writing. Basically, I wanted to know how I could create some kind of a Lookup Table for handling keystrokes and extended keys and I thought of a table identical to IDTs and GDTs. Each descriptor which basically is in charge of handling one key or a range of keys is made of 8 bytes. The first byte is the flags, the second is reserved, the third is the upper case key and the fourth is the lower. The next four bytes can be used as a pointer to a key handler.
What I have coded so far is given below. What I want to ask is whether or not this design is good or bad. I know that the size of the table can get extremely large but I couldn't think of a better way that can reduce the size of the code:
What I have coded so far is given below. What I want to ask is whether or not this design is good or bad. I know that the size of the table can get extremely large but I couldn't think of a better way that can reduce the size of the code:
Posted on 2007-02-08 03:38:18 by XCHG
Mimicking the xDT names is a bad idea, imho - there's a world of difference between the descriptor tables and your keytable. Second, unless you want to support only a single keyboard layout, you'll want the table to be dynamically loaded - and you might want to consider things like unicode as well.
You can start with something simple, like a scancode->ascii translation table, but eventually you'll have to ask yourself how you want keys represented later on in the system.
Do you want SHIFT,ALT,CTRL available only as "states"/"modifiers", or do you want to register them as individual keypresses/releases? Do you want unicode support? And what about special characters like ~?`^? which can act as combiners in some languages? et cetera.
You can start with something simple, like a scancode->ascii translation table, but eventually you'll have to ask yourself how you want keys represented later on in the system.
Do you want SHIFT,ALT,CTRL available only as "states"/"modifiers", or do you want to register them as individual keypresses/releases? Do you want unicode support? And what about special characters like ~?`^? which can act as combiners in some languages? et cetera.
I just created the first test version of this KDT thing (What a name, huh?) and I put it into test and it worked okay but I really am concerned about the size. A simple LUT for keystrokes could be a lot of work because of the extended keys and the state of the shift and other modifier keys. I really don't know what design would be good for a simple preemptive multitasking environment so if you could give me more insights on this, I would appreciate it. Oh and yeah UNICODE is a must.