Sunday, December 30, 2012

Wiimote+nunchuk web surfing in linux

At this point, messing around with the wiimote probably seems dated, but hey, I have one lying around with a motionplus and nunchuk. The final outcome of this post if you follow it- you'll be able to control your mouse cursor with the nunchuk analog stick, scroll up/down/left/right with the wiimote d-pad and left/right click with either the wiimote or the nunchuk. Let's get started.

Prerequisites:
  • A wiimote
  • A wiimote nunchuk
  • A linux system with the uinput kernel module
Procedure:
  1. Clone my fork of cwiid into a directory of your choice(wiimouse for example here)
    git clone https://github.com/trtg/cwiid.git wiimouse
  2. cd wiimouse
  3. aclocal
  4. autoconf
  5. ./configure --with-cwiid-config-dir=/etc/cwiid/
  6. make
  7. sudo make install

    Note that by default this will install everything using a prefix of /usr/local unless you pass --prefix=some_other_directory to configure so make sure whatever prefix you use is in your path.
  8. sudo modprobe uinput
  9. Create a new config file for the plugin I wrote by creating the file /etc/cwiid/nunchuk_stick_ptr and adding the text below to it
    include buttons
    Plugin.nunchuk_stick_ptr.X = REL_X
    Plugin.nunchuk_stick_ptr.Y = REL_Y
  10. sudo wminput -c nunchuk_stick_ptr You will see this message appear: Put Wiimote in discoverable mode now (press 1+2)... Do as it says and press buttons 1 and 2 on the wiimote then release them, the LEDs on the wiimote will blink for a while then the terminal where you entered the previous command will say: Ready.
  11. Now try moving the nunchuk analog stick and it should move your cursor around. Adjust /etc/cwiid/wminput/buttons if you want to change button mappings
Note: if you do not want to have to run wminput as root, you can configure things so that uinput may be accessed by users in the wheel users group. To make this happen, create a udev rules file in /etc/udev/rules.d/ with a name of your choosing, for example /etc/udev/rules.d/uinput.rules which contains the following line of text:

KERNEL=="uinput",GROUP="wheel",MODE="0660"

If you've already loaded the uinput kernel module prior to creating this file, you'll have to unload the module:
sudo rmmod uinput
and then reload it:
sudo modprobe uinput
Now you should be able to run wminput without sudo (assuming your user is in the wheel group)

15 comments:

  1. The history of surfboard fins traces back to Hawaii, where the locals started riding waves for fun using boards made of wood a century ago. In the past, the board was controlled using ones feet and hands in the water. Thanks to Tom Blake, who used his ingenuity to resolve board control problems and give rise to a modern sport loved and enjoyed by many. used surfboards san francisco

    ReplyDelete
  2. By reading this article I get a lot of lessons and this is very useful . cara menggugurkan kandungan

    ReplyDelete
  3. Both things are possible if you carry Michael Kors Handbags Wholesale. If you are a woman who goes for innovative designs, a designer Michael Kors Bags On Sale is perfect for you. Offering a huge selection of chic purses, handbags, shoes and accessories, Michael Kors Outlet Online Store celebrates womanhood in an entirely unique way. Michael Kors Factory Outlet Online Store At Wholesale Price are one of the most sought-after handbags worldwide. We all agree that diamonds are a woman's best friend; however Official Coach Factory Outlet Online are absolutely next in line. To Coach Outlet Sale aficionados, don't fret because we have great news: a discount Official Coach Outlet Online isn't hard to find. If you are a smart shopper looking for a good buy and great deals on your next handbag purchase, you can go to Official Coach Outlet Online.

    Friendly Links: Toms Shoes Womens | Toms Clearance

    ReplyDelete
  4. Great work.. Thanks for this post. Foreign travelers who wish to apply for Azerbaijan visa must check the visa requirement for azerbaijan before filling the application.

    ReplyDelete