I have created an input device driver that I use for controlling mouse/keyboard from an app. Everything works so far, I can generate input events for both keyboard and mouse from within the app.
The problem I'm facing right now is that I'm unable to enter special characters that are not on the keyboard. If I want to enter an eszett (ß), I can't just simulate a keypress for my input device.
If I'm not mistaken, key character map files should be able to fix this problem. I could map unicode characters to certain keys and then simulate a keypress for that key and the character would be entered.
I tried this, but it doesn't work and I don't understand why it doesn't work. I copied the Virtual.kcm file and renamed it to represent my devices vendor and product ID. To test, I replaced one line in the file to input an eszett instead of a '0' when the 0 key is pressed:
key 0 {
label: '\u00df' // instead of '0'
base: '\u00df' // instead of '0'
shift: ')'
}
I've made sure that the input device uses the correct kcm file by checking the output of 'dumpsys input':
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 a '0' instead of an 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 it doesn't. Is there something I'm missing?
What would be the solution to enter unicode characters via an input device using kcm files (or in another way)?