Jump to content

How to customize the keyboard layout on LineageOS 18.1?


Recommended Posts

16 hours ago, Sean McCreary said:

I have verified that each key generates the glyph matching the printed keycap for QWERTZ variant Pro1 devices, as long as in 'Settings -> System -> Languages & Input -> Physical keyboard' *both* 'Advanced settings -> Physical layout' is set to QWERTZ *and* 'Builtin Keyboard -> Choose keyboard layout' is set to German. I will try to find a way to make it easier for users to set the correct configuration to make this less confusing.

Because this seems to be a configuration issue rather than a bug in the default keymap in the keyboard driver, I have abandoned CR#315195.

Exactly.

Out of interest, I had applied the proposed patch to my LOS 16 on my QWERTZ Pro1: The respective key immediately stopped working correctly. With @tdm's default keymap, things have always worked - given the correct configuration you describe.

That one has to configure things in two places is of course a little cumbersome, and many of us QWERTZies stumbled on that in the beginning. Streamlining the UI here would be nice, but also not strictly necessary, as for most users configuring this is a one-time action.

  • Like 1
Link to post
Share on other sites
  • Replies 294
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

tdm added a feature to his keyboard driver that allows the user to specify a custom keyboard map. Unfortunately there is no documentation (other than the source code), but you should be able to remap

I have made a lot of keyboard-related changes on the code, now I will try to summarize them. Also, I have tried to reach a state what probably all of us may find useful and also original working

Yes, this is a 2-in-1 problem. The first one is the different keymap of shifted (QWERTY) and normal (QWERTZ) variants of keyboards we have. It is a bit strange that F(x)tec itself has generated

Posted Images

On 9/14/2021 at 11:57 PM, Sean McCreary said:

I have verified that each key generates the glyph matching the printed keycap for QWERTZ variant Pro1 devices, as long as in 'Settings -> System -> Languages & Input -> Physical keyboard' *both* 'Advanced settings -> Physical layout' is set to QWERTZ *and* 'Builtin Keyboard -> Choose keyboard layout' is set to German. I will try to find a way to make it easier for users to set the correct configuration to make this less confusing.

Because this seems to be a configuration issue rather than a bug in the default keymap in the keyboard driver, I have abandoned CR#315195.

Thanks. But if it ONLY works with German, this seams to break the whole original idea of letting the qwertz/qwerty switch select all the necessary remapping to get a standard layout so ANY available android standard layout could be selected, fitting the users language.

ADD:
Obviously if I select a qwerty based language on the qwertz keyboard with the qwertz switch, I EXPECT the letter between T and U to send a Y, and similar others will not match the print.
(and obviously similar issues the other way round)

No better or worse than if I selected to write with another language on a physical German PC-qwertz keyboard.

  • Like 1
Link to post
Share on other sites
2 hours ago, EskeRahn said:

Thanks. But if it ONLY works with German, this seams to break the whole original idea of letting the qwertz/qwerty switch select all the necessary remapping to get a standard layout so ANY available android standard layout could be selected, fitting the users language.

Yes, this is a 2-in-1 problem.

The first one is the different keymap of shifted (QWERTY) and normal (QWERTZ) variants of keyboards we have.
It is a bit strange that F(x)tec itself has generated this issue as otherwise these layouts would work exactly the same way deep inside.

So the problem is the shifting itself which made default layout of Pro1 to be unusual while QWERTZ variant is a perfectly usual layout.

So @tdm's keyboard driver solved this issue by allowing to map appropriate keycodes to shifted keys respective to its written functions while also maps appropriate keycodes for normal layout.

The second problem is a bit different as there are also yellow texts on the keyboard which are at non-standard positions, so they should be handled in relation to its theoretical layout, so US and German.

As low-level keycodes are identical even of international keyboards, a specific key should generate exactly the same code, even if there is ";", "Ö" or "É" is written on it which is the same key in US/German/Hungarian layout.

Basically a keyboard driver should generate a scancode of 39 for the key above at its own level.

...then OS should determine if scancode of 39 arrives, then it should handle it as ; Ö or É, so that is a function of a higher level interface.

