Making a Wiimote work with Ubuntu

I wanted to use my Wiimote to control my Boxee install on Ubuntu 10.10 (Maverick Meerkat, don’t ask about Natty Narwhal). However I didn’t want it as a pointer like the Wii interface but to hold it on its side like a NES controller and move around like that.

I got this working ages ago when I first used Boxee on Linux but didn’t document getting it work (and it was a pain in the arse at the time). After a disastrous update to Natty Narwhal (see point above, don’t ask) which broke various things I did a clean install of 10.10 (after backing everything up).

This meant I lost a few settings and applications, thankfully the main one was Boxee which installed easily and just pulled all the info from the media which was on a external drive so that was fine. Now I just needed to get the Wiimote working again, which I was not looking forward to.

It was not simple but a lot easier than the last time. So I started with this guide. Which seemed straight forward. In the end it didn’t give me the ability to just start my machine and pair the Wiimote without any hassle. I eventually got it working, this is what I did (this assumes you have a working bluetooth connection on your machine but this is easy to setup with Ubuntu, worked out of the box for me):

To install the necessary packages, in a terminal window type:

sudo apt-get install libcwiid1 lswm wmgui wminput

To get the Wiimote doing what I wanted (Up on the d-pad = Left, Left on the d-pad = down, down on the d-pad = right, right on the d-pad up = Up, 1 = Enter, 2 = ESC, A = Spacebar, B = Spacebar, + = Up, – = Down) I edited the file /etc/cwiid/wminpu/buttons to say this (I left everything else unchanged):

#buttons
Wiimote.A = KEY_SPACE
Wiimote.B = KEY_SPACE
Wiimote.Up = KEY_LEFT
Wiimote.Down = KEY_RIGHT
Wiimote.Left = KEY_DOWN
Wiimote.Right = KEY_UP
Wiimote.Minus = KEY_DOWN
Wiimote.Plus = KEY_UP
Wiimote.Home = KEY_H
Wiimote.1 = KEY_ENTER
Wiimote.2 = KEY_ESC

At this point to check this has will work as expected, in a terminal window:

sudo modprobe uinput

This turns on the uinput module which is needed.

Now again in a terminal window:

sudo wminput -d -c buttons

This runs wminput constantly looking for any Wiimote in discoverable mode (-d) and tells it to use the configuration file buttons (-c buttons) to understand what the user wants it to do. This should result it nothing other than a blinking cursor on a new line. When you now hold down 1 + 2 on the Wiimote the blue lights on the bottom of the controller should flash and eventually stop. Now when you push left or right you should see some movement on the terminal window.

Congrats your Wiimote can now talk to your Ubuntu box. Don’t close the terminal window and if you now launch Boxee (I disable the mouse in the Boxee settings so you don’t see a pointer) you should be able to navigate around Boxee and do what you want. This does mean to do this you need to play around with terminal windows and stuff every time you turn it on to use Boxee. To make it an automatic process is easy when you know how. I tried many things but the problem is the “sudo” needed to do both steps which require you to input your password.

The first thing to do is to initialise the input module just add a single line/word to the file “/etc/modules”:

uinput

Now this next bit is the kicker, to use winput it needs to be run as root to access uinput. Most solutions I have found try to make uinput usable to all users but I could not make them work so I used this slightly simpler method. Open the file “/etc/rc.local” and add the line:

wminput -c -d buttons

Now uinput is run at start up and the wminput is run as a daemon in the background every time the machine is turned on. If Boxee is a startup application (the command is “/opt/boxee/run-boxee-desktop”) then it will start up when you launch your Ubuntu box and when you hold down 1 + 2 on any Wiimote you can control Boxee with it.

I hope this helps some other people cause it makes Boxee great to use (IMO) but also means it is there for me to use when I have to do it all again in the future.

Later days,
Halo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.