Pyrofan1 wrote:Okay, I did that and now I can press a key and have it displayed, but when I'm using the qwerty layout, it prints the qwerty key and the same key on a dvorak keyboard and when i'm using the dvorak layout I get the key and a weird character or with certain keys, the letter disappears. I have attached my code.
Actually, I'd wager when using a qwerty layout it prints the qwerty key when you press it and the dvorak key when you release it, correct?
And the "weird character" on dvorak only shows up when you release as well?
You forgot to filter out the release codes, which are "0x80 | code" which is "128 + code" (since the top bit of the actual code is always 0). This causes your array index to be out of bounds when you try to translate them to ascii, and so you're accessing memory after the keymap. The qwerty map is followed directly by the dvorak map, so you get extra "dvorak characters" when you release keys. After the dvorak map is some other stuff, which when interpreted as a keymap causes the "weird characters" or control codes when you release keys while using a dvorak layout.
If you have no need for the release codes (yet), just put a big "if (scancode < 0x80) {}" around the if-statement (including else clause) in your keyboard_handler.