If you've not looked into them before, wiimotes are a pretty nifty bit of kit. There basically a bluetooth mouse and are recognised by computers as Human Interface Devices (HID). But they do more than a mouse can, there is a InfraRed (IR) CCD camera, accelerometers and of course, a few buttons.
I decided I wanted to use one of these devices as a remote control. I can see it being more useful than a IR remote because it doesn't necessarily mean that you have to completely redesign the user interface, you can just tweak things so that it is easy to navigate using your wiimote as a mouse. This will be the first post in a series that should
There are loads of ways you can do this, and of course, it depends on your operating system. There's GlovePIE for Windows, Darwiin Remote for Mac and CWiiD for Linux. Here, I'm only going to talk about controlling a linux machine, Specifically Ubuntu 8.10.
So, first things first, get the Wiimote working. I found the guide at the Ubuntu Forums to be the best. If you're used to the command line, here is the short skinny version.
1. Install the necessary packages.
apt-get being what it is, all the dependencies should be installed automatically. Basically, it will be all the bluetooth packages if you don't already have them installed.
Code:
So, first things first, get the Wiimote working. I found the guide at the Ubuntu Forums to be the best. If you're used to the command line, here is the short skinny version.
1. Install the necessary packages.
apt-get being what it is, all the dependencies should be installed automatically. Basically, it will be all the bluetooth packages if you don't already have them installed.
Code:
sudo apt-get install wminput wmgui lswm
2. Find the mac address of your wiimote.
Plug in your bluetooth dongle and run the lswm command.
Code:
lswm
You should see something like this;
Code:
rob@sol:~$ lswm Put Wiimotes in discoverable mode now (press 1+2)... 00:17:AB:39:4E:C5
make a note of the address that is given. Don't use mine, it wont work.
At this point you can spend a few minutes playing with wmgui (Accessories>wmgui). If you have a candle of some other source of IR kicking around you can also check if the CCD is working.
3. Allow your Wii remote to be a keyboard / mouse / joystick:
Unless you want to run 'sudo modprobe uinput' every time you start Ubuntu, it's recommended that you make it automatically run upon Ubuntu start up.
Open a terminal and type:
Code:
gksudo gedit /etc/modules
Code:
uinput
Code:
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. fuse lp sbp2 uinput
Alternately, you can just open a terminal and type:
Code:
sudo modprobe uinput
Using your Wii remote as a mouse using acceleration data:
If you want to use your Wii remote as a mouse by tilting your Wii remote, then press buttons 1 + 2 on your Wii remote and from a terminal run this:
Code:
gksudo wminput
Using your Wii remote as a mouse using an Infra-Red light source:
IMPORTANT NOTE: To use the wiimote in Infrea-Red mode you need an Infra-Red source, like: incandescent candles, or a Wireless Wii Sensor Bar. I personally use a homemade source made from IR LED's. You won't need to experiment making your own bars, if you don't want to. You can find "sensor bars" in lots of places, including online stores. Keep in mind that the sensor bar is nothing more than a few LED lights and some plastic to make it look pretty. There is a short how to in the works if you want to make your own. Watch this space.
There's a configuration file that you must first edit before this is possible.
From a terminal, type this in:
Code:
gksudo gedit /etc/cwiid/wminput/ir_ptr
Code:
Plugin.ir_ptr.X = ~ABS_X Plugin.ir_ptr.Y = ~ABS_Y
Code:
Plugin.ir_ptr.X = ABS_X Plugin.ir_ptr.Y = ABS_Y
Code:
gksudo wminput -c ir_ptr 'your wiimote address'
Swapping default left and right mouse buttons:
If you prefer the left mouse button to be button B (the trigger) on your Wii remote, and the right mouse button to be button A on your Wii remote, then from a terminal run this:
Code:
gksudo gedit /etc/cwiid/wminput/buttons
Code:
Wiimote.A = BTN_LEFT Wiimote.B = BTN_RIGHT
Code:
Wiimote.A = BTN_RIGHT Wiimote.B = BTN_LEFT
This is done using a simple bash script. However, you have to fiddle with a few permissions and things. By default, wminput w ill not work properly without being started with the sudo or gksudo command. To fix this you can allow wminput to be started with sudo without needing to input the password.
First, change the permissions of wminput
Code:
cd /usr/bin/
sudo chmod +s wminput
Then create a scripts directory in your home folder and create the bash script
Code:
mkdir scripts
cd scripts
touch wiiconnect
Add the following code to the file you just created using your favourite text editor.
Code:
#! /bin/bash
#
# Starts Wiimote deamon in IR mode
wminput -d -c ir_ptr 'your wiimote address'
Now, make the script file executable.
Code:
sudo chmod a+x wiiconnect
Now add a entry to your sessions (system>preferences>sessions) so that the script is run at startup.
The next time you boot your computer, all you have to do to connect the wiimote is press 1 + 2 on your wiimote and everything should connect automatically. To stop the wiimote, simply press and hold the power button on the wiimote. To reconnect the wiimote, simply press 1 + 2 again.
So there we have it, have fun. In the future, I will show you how to integrate the wiimote into gnome, remapping buttons so that elisa media centre can be started and stopped using the wiimote. Currently, I'm working on modifying the gnome desktop to make it wiimote friendly. Watch this space!
No comments:
Post a Comment