Announcement

Collapse
No announcement yet.

Wiimote Button Routing into Processing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wiimote Button Routing into Processing

    Hi,

    I'm using the Wiimote through Osculator into Processing with the OSCp5 library. Can get acceleromoter and IR information through no problem - and had lots of fun playing - but have just tried to route a button press through and it doesn't seem to be working. On quickview in Osculator, I can see that the button works - produces a value of either 1.0 or 0.0 as one would expect, but I can't seem to bring that information into Processing properly - what am I doing wrong?!
    Here is the code:

    Code:
    import processing.opengl.*;
    import oscP5.*;
    import netP5.*;
    
    float x;
    float y;
    
    OscP5 osc;
    
    void setup() {
      size(400, 400, OPENGL);
    
      osc = new OscP5(this,9000);
      osc.plug(this,"pry","/wii/1/accel/pry");
      osc.plug(this,"pitch","/wii/1/accel/pry/0");
      osc.plug(this, "ir1", "/wii/1/ir/xys/1");  
      osc.plug(this, "ir2", "/wii/1/ir/xys/2");
      osc.plug(this, "trigg", "/wii/1/button/B");
    
      background(255);
      smooth();
      fill(0);
      stroke(0);
    }
    
    float pitch;
    float roll;
    float yaw;
    float ir1x;
    float ir1y;
    float ir1s;
    float ir2x;
    float ir2y;
    float ir2s;
    float triggon;
    
    void pry(float _pitch, float _roll, float _yaw, float _accel) {
      pitch = _pitch;
      roll = _roll;
      yaw = _yaw;
    }
    
    void ir1(float _ir1x, float _ir1y, float _ir1s) {
      ir1x = _ir1x
      ir1y = _ir1y;
      ir1s = _ir1s;
    }
    
    void ir2(float _ir2x, float _ir2y, float _ir2s) {
      ir2x = _ir2x;
      ir2y = _ir2y;
      ir2s = _ir2s;
    }
    
    void trigg(float _triggon) {
      triggon = _triggon;
    }
      
    void draw() {
      background(255);
      float realX = map(ir1x, 0.0, 1.0, 1.0, 0.0);
      x = realX*width;
      y = ir1y*width;
      if(triggon == 1.0) {
        fill(0);
      } else {
        fill(127);
      }
      ellipse(x, y, 30, 30);
    }

  • #2
    Hello,

    Don't you need a handler like void oscEvent(OscMessage theOscMessage)?
    It seems all the examples I've found use that to handle incoming OSC events.
    I've looked at this example.

    Best,
    Cam

    Comment


    • #3
      Aha! It seems you're right.
      I'm still struggling with how to differentiate the different OscMessages as they come in, according to whether they are coming from a button or an accelorometer... I thought if I had something like this:

      if(theOscMessage.addrPattern() == "/wii/1/buttonB") {
      if(fillon == 0) {
      fillon++;
      } else {
      fillon--;
      }

      It would work... but it doesn't.
      How can I make just the oscEvents coming in from /wii/i/button/B do one particular thing?

      Comment


      • #4
        You should read a tutorial for OSCp5 where they explain how to extract arguments from received message.
        Once you know how to get the arguments of a message and assign them to a variable, I guess you can use them in the draw() function and update the display.

        In your code snippet the address you are trying to match is not correct, a '/' is missing between 'button' and 'B'.

        Comment


        • #5
          Just to clarify, all I really want to be able to do (which I can't seem to figure out since I am so new to all this) is how to make the trigger on the Wii mote (button B) trigger something. I want it to be the equivalent of mousePressed. I'm tying myself in little knots of code trying to do it...
          All help much appreciated!
          (And forgive my stupidity. Started learning to program about a week ago).
          S

          Comment


          • #6
            Ok!
            Found this tutorial http://www.makingthings.com/document...-analog-inputs
            Sort of makes sense to me now.

            Thank you so much for your help!
            S

            Comment

            Working...
            X