Almost OT: got Wiimote working with Amarok on 8.10
Chris Mohler
cr33dog at gmail.com
Sun Aug 9 00:14:28 UTC 2009
I created a blog entry covering the basics of getting it working:
http://cr33dog.blogspot.com/2009/08/wiimote-on-ubuntu-810.html
Now I can control Amarok from the next room. Very handy if you have a
bluetooth-enabled machine and a Wiimote laying about. Only blogged it
b/c I had to do quite a bit of research to get it working, and I want
to remember the steps on the next clean install. Maybe even help
another linux user ;) Only mention it here for the
curious/interested...
Chris
PS - in case the blog format is annoying, I've pasted the content below:
Since my laptop (Vostro 1500) has bluetooth, and I have Wiimote handy
I decided that it was time to hook up the Wiimote as a remote control.
A few details on the setup:
- I'm using XFCE
- My preferred media player is Amarok
- I've already set up the multimedia keys on the front of the laptop,
which saved me a step in getting the Wiimote working.
OK - first things first. I already had cwiid installed - you need to
install this first. Google around :) Next, I added a udev rule:
KERNEL=="uinput", GROUP="uinput"
I put mine in /etc/udev/rules.d/91-uinput-cr33.rules
Next, I added a group 'uinput' and added myself and root to the group.
(this allows running wminput without sudo)
Then I restarted udev - which was a mistake ;) Better to reboot
(unless of course you LIKE watching Xorg barf over and over...).
At this point, I was able to run the command 'wmgui' and connect to
the Wiimote. So far, so good - pressing buttons lights up the wmgui
interface. Killed wmgui.
Now - the tricky part: getting the buttons to control Amarok. Like I
said above, I already had the media keys on the front of the laptop
working. IIRC, in Applications->Settings->Settings Manager, I went to
the Keyboard settings, then the Shortcuts tab. I don't remember
exactly where I got the keycodes (maybe 'showkey -k' on VT1), but my
shortcuts look like:
amarok XF86AudioMedia
aumix -v0 XF86AudioMute (similar for volume up/down)
dcop amarok player next XF86AudioNext (similar for other playback
buttons - note the use of dcop)
So, with that already set up, all I needed was a conf file for
wminput. Easy right? not so much - I finally found a list of all keys
for wminput in the source code, then matched them up to the keycodes
given by 'showkey -k':
http://abstrakraft.org/cwiid/browser/trunk/wminput/action_enum.txt
Once I had my amarok.conf file, I started wminput thusly:
wminput -w -c /home/cr33/amarok.conf
So my amarok.conf ended up looking like this:
#acc_ptr
Wiimote.A = KEY_PLAYPAUSE
Wiimote.B = KEY_STOPCD
Wiimote.Up = KEY_VOLUMEUP
Wiimote.Down = KEY_VOLUMEDOWN
Wiimote.Left = KEY_LEFT
Wiimote.Right = KEY_RIGHT
Wiimote.Minus = KEY_PREVIOUSSONG
Wiimote.Plus = KEY_NEXTSONG
Wiimote.Home = KEY_MEDIA
Wiimote.1 = KEY_MUTE
#Wiimote.2 = KEY_MUTE
#Plugin.led.Battery = 1
Plugin.led.Button = BTN_2
#Plugin.acc.X = REL_X
#Plugin.acc.Y = REL_Y
Notice that #acc_ptr is commented out - this keeps the Wiimote tilt
from affecting the pointer position. I also ended up commenting out
Button 2 - as you can see, I've installed the nifty led plugin, which
can be found here:
http://abstrakraft.org/cwiid/attachment/ticket/65/led.py
It needs to go into ~/.cwiid/plugins (note the lowercase cwiid - some
of the docs are wrong)
I edited the plugin on line 10 to look like:
Button = cwiid.BTN_2
That's probably wrong - since I get an error on starting wminput:
"Invalid plugin button: led.Button". Oh well - it works though.
Pressing Button 2 on the Wiimote shows me how much battery charge is
left.
Anyway, that's a wrap. I just wanted to document this, since it look
longer to get this working than it should have :)
More information about the ubuntu-users
mailing list