wireless game controller


I’ve seen that you’re using a wireless game controller with OF, zach, how does it work?

Do you use an xbox controller through directx? Do you have some code for reading the input from a controller, like onKeyDown(int key)?

Does anyone else have experience from wireless controllers of any kind?


yes, i used the wiimote for mac. it was a little bit complicated to adapt the objectiveC framework of DarwinRemote for the c++ of OF but in the end it worked.
reliability is not really great. especially connecting the wiimote is somehow flawed. i didn’t have time to find out what is the problem, it was just for a prototype.


Cool joerg - I would love to see the wiimote in action !

I use this - “wireless logitech rumblepad”


which is about 25$ and as a nice bonus, you can basically program any of the keys to give you key commands on a per app basis. Ie, button 2 = “k” on “myDemo.exe”. So hooking it in, just for button presses, is great and very easy. it’s a great, simple device.

(ps if you are performing with it, learn about the reset button on the receiver that will resync - you may need to do it in some environments. also, it chews through batteries quickly)

I was using a while back glwf, and then I had hooked into glwf’s joystick support, ie, “glfwGetJoystickParam( id, GLFW_AXES)”

it looks like glut has a similar level of support for polling joysticks.

on another front (non wireless), someone here at eyebeam has done the wii numchuck to arduino (into OF), which is a cheap (20$) accelerometer to experiment with. it give alot of data (3axes, 2 buttons and one joystick) for very little cost.

hope that helps!

Thanks for the info,

