Monday, October 17, 2011

Using a TomTom Bluetooth Remote with Android

EDIT: The TomTom Bluetooth Remote only works with Android 2.3 and below. The issue is that on Android 2.3 and below, the user first enters the pairing key for keyboard devices on the phone and then on the keyboard. From Honeycomb and above, Android generates its own random pairing key and since the TomTom remote doesn't have any real keys, it's impossible to type that code in. If anyone finds a workaround, please let me know so I can update this.
EDIT: A workaround has been found! Read Becherraecher's comment below for more details.


I was digging through my box of assorted crap and stumbled upon an old TomTom Bluetooth Remote that I got from my old job (because after all, why does a store display TomTom need a remote?). When I first got it I couldn't find a use for it, but 2 years later with a good deal of Android experience under my belt, I decided to see what I could do with it.


Now the first hurdle was pairing the device with my phone. Although it's using Bluetooth, the pairing isn't done the standard way. However, I found the following method to work most of the time. Note: Your device must support the Bluetooth HID profile for this to work.

1. Remove one of the batteries from the remote for 30 seconds. This clears any previous pairing data and gives you a fresh slate to start from.
2. Tap "Scan for devices" and quickly insert the batteries. It probably won't be found on the first try, so keep on hitting "Scan for devices" until TomTom Remote shows up. At this point, if you try to pair, it will probably fail.
3. When the blue light on the remote stops blinking, select the remote on your Android device and pair with the passcode "0000".
4. Now your Android device should show that it is trying to pair with the remote. Press the middle button on the remote and your Android device should prompt your for the passcode again. Enter "0000" again.
5. The Android device should now show that the remote is paired but not connected. Long press the remote, check the box for Connect, and go back. Now press the center button on the remote again and it should be connected to your phone!

We just got over the first major hurdle! Select a text input box and press some buttons on the remote and you'll see text being entered! However, a keyboard with a few random buttons isn't really useful, so let's remap the keys!

To do this, we'll have to create a custom keyboard profile for the remote which will map the scancodes sent by the device to keys recognized by Android. I'm going to save you the effort of finding out the scancodes since I already found them myself.

Direcrional Keys
Up 103
Down 108
Left 105
Right 106
Center 28

3 Middle Keys
A 1
B 13
C 14

Vol+ 67
Vol- 68

Next, you'll need to pull 2 files off of your phone to modify. Fire up command prompt, navigate to the platform-tools directory of the Android SDK, and enter the following commands:


adb pull /system/usr/keychars/qwerty.kcm.bin TomTom_Remote.kcm.bin

adb pull /system/usr/keylayout/qwerty.kl TomTom_Remote.kl


Open up TomTom_Remote.kl in your favorite text editor, see how the syntax works, erase everything, and create an entry for each of the 10 buttons. For example, mine looks like this:


key 106 MEDIA_NEXT
key 105 MEDIA_PREVIOUS
key 28 MEDIA_PLAY_PAUSE
key 108 1
key 1 3
key 13 4
key 14 5
key 68 VOLUME_UP
key 67 VOLUME_DOWN
key 103 POWER WAKE


You may chose to map the remote's D-Pad to Android's directional keys if you like, but since I'm using it as a music remote in my car, I used those keys. You can find a list of all the possible keys here. (If you're wondering why I mapped some key's to 1,3,4, and 5, it's because I also programmed my personal media player to preform special functions with those keys.)

Save your changes to the .kl file and enter the following commands into your command prompt:


adb push TomTom_Remote.kl /system/usr/keylayout/TomTom_Remote.kl

adb push TomTom_Remote.kcm.bin /system/usr/keychars/TomTom_Remote.kcm.kl

adb shell "chmod 644 /system/usr/keychars/TomTom_Remote.kcm.kl"

adb shell "chmod 644 /system/usr/keylayout/TomTom_Remote.kl"


Restart your phone, connect to the remote, and it should now preform the new functions!

Many thanks to this blog post for teaching me how to remap buttons.