JSubelj / g910-gkey-macro-support

GKey support for Logitech G910 Keyboard on Linux
GNU General Public License v3.0
99 stars 29 forks source link

[Feature] Localization - helper to create a mapping for every language #68

Closed suabo closed 9 months ago

suabo commented 1 year ago

I have good news for everybody with a currently not supported language.
I'm adding a helper which you can run in the terminal and create a mapping for your language.

Why does it matter to have the right mapping for your language? The driver uses uinput to register a virtual device to send keyboard commands. For example if you config a shortcut for your g1 key the driver have to send this shortcut like your keyboard would do. Since you ride down a string interpretation of the keys you want pressed the driver have to translate it into a uinput key. Here is where localization is important, because the uinput keys aren't localized. They just use the English layout. On the German keyboard the letters "z" and "y" are flipped, compared to the English keyboard. This is what the mapping for these two keys look like in the German layout:

  'y': click(uinput.KEY_Z),
  'Y': wrap_shift(click(uinput.KEY_Z)),
  'z': click(uinput.KEY_Y),
  'Z': wrap_shift(click(uinput.KEY_Y)),

But this isn't the only difference. Mostly all of the special chars are on different keys:

  'ä': click(uinput.KEY_APOSTROPHE),
  'Ä': wrap_shift(click(uinput.KEY_APOSTROPHE)),
  'ö': click(uinput.KEY_SEMICOLON),
  'Ö': wrap_shift(click(uinput.KEY_SEMICOLON)),
  'ü': click(uinput.KEY_LEFTBRACE),
  'Ü': wrap_shift(click(uinput.KEY_LEFTBRACE)),

The English keyboard doesn't have this fancy German letters with the two dots. So you could now try to compare your language keyboard layout to the English and write the mapping manually. But this is a long tedious process with a lot of try and error.

How will it work?
You simply get printed out a mapping for your currently set up keyboard layout on stdout. The helper will go trough all the keys on the keyboard end emit them to write the corresponding char for the config. If the helper is finished you copy and paste the config to lib.data_mappers.char_uinput_mapper and reinstall the package.

I think this will take a few weeks till i get it ready to try for everyone, but maybe i will push it branched out to try in the early stage if someone is interested.

suabo commented 9 months ago

Till v0.4.0 you can run python3 cli_layout_config_helpers.py --create to create a mapping for a not supported keyboard layout. There is also a note on installing the driver with not supported keyboard layout with instructions how to create new layout and reinstall the driver.