Nintendo Wii Remote

Alternative Hardware:

Sony Playstation Move http://en.wikipedia.org/wiki/PlayStation_Move. To buy it in Germany: http://geizhals.at/deutschland/a543585.html

building the Sensor Bar

http://wiibrew.org/wiki/Wiimote/Pointing
http://doctabu.livejournal.com/64758.html
http://terbidium.com/content/projects/wiihacks/usb_sensorbar.php

WiiPresent (for OpenOffice.org / Evince / Adobe Reader)

http://dag.wieers.com/home-made/wiipresent/
http://blog.jorgeivanmeza.com/2009/07/instalacion-de-wiipresent-en-linux-ubuntu-9-04-un-largo-camino/

sudo aptitude install bluez bluez-compat

cd ~/Downloads
wget http://sourceforge.net/projects/libwiimote/files/libwiimote/0.4/libwiimote-0.4.tgz/download
tar -xf libwiimote-0.4.tgz
cd libwiimote-0.4

change hci_remote_name to hci_read_remote_name in the following two files:

  1. src/wiimote_link.c
  2. configure.in

and compile:

autoconf
./configure
make
sudo make install
sudo ln -s /usr/local/lib/libcwiimote.so.0.4.0 /usr/local/lib/libcwiimote.so
sudo ldconfig

cd ~/Downloads
svn checkout http://svn.rpmforge.net/svn/trunk/tools/wiipresent/ wiipresent

or get a specific version:

cd ~/Downloads
wget http://dag.wieers.com/home-made/wiipresent/wiipresent-0.7.2.tar.bz2
tar -xf wiipresent-0.7.2.tar.bz2
cd wiipresent-0.7.2
mv wiipresent-0.7.2 wiipresent

cd ~/Downloads/wiipresent
gedit Makefile

replace the path /usr/include/libcwiimote with /usr/local/include/libcwiimote-0.4.0/libcwiimote

sudo aptitude install libxtst-dev
sudo aptitude install asciidoc

asciidoc is optional to generate documentation for the application.

make
sudo make install

usage

first step

hcitool scan.

Press buttons 1 and 2 of the remote (maybe you have to press the sync button found unter the battery cover) search for an entry of the following form:

00:22:4C:72:9D:F1   Nintendo RVL-CNT-01

now run wiipresent:

wiipresent -b <wiimote bluetooth address> -r &

Press buttons 1 and 2 of your wiimote. if the command above does not work you might try

wiipresent -l 45 -r -t -v

and press buttons 1 and 2 of your wiimote.

Now open an application like OpenOffice Presentation and control it using the wiimote.

NORMAL MODE

The following keys are mapped in NORMAL mode, depending on the application that has the focus this may vary.

  • Left/Right buttons: change slide, change channel, change tab
  • Up/Down buttons: change volume, change links
  • -/+ buttons: change volume, zoom out/in
  • A button: toggle play/pause, change source
  • 1 button: toggle fullscreen
  • 2 button: change aspect ratio
  • home button: go back, home key
  • exit button: exit wiipresent (not implemented yet due to libwiimote bug)

WINDOW MODE

The following keys are mapped in WINDOW mode, depending on the application that has the focus this may vary. The B button is pressed together with the buttons below.

  • Up/Down buttons: scroll up/down
  • Left/Right buttons: switch between applications (window manager)
  • -/+ buttons: change workspace
  • A button: toggle MOUSE mode
  • 2 button: blank screen, mute audio (censor info)

MOUSE MODE

The following keys are mapped in MOUSE mode, depending on the application that has the focus this may vary. MOUSE mode is toggled by pressing the A button and B button at the same time.

  • Up/Down buttons: scroll up/down
  • Left/Right buttons: switch between applications
  • -/+ buttons: left/right mouse buttons
  • A button: left mouse button

CWiid (and wminput)

http://abstrakraft.org/cwiid/ https://help.ubuntu.com/community/CWiiD

CWiid is a collection of Linux tools written in C for interfacing to the Nintendo Wiimote. CWiid consists of three components:

  1. libcwiid - API to integrate the Wii Remote into your application
  2. wmgui - a graphical representation of all the a data gathered by the Wii Remote
  3. wminput - event/mouse/joystick driver that allows you to emulate mouse joystick and keyboard events

On Ubuntu / Debian, the installation is very simple:

sudo aptitude install wmgui wminput

load module uinput

sudo modprobe uinput

or add uinput to /etc/modules for having it loaded at every system startup.

Start wmgui by typing 'wmgui'. Connect the Wii Remote via File → Connect, then set all mark under the 'Settings' menu.

wminput

