iGo Stowaway Bluetooth Keyboard on Android

HID support on Cyanogenmod makes Stowaway connects to your deviceFew 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 [1], 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 ;-) ).

Use ssh on Android and your Stowaway Think Outside Bluetooth keyboard

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.

  1. Rooting
    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.
  2. 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 [2]. 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.
  3. Preparations
    • 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 shell and 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

      Schematic Example

  4. 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 [3].
    • Copy the layout to your machine, too:
      adb.exe pull /system/usr/keylayout/qwerty.kl .
  5. 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 Y with 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 [5].
    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 Ctrl by pressing Volume_Down button. Pressing Volume_Down followed by the key 1 emulates 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_DOWN onto the Ctrl key. If I like to use Escape now, I’ve got to press the Ctrl+1 combo 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.
  6. Replacing the files
    Mounting for write access in Recovery Mode

    Mounting for write access in Recovery Mode

    Mounting /system for rewrite access

    Mounting /system for rewrite access

    I’m getting this, if I boot into the Bootloader:

    BRAVO PVT4 SHIP S-ON
    HBOOT-0.93.0001
    MICROP-051d
    TOUCH PANEL-SYNT0101
    RADIO-5.11.05.27
    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 memory errors. So this doesn’t work for me:

    adb shell busybox mount -o remount,rw /system

    This genius-like S-ON bit 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 /system/.
    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/*" 
  7. You’re done here. Reboot and use the keyboard. If you want to download the German keyboard files, go ahead reading.

  8. Download (German Keyboad Mapping)
  9. 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 ;-)

6 thoughts on “iGo Stowaway Bluetooth Keyboard on Android

  1. plasmadis

    Hi. I too am a proud Stowaway owner, and happy I can finally able use it with my LG Optimus V, thanks to the AOSPCMod:

    http://androidforums.com/lg-optimus-v/339102-bluetooth-keyboard-update.html

    Thanks for the info on remapping the keys, something I’d really like to do, but just looking at all that hex gives me a headache. You can see the “remapping” I’ve done with tape. Hopefully someday someone will made an app that goes through the process you’ve pointed out.

  2. Robert

    Ok im running a Debian on my phone with full root access. So i usually just go straight to /system/usr/keylayout and nano qwerty.kl. I’ve got a decent grasp of whats going on so far but nothing I’ve done has actually worked. So since i failed horribly at getting the real ctrl or escape keys to do there thing by setting there scan codes equal to the constants on the android website i decided to just add
    Key 29 VOLUME_DOWN to get ctrl working in the Terminal so i could use emacs for now. But when i hit Ctrl on the stoaway the key scanner says the keycode is 0 still. Its like anything i do in this file either breakes the kb or doesnt work.. am i missing something Im under the assumption the keymap.kcm.bin or whatever is just for changing shift bases and alt keystrokes things like that.

  3. acmelab68 Post author

    @Robert:
    Unfortunately I don’t know it either. A properly working Escape key would make my life a lot easier using vi. If anybody reading this know what to do, please let us know. Thanks.

  4. 1hundredfingers

    Uhhh…. Use the other comand for ESC in VI which is “Cntrl [” does the same thing!

    I’m not sure I could use this keyboard for VI hacking. I really like the portability but some of the keys are in weird places. Not sure I could get used to that.

Comments are closed.