Game control plus bluetooth controller


@quark, sorry to bother you…
I was wondering if it were possible to connect a bluetooth controller to processing with the game control plus library. I have a playstation 4 2nd gen controller which can connect to my laptop with bluetooth, but when I open the configurator (or the showDevices, or any self-made) sketch, it gives me this error:
ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
it also highlights the code: controlIO = ControlIO.getInstance(this);
somehow when I connect the controller over USB it works just fine. and when I connect another bluetooth device while the controller is disconnected the sketch can run too…

Is there anything else you can fill in instead of “this” in the getInstance() parameter to enable these bluetooth controllers?
or do you have any other idea that causes this problem?

I look forward to hearing from you.



I have no idea because I don’t have a Bluetooth controller to test it with.

Do the GCP examples work without the Bluetooth controller attached?

No this refers to the PApplet class object that encompasses the sketch code.

GCP is updated and extended version of proCONTROLL created and abandoned by Christian Riekoff in 2005.

The core of the library consists of

  • OS specific system exe files
  • JInput

both of these are very old pre 2005 and I don’t have the resources to modify them so GCP either works with your device or not there is little I can do. Sorry about that.


@quark thank you for your reply,
I did some more testing, initially I did it on my macbook on macOS Mojave, which gave the error like described above (and yes, the GCP examples do run without the bluetooth controller attached, even when the same controller is connected via USB).
I also have Windows installed with bootcamp, so I booted that up, tried it and it did work… I did have DS4Windows though. tried the same thing on my pc as well, without ds4windows yet and it also worked…
The final use of the controller would actually be on a raspberry pi and i thought macOS would be more similar to it than windows.
turns out it does also actually work on the Raspberry (model 3 B+ with internal bluetooth), given I did have to download a different file to make the library work at all.

All in all I haven’t figured out why it doesn’t work on my macbook, maybe mojave specific?.. But I am glad it does work on both windows and Raspberry Pi.


Happy that you seem to have it working for you. Good luck with your project. :relieved:


haha thank you!

BTW, is there an easy way to know if there is a controller available at all before connecting to it?
Like I would like to just run the sketch autonomously, but when the controller is turned on with bluetooth it connects to the Raspberry and only then processing should start the whole

control = ControlIO.getInstance(this);
  controller = control.getMatchedDevice("DS4");

  if (controller == null) {
    println("no controller found");

I know this is possible with a mouseclick, but i won’t have a mouse available at that time.
I also noticed when I run ControlIO.getInstance(this) it prints “Linux plugin claims to have found 0/1 controllers” (0/1 depending if it found 1)
Is it possible to compace this object with something? I tried with .equals and the string like above that gets printed, doesn’t work.

Edit: Also tried it with controller (which is control.getMatchedDeviceSilent(“ds4”); )
somehow this will always become null when you recall control.getMatchedDevice, even when the controller is connected.
it also doesn’t update when you disconnect the controller, it will keep saying “wireless controller” but now with and extra: “Failed to poll device: Failed to get key states (19)”
this is why i thought i had to update it again with controller = control.getMatchedDevice’Silent’(“DS4”);

Edit2: even control.getNumberOfDevices() doesn’t get updated unless you restart the entire sketch…

If you could help me with that too, it would be much appreciated! :hugs:


Have you tried ControlIO.getDevices()

control = ControlIO.getInstance(this);

Does not have to be in setup() simply call this code when a certain key is types. To avoid crashing the sketch you should check that control is not null before using it.


@quark I’m getting the error “Cannot make a static reference to the non-static method getDevices() from the type ControlIO”
I tried it with control.getDevices, which doesn’t give this error, but it still doesn’t update when I connect or disconnect the controller.