So, @tdmwanted the yellow-labeled keys to produce the very same symbols what they have written on it and as these are not at a standard position, he had to apply a trick on it.
So that way the low-level driver accommodates to high-level code, in this case, for QWERTZ variant, it is German.

So it will work perfectly if German layout is selected but it worth nothing for other layouts.

That is why I thought we may need an option to disable this behaviour and exposing modifiers for custom layouts applied at high level of the system.

For me, the QWERTY / QWERTZ keycode correction is a very good solution which should has been solved by IdeaLTE also in stock OS before launch, this is the absolute correct way of handling it.

However, the actual form of default keymap is very restricting, thus, an annoying function for me.

Anyway, @tdmhas also made an interface where default keyboard map can be changed, so, theoretically all international layouts may have a respective value somewhere in system UI, so the very same function of producing the written text of these keys are possible and even a standard layout with AltGr applied on second interface is possible.

Other than that, different modifiers like keycode of FN or Meta is currently not supported which would mean one has to overdefine standard AltGr function of a key instead of having another layer as a potential custom layout and keeping language-specific AltGr function as well.

So, at last... the problem of yellow keys can not be solved perfectly at low level as it is basically not a low-level task but a high-level one and I would not put it there as a default option in driver level as it is basically not the right behaviour per standard.

2 hours ago, EskeRahn said:

Obviously if I select a qwerty based language on the qwertz keyboard with the qwertz switch, I EXPECT the letter between T and U to send a Y, and similar others will not match the print.
(and obviously similar issues the other way round)

It works this way as Z/Y keys are fortunately not touched by any special modifications.

Basically "Z" has a scancode of 44 on US keyboard and 21 on German keyboard while "Y" has 21 on US keyboard but 44 on German.

So, the key between "T" and "U" or the key on the left of "X" always has the same scancode and an upper layer will decide if they should generate "Z" or "Y" or anything else.

That is where the solution of remapping non-standard yellow symbols mixed up the normal behaviour of any keyboards and that is why I don't like it to be there as default.

Edited by VaZso
  • Like 3
  • Thanks 2
Link to post
Share on other sites
23 hours ago, EskeRahn said:

But if it ONLY works with German

Yes, there is still a problem to be solved, it just can't be solved by changing qwertz_fn_keys[] in the keyboard driver. @VaZso's summary is quite correct, that we will most likely need additional language-specific custom keymaps to make this work properly. We probably also need the ability to remap the six 'modifier' keys with dedicated GPIO lines (shift, ctrl, fn_l, F logo, alt, and fn_r), and this is not possible with the current custom keymap feature. However, we are making good progress towards adding support for that.

  • Thanks 3
Link to post
Share on other sites
15 minutes ago, Sean McCreary said:

we will most likely need additional language-specific custom keymaps to make this work properly.

Right - anyway, for the keyboard itself, the most convenient way of working would be for me:

  • Two slant arrows could be used freely for my custom layout (defined in .kcm file)
  • Original AltGr function of the selected international layout could be reachable for example by "Alt" button
  • Additional yellow characters would be accessible by another modifier like the "Sym" button.
  • Maybe another modifier would be usable to quick-launch applications like the "F(x)" button

For the functions above, an additional modifier like FN or Meta would be needed.
Quick launch may be possible by a 3rd-party solution like Button Mapper.

For the rest, that can be done by the ability of remappable modifiers together with an appropriate .kcm file.

Anyway, wasting two modifiers to reach yellow signs of the keyboard preventing them to be used for anything else is not a good idea. However, reaching these signs is a good idea, but for a single modifier as it is much less important for me - but that is me...

Edited by VaZso
  • Thanks 1
Link to post
Share on other sites
29 minutes ago, VaZso said:

Quick launch may be possible by a 3rd-party solution like Button Mapper.

Android uses 'meta' for the built-in keyboard shortcuts, such as meta+B for the web browser, meta+E for the email app, meta+enter to switch back to the launcher (i.e. 'HOME'), and meta+backspace for 'BACK'. This list of shortcuts is extensible, but I don't think the interface is currently exposed in any system app. By default, the 'F logo' key generates KEY_META in LineageOS, enabling these shortcuts. You can display a list of the currently defined shortcuts with meta+/, although this is unfortunately a three-key chord on the Pro1 which makes it rather difficult to type. 😕  However, pressing both the diagonal yellow arrow 'fn_l' and the adjacent F logo key 'home' with one thumb and the 'P' or 'L' key with the other will work without too much finger gymnastics. In the list, Android uses the magnifying glass icon to denote KEY_META.

  • Like 1
  • Thanks 2
