Hello. I’ve been able to use GCP to connect a Logitech game controller to Processing, mostly. I have been trying to set up the configuration file so that it only recognizes 4 buttons.
I started with the “joystick” example and have removed all the parts I don’t want to use, and everything is working fine except I can’t understand one thing.
Whenever I try to remove the “SLIDER” line from the configuration file, the sketch stops responding to the button presses. This is the config file named buttonTest3:
Buttons Only
blue Blue button 1 BUTTON 0 0 0.0 0.0
green Green button 1 BUTTON 1 0 0.0 0.0
red Red button 1 BUTTON 2 0 0.0 0.0
yellow Yellow button 1 BUTTON 3 0 0.0 0.0
X X position 3 SLIDER x 0 1.0 0.0
When I remove the last line in this file, the buttons no longer call the functions. Is there some reason a SLIDER must remain in the config? Or why might this not be working?
I tried creating a configuration with just the 4 buttons using the configuration tool, and it didn’t work. So I started over with the “joystick” example, and kept removing things until it broke, and it turns out that if this “SLIDER” line is not in the config file that’s what makes it stop working.
Can someone please help me understand what’s going on?
Here is the sketch:
import org.gamecontrolplus.gui.*;
import org.gamecontrolplus.*;
import net.java.games.input.*;
ControlIO control;
ControlDevice buttonPad;
public void setup() {
size(400, 400);
control = ControlIO.getInstance(this);
buttonPad = control.getMatchedDevice("buttonTest3");
if (buttonPad == null) {
println("No suitable device configured");
System.exit(-1);
}
buttonPad.getButton("blue").plug(this, "blueButton", ControlIO.ON_RELEASE);
buttonPad.getButton("green").plug(this, "greenButton", ControlIO.ON_RELEASE);
buttonPad.getButton("red").plug(this, "redButton", ControlIO.ON_RELEASE);
buttonPad.getButton("yellow").plug(this, "yellowButton", ControlIO.ON_RELEASE);
}
void blueButton() {
println("Blue button");
}
void greenButton() {
println("Green button");
}
void redButton() {
println("Red button");
}
void yellowButton() {
println("Yellow button");
}
public void draw() {
}