gamecontrolplus - no joystick plugged in, ignore config setup?

edited January 2016 in Library Questions

This question is perhaps to Quark, maker/porter of the great gamecontrolplus lib I've just started using to recognize an Atari USB joystick = thankyouverymuch!

Nevertheless, I'm making a simple game that is playable either with the joystick attached or the keyboard arrow keys if it's not... however I can't figure out how to ignore the popup 'select device' config feature if the joystick isn't installed when launching. I already have a switch installed to ignore the user input function if it's not plugged in.. but how can I simply start the game without an alternate joystick? Is there an ideal way to stop it??

Basic code I have right now for that part in the setup is:

control = ControlIO.getInstance(this); stick = control.getMatchedDevice("joystick"); if (stick == null) { useJoystick = false; }

Is there a simple code in the lib I've missed to check for js0 being present? The game is being made for specific setup/hardware, so no need for alternates.

Answers

  • Answer ✓

    For future reference if you need to get my attention for a particular question simply include my name (quark) preceded by an @

    So this line will cause a message sent to you @FFD8 and @quark to notify both of us that we have been mentioned in a post. Saves doing a PM as well :)

    I always assumed that if a device was not found the user would want to select an alternative connected device. Just shows the dangers of assumptions ;)

    So at the moment there is no way to stop the popup window. :(

    It's not all bad news. I will add a new method to the this library to silently load a matching device. Probably something like getMatchedDeviceSilent(...). Not sure when I will be able to release it probably next weekend.

  • @quark - Thanks for the quick reply + forum tips! :-\"

    Yeah, as I dug through the reference trying to find some function to check if/what device was there (only found getDevices), I started to have the feeling that it was implied from the beginning (and via your tutorial videos) that one would simply want to use an alternate joystick in every case.

    For now the installation/project will always have the joystick attached, so no rush to this getMatchedDeviceSilent() function - although great idea and contrib to the lib.

    About to try pushing my code to Processing v3 running on a Raspberry PI, so hoping it all goes smoothly...!

  • edited January 2016

    @quark - Hmm ran into a snag... getting an error while trying to use the lib on a Raspberry PI B+, Raspbian 8.0(?), Processing 3.0– that the library has an error, stating that:

    A library used by this sketch is not installed properly.

    UnsatisfiedLinkError:

    /home/pi/Documents/libraries/GameControlPlus/library/libjinput-linux.so: /home/pi/Documents/libraries/GameControlPlus/library/libjinput-linux.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)

    A library relies on native code that's not available.

    Or only works properly when the sketch is run as a 64-bit application.

    Unfortunately I'm not much of a linux wizz.. let alone RaspberryPi.. just enough to get Processing working fine and running on here with my sketch (now minus joystick). Any ideas off hand that might be able to fix this? Or does the lib simply require 64-bit mode (which it seems Processing on ARMv6 can't do). As for installing the library, I did it from within Processing 3, managing libs and installed. It's the only lib I'm using here except for the built in serial.

    ** I should add, that it also highlights this section of code: control = ControlIO.getInstance(this);

  • WOW- solved in a weird dumb-luck way... did more digging into the jinput lib.. armv6.. etc etc- and stumbled across this a raspberrypi project that also needed a 32-bit version of the library. Downloaded the libjinput-linux.so file from their repo:

    https://github.com/MyRobotLab/repo/tree/master/net.java.games.jinput/20120914/arm.32.linux

    Swapped out the .so file with your library and presto chango- it worked!*

    *after it did ask me to identify the controller and remap-config it = I guess that default function of reconfiguring isn't soo bad... :D

    Hope that somehow helps someone else in the future.

  • I have released V1.2.1 which includes the getMatchedDeviceSilent(...) method discussed above. It should be available through the library manager in the next couple of days.

  • That's great- thanks for the quick lib update. My occasionally joystick'less programming thanks you!

Sign In or Register to comment.