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.


15 comments:

  1. Hi Norvan;

    Thanks for this idea, I have been looking at this info for a long time, but I got a problem.
    First try I attempted to pair the remote with my Samsung galaxy S (Android 2.3.4) it worked fine, but I started again to try to register first with the Tomtom first, and now it doesn't work. When pairing I get a request to enter a pairing code (everytime a different code) but I don't get a field to enter the code.

    Any hint based on your investigation

    ReplyDelete
    Replies
    1. I had the same problem trying to pair to my Samsung Galaxy S 4G. I found the solution is an app in the Google Store called Bluetooth Auto-Pair by Michael Brachmann. It took a few tries, but it finally worked after I restarted the phone and removed the batteries from the TomTom for a minute.

      Delete
  2. Thank you so much for this. Since I didn't have root I wasn't able to do the push but I found an app called "External Keyboard Helper" (https://play.google.com/store/apps/details?id=com.apedroid.hwkeyboardhelperdemo#?t=W251bGwsMSwxLDIxMiwiY29tLmFwZWRyb2lkLmh3a2V5Ym9hcmRoZWxwZXJkZW1vIl0.) and was able to get it working using the free version of that app.

    Between you and that developr I now haev an awesome android music remote

    ReplyDelete
  3. I'm running a Samsung Galaxy S3 with Android 4.1.1, and I can't pair the remote either.
    Only solution I found is to use a €1.5 app called Bluetooth Auto Pair (https://play.google.com/store/apps/details?id=com.brachcon.btautopair&feature=also_installed#?t=W251bGwsMSwxLDEwNCwiY29tLmJyYWNoY29uLmJ0YXV0b3BhaXIiXQ..) which somehow seems to be able to override Android's limitations and allow the user to feed a specific pairing code to the 'external keyboard'.
    Hope this helps (and thank you thank you thank you for this article, BTW!)

    ReplyDelete
  4. Hi

    Got TomTom Remote working with Nexus 4, rooted Stock ROM 4.3

    All you need to do is:
    1. get acces to folder "/data/misc/bluedroid"
    (root required; try with "es file explorer" or "Terminal Emulator" app)
    2. rename "bt_config.xml" and "bt_config.old"
    (e.g. to "bt_config_rm.xml" and "bt_config_rm.old")
    3. reboot phone.
    4. switch on bluetooth
    5. press button on TomTom Remote (LED should start flashing)
    6. scan for new devices on phone (don't try to pair while LED of remote still flashing)
    7. wait for remote to stop flashing blue LED
    8. tap remote on phone for pairing
    9. LED of remote should permanently glow
    10. feel happy and control your device

    what this does:
    - android system is creating renamed files freshly on reboot without prior restrictions for connecting to "insecure devices".
    - "old files" ("bt_config.xml", "bt_config.old") still available if there are future issues with bluetooth.

    Also connection to priorly blocked devices like special car audio system or other bluetooth keyboards should be fixed.


    Greetings
    Basti

    ReplyDelete
  5. I recently installed CyanogenMod 10.2 (Android 4.3) on my Galaxy Note I, and noticed that the TomTom Remote is no longer recognized as a keyboard but rather as an 'input device', ie with a nice 'joystick' icon next to it.
    Needless to say, the keyboard definition files won't work anymore.
    Any clues on how to work around this?

    ReplyDelete
    Replies
    1. Hi Mack
      I managed to make it work as an Input Device on Android 4.4.
      Just put the kl file as in the original post (kcm is not needed). I also had to create system/usr/idc/TomTom_Remote.idc (or copied from an existing one), and put this value : keyboard.layout = TomTom_Remote.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Hmmm I think mines appears to be connected as Broadcom Bluetooth HID rather than TomTom remote, will report back.

      Delete
    4. I am also with 4.4.2. Bluetooth config tab shows keyboard icon before pairing with name "TomTom Remote", and as a joystick after pairing, paired fine with bt_config.xml trick and got it working as dpad keys (default), but under system > language and input > physical keyboard: shows "Broadcom Bluetooth HID".

      I have not been able to remap any key, tried steps in original post with names and permissions etc double checked. Nothing. Also tried adding the idc files as "TomTom_Remote.idc" and "Broadcom_Bluetooth_HID.idc", but no luck.
      Did you or anyone got it working in 4.4.2?

      Delete
  6. I can't connect my TomTom remote (4M02.000) to my Gingerbread (2.3.4) phone. I managed to pair it after some struggling with the "Bluetooth Auto Pair" app mentioned above but it just won't connect now.

    Also, when I paired it for the first time, it was shown as an HID device and had "Options..." in its context menu (no such option anymore, re-pairing won't help). But it wouldn't connect, and it doesn't connect now. Pressing buttons before or after the connection attempt doesn't help. The LED just keeps blinking.

    I managed to connect it to my PC though - the LED was solid.

    ReplyDelete
    Replies
    1. The Gingerbread phone I was trying to connect the remote to seems to have some bug that won't allow to enter the PIN code when pairing.

      I got a new 4.2.1 Android phone and the remote has connected easily.

      Delete
  7. Modern technology are introducing useful thing like remote joystick every day i really like your information.
    remote joystick

    ReplyDelete
  8. Tried everything mentioned here to pair, used to work using the Bluetooth Auto Pair app on my Android 6, not so much with Android 7. Now I can't get it to pair no matter what.

    ReplyDelete