WiiuseCpp and PyWii

Post date: Oct 07, 2012 5:4:6 PM

Wiiusecpp is a C++ wrapper library for the wiiuse Nintendo Wiimote library. Pywii is a python swig wrapper of the wiiusecpp library and can be found as part of that library distribution. Download the library at the bottom of this page.

For those not familiar, wiiuse.net offers the following brief description for the wiiuse library:

    • Wiiuse is a library written in C that connects with several Nintendo Wii remotes. Supports motion sensing, IR tracking, nunchuk, classic controller, and the Guitar Hero 3 controller. Single threaded and nonblocking makes a light weight and clean API.

    • Licensed under GNU GPLv3 and GNU LGPLv3 (non-commercial).

This project heavily depends on wiiuse and so I offer the library with the same license options. Users of either wiiusecpp or pywii will need to download and install the wiiuse library prior to building this library.

This library has been in the wild for quite some time and I've not heard of any bugs. So for now I'm calling this stable.

My true motivation for this library is the python wiimote driver. When I started there are a few attempts at a Python wiimote library on the internet but I did not find any that were as full featured as the wiiuse library. There is a ctypes based python wrapper of wiiuse discussed here but it did not work for me and it would not have been very ‘pythonic’ since it really just gave access to the functions and structures of wiiuse. I hope I have succeeded at a functional and clean implementation with this library.

Unfortunately for now the documentation is going to be limited to reading the code of the library and examples. Most of the code is is not very complicated so it should be pretty straightforward to see how to use the libraries. The library code can be found in the source directory (wiiusecpp.h and wiiusecpp.cpp). Python users be sure to look in pywii/pywii.i for some extra python code I’ve thrown in to extend the C++ libraries. I have C++ and Python implementations roughly equivalent to the wiiuse-example program (example/example.cpp, pywii/example.py) and I tried to follow the same overall program layout so you can compare the three to see how things work. There is an extra python example (pywii/synthdemo.py) which uses wiimotes with or without the nunchuk expansion to play notes. Use the wiimotes like drumsticks to play notes and rotate them in your hand (or swing sideways) to set the pitch. If you are using the nunchuk attachment the angle you are holding it at determines the pitch. It is very crude but it shows off an application class in the library which I think is a good way to make a wiimote program.

Presently wiiuse is available for Linux and Windows. I have done all my development on Ubuntu Linux so I have not tested compilation on Windows. I don’t expect any code to be affected to make it compile on windows but the make system is Linux oriented. If anybody on Windows is so inclined to generate them I’ll add project files for VC++ to the distribution. At one point in time when I still developed on windows I had a VC++ project file that automatically generated python swig wrappers so it is possible to automate the process. Email me if you are interested in getting that working and I’ll see if I can dig up some links on how to do it. Update: It looks like the University of Rochester has a course on programming with the wiimote. They have some instructions and Visual Studio makefiles for both wiiuse and wiiusecpp here.

Download wiiusecpp_v0.12_src.tar.gz: https://drive.google.com/file/d/1x8U1kFWVb0wafU_iM9lg1Wx-3WchtUuQ/view?usp=sharing