About the author
Boaz I'm a software developer, working at a small company in the Netherlands. Currently I'm mostly using techniques like .NET, C#, SQL and jQuery, but I have experience with JAVA and PHP as well.

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

My Raspberry pi is used almost daily with Raspbmc, and I mostly control it with my android phone. I had some Wiimotes laying around and an old bluetooth device so i thought it would be nice to be able to use the those as an alternative.

First I started with a program called wminput, but I couldn't get it to work in XBMC, only in the console (what is pretty much useless). But then I read somewhere that I sould have used WiiUse_WiiRemote of which the source is in the XMBC repository. So I decided to try to build it and guess what? It works!

Here are the steps I executed to make the Wiimote work with Raspbmc:

First of all we need a USB bluetooth device and get it to work. Once you plugged in the device the output of the lsusb command should contain a bluetooth device.

Now we have to make the device work, run:
sudo apt-get update
sudo apt-get install bluez
If this gives you an error you can fix this by running:
sudo update-rc.d -f dbus defaults
Now we have to get the XBMC source to compile WiiRemote, run:
sudo apt-get install libbluetooth-dev g++ libcwiid1 xbmc-eventclients-common make git-core
mkdir /usr/local/src/xbmc
git clone git://github.com/xbmc/xbmc.git /usr/local/src/xbmc
cd /usr/local/src/xbmc/tools/EventClients/Clients/WiiRemote
Now we have to do a small modification to the Makefile:
modify MakeFile to add "-l bluetooth" on the line "$(OBJS) -o $(BIN)"
$(OBJS) -o $(BIN) -l bluetooth
Now we can build it by running:
sudo make
We are ready to test if our setup works, to do this we stop XBMC and restart it when the Wiimote is connected run:
sudo initctl stop xbmc
/etc/init.d/bluetooth restart
cd /usr/local/src/xbmc/tools/EventClients/Clients/WiiRemote
./WiiUse_WiiRemote
Now press button 1 and 2 on the Wiimote to connect and when only the first led is on run:
sudo initctl start xbmc
Congratulations, you should now be able to control Raspbmc with your Wiimote! The only thing left to do is make it start when you power on your Raspberry pi and optionally, only allow certain Wiimotes to operate Raspbmc.

Therefore we have to find the bluetooth address of the Wiimote, we can do this by running:
hcitool scan
We create a file that will be run at startup:
nano /home/pi/wiimote.sh
The contents will be:
#!/sbin/sh
/etc/init.d/bluetooth restart
sleep 2
cd /usr/local/src/xbmc/tools/EventClients/Clients/WiiRemote
./WiiUse_WiiRemote --btaddr XX:XX:XX:XX:XX:XX
Where XX:XX:XX:XX:XX:XX is your Wiimotes bluetooth address.

Give the file execute permissions:
chmod +x /home/pi/wiimote.sh
And edit rc.local to run it at start up:
sudo nano /etc/rc.local
Just before the last line that reads "exit 0" add:
sh /home/pi/wiimote.sh &
January 23, 2013 - Comments [16] - Posted in Raspberry pi | Raspbmc