Simple Bluetooth Phone Remote Control

This may be of use to you if you want to use your Bluetooth phone as a remote control for presentations. It turns key presses on your phone into fake X key events on your computer, essentially. This is very simple, so I'm not sure it's worth declaring it to be under any particular license, but the source code is available if you're interested. The MIDlet end is very similar to the BluetoothDemo in the WTK examples anyway.

This implementation hasn't been extensively tested by anyone, so I'd be interested to hear if it works for you. People actually make money and win awards for this kind of thing, apparently.


This section describes, rather tersely, how to set this up - the section below describes what's going on in more detail and explains how to build everything.



Connecting to device: /dev/rfcomm2
Successfully opened.
Got line: 53    KEY_NUM5        8       FIRE
   field1: 53
   field2: KEY_NUM5
   field3: 8
   field4: FIRE
Got key name: 5
5Got line: -4   unknown 5       RIGHT
   field1: -4
   field2: unknown
   field3: 5
   field4: RIGHT
Got key name: Right

More Details

A long time ago now, I wrote a small Windows application that would allow you to use your Sony Ericsson T68 as a Bluetooth remote control for presentations. (Lots of other people had written more or less the same application, since it was a fairly obvious thing to do.) This was particularly easy on that phone since you could use an AT command to turn on the reporting of keypresses. It was quite neat nonetheless - unfortunately, I don't think I can release the source or binary for that since I wrote it while working at a deeply unenlightened company, so legally they own it, as far as I can tell.

Anyway, since it's quite nice being able to use your phone as a remote control for presentations, I thought I would recreate the same thing, but for Linux and using a MIDlet on the phone to offer an RFCOMM service that reports keypresses.

The other thing I wanted to add was being able to send notes on your presentation's current slide to your phone. I've stopped short of doing that, however, since writing an OpenOffice plugin to do that looks to be more work than it's worth. However, the MIDlet will display any notes sent to it over the RFCOMM channel, terminating each note with an empty line. You can test this with minicom -s to the RFCOMM device.

Building the MIDlet

The simplest way I've found of building Java MIDlets is to use version 2.2 of Sun's J2ME Wireless Toolkit. There are later versions of the toolkit, but so far only for Windows. The FAQ suggest there'll be a version for other platforms soon, but make of that what you will - the truly annoying bit is that they seem to now be preventing you from downloading the older version at all. Idiots.

If you have the Wireless Tookit installed, copy the unpacked BluetoothRemote directory to the "apps" subdirectory of your installation. Start ktoolbar, open the project, build it with "Build" followed by "Project -> Package -> Create Package".

The other annoying bit here is signing the package. I use a flaky bash script for signing the package and sending to my phone. You'll need to change the variables at the top for that to have any chance of working, and have already generated a code-signing keypair and certificate. There are some examples of how to generate your own certificate here.

Customizing the Interpretation of Keypresses

The desktop client program is a few hundred lines of C. The function at the top hardcodes the mapping of keys on the phone to names of keys that xte will understand. (See xte's man page for more details of those.) It would be nicer to have this mapping set up in a configuration file, but that's not something I think it's worth doing - it should be obvious how to change that from the output of the program when you press keys. The default setup is useful enough for presentations anyway.

Extensions That Might Be Fun

Do let me know if you're enthusiastic about doing any of these, since I probably won't bother: