http://www.osdev.org is confused by my keyboard code.
Let's worry about the end-user API.
when a KEY_DOWN message is sent, it's two parameters are ASCII code and scan code. In LoseThos, parameters are 64-bits (8-bytes).
The ASCII is just one byte and is pretty normal, except SHIFT-SPACE is 31.
Bits 0-6 are scan code like eveyone else has.
Bit 7 is set if it had an E0 Scan code prefix.
Therefore the lowest byte makes a scan code value that works for NONASCII keys like cursor key. They would normally be preceded by an E0 byte, but the driver absorbs that and sets bit 7.
Bits 8-19 are flags for CTRL ALT NUM SHIFT, ect.
You can check for CTRL-CURSOR_LEFT for example
Code:
U64 p1,p2;
GetMsg(&p1,&p2,1<<MSG_KEY_DOWN);
if (p2&SCF_CTRL && p2.u8[0]==SCF_CURSOR_DOWN)
PutS("CTRL CURSOR-DOWN");
In losethos, every 64-bit integer value can be accessessed as an array of 8 bytes or a single 64-bit value.
Since we're not using bits 32-63, I decided to get fancy. Sometimes, you want to distinguish between left and right shift keys or left and right CTRL. most times you don't. What I did was to offer a choice of using distinct values in 32-63 or merged values in 0-31.
Merging left and right SHIFT keys means that LEFT is returned whether it's left or right.
As an added bonus, there is a bit array with the current state of scan code key values, not ascii. You can test a bit for each key at any time without affecting messages.
Silly people -- you need to support both polling and nonpolling. In your debugger (you have written a debugger, right) you don't want interrupts happening because your system might not be stable and you don't want to change values all over the place. You certainly wouldn't want to work with messaging in a debugger.
The reason LoseThos has lots of users and your operating systems don't is because LoseThos is compatible. If my mouse interrupt is not working, it falls-back on polling.
You have been brainwashed on the negatives of polling -- checking the keyboard or mouse every milisecond... there are 2 million clock cycles per millisecond. Actually, port IO takes a microsecond, so it's a thousanth of your processing power.
If you are not doing some things different from everybody else your design has no purpose. My message does have two values like Windows but I have only 63 possible messages so you can combine bits together into masks to indicate which messages you are interested in.