logo

flickr.com
PhoneHID (Bluetooth Phone keyboard / mouse)

Why would you want to use your phone as a wireless kb/ms?

There are plenty of uses for using your phone as a keyboard and mouse. Among them are for presentations where you don't want to be tied to a workstation, but I use mine to access my media PC, tucked away in a draw! On the occasion where I'm too lazy to go to a proper workstation, I get out my phone and can instantly browse the web from my living room, without having to turn the room into an office with a keyboard and mouse.

What you need

The software is written in J2ME, and uses Bluetooth. Specifically, you must have:

  • A MIDP-2.0 enabled Mobile phone
  • which supports the JSR-82 (Bluetooth) API
  • An Open Source Bluetooth HID implementation (such as for Linux) for recompilation

The third requirement is a rather unfortunate side-effect of using the Java Bluetooth API, as it prevents certain PSM's (Protocol Service Multiplexers - like ports) from being used. Specifically, it only allows ports above 0x1000 to be connected to, preventing the phone from connected to the computer in client mode (0x12 and 0x13)..

Screenshot

Additionally, the computer can't connect to the phone in host mode, as J2ME isn't able to set the Service record properly. To do so requires setting some binary values, which can only be done as Strings, which get converted to UTF-8 during serialisation (arghh) !?! Extensive experimentation leads me to conclude it just isn't possible in J2ME, and we need to ditch it for .net or a native implementation.

Download

Get the Jar and Jad files

The phone app defaults to use ordinary HID PSM's + 0x1000. I've modified BlueZ's hidd program to take an extra parameter to offset the default PSM, so you could use: hidd -p 0x1000. You can obtain the patched hidd utility by applying the patche below to hidd utilities v2.15. If you have a different version, it should be easy enough to alter the utility using the patch as a reference.

Program Details

The program is actually very simple. It makes use of the default 'boot' mode keyboard and mouse packet format, and uses BenHui's package for service discover.

The HID Page has lots of information about HID packets, and Bluetooth.com gives the specification for the Bluetooth related programming aspect (registration required).

Shoutback

by Steven Lovegrove Jump to top