onlyonemac wrote:
Make it "scan code -> key code -> key event -> ASCII character -> terminal event" and you shouldn't go far wrong.
I actually meant to say scan code -> key code -> key event -> terminal event -> ASCII character, but I messed up, and I was too lazy to go back and fix it...
And I do think that I'm going to combine the first three together, or more likely, have three different readers -- one that returns scan codes, one that returns key codes, and one that returns events, and I'll just pick the one I need at that moment.
Combuster wrote:
On top of that I'd have an IME driver that converts keystrokes into interaction events.
IME? As in Intel Management Engine?
Brendan wrote:
The approach I'd recommend is for keyboard driver to send "events" consisting of a set of flags (e.g. control, alt, shift and LED states, plus a pressed/repeated/released 2-bit field), a Unicode codepoint (that may be null where it doesn't make sense), a key code (an integer that identifies the raw key number itself), and possibly a time-stamp indicating when the key was pressed
This is pretty much what I had in mind, but I wanted to be able to convert that back to ASCII in case I just wanted to print characters to the screen, or send them to a text file, or print them to the LPT port, or send them to a serial port... Hence the addition of the final link in the chain, above.
embryo2 wrote:
But is there just one code set on the side of internal text representation in your OS?
Well, right now, it's mainly ASCII... or byte streams that just happen to show up as ASCII characters on the screen. But I'm currently working on moving to key events / terminal events, and getting away from ASCII characters.
embryo2 wrote:
In the end we have many code sources accompanied by code set converters. After converters we have one transport.
I guess this was my original question. What format should the internal transport use? Bytes, characters, escaped characters, or structs? And I think the consensus here is "structs", and convert everything from/to that format on both ends.