Jump to content

Improved keyboard support for several languages - FinQwerty


Recommended Posts

  • 8 months later...
37 minutes ago, pebert said:

as I understand it esc works as "back", and it does in many cases, but not in chrome. why is that?

 

chrome is one of the apps there this function would be most useable (at least for me)

Odd they must have been breaking this recently, try Fulguris instead.

Edited by Slion
  • Like 1
Link to post
Share on other sites
1 hour ago, pebert said:

as I understand it esc works as "back", and it does in many cases, but not in chrome. why is that?

 

chrome is one of the apps there this function would be most useable (at least for me)

in the FinQwerty layouts the Esc-key acts as Esc if the app supports Esc, otherwise it has a fallback as Back.

On the "fallback"  all I know is what can be seen in the "Behaviours" section of this

Quote

fallback <Android key code name>: Perform a default action if the key is not handled by the application.

This behavior causes the system to simulate a different key press when an application does not handle the specified key natively. It is used to support default behavior for new keys that not all applications know how to handle, such as ESCAPE or numeric keypad keys (when numlock is not pressed).

When a fallback behavior is performed, the application will receive two key presses: one for the original key and another for the fallback key that was selected. If the application handles the original key during key up, then the fallback key event will be canceled (KeyEvent.isCanceled will return true).

So maybe Chrome has implemented Esc as e.g. stop loading a page.

In Stock layouts it just sends Back. But the fallback solution in FinQwerty makes Esc available to apps where it is crucial such as Termux.

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

maybe Chrome has implemented Esc as e.g. stop loading a page.

yes that's what it is, except that it when it does not do anything with esc which is the case most of the time it should tell it and the fallback would work.

Fx Qwerty back with alt+left works.

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

using swedish qwerty

was thinking of using external keyboard helper pro instead, but was a lot of remapping to do. 

is it possible to just put a keymap .kcm file somewhere? and use it?

if you have root, yes /system/usr/keychars/Vendor_181d_Product_5018_Version_0001.kcm if not mistaken is the default (when no keymaps selected)

alternatively unzip finqwerty or fx-qwerty (apk files are just zips) and edit one of the keymaps in the res/raw/ directory (or add one and edit the xml file in res/xml/ that that tells where the .kcm files are) then zip it again and use and then use jarsigner to sign it and then zipalign, or first zipalign then apksign (java sdk and android sdk provide these things) to sign and align them so android is happy and you can use that (either search google how to use those things or ask me and i will tell you when i sober up... too many beer to explain in detail)

both finqwerty and fx-qwerty use a pretty cool API that allows them simply to tell android where a bunch of extra .kcm files are that it should show in the keyboard layout options, they do not use any more resources than just editing .kcm from android - so if you don't want to root they're an absolutely excellent solution

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

thanks, I found the default .kcm yesterday, but didn't manage to edit it, either the filsystem is mounted ro, or I forgot to open as root.

 

Quote

both finqwerty and fx-qwerty use a pretty cool API that allows them simply to tell android where a bunch of extra .kcm files are that it should show in the keyboard layout options, 

where do finqwerty store thoose .kcm? and how does it tell system where to find it?

would be nice to point it to somewhere in /storage/ to easily edit it.

is the layout loaded at boot, or when launching the keyboard?

what's the functions of KeyLayoutFile: /system/usr/keylayout/Vendor_181d_Product_5018_Version_0001.kl

vs. KeyCharacterMapFile: /system/usr/keychars/Vendor_181d_Product_5018_Version_0001.kcm?

Lot's of question, but really tries to understand this whole thing

Link to post
Share on other sites
1 hour ago, pebert said:

thanks, I found the default .kcm yesterday, but didn't manage to edit it, either the filsystem is mounted ro, or I forgot to open as root.

 

where do finqwerty store thoose .kcm? and how does it tell system where to find it?

would be nice to point it to somewhere in /storage/ to easily edit it.

is the layout loaded at boot, or when launching the keyboard?

what's the functions of KeyLayoutFile: /system/usr/keylayout/Vendor_181d_Product_5018_Version_0001.kl

