Few years ago I’ve bought a really nice Bluetooth keyboard for a Windows Mobile 2003SE device. It’s really a little masterpiece and I still love this nifty gadget very much. The same day I’ve bought an Android device last year, I’ve paired this keyboard with my brand new HTC Desire, but it didn’t work.
After rooting became almost a piece of cake , I took all my courage and finally rooted my HTC Desire. The best about the Cyanogenmod 6 was, it has HID support built in. That means you can use things like standard Bluetooth mice and keyboards. But it turned out most of very basic keys weren’t mapped properly – especially the German umlauts. But what I’ve really missed was the Escape key for vi (best editor in world 😉 ).
Some guys at xda-developers.com found out how to remap the keys on keyboards, and I began my own research on this issue.
What I came finally up with, was a quite usable keyboard mapping for my iGo Think Outside Stowaway Bluetooth keyboard. This a step by step guide for experienced users. I hope also, that some a bit more talented folks will do a better job I did, and will fill the gaps I left open.
So – let’s go.
Look up your Android device here, to see if your device is supported. If you’ve rooted your device and you are using a custom ROM already, be sure your distro supports HID. Since Cyanogenmod 6 HID is supposed to work with Bluetooth keyboard and mice. And NO – There’s no way to use this w/o rooting. The answer is simple, because the ROMs from the manufacturer doesn’t offer the HID feature. So rooting and installation of a custom ROM like Cyanogenmod is a must.
- Android SDK
You must be able to communicate with your Android device in order to see some log files and copy a few files onto it. This is done with
adb. Installing the Android SDK isn’t enough, if you are using anything different than Google its own devices (Nexus 1 and Nexus S). I’m using a HTC Desire, therefor I need the appropriate driver for it. You can install the huge HTC Sync awesomeness (Yes, it’s ironic!). Or you can only download and install the driver from http://developer.htc.com/ here . It’s at the bottom of the page. Actually I’m doing all my stuff on Linux boxes, but I dunno have a clue if all can be done with Linux, too.
- Pair your keyboard
- get acquainted with the scientific calculator (
calc) and/or with the hexadecimal system.
- You need a hexeditor. I’ve used this freeware tool.
- Install on your Android device the tool KeyTest. You can use your Android barcode scanner in order to download this tool. Google Goggles e.g. recognizes automatically QR Codes. See picture in step 3.6.
- Now connect to your android device with
adb.exe shelland invoke
logcat | grep kcm
You should see an error message:
Error loading keycharmap file '<your_keyboard_name_here.kcm.bin>'
This is what your Android expects to be there, and your job now is, to give your device what it demands.
- How things are linked together
- Modifying keychars
- Copy the original qwerty.kcm.bin to your Windows machine:
adb.exe pull /system/usr/keychars/qwerty.kcm.bin .
- Rename it to
Think_Outside_Keyboard.kcm.bin, this is the name you figured out in step 3.5. Now modify it accordingly to your needs. Use the diagram (step 3.6) to see the logical connections.
If you need more information on that, read here .
- Copy the layout to your machine, too:
adb.exe pull /system/usr/keylayout/qwerty.kl .
- Copy the original qwerty.kcm.bin to your Windows machine:
- Rearranging keylayout
If you are on a English keyboard layout, you probably won’t need to modify the file you copied onto your machine in step 4.3. On a German keyboard you can e.g. swap the letter
Ywith the key
Z. Hence it’s for rearranging the keys across your keyboard. There’re some interesting keys you probably want to try out. Look up all available codes here .
If you like to use vi, or a console in general, you’ll definitely miss the Escape key. The console (Terminal Emulator) Google ships with its development package (and also included in Cyanogenmod) can emulate
Ctrlby pressing Volume_Down button. Pressing Volume_Down followed by the key
1emulates the Escape key. Wow! Here we go with “Esc”! If Volume_Down doesn’t work for you, go into settings and adjust it accordingly.
So I’ve mapped
key 29 VOLUME_DOWNonto the
Ctrlkey. If I like to use Escape now, I’ve got to press the
Ctrl+1combo on the keyboard. It’s kinda pedestrian, but at least it’s working reliably. The first prize would be to map Escape onto the real Escape key on the keyboard though, but this I didn’t manage.
- Replacing the files
I’m getting this, if I boot into the Bootloader:
BRAVO PVT4 SHIP S-ON
Aug 10 2010,17:52;18
The bad part about this information is, I cannot remount my file system in rewrite mode in order to copy the files back on my device. You’ll keep getting
out of memoryerrors. So this doesn’t work for me:
adb shell busybox mount -o remount,rw /system
S-ONbit prevents ROM access while run time. There’re maybe ways to circumvent this S(illy)-Bit, too, but there’s a much simpler solution for it. Reboot into the recovery mode. Go to the mount menu and mount
Perform these lines on your Windows machine:
adb push Think_Outisde_Keyboard.kcm.bin /system/usr/keychars/Think_Outisde_Keyboard.kcm.bin adb push qwerty.kl /system/usr/keylayout/qwerty.kl adb shell "chmod 644 /system/usr/keychars/*" adb shell "chmod 644 /system/usr/keylayout/*"
- Download (German Keyboad Mapping)
You’re done here. Reboot and use the keyboard. If you want to download the German keyboard files, go ahead reading.
If you are happy with my a bit crappy mapping, you can leave out the mapping part, and just copy it onto your device (See step 6). All basic keys are accessible (all kind of brackets, pipes and redirects), but you have to use
Alt or even
Alt+Shift in order to access the keys. The “Fn” blue and green does nothing special, except some funky stuff I didn’t manage to figure out. Here’s still work to do. You won’t be able to use the keyboard (iGo Think Outside Stowaway), the way you used to use it with Windows Mobile, but at least you’ll be able start an terminal session and login via
ssh at your server – Errr yes – you can of course type a letter or stuff, too 😉