Jump to content

How to customize the keyboard layout on LineageOS 18.1?


Recommended Posts

I recently migrated to LineageOS from stock, where I was a happy FinQWERTY user. After seeing it was broken and finding out in the forums that FinQWERTY is expected not to work, I've been crawling all threads related to keyboard layouts and adjustments and nothing I did worked.

(In my case -- I'd like to type Portuguese, so I want combining ` ' ~ ^ and ç; none of the built-in options really seem to be comfortable for typing. There's a few alt combinations that are really hard to reach for a couple of them, but not all...)

I tried tweaking a KCM as described in

but the changes don't seem to be applied.

I also found out about /data/system/keyboard/keymap (see https://github.com/LineageOS/android_device_fxtec_pro1/blob/2bfa41a3f649e1c97b588dc08ee7ff09d7bd1447/devicesettings/src/org/lineageos/settings/device/Constants.java#L27 ) but I don't really understand the format, since it's different from the kcms.

Has anyone managed to customize the keyboard on LineageOS? It'd be a big shame if I needed to go back to stock just so I could type comfortably 😕

  • Like 4
Link to post
Share on other sites
  • 2 weeks later...
  • Replies 280
  • 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

I recently migrated to LineageOS from stock, where I was a happy FinQWERTY user. After seeing it was broken and finding out in the forums that FinQWERTY is expected not to work, I've been crawling all

Posted Images

5 hours ago, EskeRahn said:

Something odd seems to be wrong with the keyboard handling on 18.1
(I added an error report  on it here)

The short story: the keyboard layouts seem to need a factory reset after upgrade to 18.1

For the long story, see the error report linked above...

  • Thanks 2
Link to post
Share on other sites
On 4/3/2021 at 10:05 AM, ivoanjo said:

Has anyone managed to customize the keyboard on LineageOS? It'd be a big shame if I needed to go back to stock just so I could type comfortably 😕

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 any non-modifier key (e.g. not shift or ctrl) to generate any keycode you want. By default, the QWERTY and QWERTZ maps are set to match each key to the glyph printed on top, but of course the FinQWERTY maps make different choices than F(x)tec did when they designed the two keyboard layouts.

The relevant source code is here:

https://github.com/LineageOS/android_device_fxtec_pro1/tree/lineage-18.1/devicesettings/src/org/lineageos/settings/device

and here:

https://github.com/LineageOS/android_kernel_fxtec_msm8998/blob/lineage-18.1/drivers/input/keyboard/qx1000.c

plus the Linux input event codes listed here:

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

Your custom keymap file should be placed in "/data/system/keyboard/keymap", and uses a custom format that I will describe below.

Each line in the custom keymap file specifies a triplet of numbers, each on a single line and separated with colons. The first parameter is a decimal 'key number' specific to tdm's kernel driver, which are listed here in the qx1000.c source file. Referring to:

https://github.com/LineageOS/android_kernel_fxtec_msm8998/blob/lineage-18.1/drivers/input/keyboard/qx1000.c#L330

Quote

    /* 48..55 */
    KEY_SPACE,    KEY_G,        KEY_V,        KEY_M,
    KEY_I,        KEY_8,        KEY_T,        KEY_5,
 

Key #48 is mapped to KEY_SPACE by default, and is the spacebar key on the physical keyboard. In similar fashion, key #49 is 'G', and key #53 is '8'. Now, Referring back to the first custom keymap example from the Java code:

https://github.com/LineageOS/android_device_fxtec_pro1/blob/lineage-18.1/devicesettings/src/org/lineageos/settings/device/Constants.java#L29

Quote

    public static final String[] KEYBOARD_KEYMAP_SPACEPOWER_TEXT = {
        "48:0039:0074"
    };

Recall that the first number in the the triplet is the driver key number, in decimal. The second and third numbers in the triplet are Linux input event codes the key should generate in hexadecimal. These are codes from input-event-codes.h, for example:

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

Quote

#define KEY_LEFTALT        56
#define KEY_SPACE        57
#define KEY_CAPSLOCK        58

The second number listed in the modified keymap is 0x39 (or 57 in decimal), and corresponds to KEY_SPACE. The third number in the the triplet is the Linux input event code the key should generate when chorded with the 'fn' or diagonal yellow arrow keys, and in this case is 0x74 (116 in decimal) or KEY_POWER. So this remapping changes Fn-Spacebar from the default value of KEY_WWW to KEY_POWER.

Now, there is a second sample remapping in:

https://github.com/LineageOS/android_device_fxtec_pro1/blob/lineage-18.1/devicesettings/src/org/lineageos/settings/device/Constants.java#L33

KEYBOARD_KEYMAP_FNKEYS_TEXT defines a more complex keymap alteration which makes the number keys in the top row generate their function key equivalent when chorded with the 'fn' keys on the keyboard. Hopefully I've provided enough information to allow you to decode these modifications on your own.

With a bit of work it should be possible to encode the FinQWERTY keymaps using this alternate remapping feature. However, simple changes (like adding a specific missing key) should be fairly simple and straightforward.

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

The short story: the keyboard layouts seem to need a factory reset after upgrade to 18.1

For the long story, see the error report linked above...

Bummer...

  • Like 1
Link to post
Share on other sites
  • 1 month later...
On 4/14/2021 at 1:44 PM, Rob. S. said:

Bummer...

It seems to not always be a requirement, but it do seem to fix it if you got the issue. But an upgrade can survive! The precise condition for when it survives and when it fails is unfortunately currently unknown.
PERHAPS it is related to installed keyboard drivers and/or FinQWERTY, but could well be even more complex. Mine was upgraded from 16 to 17 last year and now to 18. I do not recall if I even made a factory reset going from test-16 to release-16 in the autumn... So might be old rudiments that triggers the issue now. If so it could be very hard to reproduce consistently, and thus not very likely to be remedied.

  • Thanks 1
Link to post
Share on other sites
  • 3 weeks later...
2 hours ago, TeZtdevice said:

I have a fresh installed version of 18.1, but just only the Z and Y are correct on my QWERTZ layout.
Any chance to get the full keyboard working?

I'm not sure I quite understand your question.
You can select the physical layout Inside Lineage settings ("languages and input", "physical keyboard", "Advanced settings", "physical layout").

If it is selecting the layout you wish, that does not seem to work, then see a few pages back, where I had odd problems with the layouts going to 18.1, that was fixed by a factory reset. We never really found out why the upgrade failed. For some the upgrade goes just fine, so some combo with other stuff...

Link to post
Share on other sites

Thx EskeRahn 🙂

I read the info about the factory reset. I didn`t do a upgrade from 16 or 17 to 18.1., Just a clean install over Android. That`s why I won`t think a factory reset would help?! 🙂

After the installation I select the german layout for my hardware kb, but only the Z and Y are correct.

Link to post
Share on other sites
2 minutes ago, TeZtdevice said:

Thx EskeRahn 🙂

I read the info about the factory reset. I didn`t do a upgrade from 16 or 17 to 18.1., Just a clean install over Android. That`s why I won`t think a factory reset would help?! 🙂

After the installation I select the german layout for my hardware kb, but only the Z and Y are correct.

You need to BOTH tell it whether it is the qwertZ or qwertY version (see above) and ALSO select the language you want to type on it.
e.g. German on qwertZ.
 

  • Thanks 1
Link to post
Share on other sites
17 minutes ago, EskeRahn said:

You need to BOTH tell it whether it is the qwertZ or qwertY version (see above) and ALSO select the language you want to type on it.
e.g. German on qwertZ.
 

Yes. I selected both.
German as language and as physical layout QWERTZ.

Link to post
Share on other sites
8 hours ago, TeZtdevice said:

Yes. I selected both.
German as language and as physical layout QWERTZ.

Oh you are right, sorry did not test, just asummed it still worked.... But yes It is destroyed on mine again(!)


Ctrl+Space for changing languages is again ignored. Is it on yours two? (you have to have selected more than one first obviously)

I will try to do a factory reset (yes tedious!!!) to see if this fixes it this time too....
(tried the two softer resets of network and then apps, and as expected that did NOT make any difference)

Link to post
Share on other sites
15 minutes ago, EskeRahn said:

Oh you are right, sorry did not test, just asummed it still worked.... But yes It is destroyed on mine again(!)


Ctrl+Space for changing languages is again ignored. Is it on yours two? (you have to have selected more than one first obviously)

I will try to do a factory reset (yes tedious!!!) to see if this fixes it this time too....
(tried the two softer resets of network and then apps, and as expected that did NOT make any difference)

Oh no, I hope this was not your daily driver!!
CTRL+Space is not switching my languages, correct.

Link to post
Share on other sites

  

43 minutes ago, TeZtdevice said:

Oh no, I hope this was not your daily driver!!
CTRL+Space is not switching my languages, correct.

Nope, it is a test-device (the old pre-production unit without a few radios...)

A factory reset does NOT fix it... Will try to flash a few weeks back and do a reset...

Edit I. It still worked flashing 20210510 (and doing a factory reset)
Edit II. It still worked flashing 20210517 (no reset)
Edit III. It still worked flashing 20210524 (no reset)
Edit IV. It still worked flashing 20210531 (no reset)

SO the conclusion is that keyboard selection was broken with the 20210607, beyond what a factory reset can fix!

(will not re-flash now, but optimistically try going from 0531 to 0614 tomorrow).

  • Thanks 2
Link to post
Share on other sites
10 minutes ago, EskeRahn said:

  

Nope, it is a test-device (the old pre-production unit without a few radios...)

A factory reset does NOT fix it... Will try to flash a few weeks back and do a reset...

Edit I. It still worked flashing 20210510 (and doing a factory reset)
Edit II. It still worked flashing 20210517 (no reset)
Edit III. It still worked flashing 20210524 (no reset)
Edit IV. It still worked flashing 20210531 (no reset)

SO the conclusion is that keyboard selection was broken with the 20210607, beyond what a factory reset can fix!

(will not re-flash now, but optimistically try going from 0531 to 0614 tomorrow).

Thank you so much for your testing!!!
Ok, I will wait for tomorrow and if nothing change, I have to reset my phone again and install an old ROM.
Please report me, if the version 0614 broke your settings again.

  • Like 1
Link to post
Share on other sites
2 minutes ago, TeZtdevice said:

I have to reset my phone again and install an old ROM.

PS I will suggest the opposite order. Install the functioning rom, and do a reset from that (you can do it from the recovery menu, so it is a clean boot on the newly flashed rom)

(I have updated the original bug report with this new variant, so if we are very lucky and a developer is bored today, we might see a fix included in tomorrows update...)

  • Like 2
  • Thanks 1
Link to post
Share on other sites

Thanks EskeRahn for the testing. I've been dragging my feet on resetting as well to fix these damn keyboard issues, as my Pro1 is my daily driver, so this info will be very valuable.

Of all the things to be broken on this phone, it had to be the keyboard. Damn 😞

  • Like 2
Link to post
Share on other sites
4 hours ago, ivoanjo said:

I've been dragging my feet on resetting as well to fix these damn keyboard issues

You could try to flash the 20210531, with a little luck it will work stepping back 'one step' even without resetting.

  • Like 1
Link to post
Share on other sites
53 minutes ago, TeZtdevice said:

Ehm... no, not on my device 😞
 

Are you using the FinQwerty app or another user-customized key map? So far I have had no luck duplicating these problems on a vanilla LineageOS installation (with or without gapps).

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

Are you using the FinQwerty app or another user-customized key map? So far I have had no luck duplicating these problems on a vanilla LineageOS installation (with or without gapps).

No 😕 I just tried out the FinQwerty, but just to test if it solve the problem.
But, perhaps you could send the me a clean version of the keyboard map files?

Edit: I have a app that customized my keyboard. Let me check...
Edit 2: No, that wasn´t the problem. Issue still there

Edited by TeZtdevice
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