vs. KeyCharacterMapFile: /system/usr/keychars/Vendor_181d_Product_5018_Version_0001.kcm?

Lot's of question, but really tries to understand this whole thing

The .kl file is a Key Layout file that maps physical scan-codes (which the keyboard driver spits out) to Androids key-codes, the .kcm is a Key Character Map which maps those key-codes to characters or actions (and allows you to have different binding for combinations of modifiers (ctrl, alt, shift, fn) and keys). The .kcm can also remap scan-codes to different key-codes, so I'd recommend leaving the .kl alone unless there's a good reason to edit that one.

In the kcm file you can map a scan-code to a key-code by a statement like:

map key 158 ESCAPE

And a key-code to a character like:

key SLASH {
    label:                              '`'
    base:                               '/'
    shift:                              '?'
    fn:                                 '~'
    fn+shift, fn+ctrl:                  '`'
    alt:                                '\u0300'
    alt+shift:                          '\u0303'
}

The line for the 'label' modifier is what Android will tell the software is physically written on the key and fairly insignificant for most software. The line for 'base' modifier is for when there is no modifier held down. The + like with fn+shift tells it to output that character for combination of fn and shift held together when the key is pressed. The comma is equivalent to putting the same character for either modifier (or combination of). Note that the syntax for the + does not allow spaces between the + and the modifiers around it.

Also you can send another key-code instead of a character with the syntax like in this example:

key DPAD_UP {
    fn:                                 replace PAGE_UP
}

Also you can use the 'fallback' keyboard in exactly the same way like the replace one in above example, which will only send that key-code if the active application did not report that it handled the original keycode (DPAD_UP in the example).

 

I don't think you can edit the installed files from Finqwerty or Fx-qwerty in android directly. As far as I know the only ways are to either compile them yourself, or extract the apk with unzip tool or apktool and then repackage and sign them (you can self-sign with any certificate, but they have to have some kind of signature or android will refuse to install them). Inside the apk there is the 'res/raw' folder where the .kcm files are located and an XML file in 'res/xml' that tells Android which kcm files to look for in res/raw. I didn't think of it in my first message, but to edit that XML file you need to use apktool or something to extract as it's stored as Androids weird binary XML format which isn't practical to modify without converting it (apktool does that for you). If you just want to modify the .kcm files all you need is something to unzip and zip, either jarsigner or apksinger, and zipalign.

 

[Edit] To be fully complete with this description, the kcm files also support mapping "usage codes" to key-codes, by saying `map key usage <some number> <some key code>` similarly to mapping scan-codes. But I don't know what usage codes are, I don't know why you would want to remap them, and I can't find any proper documentation on that syntax and only know it exists because I've read this thoroughly: https://android.googlesource.com/platform/frameworks/native/+/master/libs/input/KeyCharacterMap.cpp.

Edited by netman
  • Like 1
  • Thanks 1
Link to post
Share on other sites
1 hour ago, pebert said:

where do finqwerty store thoose .kcm? and how does it tell system where to find it?

I forgot to answer this question properly, Finqwerty tells Android it has keyboard layouts and where they are by responding to this message https://developer.android.com/reference/android/hardware/input/InputManager#ACTION_QUERY_KEYBOARD_LAYOUTS

Edited by netman
  • Thanks 2
Link to post
Share on other sites

Thanks for the really good explanation. Seems like the easiest "dirty" solution is to use the .kcm from finnqwerty, edit what I want, and replace the Vendor_181d_Product_5018_Version_0001.kcm.

After rooting with magisk, skall I remount the system partition, or is it linked somewhere else? Don't remember how it works. 

  • Like 1
Link to post
Share on other sites
49 minutes ago, pebert said:

Thanks for the really good explanation. Seems like the easiest "dirty" solution is to use the .kcm from finnqwerty, edit what I want, and replace the Vendor_181d_Product_5018_Version_0001.kcm.

After rooting with magisk, skall I remount the system partition, or is it linked somewhere else? Don't remember how it works. 

Pro1 is system-as-root so you simply `mount -o remount,rw /`.

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