The kcm file for Android does not seem to work. What am I missing?

I created an input device driver that I use to control the mouse / keyboard from the application. Everything works so far, I can generate input events for the keyboard and mouse from the application.

The problem I'm currently facing is that I cannot enter special characters that are not on the keyboard. If I want to enter eszett (ß), I cannot just simulate a keystroke for my input device.

If I am not mistaken, files with key symbols should be able to solve this problem. I could match Unicode characters with specific keys, and then simulate a keystroke for that key, and the character will be entered.

I tried this, but it does not work, and I do not understand why it does not work. I copied the Virtual.kcm file and renamed it to represent the device provider and product identifier. To check, I replaced one line in the file to enter eszett instead of “0” when 0 was pressed:

key 0 {
    label:         '\u00df'  // instead of '0'
    base:          '\u00df'  // instead of '0'
    shift:         ')'
}

I made sure that the input device is using the correct kcm file by checking the dumpsys input output:

6: custom-input
  Classes: 0x8000006b
  Path: /dev/input/event5
  Descriptor: ab3fb155bce23398b91099a8f37d5cae61f29d21
  Location: 
  UniqueId: 
  Identifier: bus=0x0003, vendor=0x1111, product=0x2222, version=0x0001
  KeyLayoutFile: /system/usr/keylayout/Vendor_1111_Product_2222.kl
  KeyCharacterMapFile: /system/usr/keychars/Vendor_1111_Product_2222.kcm
  ConfigurationFile: 
  HaveKeyboardLayoutOverlay: true

Everything looks fine so far, but when I actually generate an input event using sendevent, it still enters "0" instead of eszett.

sendevent /dev/input/event5 1 11 1  (KEY_EV, KEY_0, DOWN)
sendevent /dev/input/event5 0 0 0   (SYNC)
sendevent /dev/input/event5 1 11 0  (KEY_EV, KEY_0, UP)
sendevent /dev/input/event5 0 0 0   (SYNC)

I really expected this to work, but apparently this is not happening. Is something missing?

What would be the solution to enter Unicode characters through an input device using kcm files (or otherwise)?

+4
1

"Android . , .

OEM- , .

Android . " https://source.android.com/devices/input/key-character-map-files.html#examples

, , OEM- . . , OEM ( ) , , . , , , , , eszett , , , OEM- (, Google , OEM ).

+1

Source: https://habr.com/ru/post/1606265/


All Articles