Wii Remote on PS3 Linux
Introduction
WMD is a Wii Remote driver for Linux fully written in Python. WMD utilizes the BlueZ Bluetooth stack to communicate with a Wii Remote and the uinput interface to act as an input device of Linux.
It's a really nice hack, but there are many obstacles to use WMD on PS3 Linux. WMD is probably written for x86 platforms and it (and Python itself) lacks some portability. And furthermore, the uniput driver has no consideration for the biarch environment such as powerpc userland (32bit) on ppc64 kernel (64bit). You will need to patch and rebuild them all.
Applications, Related Links
Cube Presenter: Show presentation slides on the 3D rotating cube. Used in Binary 2.0 Conference 2006
- My blog entries (in Japanese)
Patches
WMD/Python fix
- The ioctl constants vary in archs. Fix for powerpc.
--- WMD.py 2006-12-12 22:42:25.000000000 +0900 +++ WMD_ps3.py 2006-12-12 22:41:53.000000000 +0900 @@ -405,13 +405,13 @@ # These are uinput control codes -UI_DEV_CREATE = 0x5501 -UI_DEV_DESTROY = 0x5502 +UI_DEV_CREATE = 0x20005501 +UI_DEV_DESTROY = 0x20005502 -UI_SET_EVBIT = 0x40045564 -UI_SET_KEYBIT = 0x40045565 -UI_SET_RELBIT = 0x40045566 -UI_SET_ABSBIT = 0x40045567 +UI_SET_EVBIT = 0x80045564 +UI_SET_KEYBIT = 0x80045565 +UI_SET_RELBIT = 0x80045566 +UI_SET_ABSBIT = 0x80045567 EV_SYN = 0x00 EV_KEY = 0x01
PyBluez seems to have the endianness problem for bluetooth sockets. Here's a workaround for WMD.
@@ -1663,8 +1663,8 @@ socket['receive'] = BluetoothSocket( L2CAP ) socket['control'] = BluetoothSocket( L2CAP ) - socket['receive'].connect( ( addr, 19 ) ) - socket['control'].connect( ( addr, 17 ) ) + socket['receive'].connect( ( addr, 19<<8 ) ) + socket['control'].connect( ( addr, 17<<8 ) ) if socket['receive'] and socket['control']: log(LOG_INFO, "We are now connected to Wiimote at address " + addr)Python's fcntl.ioctl raises an exception when ioctl cmd's MSB is set, like powerpc's UI_SET_EVBIT (= 0x80045564). There seems no workaround for WMD; you need to rebuild Python with this patch.
drivers/input/misc/uinput.c fix
You need to implement some compat routines in uinput.c, as seen in evdev.c, to handle requests from the 32bit userland. Apply this patch to uinput.c and rebuild. Note, the patch is by far not complete. It leaves many structs unhandled.
Resources
WMD.py: Original WMD
WMD-PS3.py: The modified version for PS3
evtest.c: Event device tester