Have you tried something called glovePIE (http://carl.kenner.googlepages.com/glovepie), as i understand it, it’s a external program you can use to map lots of game controllers (including wiimote) and vr-gloves to keyboard strokes. This might be an easy, but not optimal way to go.

I’ll try it as soon as i get my hands on a wiimote…



I found a library for c++/windows called WiiYourself (http://wiiyourself.gl.tter.org) which works super nicely. I’m so suprised! Try the Demo and be amazed how well it works, even with nunchuk or classic extension. =) Put two candle lights (or other IR-emitters) at some distance and you’ll have the pointer running as well.

There is one drawback i realized though: you need to pair the wiimote to your computer each time you restart it. This will e annoying for installations probably, but if it’s for a show or something else, it might be ok.

Another thing is that you need to download the Driver Developer Kit (which is outdated, but the old one still works, and the new version can only be reached through msdn, where you have to be a paying user as i understood it). The DDK is 600mb but you only need 1 Human Interface Lib-file. I extracted that one (for WindowsXP) and uploaded it here: http://carljohanrosen.com/files/hid.lib

The library itself is fairly easy to use if you can skip through all the crap for the gui output. I’ll try to upload an addon to of to make it simpler to understand. It will probably only work for XP though =(


Hi again,

Here is an example on how to use WiiYourself! in OF: http://carljohanrosen.com/files/wiimoteExample-visualStudio.zip

There are some instructions inside. It shouldn’t be too complicated, but i might have forgotten a step. If so, please let me know.

It includes the hid.lib file from the Driver Developer Kit i mentioned above (for WinXP). I dont know if its enough to replace this one with another one to get it running on Vista, but i got the impression that’s the case.

I will probably keep working on it and try to wrap it a bit more nicely.

rock, rock on

Thanks for example, cj. It works on Vista too.

I try to use it in CodeBlocks on Vista but can’t get it working.

-I added WiiYourself!.lib to my link library
-added the header files to my project
-added the include folder to my search directories

Does the lib file need to be compiled in an other way to be used with CodeBlocks?

I might understand what you are trying to do wrong - but you might have difficulty in using a c++ library compiled in visual studio in CB, this is because of c++ name mangling, which makes it fairly hard to share libraries across compilers. you might try building the .lib in CB itself, and the resulting lib (or .a) should be recognizable for linking.

take care!

Thanks zach,

I managed to recompile the library for use with Code::Blocks on Win32 Vista.

Download it here

jroge I am working on getting Darwiin to work on OF for the mac. How successful were you? I need to run several separate wiimotes through the IR sensor.

hey, found darwiinosc today ( http://code.google.com/p/darwiinosc/ ) which surprisingly does not have these connecting issues, and runs as standalone app sending osc messages.

it was pretty easy to glue because of osc x) its maybe not the best solution, but what about a standalone HID application that handels all the core hid events and then populates them in a clean way to oF. a bit like glovePIE.

how is oF going you integrate a many kinds of human-input-devices in a clean way? any plans? besides ofArduino which is great!

for now i use this process_message function to receive darwiinosc’s wiimote messages

virtual void process_message(ofxOscMessage _m, string _address) {  
hid_state.type = 6;  
if (_m.getNumArgs() == 1) {  
	if (_m.getArgAsInt32(0) == 1) hid_state.button_pressed = true;  
	else					          hid_state.button_pressed = false;  
	if ( _address == "/wii/button/a" )		    hid_state.button=0;  
	else if ( _address == "/wii/button/b" )	  hid_state.button=1;  
	else if ( _address == "/wii/button/up" )    hid_state.button=2;  
	else if ( _address == "/wii/button/down" )  hid_state.button=3;  
	else if ( _address == "/wii/button/left" )  hid_state.button=4;  
	else if ( _address == "/wii/button/right" ) hid_state.button=5;  
	else if ( _address == "/wii/button/minus" ) hid_state.button=6;  
	else if ( _address == "/wii/button/plus" )  hid_state.button=7;  
	else if ( _address == "/wii/button/home" )  hid_state.button=8;  
	else if ( _address == "/wii/button/one" )   hid_state.button=9;  
	else if ( _address == "/wii/button/two" )   hid_state.button=10;  
	else if ( _address == "/wii/mousemode" ) {  
		hid_state.wiimote->event_type = 4;  
		if (hid_state.button_pressed)	wiimote_state.mode = 1;  
		else							wiimote_state.mode = 0;  
		hid_state.button_pressed = false;  
		populateCurrentEvent(); return;  
	else if ( _address == "/wii/connected" ) {  
		hid_state.wiimote->event_type = 4;  
		wiimote_state.connected = hid_state.button_pressed;  
		hid_state.button_pressed = false;  
		populateCurrentEvent(); return;  
	// ofxOscMessage _c;  
	// _c.setAddress( "/wii/forcefeedback" );  
	// if (hid_state.button_pressed == true)	_c.addIntArg( 1 );  
	// else									_c.addIntArg( 0 );  
	// oscSender.sendMessage( _c );  
	hid_state.wiimote->event_type = 0;  
	populateCurrentEvent(); return;  
else if ( _address == "/wii/point" && _m.getNumArgs() == 2 ) {  
	wiimote_state.point.x = _m.getArgAsFloat(0);  
	wiimote_state.point.y = _m.getArgAsFloat(1);  
	hid_state.wiimote->event_type = 3;  
	populateCurrentEvent(); return;  
else if ( _address == "/wii/acc" && _m.getNumArgs() == 3 ) {  
	wiimote_state.acceleration.x = _m.getArgAsFloat(0);  
	wiimote_state.acceleration.y = _m.getArgAsFloat(1);  
	wiimote_state.acceleration.z = _m.getArgAsFloat(2);  
	hid_state.wiimote->event_type = 1;  
	populateCurrentEvent(); return;  
else if ( _address == "/wii/orientation" && _m.getNumArgs() == 2 ) {  
	wiimote_state.orientation.x = _m.getArgAsFloat(0);  
	wiimote_state.orientation.y = _m.getArgAsFloat(1);  
	hid_state.wiimote->event_type = 2;  
	populateCurrentEvent(); return;  

Hi Companje,
Thanks for compiling for codeblocks. I use WinXP/32bit/Codeblocks and when i’ve compiled and try to run the app it fails because it cant find the wiimote.dll. Do you have one? Or am i wrong to include the libwiimote.dll.a instead of wiimote.o? .o-files are not recognized as libs by codeblocks

Maybe you have a codeblocks project i can look at?


Hey cj

recently i compiled this for codeblocks. you need both libwiimote.dll.a for compiling and wiimote.dll to be able to run the app. don’t have the files, as this was in a workshop, and i compiled it in one of the students’ computer

i needed to compile it using msys + mingw, don’t try to use codeblocks mingw, at least for me it didn’t worked, just download mingw, install it at c:\mingw and then install msys telling it to use the new mingw, not the codeblocks one.

with this you’ll be able to do:

sh ./configure

and will compile both libwiimote.dll.a and wiimote.dll. setup the project to compile against libwiimote.dll.a and put wiimote.dll in the bin directory with the rest of the dlls so it find it when running the exe.

Thanks arturo,
Here are the lib, dll and h-files if someone needs it: http://carljohanrosen.com/share/WiiYourself-MinGW-Win32.zip

Has anyone successfully used GlovePIE for Win w/a WiiMote? I’d like to be able to make some OF code that uses ofxOSC to communicate over darwiinremote or GlovePIE but since I don’t own a win machine I can’t really start hacking myself. If anyone would be interested in helping out or has done this successfully let me know. Thanks!

Well, actually after looking at GlovePIE and working OSC, I’d prefer not to require GlovePIe and a bunch of extra scripting around that in order to get OSC working, so does anyone know of a better way to do that?

=== EDIT

ton of info on this sort of thing here: http://www.wiili.org/index.php/Wiimote-driver


I am a new to c++ and openframeworks.
I am trying to compile with Code::Blocks all the examples above, with no success…
Has anyone already compiled any of these examples with Code::Blocks?
If so, is he/she so kind to upload it? :roll:


[quote author=“petrosv”]Hello!

I am a new to c++ and openframeworks.
I am trying to compile with Code::Blocks all the examples above, with no success…
Has anyone already compiled any of these examples with Code::Blocks?
If so, is he/she so kind to upload it? :roll:


I assume you’re using windows?

First, try to set up Code:Blocks as described exacty here:
Don’t skip any steps!

Then, download the “fat” version of openframeworks,

and try to compile the examples.

It should work for you.

Thank you for your help!!!
Problem solved! (I only had to link the libwiimote.dll.a of the WiiYourself_MinGW_Win32 example).

Thank you for your time! :smiley: