MAUWii.ck

From CSWiki
(Redirected from MAUWiiI.ck)
Jump to: navigation, search
// modified from the example code that comes with Andreas Schlegel's 
// DarwiinRemote_OSC app.
// http://www.sojamo.de/
// This code also needs a Wii controller.


// create MAUI sliders for monitoring data

MAUI_View view;
view.size(300,300);

MAUI_Slider x_axis;
x_axis.name("x axis");
x_axis.range(90,160); // Wii data seems to live between 100-150
x_axis.size(300, 50);
x_axis.position(0, 0);

MAUI_Slider y_axis;
y_axis.name("y axis");
y_axis.range(90,160);
y_axis.size(300, 50);
y_axis.position(0, 50);

MAUI_Slider z_axis;
z_axis.name("z axis");
z_axis.range(90,160);
z_axis.size(300, 50);
z_axis.position(0, 100);

view.addElement(x_axis);
view.addElement(y_axis);
view.addElement(z_axis);
view.display();

// create an OSC receiver
OscRecv recv;
// use port 6449 (or whatever)
5600 => recv.port;
// start listening (launch thread)
recv.listen();

// create an address in the receiver, store in new variable
recv.event( "/wii/acc, f f f" ) @=> OscEvent oe;

// infinite event loop
while( true )
{
    // wait for event to arrive
    oe => now;

    // grab the next message from the queue. 
    while( oe.nextMsg() )
    { 
		// get values
        float x, y, z;
        oe.getFloat() => x; 
        oe.getFloat() => y;
	 oe.getFloat() => z;
	// assign them to the MAUI sliders
	x_axis.value(x);
	y_axis.value(y);
	z_axis.value(z);
    }
}