run using

sudo wminput -w

include the ir sensor for moving the mouse:

sudo wminput -c ir_ptr -w

create a menu entry for wminput:

Save the following Application Link as /usr/share/applications/wminput_noIR.desktop and put wii.png to /usr/share/pixmaps :

[Desktop Entry]
Encoding=UTF-8
Name=wminput acc
Comment=Use your Wii Remote to control the mouse
Exec=bash /usr/share/wminput/startup.sh
Icon=wii.png
Terminal=true
Type=Application
StartupNotify=true
Categories=Application;Office;

you also need the startup script sudo gedit /usr/share/wminput/startup.sh:

#!/bin/bash
sudo modprobe uinput 2> /dev/null ; sudo wminput -w

configure keys using

sudo gedit /etc/cwiid/wminput/buttons

Available keynames are defined in http://abstrakraft.org/cwiid/browser/trunk/wminput/action_enum.txt (republished on https://gist.github.com/981318#file_action_enum.txt).

GUI for wminput: gwminput http://jpizarro.kimapu.com/wp/?page_id=41
http://joteiro.wordpress.com/gwminput/
http://gitorious.org/gwminput/

to press configure the keys in an advanced kind: sudo gnome-keybinding-properties

Program using CWiid

http://abstrakraft.org/cwiid/wiki/ProgramsUsingCWiid

  • freej: Vision Mixer. Provides Java Script WiiController() Object to setup interactive video installations etc.
  • TransferMii: a simple mii transfer program with a GUI (latest : v0.6.1 (2008/03/05)).
  • Wii-lla: Allows control of DMX lighting using the Wii Remote.
  • Wiimote PD external: Allows for using WII mote inside puredata.
  • Wiimote Pan Tilt Control: Controls a pan tilt camera using the wiimote.
  • Qwiimote: This is a simple and non elegant frontend for Cwiid using python and qt.
  • wiiosc: a simple program to get Wii Data as OSC, and control LEDs and rumble via OSC
  • SuperCollider: Allows for using WII mote inside supercollider through the wiimote class.
  • 3D IR Detection: Uses two wiimotes to determine the 3d position of an IR source. It's fun too.
  • WairGlove: Allows you to control the mouse in the air with a glove and the Wiimote.
  • Wiimote Head Tracking: Allows you to track you head using the Wiimote to provide an immersive 3D experience (based on the idea by Johnny Chung Lee)
  • Wiimote Head Tracking in Avogadro: Avogadro is a molecular editor. There are some wiimote plugin tools in the wiimote branch and there is a head tracking extension in trunk.
  • Wiimotedev: Manage your pc remotely. GUI based on Qt4.

Wiigee - gesture recognition

http://www.wiigee.org
http://mizzler.blogspot.com/2009/01/wiigee-on-linux.html

How it works: scroll to system components on http://www.wiigee.org/development/background/background.html

Wiigee is a wiimote library written in Java that can learn and identify gestures. A demo application is available for download, and source is included in the jar file.

sudo aptitude install libbluetooth libbluetooth-dev

bluecove binaries

Download the the bluecove libraries (I used version 2.1.0) http://bluecove.org/bluecove-gpl

wget http://surfnet.dl.sourceforge.net/project/bluecove/BlueCove/2.1.0/bluecove-2.1.0.jar
wget http://surfnet.dl.sourceforge.net/project/bluecove/BlueCove/2.1.0/bluecove-gpl-2.1.0.jar

bluecove sourcecode

The bluecove (not the gpl module) MicroeditionConnector.java needs to have the L2CAP validation removed (apparently the wii mote uses non-standard ports)

sudo aptitude install maven2

cd ~/Downloads
wget http://surfnet.dl.sourceforge.net/project/bluecove/BlueCove/2.1.0/bluecove-gpl-2.1.0.jar
wget http://bluecove.googlecode.com/files/bluecove-2.1.0-sources.tar.gz
tar -xf bluecove-2.1.0-sources.tar.gz

cd ~/Downloads/bluecove-2.1.0/
gedit ./src/main/java/com/intel/bluetooth/MicroeditionConnector.java

mvn -Dmaven.test.skip=true -e

Install Java 3D

http://wiki.ubuntuusers.de/Java3D and https://java3d.dev.java.net/binary-builds.html

cd ~/Downloads
wget http://download.java.net/media/java3d/builds/release/1.5.2/j3d-1_5_2-linux-amd64.zip
unzip j3d-1_5_2-linux-amd64.zip
cd j3d-1_5_2-linux-amd64
unzip j3d-jre.zip
sudo cp lib/ext/* /usr/lib/jvm/java-6-sun/jre/lib/ext/
sudo cp lib/amd64/* /usr/lib/jvm/java-6-sun/jre/lib/amd64/

get the wiigee demogui:

cd ~/Downloads
mkdir wiigee-demogui
cd ~/Downloads/wiigee-demogui
wget http://www.wiigee.org/download_files/wiigee-demogui.zip
unzip wiigee-demogui.zip

the wiigee library:

cd ~/Downloads
wget http://surfnet.dl.sourceforge.net/project/wiigee/wiigee-lib/wiigee-lib-1.5.6.jar

Usage with the bluecove binaries

cd ~/Downloads
java -cp bluecove-2.1.0.jar:bluecove-gpl-2.1.0.jar:wiigee-demogui/wiigee-gui.jar wiigeegui.wiigeemain

usage with the bluecove self compiled bluecove-2.1.0.jar:

java -cp bluecove-2.1.0/target/bluecove-2.1.0.jar:bluecove-gpl-2.1.0.jar:wiigee-demogui/wiigee-gui.jar wiigeegui.wiigeemain

or add bluecove-2.1.0.jar and bluecove-gpl-2.1.0.jar to your classpath and run:

cd ~/Downloads/wiigee-demogui
java -jar wiigee-gui.jar

WiiGLE - win software for gestures

http://mm-werkstatt.informatik.uni-augsburg.de/documents/WiiGLE/doku.php

WiiGLE is an environment to record gestures, calculate features, train classifiers, and use the Wiimote for online gesture recognition based on accelerometer data. Up to date information on how to use WiiGLE can be found on the WiiGLE Wiki.

download: http://mm-werkstatt.informatik.uni-augsburg.de/downloads/WiiGLE_2_0_1.zip

  • Tetriis (only 32 bit)

http://sylfurd.free.fr/?cat=13

needs cwiid...

cd ~/Downloads
wget http://sylfurd.free.fr/tetriis/tetriis10b1/tetriis10b1linux.tar.gz
tar -xf tetriis10b1linux.tar.gz

wii_ks

http://www.imn.htwk-leipzig.de/~dborkman/wiimote/index.html

requirements:

sudo aptitude install libbluetooth3 libbluetooth-dev

retrieval:

cd ~/Downloads
mkdir wii_ks
cd wii_ks
wget http://www.imn.htwk-leipzig.de/~dborkman/wiimote/wiimote.tar.gz
tar -xf wiimote.tar.gz

and compilation and installation:

cd ~/Downloads/wii_ks
make
sudo insmod wii_ks.ko
sudo chmod a+rwx /dev/wiimote
./wii_us /dev/wiimote 00:22:4C:72:9D:F1 &

my own calibration:

resources:

As explained on wiibrew.org:

"The four bytes starting at 0x0016 and 0x0020 store the calibrated zero offsets for the accelerometer (high 8 bits of X,Y,Z in the first three bytes, low 2 bits packed in the fourth byte as --XXYYZZ). Apparently, the four bytes at 0x001A and 0x24 store the force of gravity on those axes."

So my 8 calibration bytes are: 0x82 0x81 0x7D 0x01 0x9C 0x9B 0x97 0x00 0x40 0xE4 In binary notation this is: 10000010 10000001 01111101 00000001 10011100 10011011 10010111 00000000 01000000 11100100 And in integer notation (base 10): 130 129 125 1 156 155 151 0 64 228

so my calibration values are: (with respect to 1byte values): zeroX = 130 zeroY = 129 zeroZ = 125.25

oneX = 156 oneY = 155 oneZ = 151

so I have to adjust the values in ./wii_ks/wii_us.c to:

    calx = 130.f;
    caly = 129.f;
    calz = 125.25f;

or to have an automatic calibration to the values of your wii: change in ./wii_ks/wii_us.c:

        if(buff[0] != 0xA1 && buff[1] != 0x33)
            continue;

to

        if(buff[0] == 0xA1 && buff[1] == 0x21) {
            calx = (float)buff[7];
            caly = (float)buff[8];
            calz = (float)buff[9];
        } else if(buff[0] != 0xA1 && buff[1] != 0x33)
            continue;

and

#define WII_BLK_LEN                        0x07

to

#define WII_BLK_LEN                        0x0A

and set default calibration data:

calx = 128.f;
caly = 128.f;
calz = 128.f;

to set the LEDs automatically on startup add the following lines to wii_us.c :

#define SET_LEDS     { 0x52, 0x11, 0xF0 } // LEDs all on (F) and rumble off (0) -> F0

inside wii_connect add:

    static unsigned char wii_led_data[] = SET_LEDS;

and

    err = write(sock_ctrl, wii_led_data, sizeof(wii_led_data));
    if(err < 0){
        perror("write");
        return err;
    }

wiimotecomm (PyBluez Script)

This has been found on http://www.wiili.com/index.php/Wiimotecomm. The site, however, does not exist anymore.

A tiny script for testing communication with a Wiimote by sending custom data over a L2CAP connection.

sudo aptitude install python-bluez

Usage examples

./wiimotecomm discover "52 15 00"
[Searching for Wiimotes...]
[Found Wiimote at address 00:22:4C:72:9D:F1]
[Connected to Wiimote at address 00:22:4C:72:9D:F1]
Send:    (52) 15 00
Receive: (A1) 20 00 00 02 00 00 9C
[Disconnected]
  1. Search for a Wiimote that is in discoverable mode
  2. Connect to it and send byte sequence "0x52 0x15 0x00" (0x52: (HID)SET_REPORT, 0x15: "Controller status", 0x00: Payload) to the Wiimote
  3. (Disconnect and Terminate)

    ./wiimotecomm 00:22:4C:72:9D:F1 5211F1 wait:1000 521110 52120031 wait:30000 [Connected to Wiimote at address 00:22:4C:72:9D:F1] Send: (52) 11 F1 Receive: (A1) 20 00 00 02 00 00 9E Receive: (A1) 30 00 00 Send: (52) 11 10 Send: (52) 12 00 31 Receive: (A1) 31 00 00 85 81 98 Receive: (A1) 31 40 00 84 81 98 Receive: (A1) 31 60 00 83 81 99 Receive: (A1) 31 00 40 84 82 9A Receive: (A1) 31 60 60 84 82 9B Receive: (A1) 31 00 20 86 81 9A ... (More button and motion sensor data) Receive: (A1) 31 60 40 84 81 98 Receive: (A1) 31 00 60 84 81 9A Receive: (A1) 31 60 60 84 82 9B [Disconnected]

  4. Connect to Wiimote at bluetooth address 00:22:4C:72:9D:F1

  5. Send byte sequence "0x52 0x11 0xF1" (0x52: (HID)SET_REPORT, 0x11: Set LEDs/Rumble, 0xF1: All LEDs and rumble on)
  6. Wait for 1 second (1000 milliseconds)
  7. Send byte sequence "0x52 0x11 0x10" (0x52: (HID)SET_REPORT, 0x11: Set LEDs/Rumble, 0xF1: LED 1 on, rumble off)
  8. Send byte sequence "0x52 0x12 0x00 0x31" (0x52: (HID)SET_REPORT, 0x12: Set Report ID, 0x00: No rumble, no continuous output, 0x31: Choose report ID 0x31 = Buttons and Motion Sensing)
  9. Wait for 30 seconds (30000 milliseconds), dump any incoming data
  10. (Disconnect and Terminate)

here is the ./wiimotecomm:

Wiiewer (PyBluez Script)

Perlwiimote

http://www.windmeadow.com/wiimote

Linux::Input::Wiimote - Wiimote.pm is a perl module that interfaces to the libcwiimote API. It can access most of the functions of the wiimote including: D-pad, wiimote buttons, nunchuck buttons, nunchuck joystick, axis and tilt data on both wiimote and nunchuck, and rumble.

XWii

http://www.resplect.com/xwii/?cat=6

documentation: http://www.resplect.com/xwii/?cat=4

sudo aptitude install libbluetooth-dev libxtst-dev
sudo aptitude install libsdl-dev freeglut3-dev
cd ~/Downloads
wget http://www.resplect.com/xwii/files/releases/2.8/XWii_2.8_source.tar.gz
tar -xf XWii_2.8_source.tar.gz
cd XWii_2.8_source
make
./start_xwii.py

The make command make compiles the source code of xwii into an executable program (this way, people on 64-bit architecture, etc. can use the same archive. a version of wiiuse (the library xwii is based on) is included. This requires the necessary BlueZ bluetooth libraries to be available on your system.

start_xwii.py runs a python script that lets you select one of the available profiles (a profile defines mappings of the wii remote buttons, joysticks, etc. to mouse/keyboard input) for xwii to use. This requires python to be installed on your system.

Problems when not connecting: http://xbmc.org/forum/showthread.php?p=451536#post451536 add memset(&addr, 0, sizeof (addr)); at the line 174 of io_nix.c

start XWii:

xwii path/to/config/file.xwii

XWii config files are made up of BBCode style “tags” like this: [a]KEYBOARD Return[/a] for the A button.

Resources

Comments