Link to post
Share on other sites
1 minute ago, Sean McCreary said:

Android uses 'meta' for the built-in keyboard shortcuts, such as meta+B for the web browser, meta+E for the email app, meta+enter to switch back to the launcher (i.e. 'HOME'), and meta+backspace for 'BACK'. This list of shortcuts is extensible, but I don't think the interface is currently exposed in any system app. By default, the 'F logo' key generates KEY_META in LineageOS, enabling these shortcuts. You can display a list of the currently defined shortcuts with meta+/, although this is unfortunately a three-key chord on the Pro1 which makes it rather difficult to type. 😕  However, pressing both the diagonal yellow arrow 'fn_l' and the adjacent F logo key 'home' with one thumb and the 'P' or 'L' key with the other will work without too much finger gymnastics. In the list, Android uses the magnifying glass icon to denote KEY_META.

Also, https://play.google.com/store/apps/details?id=flar2.homebutton says:

Quote

This app uses Accessibility services

That may trigger the keymap bug that Google introduced in Android 11

  • Thanks 1
Link to post
Share on other sites
2 minutes ago, Sean McCreary said:

Also, https://play.google.com/store/apps/details?id=flar2.homebutton says:

That may trigger the keymap bug that Google introduced in Android 11

Anyway, I had a problem with Button Mapper on stock Android of Pro1 as it caused lag on my hardware keyboard and a feeling it is not fluent which was solved by removing it...

  • Like 1
  • Thanks 1
Link to post
Share on other sites
On 9/8/2021 at 4:21 PM, Sean McCreary said:

Now that custom keymaps are working, you can remap the 'up arrow' key to '/', with Android handling shift+'/' -> '?' with the following:


04:0035:0067

I chose to remap Fn+'/' to 'up arrow' so you can still use that, but it overwrites the default keycode of 'page up'. That's the '0067' part in the string above, where 'page up' would be '0068'

Okay, virtually everything in this thread is over my head.  Can someone direct me to good sources to figure out how to create or modify a keymap and what to do with it.  I'd really like to understand how to make this modification on my Pro1 and I'm willing to do my own homework, but would appreciate being pointed in the right direction.  🙂 TIA.

  • Like 1
  • Thanks 1
Link to post
Share on other sites
On 9/17/2021 at 8:55 AM, Hook said:

Can someone direct me to good sources to figure out how to create or modify a keymap and what to do with it

Right now you will need to use 'adb' to install the custom keymap, and there isn't any app to help you create the map 😕 @Slion made this nifty QWERTY keyboard image with each key labelled with the 'key number' in yellow:

keyboard-layout.png.903cffe536767ca6df303476abf29a16.png

The manual process is to choose which key you want to remap, and to look up the keycode you want it to generate in this list:

https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h

You will need to convert the keycodes from decimal to hexadecimal if they don't begin with '0x'.

The custom keymap is a file with lines containing three numbers separated by colons. Each line remaps one key. For example, to make the capslock key send ctrl:

40:001d:001d

The capslock is key #40 in the image above, and KEY_LEFTCTRL is 29 == 0x1d in hexadecimal. I chose to map the 'Fn shifted' version of the key to ctrl as well, so both hexadecimal numbers are the same. If you wanted to map the key to capslock when pressed at the same time as one of the 'Fn' keys, then the line should be:

40:001d:003a

since KEY_CAPSLOCK is 58 == 0x3a in hexadecimal.

Save the list of modifications, and install it with:

adb root; adb push my_keymap /data/system/keyboard/keymap

Then you need to enable it in Settings -> System -> Languages & input -> Physical keyboard -> Advanced settings -> Custom keymap. If the toggle is greyed out or it won't stay on, then there was a problem installing the custom keymap file. Check your custom map for mistakes, and then push it to the Pro1 again. You may need to reboot before the Settings app will recognize there is an updated custom keymap file.

