Welcome

WiiMote in X

The hardware is nice, but Debian, like all distro's I know of, doesn't come with multiple-WiiMotes-as-input-devices as a standard out-of-the-box feature. These were the steps I had to take to get it to work:

On the hardware side, I plugged in a compatible bluetooth-stick. Most of the sticks nowadays use the usb-hcd protocol, so they are almost guaranteed to work with Linux; I haven't found one yet that didn't. The other thing what was needed was a source of infrared light. The Wiimote tools I was going to use only needed a single source, so I ended up using a IR-LED from an old remote control to test and finetune the contraption.

Then came the software-side. First of all, I installed the wiimote utils and bluetooth helper stuff:

apt-get install bluetooth wminput lswm

With that installed, I could test the wiimotes by running wminput as root. The default configuration, however, allows you to control the mouse by using the acceleration sensor, and that's not completely what I wanted. I ended up hacking the wminput files in such a way that I ended up with the daemon outputting absolute pointer data to its own event files. In the process, I decided to set the buttons to something more practical too, and to add a second config for my second WiiMote. You can get my configfiles here if you want.

Next, I created a init.d-file to start the wminput-programs for both wiimotes at bootup. You can get it here, but if you use it, make sure to replace the wiimotes bluetooth adresses with those of your wiimotes. You can find the addresses by running 'lswm', by the way. Then chmod 755 it, dump it in /etc/init.d and make sure the file gets run on bootup by running 'update-rc.d wiimote defaults 80 20' as root (or a similar tool like 'service' if you don't use a Debian-based distro. Make sure the service gets started after bluetooth comes up, though!)

Now, we have to find out the device files the Wiimotes end up as. The easiest way for this is to just reboot and look in /dev/input. There should be a couple of eventX-files, with X being a number. The two with the highest number for X probably are your WiiMotes. To test this, connect both your wiimotes by pressing buttons 1+2, and after the leds have stopped blinking, run 'evtest /dev/eventX' on both the files. (evtest comes in the 'joystick'-package on Debian, if you can't find it perhaps you should apt-get install that.) The 'Input device name' should read 'Nintendo Wiimote', and the program should react when you point the Wiimote at a source of infrared light.

Let's make X react on the WiiMote. Edit your /etc/X11/xorg.conf-file, and insert these sections somewhere:

Section "InputDevice"
	Identifier "WiiMote0"
	Driver "evdev"
	Option "Device" "/dev/input/event4"
	Option "SendCoreEvents" "True"
EndSection

Section "InputDevice"
	Identifier "WiiMote1"
	Driver "evdev"
	Option "Device" "/dev/input/event5"
	Option "SendCoreEvents" "True"
EndSection

Change the /dev/input/event[4|5] into the event-values you found earlier. Next, include these devices in your config by putting these two lines in the ServerLayout-section of the file:

	InputDevice    "WiiMote0"
	InputDevice    "WiiMote1"

Finally, restart X (ctrl-alt-backspace should work; you'll close all your active programs unceremoniously that way though) and your WiiMotes should be usable as a mouse. X only is capable of using one pointer, by the way, so don't point both Wiis to the screen at the same time if you want to control the cursor.

You should now have a working Wiimote setup: you can use the Wiimotes to control the cursor, the A-button is left-click and all the other keys generate keyboard-events, which you can bind to buttons in your favorite emulator.

« Prev 2 Next »


© 2006-2022 Sprite_tm - Contact