GameControlPlus on RaspberryPI Model5

Hi@All!

I want to use the GameControlPlus Library on the new RaspberryPi Model 5, which is aarch64 architecture. GameControlPlus uses the JInput library, which is not provided in the correct architecture in the library itself:
UnsatisfiedLinkError: /home/myuser/sketchbook/libraries/GameControlPlus/library/libjinput-linux.so: /home/myuser/sketchbook/libraries/GameControlPlus/library/libjinput-linux.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load IA 32 .so on a AARCH64 platform) A library used by this sketch relies on native code that is not available.

So I installed JInput directly on the PI via apt, which installs version “20100502+dfsg-11”, of which I copied libjinput.so to the library folder and named it libjinput-linux.so. That changes the error to:
UnsatisfiedLinkError: 'void net.java.games.input.LinuxEventDevice.nGetDeviceUsageBits(long, byte[])'

This makes me believe that my approach halfway worked, because Processing/Java could load JInput, but maybe the installed version is wrong?

Is there any way GameControlPlus could work on a raspberry pi? I would appreciate pointers in the right direction!

Kind Regards,
Christian.

1 Like

Hi Christian welcome to the forum.

As I said on my website GCP is based on a library called proCONTROLL first released 20 years ago. Even when I updated it to Processing 3 (back in 2014) I did not change any of the low level code, I simply added a higher level API. It is unlikely that GCP will work on a raspberry pi and even if it did it is unlikely to work with modern input devices.

Sorry about that :slightly_frowning_face:

1 Like

I haven’t tried it, but it looks like jamepad might be a possible alternative.

Hi@All.

Got it working for my needs, but not with GameControlPlus. I used JInput directly instead, see below.

But I got GameControlPlus somewhat running on the RaspberryPI: I installed libjinput via apt, then (if I recall correctly, has been last week and i did not pursue that approach any further) copied the *.jar (/usr/share/java/jinput.jar) and *.so (/usr/lib/jni/libjinput.so) files to the library directory (replacing the corresponding GameControlPlus files installed via processing) and renamed the *.so file to libjinput-linux.so.

Alternate Idea using JInput directly works very good:

import net.java.games.input.Controller;
import net.java.games.input.Component;

GamePad gamePad1 = null;

void setup() {
  Controller[] controllers = ControllerEnvironment.getEnvironment().getControllers();
  
  if (controllers.length > 0) {
    gamePad1 = new GamePad("Player 1 GamePad", controllers[0], 0.01);
  }
}





import net.java.games.input.Component;
import net.java.games.input.Component.Identifier;
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;

public class GamePad {
  String name = "";
  Controller controller = null;
  float switchTolerance = 0;
  
  public GamePad(String name, Controller controller, float switchTolerance) {
    this.name = name;
    this.controller = controller;
    this.switchTolerance = switchTolerance;
    
    if (controller == null || !poll()) {
      println(name + " controller not found!");
      System.exit(-1);
    }
  }
  
  public boolean poll() {
    return controller.poll();
  }
  
  private float getComponentValue(Identifier identifier){
    return controller.getComponent(identifier).getPollData();
  }
  
  private float normalize(float input) {
    if (abs(input) < 0.01) return 0;
    
    return input;
  }
  
  public float getX() { return normalize(getComponentValue(Component.Identifier.Axis.X)); }
  public float getY() { return normalize(getComponentValue(Component.Identifier.Axis.Y)); }
  public boolean isTriggerDown() { return getComponentValue(Component.Identifier.Button.TRIGGER) > 0; }
}

Regards & thanks for the help,
Christian Weber.

2 Likes