AnthonyDiGirolamo / teensy-thumb-keyboard

Handheld tactile switch keyboard for Teensy 3.2 compatible boards.
GNU General Public License v3.0
89 stars 6 forks source link

Different language layout #2

Open teldra opened 5 years ago

teldra commented 5 years ago

I build this keyboard successfully and it is working when setting Xorg to an english layout. But most of my computers are set to a different keyboard layout (german). So, when I press '/' on the keyboard I get '-'.

How do I change the send keycode, when using 'usb_key_matrix'? Changing 'Tools->Keyboard Layout' to German in Arduino IDE is not working.

AnthonyDiGirolamo commented 5 years ago

I think it's because I'm using Keyboard.press() and Keyboard.release(). According to https://www.pjrc.com/teensy/td_keyboard.html the layout option in the arduino IDE only affects Keyboard.print() and Keyboard.write(). I didn't know that :sweat_smile:

To fix I think you'd have to update or copy LayoutThumbKeyboard.h to use different key codes in usb_key_matrix.

Here's what / would be with the German layout option:

#define ASCII_2F    KEY_7 + SHIFT_MASK          // 47 /

So you'd have to change KEY_SLASH in LayoutThumbKeyboard.h to KEY_7 + SHIFT_MASK.

Full list of conversions is in https://github.com/PaulStoffregen/cores/blob/master/teensy3/keylayouts.h#L562. You would still need to select German in the Arduino IDE to make sure SHIFT_MASK and other defined values are correct.

If you make a new LayoutGermanThumbKeyboard.h and send me a pull request I can add it to the repo.

teldra commented 5 years ago

When I change KEY_SLASH to KEY_7 + SHIFT_MASK I get a <. And when I set KEY_EQUAL to KEY_0 + SHIFT_MASK I get a = when I press it with or without shift.

teldra commented 5 years ago

I think I found a solution: https://github.com/teldra/teensy-thumb-keyboard/blob/german_layoout/firmware/LayoutThumbKeyboard.h https://github.com/teldra/teensy-thumb-keyboard/blob/german_layoout/firmware/teensy32_thumb_keyboard.ino but I wonder, if it is an elegant or correct one. ;) (First time working with Arduino)