Specifications

32 | august 2008 www.linuxjournal.com
If you think about it, there are almost as many
ways to interface with your computer as there are
Debian-based distributions—and that’s a lot. Besides
the trusty keyboard and optical mouse, there are
trackpoint mice, touchpads, touchscreens, twiddlers,
joysticks, presentation remotes and even devices that
measure your brain waves. Although I mostly stick
with my tried-and-true keyboard and trackpoint
mouse (fingers on home row, thank you), when I
started hearing about all the interesting things people
were doing with the Wiimote (the main controller
from the Nintendo Wii), I knew I had to give it a try.
Now traditionally, connecting a brand-new
device to a Linux machine was an investment in
Internet research, kernel module hacking, prayer
and obscure programming skills I haven’t used since
college. I figured the mere fact that this was a
Bluetooth device meant I was going to have to
spend some quality time with hcidump. To my
surprise, all the hard work already had been done
for me, and I could connect and use a Wiimote
on my laptop with only a few basic steps.
Configure udev
First, your kernel needs the uinput module available
and loaded. This module is available in modern ker-
nels, and my Ubuntu Gutsy install already had it. If
you want to be able to connect to the Wiimote as a
regular user, however, you need to add a new udev
rule to extend permissions to the uinput device. I
created a file called /etc/udev/rules.d/95-uinput.rules
that contained the following:
KERNEL=="uinput", GROUP="plugdev"
Then, I made sure my user was a member of the
plugdev group. If your system doesn’t have a plugdev
group, you could choose or create another group
to use for this device. Next, run
/etc/init.d/udev
reload
to make sure your changes are seen. Finally,
I ran
modprobe uinput
to make sure the module was
loaded, and I also added uinput to /etc/modules to
make sure it was loaded at boot.
Install wminput
The next step is to install the wminput software. For
me, this was simple, as wminput is packaged for
my distribution; otherwise, you can download the
source from the official site (www.cwiid.org).
Then, make sure the Bluetooth device in your
computer is enabled. For my laptop, I had to flip a
switch on the side, but if you have an external USB
Bluetooth adapter, for instance, now is a good time
to plug it in. Finally, run wminput in a console and
follow the directions:
greenfly@minimus:~$ wminput
Put Wiimote in discoverable mode now (press 1+2)...
Ready.
When you press buttons 1 and 2 on your Wiimote,
it goes into discoverable mode, and the blue LEDs
along the bottom start blinking. Sometimes you might
not start discoverable mode fast enough, or wminput
won’t detect it, but as long as the LEDs on the Wiimote
are blinking, it is still in that mode. So if wminput times
out, just run the program again.
If you continually can’t connect, you probably
should double-check that your Bluetooth device is
working. To do this, press buttons 1 and 2 on the
Wiimote and then use hcitool to scan for the Wiimote.
A successful scan will look like the following:
greenfly@minimus:~$ hcitool scan
Scanning ...
00:1B:7A:3E:8C:54 Nintendo RVL-CNT-01
After wminput connects, you also can look in
/var/log/dmesg for confirmation that the Wiimote
is connected:
[ 1226.247203] usb 3-2: new full speed USB device using
¯uhci_hcd and address 13
[ 1226.288768] usb 3-2: configuration #1 chosen
¯from 1 choice
[ 1227.922403] input: Nintendo Wiimote as
¯/devices/virtual/input/input21
Use the Wiimote as a Mouse
Once the Wiimote is connected, the default bindings
use it as a mouse. The accelerometers in the Wiimote
are used to move the mouse pointer, so if you point the
Wiimote Control
Why let your Wii have all the fun? Find out how to connect your
Wiimote to your computer and use it as a mouse or an input device
for any number of popular gaming emulators.
HACK AND /
COLUMNS
KYLE RANKIN
The great thing about wminput is that all
these mappings are completely configurable.