Edited by Sean McCreary
Updated image w/ key label for space bar
  • Thanks 4
Link to post
Share on other sites
On 9/17/2021 at 12:41 AM, Sean McCreary said:

This list of shortcuts is extensible, but I don't think the interface is currently exposed in any system app. By default, the 'F logo' key generates KEY_META in LineageOS, enabling these shortcuts. 

The other day I was trying to figure out how those Android built-in shortcuts work.
I'm pretty sure global shortcuts are not extensible or configurable unless maybe through resource file override somehow.

I collected those links also available from there:

On 8/30/2021 at 11:59 PM, Slion said:

There is also a disconnect it seems between publishing shortcut in that Fn+Meta+? dialog and the actual handling of the shortcut. Meaning you could publish a shortcut but no implement it properly. App can publish shortcut which will then be displayed in that dialog but those are not global they only show when the application is running. Though maybe a service could somehow make them global? Moreover I spoted the place where they starve applications from that Meta key apparently this was done because of disfunctional keyboards, so wrong reasons it seems, it ought to be fixed.

Here is what that shortcut dialog looks like in Lineage OS Trebuchet default home screen for instance:

Screenshot_20210918-090808_Trebuchet.thumb.png.bc26015ac42eeff0024dbfabcbc2c2b2.png

Edited by Slion
Link to post
Share on other sites
7 hours ago, Slion said:

Here is what that shortcut dialog looks like in Lineage OS Trebuchet default home screen for instance:

Screenshot_20210918-090808_Trebuchet.thumb.png.bc26015ac42eeff0024dbfabcbc2c2b2.png

This list of shortcuts is scrollable, even though the UI doesn't indicate it. The full list has 14 entries by default.

7 hours ago, Slion said:

Though Meta+A does not launch the Calculator for some reason, not on my Pro1, not on my Galaxy Tab S6.

The app must register properly for the shortcut to work. For example, K9 never used to work with the meta+E shortcut, but after the recent UI redesign it now does.

Link to post
Share on other sites
8 minutes ago, Sean McCreary said:

This list of shortcuts is scrollable, even though the UI doesn't indicate it. The full list has 14 entries by default.

Thanks for the tip 🤣 just want to illustrate what it looks like when an app publishes its own shortcuts.

Edited by Slion
Link to post
Share on other sites
5 minutes ago, Sean McCreary said:

The app must register properly for the shortcut to work. For example, K9 never used to work with the meta+E shortcut, but after the recent UI redesign it now does.

I think you mean register the intent in app manifest. That's the first thing I checked, and the calculator does register the proper intent. Maybe I missed something though.

Link to post
Share on other sites
Just now, Slion said:

I think you mean register the intent in app manifest. That's the first thing I checked, and the calculator does register the proper intent. Maybe I missed something though.

Yes, that is what I meant. FWIW, meta+A doesn't appear in the list shown by Trebuchet, so perhaps there is missing code somewhere in the framework.

  • Like 1
Link to post
Share on other sites
31 minutes ago, Sean McCreary said:

Yes, that is what I meant. FWIW, meta+A doesn't appear in the list shown by Trebuchet, so perhaps there is missing code somewhere in the framework.

Right, that is what I wanted to write here.

Anyway, it could open calculator for me although it is not in that list.

Link to post
Share on other sites
On 9/18/2021 at 5:27 AM, Sean McCreary said:

there isn't any app to help you create the map 😕

Thanks for your guidance.

2½ years ago I started on a project doing exactly that, but lacked the information, I will try to find time to finish it.
If anyone wants to finish it, or fork it PLEASE feel free, it is in simple C# and feel free anyone, all I request is if someone uses it to make something useful, is that I get a copy. 😁

(Just reopend it, and it is currently not much-more than an UI template)

I had an idea that it should have some 'layers' that could be shared/imported by dfferent languages. say you had a math-layer that you mapped to Ctrl+Yellow, Or whatever, someone else might like that as a Ctrl+Shift layer.... The point being the easy share, so anyone interested could mix templates from others, as they find suitable.

FxtecKeyboardSetup.zip

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Terms