/*
  oscemote.pde

  The simplest possible example of using oscemote with Processing
  For a couple slightly more sophisticated examples, check out:
  ../../../../2009/05/13/iphone-and-processing/  
  
  rob@rahji.com 
  http://www.robduarte.com 
  http://creativecommons.org/licenses/by/3.0/us/
*/

import oscP5.*;
import netP5.*;

OscP5 oscP5;

void setup() {
  
  oscP5 = new OscP5(this,8000); // start listening for osc messages on port 8000
  
  // look at the oscemote wiki for the format of the messages that oscemote sends
  // based on those formats, assign a callback function to each message of that format...

  // tuio messages might be easier handled using the TUIO library for Processing
  // at http://www.tuio.org/?processing but it's not that hard to do without it...
  
  oscP5.plug(this,"tuio_function","/tuio/2Dcur","sifffff");

  // the above format matches a "set" message as shown in the wiki:
  // eg:  /tuio/2Dcur set 1 0.41875 0.6691 0 0 0

  // the other messages are even simpler to identify...

  oscP5.plug(this,"accel_function","/acceleration/xyz","fff"); // accelerometer
  oscP5.plug(this,"slider_function","/slider/1","f");          // slider
  oscP5.plug(this,"switch_function","/switch/1","i");          // sliding switch
  oscP5.plug(this,"button_function","/button/B2","i");         // button

}

// we can do something interesting with the values in these functions, of course,
// but for now just print the values
  
public void tuio_function(String s, int i, float fx, float fy, float fvx, float fvy, float fa) {  
  println("finger # " + i);
  println("finger x:" + fx + " y:" + fy);
  println("speed/direction  x:" + fvx + " y:" + fvy + " acceleration:" + fa);
}
 
public void accel_function(float x, float y, float z) {
  println("accelerometer x:" + x + " y:" + y + " z:" + z);
}

public void slider_function(float f) {
  println("slider1: " + f);
}
   
public void switch_function(int i) {
  println("switch1: " + i);
}

public void button_function(int i) {
  println("button B2: " + i);
}

void draw() {
}