View Single Post
Posts: 393 | Thanked: 112 times | Joined on Jul 2007
#1
Porting CWiid to OS2008 - See http://abstrakraft.org/cwiid/

CWiid is a library to access Wiimotes under Linux. Wiimotes are fantastic hardware devices that open up a wealth of interaction possibilities with linked hosts. They are relatively common and cheap thanks to the uptake of the Nintendo Wii.

The Wiimote provides triple gyroscopic tilt sensors, a 1024x768 infra-red camera with hardware optimized tracking facilities, a mono-speaker, a tiny amount of non-volatile memory, a digital joypad which includes 7 buttons, 4 LEDs, and the possibility for wired expansion with various hardware addons. Communication with the host is made wirelessly through bluetooth.

An initial cross-compile of CWiid revealed that the onboard bluetooth module on the N800 and N810 is very much compatible with the Wiimote.

At the very least this should provide a cheap bluetooth joypad. Because of the innovative nature of the Wiimote, MANY other additional applications have been created including sensitive motion sensing devices (time the acceleration of a car) to motion tracking applications (See: http://www.cs.cmu.edu/~johnny/projects/wii/ )

Possible extensions to CWiid include relative mouse movement (assuming we can hack into tslib say by creating a plugin), extensions to dbus, innovative application.

This needs a little tweaking to run.

Installation:
# 1) Extract the TARBALL straight to root.
cd /
tar xzvf cwiid-0.6.00.tar.gz

# 2) add usr/local/lib to library path
echo "/usr/local/lib" >> /etc/ld.so.conf

# 3) run LDConfig
ldconfig


Usage:
CWiiid automated detection fails for some reason (HCIread fails to return the wiimote name for some reason despite setting timeouts to ridiculous numbers!) I've used DBus methods to query wiimotes instead. Despite this; if you know your wiimote bluetooth address you can get cwiid to connect anyway.

1) Setup Wiimote for pairing by either pressing A+B together so the blue LEDs flash, or pressing the connect button under the battery cover.

2) Run lswm - this should eventually return the bluetooth address of your wiimote.

> lswm

3) Export the bluetooth address as an environment variable:

> export WIIMOTE_BDADDR=00:19:FD:YOURBLUETOOTHADDRESS

If you expect to use the same Wiimote here, you could export the above line to bashrc and skip steps 1-3 next time.

4) Insmod the kernel drivers
insmod /lib/modules/uinput.ko
insmod /lib/modules/joydev.ko

5) Run the driver:
wminput -d &

6) Setup Wiimote for pairing by either pressing A+B together so the blue LEDs flash, or pressing the connect button under the battery cover. (YES - do this again!)

Wiimote should pair at this stage. Bluetooth icon turns solid blue.

Now you will have the relevant udev devices in /dev/ including a joystick, keyboard and mouse. Setup your game/application/etc accordingly.



Troubleshooting:
Use WMGui to provide graphical feedback from the wiimote instead of running wminput above. The menu/button options here should be self-explanatory.

Configuration:
You can configure the relevant buttons by editing /usr/local/etc/cwiid/wminput/buttons (see other files here and refer to readme on what this all means.)

There are other "plugins" that extend or enhance the functionality of CWiid and I suggest you see the readme there for more info on what these do. Using other plugins requires changing a link to the relevant plugin (step 3 in installation above.)

HelperApps I've tried using to extend and query functionality include xsetpointer, mouse_poll, xev, evtest and xdotool. All are included here.

Problems:
Insmodding the kernel drivers results in maemo software keyboard not working. You will need to rmmod the modules after using the joypad if you use the onscreen keyboard. Hardware keyboard on N810 is not affected, neither are bluetooth attached keyboards.
rmmod uinput.ko
rmmod joydev.ko



To-do:
1) Fix CWiid automated Wiimote detection by using DBus methods.
2) Create debian installation package.
3) Find a means to hook the mouse driver to the tablet.
4) Hildonize WMGui
5) Find means to fix maemo software keyboard not working on insmod.
6) Create menus for:
* Starting and stopping (insmod/rmmod) kernel modules.
* Starting/Stopping wminput with autoconfigure.
* WMGui

Last edited by yabbas; 2008-03-06 at 02:29. Reason: Simplify install,and screenshot.
 

The Following 21 Users Say Thank You to yabbas For This Useful Post: