Robots w/Lasers

December 6, 2006

Control X.Org cursor with Wiimote

READ THIS –> WMD has been apparently discontinued…so here are two other projects for dealing with wiimotes under linux:

1. Cwiid (I use this one personally, works well for my basic needs, mostly for playing NES emulators)
2. libwiimote


Our good friend e-Hernick is working on a “driver” for linux to use the wiimote (The controller for Nintendo’s Wii). I say “driver” in quotes, because it’s not really a driver, as it doesn’t have any kernel-mode code. In fact, it is simply a python script.

e-Hernick sez: “OH YEAH! I am now controlling the XORG MOUSE with the WIIMOTE IR, with the use of my very own wiimotulator.py!”

I haven’t personally tested it, (mainly since I don’t have a wiimote). But it looks neat.

Latest versions can now be found at: ForTheWiiN.org

Requirements: Linux 2.6 with evdev and uinput, Xorg 7.0 with evdev BlueZ, PyBluez 0.9.1, a Wiimote, 2 IR emitters of some sort (even candles work apparently!)

64bit users:for 64bit linux, you could try changing line 729 from:

    STRPK_INPUT_EVENT = "LLHHl"

To:

    STRPK_INPUT_EVENT = "LLHHi"

Non-Linux users:
Windows: LiquidIce’s page and GlovePIE.
Mac OSX: DarwiinRemote.

FINAL UPDATE: WMD now has a website! See the link above.

Filed under: Wii — davr @ 1:08 pm

46 Comments »

  1. Sweet, now I can play nintendo games, with a Wii-mote, ON MY PS3!

    Comment by SnowflakePillow — December 6, 2006 @ 1:48 pm

  2. SnowflakePillow: That makes no sense at all.

    Comment by davr — December 6, 2006 @ 2:13 pm

  3. Um, he mentions IR, is the IR pointing function up and running? Or is it just the tilt from the videos I’ve seen.

    Comment by Waffle — December 6, 2006 @ 3:39 pm

  4. Awesome!! Now we just need a little code that uses a neural network to learn and recognize recorded gestures for specified events (launch specific application, terminal, website, etc.) Any coders willing to code it? I’m still learning python so it may be a while if you all wait on me ^_^

    Comment by NeuralZen — December 6, 2006 @ 3:42 pm

  5. Looks like Sony released a firmware patch for the PS3 and can now be controlled by a bluetooth remote. Are you thinking what I am thinking, Pinky?

    Comment by NeuralZen — December 6, 2006 @ 3:47 pm

  6. @NeuralZen:

    Comment by jr — December 6, 2006 @ 3:47 pm

  7. Do I need Linux to run this? If not, are there any instructions on how to run it, or any
    further information about it?

    If so, do you guys see a Windows version in the future?

    Thanks?

    Comment by Don — December 6, 2006 @ 5:26 pm

  8. Waffle: Yes, it seems to support IR for controlling the mouse pointer. Again, I cannot personally test it, but it works for him (the author).

    NeuralZen: heh…maybe you could just use it as a mouse pointer, and find some pre-made guesture app. Something like Freehand Gestures maybe?

    Don: This is for Linux only.

    For Windows, check out LiquidIce’s page for instructions on using GlovePIE.

    For Mac OSX, check out DarwiinRemote.

    Comment by davr — December 6, 2006 @ 5:33 pm

  9. Why oh why do people think neural networks are useful in these kinds of applications. They are cool, sure. But making something useful out of them is really really hard, and only useful for certain applications. If we should do a mouse gesture program based on neural networks it would NOT simply be plugging the x/y-coordinates into a generic neural network and everything works. By the way, problems involving time are especially hard to solve with a neural network.

    There are however other machine-learning techniques that would probably be much more useful. But it was a few years since I did that stuff, it requires some pretty complex mathematics in the area of correlations and the like.

    Comment by meros — December 6, 2006 @ 11:29 pm

  10. Thanks dude, great work :D

    Comment by Growlizing — December 7, 2006 @ 1:34 am

  11. -, +, 1 and 2 keys don’t work on my amd64(gentoo). Other keys work fine.

    message when I push 1 key:

    Traceback (most recent call last):
    File “./wiimotulator.py”, line 1178, in ?
    main_loop()
    File “./wiimotulator.py”, line 774, in main_loop
    proc_pkt19(data)
    File “./wiimotulator.py”, line 602, in proc_pkt19
    which_buttons(rawbtd)
    File “./wiimotulator.py”, line 639, in which_buttons
    update_button_states( btps )
    File “./wiimotulator.py”, line 620, in update_button_states
    bt_down(bt)
    File “./wiimotulator.py”, line 643, in bt_down
    send_command_code( command )
    File “./wiimotulator.py”, line 359, in send_command_code
    uinput_sendkey( keycode )
    File “./wiimotulator.py”, line 745, in uinput_sendkey
    ui_send_event( EV_KEY, KEY_CONST, 1 )
    File “./wiimotulator.py”, line 731, in ui_send_event
    os.write( socket['uinput'], evstruct )
    OSError: [Errno 22] Invalid argument

    64bit issue? I don’t know.
    The kernel is 2.6.18.(gentoo-sources-2.6.18-r3)

    $ zgrep -i “evdev\|uinput” /proc/config.gz
    CONFIG_INPUT_EVDEV=y
    CONFIG_INPUT_UINPUT=m
    $ lsmod | grep uinput
    uinput 7424 0

    any ideas?

    Comment by matsuu — December 7, 2006 @ 6:36 am

  12. matsuu: for 64bit linux, you could try changing line 729 from:

        STRPK_INPUT_EVENT = "LLHHl"

    To:

        STRPK_INPUT_EVENT = "LLHHi"

    I have a report from another 64bit linux user that this is all you need to do.

    Comment by davr — December 7, 2006 @ 6:50 am

  13. It works! thanks.
    But the 2 key means middle mouse button on my env.

    xorg.conf setting:
    Section “InputDevice”
    Identifier “Mouse0″
    Driver “mouse”
    Option “Protocol” “auto”
    Option “Device” “/dev/input/mice”
    Option “ZAxisMapping” “4 5″
    EndSection

    Comment by matsuu — December 7, 2006 @ 7:05 am

  14. If it’s pressing middle button instead of right button, try changing ‘BTN_RIGHT’ on line 116 to ‘BTN_MIDDLE’

    Comment by davr — December 7, 2006 @ 7:13 am

  15. I try to change to BTN_MIDDLE, but it has no action.

    Comment by matsuu — December 7, 2006 @ 7:26 am

  16. IR doesn’t work with two candles.;)

    Comment by matsuu — December 7, 2006 @ 7:37 am

  17. GentooLinuxでWiiリモコンを試す その2…
    から大幅に進展。
    Control X.Org cursor with Wiimoteで公開されたドライバにより、LinuxなどのX環境でWiiリモコンが使えるようになったらしい。赤外線センサーにも対応した模様。早速試す。

    Trackback by もしもし、matsuuですが… — December 7, 2006 @ 8:32 am

  18. Does anyone recommend any good yet cheap hardware I can throw in my ubuntu machine (its an old dell with a few card slots open) in order to make the blue tooth work?

    Comment by Peter — December 7, 2006 @ 10:10 am

  19. I’ve used this adaptor in linux before, with no problems. Disclaimer: I have no wiimote, have not tested it with a wiimote. But it should work fine. (Sidenote: Sparkfun has lots of neato stuffs, check it out)

    Comment by davr — December 7, 2006 @ 10:23 am

  20. WAIT – how about recording some moves with the wiimote and then telling emulators like ZSNES: if move=[inster your übercool wiimote move here] do tiger uppercut in streetfighter2. sounds like buying a wii itself would be obsolete…

    Comment by duncan — December 7, 2006 @ 12:54 pm

  21. My theory on this is that Nintendo didn’t secure the Wiimote so people WOULD reverse engeneer it and use it on their pc. By doing this, the Wiimote might also become very popular on other platforms, such as the PC or PS3. And since the Nintendo Wii will probably stay the only console with Wiimote-exclusive games for while, a strategy like this will most probably boost sales.

    Also, Nintendo does’t lose any money on their consoles, so they are in a strong position. Or as I would describe their situation in Dutch: “Altijd prijs.”

    Comment by MisteryMan — December 7, 2006 @ 1:26 pm

  22. Hey, It seems to detect it, but then it fails, here is my output… (Using ubuntu Edgy)

    $ sudo hidd –search
    Searching …
    Connecting to device 00:17:AB:2E:3B:38
    $ hidd
    00:17:AB:2E:3B:38 Nintendo RVL-CNT-01 [057e:0306] connected
    $ python ‘/home/omega/Desktop/wiimotulator.py’
    Registered key KEY_KPPLUS for button + with code 4e
    Registered key KEY_KPMINUS for button – with code 4a
    Registered key BTN_LEFT for button 1 with code 110
    Registered key BTN_RIGHT for button 2 with code 111
    Looking for Wiimote services at address 00:17:AB:2E:3B:38
    Victory! We have found that Wiimote!
    Traceback (most recent call last):
    File “/home/omega/Desktop/wiimotulator.py”, line 1172, in ?
    bt_connect(addr)
    File “/home/omega/Desktop/wiimotulator.py”, line 681, in bt_connect
    socket['receive'].connect( ( addr, 19 ) )
    File “”, line 5, in connect
    bluetooth.BluetoothError: (111, ‘Connection refused’)

    Comment by psymastr — December 7, 2006 @ 5:31 pm

  23. can u use this on ppc? because it would be crazy to use the wii controller on the ps3 using ydl 5.0

    Comment by z3r01 — December 7, 2006 @ 5:52 pm

  24. ydl 5.0 kernel seems to be configured without uinput.

    Comment by masaka — December 7, 2006 @ 6:40 pm

  25. [...] WiiのリモコンをLinuxで使うためのPythonスクリプトがあります。[...]

    Pingback by へっぽこ管理者の備忘録 — December 7, 2006 @ 11:13 pm

  26. Umm, need some help here… X.org registers the device as a keyboard :S

    Comment by Growlizing — December 8, 2006 @ 3:33 am

  27. [...] Tambien contar que ya por fin se esta empezando a madurar un driver del wiimote para GNU/Linux ^_^, aunque de momento esta escrito en python y no tengo ni idea si funciona y como, Control X.Org cursor with Wiimote. [...]

    Pingback by Sandia Weblog » Ya la gente empieza a “jugar” con la Wii — December 8, 2006 @ 8:21 pm

  28. anyone have any links on how to get evdev working?
    got the controller sending back info but no uinput mapped or evdev working properly

    Cheers

    Comment by NeuTek — December 9, 2006 @ 1:45 pm

  29. [...] WiiMotulator (Linux) – Turns your WiiMote into a mouse under Linux. [...]

    Pingback by Want Some WiiApps? » Archive » GAMINGtruth — December 9, 2006 @ 3:50 pm

  30. For Ubuntu edgy, i had to install python-osd as well for this to work.

    Comment by Mario — December 9, 2006 @ 10:52 pm

  31. bash: /home/miles/Desktop/wiimotulator.py : /usr/bin/python^M : mauvais interpréteur: Aucun fichier ou répertoire de ce type

    Running Ubuntu Edgy. I don’t get it.

    Comment by Miles — December 10, 2006 @ 4:41 am

  32. Miles, The problem is the file is in DOS end of line format. Either run “dos2unix wiimotulator.py” to ‘fix’ the file, or run it as “python wiimotulator.py”

    I’m also running Ubuntu Edgy on PowerPC, and I’m having the same problem as psymastr, installing python-osd as Mario suggested didn’t help.

    Comment by Rory — December 10, 2006 @ 2:38 pm

  33. [...] Among all the great articles at LiquidIce’s Nintendo Wii Hacks, I noticed: The final driver to complete Wii-Mote takeover on the computer has been posted for public consumption. e-Hernick has released python source code to use the Wii-Mote as a mouse in linux X.Org. [...]

    Pingback by Nintendo Wii News and Hacks » Blog Archive » Linux Wii-Mote Driver — December 10, 2006 @ 5:15 pm

  34. psymastr-

    I am getting the connection refused problem as well, even though the pairing of my Wiimote goes through perfectly. Did you find a solution to that problem?

    (I am pushing my luck by trying it on Ubuntu on my PC and FC5 on my PS3 :)

    Comment by Grimz — December 11, 2006 @ 4:31 pm

  35. If “python wiimotulator.py” not running, on Edgy Eft (ubuntu 6.10), try “sudo python2.5 wiimotulator.py” :)

    Comment by Cicatrice — December 12, 2006 @ 5:54 am

  36. Got it to partially work. But even with the edition of my xorg.conf file, it isn’t fully reckognized as a mouse, ie. the cursor won’t move. B is mapped to left-clic, A seems to be some sort of Ctrl+Alt (zoom out Beryl). D-Pad working fine (LED colors), + button activates the rumble.

    Comment by Miles — December 12, 2006 @ 3:48 pm

  37. Nope, still no solution. :(

    If anyone has a solution, please post it.

    Comment by psymastr — December 13, 2006 @ 9:31 pm

  38. psymastr: Did you try using both 1+2 to sync, or the red sync button (under the battery cover)? Also make sure the Wii isn’t on or something, maybe it’s connected to the Wii, and wont accept connections from the PC.

    Miles: For mouse cursor to work, you need a IR ‘sensor bar’ of some sort. A single candle in front of your monitor should be good enough to test it. You will know it’s working because Player 1 LED will be lit when it is sending position data to the PC. Note that you normally shouldn’t have to modify x.org.conf files

    Comment by davr — December 13, 2006 @ 10:25 pm

  39. Hi dude!
    Christmas Day falls on December 25. It is preceded by Christmas Eve on December 24, and in some countries is followed by Boxing Day on December 26. Some Eastern Orthodox Churches celebrate Christmas on January 7, which corresponds to December 25 on the Julian calendar. December 25 as a birthdate for Jesus is merely traditional, and is not thought to be his actual date of birth. Much respect!

    Comment by felician — December 25, 2006 @ 4:50 pm

  40. [...] Posted by me on Sunday, the 28th day of January, anno domini 2007 at 9:04 PM, local time. So, I was wandering around the web and came upon an interesting story over at Robots w/Lasers. We all knew it should be possible. We all thought it would be great. We all wanted it. Well now we have it. The Wii-mote can be used as a mouse. You don’t even need a driver or anything really, other than the normal Bluetooth and event processing stuff. There is a python script now available to translate the event stuff into mouse stuff for X.org or whatever needs the mouse. A great resource for this sort of stuff and more is over here at http://www.wiibrew.org. Very interesting stuff in there, including the math and such to convert the linear forces on the accelerometer into the rotational ones, something I know a lot of people out there were interested in. [...]

    Pingback by Complicated System of Pulleys » Wiimote Mouse — January 28, 2007 @ 7:04 pm

  41. I tried xorg.conf file, it did not work. Is there a specific edition?

    Comment by Scott Miler — March 7, 2007 @ 7:48 pm

  42. todays svn :/

    CONNECTING
    Looking for Wiimote services at address 00:17:AB:36:09:52
    Failure. We have not found that Wiimote.
    Now trying to discover a willing Wiimote, please activate your Wiimote within 5 seconds.
    FAILURE!
    Traceback (most recent call last):
    File “WMD.py”, line 45, in ?
    wmd = WMD()
    File “WMD.py”, line 40, in __init__
    if wm.connect() and wm.setup():
    File “/home/ensonic/download/wmd/wmd/Wiimote/WMManager.py”, line 21, in connect
    addr = self.backend.get_addr( )
    File “/home/ensonic/download/wmd/wmd/Wiimote/Backends/PyBlueZ.py”, line 54, in get_addr
    servs = self.find_wiimote_services( addr )
    File “/home/ensonic/download/wmd/wmd/Wiimote/Backends/PyBlueZ.py”, line 79, in find_wiimote_services
    log(LOG_INFO, “Looking for Wiimote services at address ” + addr)
    TypeError: cannot concatenate ‘str’ and ‘NoneType’ objects
    r

    Comment by Stefan Kost — April 19, 2007 @ 5:07 am

  43. great job. im still trying to make it work . but getting there. good info that helped here

    Comment by steve — May 18, 2007 @ 8:46 pm

  44. Wii リモコン…

    FrontPage 半田ごて引っ張り出そうと箱の中漁ってたら出てきた. ごめん忘れてたよ. ということでプレゼンの時にでも使いますか. Windows † WiinRemote ↑Linux † Robots w/Lasers »…

    Trackback by matoken's wiki. (PukiWiki/TrackBack 0.3) — November 8, 2007 @ 12:10 am

  45. @22 and anybody having the bluetooth.BluetoothError: (111, ‘Connection refused’) error:
    Read what I just posted about WDM usage in [link to evil site removed]
    Try running WDM without connecting first, that is let WDM do the connection – it worked on my gutsy amd64.

    Comment by UBfusion — February 15, 2008 @ 6:17 pm

  46. Занимаюсь дизайном и хочу попросить автора blog.davr.org отправить шаьлончик на мой мыил) Готов заплатить…

    Comment by Adjupt — October 14, 2008 @ 12:53 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress

Bad Behavior has blocked 2578 access attempts in the last 7 days.




Paid Advertisements
British Virgin Islands - Aquariums - Costa Rica - Renegade Motorhome