- Reputation: 2
- From: Poznań, Poland
- Registered: 16-Feb-2014
- Posts: 5
(A followup to Android External Keyboard & Colemak?)
Recently I got an Android tablet as a gift, and, naturally,
I wanted to be able to type on it normally. Since I don't
belong to the elite group of multi-layout typists,
I had to find a way to teach my device what Colemak is.
Below is what I had to do to remap keys on my 4.0 powered tablet.
I hope this helps other Colemak users to type as they want.
Most information I needed can be found here:
https://source.android.com/devices/tech … files.html
I'll use the word „keymap” instead of „key character map file”.
You'll need a way to create some directories and files in /data,
so you may need adb (for devices which are not marked
as production models) or root privileges. Other methods of putting
a file to your device, such as a recovery script, should also work.
Get your keyboard's VID and PID.
Keymaps in Android are device specific. This means you have to repeat
this tutorial for each keyboard you intend to use. Alternatively, you can
edit the default keymap, but that's not advised. If you have multiple
keyboards and you know what you're doing, change the default keymap
in /system/usr/keychars/Generic.kcm and skip this step.
Below are instructions on how to get the IDs on Linux systems (Android inclusive).
It may also work on other Unix-likes, such as the BSD family.
On NetBSD, you may want to use ‘usbdevs -v’ instead of ‘lsusb’ in this step.
Windows users may use a device manager, or their Android device directly.
Open a terminal emulator (you may need to install one first) and run `lsusb`.
Sample output from my tablet:
Bus 001 Device 001: ID 1d6b:0002 Bus 002 Device 001: ID 1d6b:0002 Bus 003 Device 001: ID 1d6b:0001
Connect your keyboard.
Rerun `lsusb` and remember the IDs of device which appeared
compared to the output in step 1.a.
In my case:
Bus 001 Device 001: ID 1d6b:0002 Bus 002 Device 001: ID 1d6b:0002 Bus 003 Device 001: ID 1d6b:0001 Bus 001 Device 002: ID 0a81:0205
… 0a81 is the VID and 0205 is the PID I'm looking for.
In fact these are IDs of a cheap PS/2 → USB adapter
which came with my TypeMatrix2020.
You can save these IDs for convenience:
VID=«your vid»; PID=«your pid»
Download http://f8l.netne.net/Colemak_pl.kcm or copy from post below.
Season to taste.
The file I provide is not a complete Colemak keymap.
Since Android doesn't support all the accent dead keys
Colemak does, it is impossible to get a full Colemak layout.
For now I've made a Polish version of Colemak with my personal
adjustments (AltGr+Shift+. → …, « and ‹ are swapped,
‚ and „ under the 9 key etc.),
so if you need other diacritical characters, you'll need to
edit the file according to the site I mentioned above.
Rename the file to Vendor_«VID»_Product_«PID».kcm
If you have saved you IDs earlier in step 1.c, you can just:
mv Colemak_pl.kcm Vendor_$VID_Product_$PID.kcm
In my case, the proper name is „Vendor_0a81_Product_0205.kcm”.
Note that the hexadecimal letters should be lowercase
(at least that's what worked for me).
From now on, I'll shortcut the name of the file as Vendor_(…).kcm
Put the file into /data/system/devices/keychars/
You can also put it into /system/usr/keychars/, but this
requires remounting your /system partition for writing.
You have to put the file into the /system partition
if your system already has a keymap for your keyboard.
There are several methods of placing the file in proper directory.
Connect your Android device to a computer with adb and execute:
adb root adb shell mkdir -p /data/system/devices/ adb push Vendor_(…).kcm /data/system/devices/keychars/
This only works on devices not marked as production models.
If the first command errors out, you'll have to use another method.
If the second command errors out due to mkdir without -p support,
try to split it like this:
adb shell 'mkdir /data/system; mkdir /data/system/devices'
… and proceed with the third command.
Using root privileges.
If your device has been rooted, the task is as easy as:
su mkdir -p /data/system/devices/ mv Vendor_(…).kcm /data/system/devices/keychars/
Like in the method above, you can split the second command if it fails.
There are some catches though. If the mv command fails, try to use cp instead.
If you don't have cp, cat is your best friend:
cat Vendor_(…).kcm > /data/system/devices/keychars/Vendor_(…).kcm
I don't know if there exist Android devices without cat,
but in case you own one, you'll have to get busybox,
or use some other hackish way of copying files.
Using recovery script
I'll not cover it in detail now, but it involves preparing a
special update.zip file, and booting the device in recovery mode.
This method works for old devices with recovery software
which doesn't require the update.zip file to be signed.
There are other ways, like flashing a custom /recovery
partitions, but this is quite invasive and you need to know
what you are doing, so you're on your own.
Re-plug your keyboard.
In case you frown at this point, you may want to launch logcat
to see what's wrong.
Unplug your keyboard.
Plug your keyboard in.
Wait a moment.
Terminate logcat or freeze your terminal.
Read the output of logcat.
Use your head or call for help.
07-May-2016 19:30 Added a hint about usbdevs
07-May-2016 19:15:09 Reworded sentence with a typo in 5b (‘If your have rooted your device’) and added this changelog
17-Jan-2015 22:23:27 Mentioned the post with .kcm file included
16-Feb-2014 20:07:19 Initial version
What do you think about a public repository with custom .kcm files
for various language variants of Colemak?