I'm trying to convert keyboard events read from /dev/input/event0 from the values defined in to their ASCII equivalent inside an embedded application that is not running X or a terminal.
I think this should be done via keymap functionality defined within Linux rather than just creating my own std::map<> but I can't seem to find a good place to start. Most of the examples I have found so far assume I am running with X windows or with a terminal.
Text input (except for the very simple case of the traditional US keyboard and the 7 bit ASCII standard) is an immensely complicated field. I'd very strongly suggest you do this using an X client, where you can take advantage of all the existing input methods.
But if you must, and you're happy with one kind of keyboard and one language, you do this by interpreting the events just as a terminal would. Check the defintion in /usr/include/linux/input.h
for the values. Track the position of the Shift and Ctrl keys (non-ASCII keys like Alt, Fn, etc... are up to you to interpret, of course) and emit the corresponding byte on the key up event. Maybe you'll want to implement an auto-repeat facility too if the defaults don't work for you application.
But basically: don't. This is a much (!) harder problem than you seem to realize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With