Game Control Plus not getting any value from joystick

I am using Game Control Plus for a “Generic USB Joystick”. In the Gpc_Congigurator, I can easily get the X Axis and Y Axis values from the joystick.

I’m trying to just print the values of the X and Y axis but just getting 0.0 for both. And this value isn’t changing. My code :

import org.gamecontrolplus.*;
import org.gamecontrolplus.gui.*;

ControlIO control;
ControlDevice stick;

float posX, posY;

void setup(){
  control = ControlIO.getInstance(this);
  stick = control.getMatchedDevice("GameConfig");
  if(stick == null){
    println("No suitable device configured");

public void draw(){
  println(stick.getSlider("X").getValue(), stick.getSlider("X").getValue());

public void getIn(){
  posX += stick.getSlider("X").getValue();
  posY += stick.getSlider("Y").getValue();

You have only specified the x and y sliders in the configuration file so when your sketch attempts to find a matching device it will stop at the first device that have sliders called X and Y, probably the mouse. :grinning:

There are two things you can do

  1. Include something unique from the joystick in the configuration, even though you don’t use it in the sketch.
  2. If you are using the latest version of GCP you can use the filter(GCP.STICK) option see this guide
  1. I used “Axis-X”, “X-Axo” but didn’t work :confused: I don’t know if my mouse or keyboard have these sliders :?
  2. But filter(GCP.STICK) worked. Thanks a lot :smiley:

That’s not what I meant. If you look at the boxes down the centre of the screen you will see that your joystick has 5 sliders, 1 coolie-hat and numerous buttons. The names in each of these boxes are those reported by your joystick so here you are creating a config file for a device that has two sliders called “X Axis” and “Y Axis”. The problem is that your mouse might also have two sliders with the same name so when you look for a matched device both the joystick and the mouse will match so you need to be lucky to get the right one.

My suggestion here is to create a link for the “Z Rotation” slider because mice don’t have these and just because you have a link doesn’t mean you have to use it in your sketch: :wink:

Anyway glad the filter worked for you. :smile:

1 Like