Hi,
I’m learning to use GCP and have followed this source so far. Here is the config for my Xbox controller:
When I try to run the same line of code from the tutorial I get the error message “RuntimeException: Error on calling plug: abtn”
gpad.getButton("Abtn").plug(this, "abtn", ControlIO.ON_RELEASE);
void abtn() {
getUserInput();
println("A Button Pressed");
}
Here is the rest of the code I have used. Please excuse all the svg files, i’m going to tidy it up when I have this bit sorted.
import net.java.games.input.*;
import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;
ControlIO control;
ControlDevice gpad;
float px, py;
PShape img;//full body
PShape h; //head
PShape u; //upper body
PShape l; //lower body
PShape lh; //left hand
PShape rh; //right hand
PShape lf; //left foot
PShape rf; //left foot
PShape e; //eyes
PShape m; //mouth1
void setup() {
size(1080, 1920);
// Initialise the ControlIO
control = ControlIO.getInstance(this);
// Find a device that matches the configuration file
gpad = control.getMatchedDevice("Character_Creator");
if (gpad == null) {
println("No suitable device configured");
System.exit(-1); // End the program NOW!
}
img = loadShape("Female-01.svg");
u = loadShape("FemaleTorso.svg");
l = loadShape("FemaleLegs.svg");
h = loadShape("Head.svg");
lh = loadShape("LeftHand.svg");
rh = loadShape("RightHand.svg");
lf = loadShape("LeftFoot.svg");
rf = loadShape("RightFoot.svg");
e = loadShape("Eyes-01.svg");
m = loadShape("Mouth-01.svg");
gpad.getButton("Abtn").plug(this, "abtn", ControlIO.ON_RELEASE);
}
void getUserInput() {
px = map(gpad.getSlider("X").getValue(), -1, 1, 0, width);
py = map(gpad.getSlider("Y").getValue(), -1, 1, 0, height);
}
void abtn() {
getUserInput();
println("A Button Pressed");
}
void draw() {
background(255);
//img.enableStyle(); //disables the original style of the image
//shape(img, 350, 350); //draws image at specified coordinates
shape(h, 374, 378);
shape(u, 374, 652);
shape(l, 435, 1020);
shape(lh, 390, 860);
shape(rh, 728, 667);
shape(lf, 390, 1332);
shape(rf, 600, 1332);
shape(e, 462, 526);
shape(m, 462, 590);
//img.disableStyle(); //disables the original style of the image
//fill(0); //styles the image with a new colour
}