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
  • Thanks 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 2
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
  • Thanks 1
Link to post
Share on other sites
1 hour ago, pebert said:

and, I have noticed that quite often Caps lock is active when I open the keyboard, anyone else seen this?

Could be a mechanical or electric fault. I've had something similar on a Pro1 that I since got replaced.

  • Thanks 1
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 2
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 2
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 3
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 /`.

  • Thanks 1
Link to post
Share on other sites

I also want to point out that Annsi of FinQwerty (and I think Slion here, but I have mostly worked with Annsi) is very open to requests and suggestions.  Contact information is at the top of this page:

https://android.onse.fi/finqwerty/

Current Pro1 layouts are here

https://android.onse.fi/finqwerty/#pro1

Probably nothing you didn't know already...

 

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

So, edit the .kcm didn't turn out very good, seems like the keyboard map in finqwerty only defines the buttons that is changed, and the non changed characters is not in that file.

 

So removing the stock .kcm was not an good idea. 

I have just flashed my phone with linage is, and now the Fx button doesn't work. Anyone knowing the scancode of that? So I can map it?

  • Like 1
Link to post
Share on other sites
3 hours ago, pebert said:

So, edit the .kcm didn't turn out very good, seems like the keyboard map in finqwerty only defines the buttons that is changed, and the non changed characters is not in that file.

 

So removing the stock .kcm was not an good idea. 

I have just flashed my phone with linage is, and now the Fx button doesn't work. Anyone knowing the scancode of that? So I can map it?

The way I did is just edit the one that is there, that did work for me.

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

I have just flashed my phone with linage is, and now the Fx button doesn't work. Anyone knowing the scancode of that? So I can map it?

On stock it is 172 I believe though I'm not sure that's still valid on LOS.

Most scan codes you should be able to find there: https://github.com/Slion/hwkbd/blob/master/app/src/main/res/raw/fxtec_pro1_template.kcm

 

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

So, just so I understood this right, when you don't choose a key map, that's when the Vendor_181d_Product_5018_Version_0001.kcm is used? 

 

And when you do choose a key map, first the Vendor_181d_Product_5018_Version_0001.kcm is read, and after this the new key map only redefines the keys that needs to be changed?

 

Could I in that case only append the custom key map in the bottom of Vendor_181d_Product_5018_Version_0001.kcm?

 

The goal is to get a kind of combination of silon's map and finqwerty swedish, toghether with some of my own shortcuts. 

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

So, just so I understood this right, when you don't choose a key map, that's when the Vendor_181d_Product_5018_Version_0001.kcm is used?

I believe this is correct.

1 hour ago, pebert said:

And when you do choose a key map, first the Vendor_181d_Product_5018_Version_0001.kcm is read, and after this the new key map only redefines the keys that needs to be changed?

I don't think this is the case, I think it just takes the other one instead unless it has type set to OVERLAY.

1 hour ago, pebert said:

Could I in that case only append the custom key map in the bottom of Vendor_181d_Product_5018_Version_0001.kcm?

With one big caveat, you can't have duplicate entries in the file, so you'd have to watch out for those. (say you have 'key A {' in the file one place, you aren't allowed to put a second one hoping it'll override the previous one). This may be useful: https://source.android.com/devices/input/validate-keymaps

  • Thanks 1
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