Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

gamecontrolplus Send Serial Data

$
0
0
import net.java.games.input.*;
import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;
import processing.serial.*;

ControlIO control;
ControlDevice device;
Serial port;

void setup() {
  size(100, 100);
  println("Available serial ports:");
  println(Serial.list());
  port = new Serial(this, Serial.list()[0], 9600);
  control = ControlIO.getInstance(this);
  device = control.getMatchedDevice("xbox");

  if (device == null) {
    println("No suitable device configured");
    System.exit(-1); // End the program NOW!
  }
}

void draw() {
  if (device.getButton("BUTTONON").pressed() == true);
  {
    int msg = 0;
    port.write(msg);
  }
  if (device.getButton("BUTTONOFF").pressed() == true);
  {
    int msg = 1;
    port.write(msg);
  }
}

Greeting I know I 'm doing something really wrong with the code XD,excuse me I'm just a beginner, program recognizes the keys, Serial communication works. But send quickly a 1 or 0 so LED on pin13 blinks rapidly. Thanks :)


Viewing all articles
Browse latest Browse all 2896

Trending Articles