Giter VIP home page Giter VIP logo

gdx-controllers's Introduction

🎮️ Game Controller Extension for libGDX, Version 2

Use game controllers with ease in your libGDX games.

📖️ Documentation - 🎁️ Feature overview - Compatibility

🚀️ Migration guide from v1

💾️ Installation

The recommended way to use gdx-controllers is via dependency management with Gradle or Maven. Artifacts are available in Snapshot Repository and Maven Central.

Sonatype Nexus (Releases) Sonatype Nexus (Snapshots)

project-root/build.gradle:

ext {
    gdxControllersVersion = '2.0.1' // see badges above for latest versions
}

Add the following dependencies:

core:

implementation "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"

desktop:

implementation "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"

This will automatically fetch the underlying SDL-based natives and Java wrappers. If you want to use a newer version, add the dependency yourself:

implementation("com.badlogicgames.jamepad:jamepad:$jamepadVersion") {
    exclude group: 'com.badlogicgames.gdx', module: 'gdx-jnigen-loader'
}

Make sure to check the compatibility doc when doing so.

android:

implementation "com.badlogicgames.gdx-controllers:gdx-controllers-android:$gdxControllersVersion"

Proguard setting:

-keep class com.badlogic.gdx.controllers.android.AndroidControllers { *; }

ios:

implementation "com.badlogicgames.gdx-controllers:gdx-controllers-ios:$gdxControllersVersion"

robovml.xml needs the following lines added to forceLinkClasses and frameworks:

<pattern>com.badlogic.gdx.controllers.IosControllerManager</pattern> 
....
	<framework>GameController</framework>

If you forget to explicitly link the framework, no game controller will show up.

html:

implementation "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion:sources"
implementation "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion:sources"

You also need to add the following file to your GdxDefinition.gwt.xml in your html project:

<inherits name="com.badlogic.gdx.controllers" />
<inherits name="com.badlogic.gdx.controllers.controllers-gwt"/>

Building from source

To build from source, clone or download this repository, then open it in Android Studio. Perform the following command to compile and upload the library in your local repository:

gradlew clean uploadArchives -PLOCAL=true

See build.gradle file for current version to use in your dependencies.

🤝️ News & Community

You can get help on the libgdx discord.

License

The project is licensed under the Apache 2 License, meaning you can use it free of charge, without strings attached in commercial and non-commercial projects. We love to get (non-mandatory) credit in case you release a game or app using this project!

gdx-controllers's People

Contributors

00-evan avatar badlogic avatar born2snipe avatar davebaol avatar dsaltares avatar dylanfrese avatar iljagnezdilov avatar jrenner avatar klianc09 avatar mobidevelop avatar mrstahlfelge avatar nathansweet avatar nfantone avatar noblemaster avatar pokemmo avatar relu91 avatar simonit avatar stbachmann avatar tom-ski avatar tomcashman avatar wickedshell avatar winteralexander avatar xoppa avatar xyaw avatar yontipon avatar yuripourre avatar zomby2d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdx-controllers's Issues

Can't run desktop module

Versions:
gdxVersion = '1.9.11'
gdxControllersVersion = '2.0.0' or '2.0.1-SNAPSHOT'

Trying to build the desktop module results in an error of "Could not resolve com.badlogicgames.jamepad:jamepad:2.0.12.1."
Even though I know the dependency is included in the desktop dependency, I tried adding it as a separate dependency and it still would not be found. Maybe the repo location is down or the source was moved?

Can't load gamecontrollerdb.txt when using packr

Hi,
I'm having this problem where getResourceAsStream returns null when running the game with packr but doesn't when running the jar directly. This causes libGDX's controller database to fail to initialize:

Failed to load mapping with original location "gamecontrollerdb.txt", Falling back of SDL's built in mappings
java.io.IOException: Cannot open resource from classpath gamecontrollerdb.txt
        at com.studiohartman.jamepad.ControllerManager.addMappingsFromFile(ControllerManager.java:285)
        at com.studiohartman.jamepad.ControllerManager.initSDLGamepad(ControllerManager.java:90)
        at com.badlogic.gdx.controllers.desktop.JamepadControllerManager.<init>(JamepadControllerManager.java:34)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.base/java.lang.Class.newInstance(Unknown Source)
        at com.badlogic.gdx.utils.reflect.ClassReflection.newInstance(ClassReflection.java:93)
        at com.badlogic.gdx.controllers.Controllers.initialize(Controllers.java:117)
        at com.badlogic.gdx.controllers.Controllers.getControllers(Controllers.java:48)
        at net.jumpai.client.desktop.MakerKingDesktop.create(MakerKingDesktop.java:89)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:150)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)

In fact any call to this addMappingsFromFile function fails. I was able to confirm the problem is that getResourceAsStream returns null using this test code:

InputStream stream = MakerKingDesktop.class.getResourceAsStream("/biggerdb.txt");
getLogger().info("biggerdb.txt is null: " + (stream == null));

(It returns null when using packr but not null when not using packr)

In my case, both biggerdb.txt and gamecontrollerdb.txt are sitting nicely inside the root of the jar.

I suspect this is due to the weirdness of getResourceAsStream() which depends on the ClassLoader of the particular class loading this file. As other forms of classpath loading works in the game, getResourceAsStream() might just not be the proper way to load the controller database.

Platform: Linux, JDK: AdoptOpenJDK 11.0.9.1
Haven't tested on Windows yet

EDIT:

After more testing, I found out retrieving the files like this actually works: Both return valid input streams even with packr.

InputStream gcdb = FileHandle.class.getResourceAsStream("/gamecontrollerdb.txt");
InputStream biggerdb = FileHandle.class.getResourceAsStream("/biggerdb.txt");

Also this call works properly when adding a slash at the beginning:

manager.addMappingsFromFile("/biggerdb.txt");

But the internal call with gamecontrollerdb.txt still fails. Weirdly enough, the code suggests mappingsPath = "/gamecontrollerdb.txt" yet looking at the error message, the first / is missing. Looking at the code I have no clue where this forward slash went, as it doesn't seem to get stripped in the source code anywhere.

Calling manager.addMappingsFromFile() afterwards with the initial path works. So a possible workaround is to call them in this order:

// now we can initialize the controllers
Controllers.getControllers(); 
ControllerManager manager = ReflectionUtil.getStatic(JamepadControllerManager.class, "controllerManager");

// add them manually
manager.addMappingsFromFile("/gamecontrollerdb.txt");
manager.addMappingsFromFile("/biggerdb.txt");

This is still annoying because we get a error on the first initialization but we still manage to add all mappings with this technique.

EDIT 2:

OK found the issue, in JamepadControllerManager line 30, mappingPaths is initialized without a / causing all those problems. The default values of the constructor of com.studiohartman.jamepad.ControllerManager did have the same string but with the /.

Potential non reporting of events on iOS

So, I can't tell whether this bug really exists in the mobiVM backend, but I guess it does. I have encountered the bug with a fork that uses a 1 to 1 translates MOE backend.

So whats the problem:

protected void onControllerValueChanged(GCControllerElement gcControllerElement) {

The valueChangedHandler is called from objc side and expects either a object of type "GCControllerButtonInput" or "GCControllerDirectionPad".
But at this point it isn't (probably) guarenteed that "bro" (iirc this was how the java-native bridge was called in mobiVM) knows that the binding classes exist, since their static init block, that register the classes, haven't needed to run yet.
This probably leads to bro falling back to the super class when creating the binding object, so "GCControllerElement". And this object will fall through all the "instanceof" checks silently.
At least this is what happens with MOE and NatJ (MOE's bro). But I think the same will happen also with mobiVM and bro.

How to fix

A simple fix is just forcing the static init block to run at the start.

Why doesn't that happen always?

Because probably in nearly all cases "getButton" or "getAxis" is called, which would run the static init block of the classes and would register them.

public boolean getButton(int i) {
GCControllerButtonInput buttonFromConst = getButtonFromConst(i);

If I'm able to fix my setup I can say whether this bug really exists. Or anyone else can test this. Anyhow, I thought it is better to report it as not reporting it.

Maven repository

On the central i can not find v2 but only up to 1.9.13
Name change ?

Android: getCurrent is always null

On Android, while Controllers.getControllers() is not an empty list, Controllers.getCurrent() return null
if i use Controllers.getControllers().get(0), no problem

I suspect listeners.add(new ManageCurrentControllerListener()); to be the culprit.
Event is never fired because Controllers is initialized too late, after input related initiliaze events.

It tried to initialize Controllers right after Gdx (so after AndroidApplication.initialize() ) but it's not working either.
I can't register this event sooner, on Application create for exemple, since Gdx isn't ready yet....

IntelliJ Library Error (missing classes root)

When importing my project I'm getting an error from IntelliJ about an invalid classes root. I was on 2.2.0 and upgraded to 2.2.1 hoping this was maybe a cache issue that would be resolved with the new version. This does not affect compilations, but there's a nice red icon next to the library. I think there maybe just needs to be an empty res dir forced into the library, or maybe excluded from the library?

image

No controller support on MacOS?

Hi,

I've cloned the repository and build the desktop test application. A connected Nintendo Switch Pro Controller is connected and works according to https://html5gamepad.com/:

image

Unfortunately, neither in my program nor the test application any controller is found:

❯ pwd
/Users/m/Documents/gdx-controllers
❯ java -jar test/desktop/build/libs/test-1.0.0.jar
AL lib: (EE) ca_open_playback: AudioUnitInitialize failed
[Controllers] added manager for application, 1 managers active
[Controllers] 0 controllers connected.

image

I've looked for other having this problem and asked in the libgdx discord channel, but to no avail.

I'd really appreciate any help here.

Thanks,
Michael

Issues with hotplugging on Desktop

Summary

Due to using Jamepad's ControllerIndex object as the main way of tracking controllers on Desktop, Controller instances can change which physical controller they are paired with. This leads to misleading connect and disconnect events, and certain values being incorrect (maxButtonIndex) or unhelpful (uniqueId). Utilizing the SDL function SDL_JoystickGetDeviceInstanceID may be a potential solution.

As an example to demonstrate the problem

(Note: If on Windows, the controllers used in this example should be of the same type (XInput or DirectInput). See later section about why.)

  1. Connect physical controller A. gdx-controllers creates virtual controller A to take its input.
  2. Connect physical controller B. gdx-controllers creates virtual controller B to take its input.
  3. Disconnect physical controller A.

What happens next depends on the platform.

When testing on GWT, things work as I expect. Virtual controller A is reported as disconnected and removed from the list. Virtual controller B remains in the list, continues to take input from physical controller B, and all of its values remain unchanged.

When testing on Windows 7, virtual controller B is reported as disconnected and removed from the list instead. Virtual controller A now takes input from physical controller B. Its stored values (uniqueId, maxButtonIndex) are retained from virtual controller A, while values that are polled each time (controller name, playerIndex) become those of physical controller B.

(Side note: When testing on Windows 10, both controllers are reported as disconnected, and a new virtual controller is created to take input from physical controller B. I don't know why this happens. It may be a separate issue, so I won't be addressing it here. In a way, this works around the issue I'm focusing on.)

Why does this happen?

The issues on Windows 7 seem to stem from using the Jamepad object ControllerIndex as the main way of tracking controllers. A ControllerIndex represents the controller at a fixed SDL index. When a controller disconnects, SDL moves the remaining controllers to fill the lowest index slots. gdx-controllers sees that the highest index slot has become empty and assumes the controller at that index was disconnected, when in reality, the highest index becomes empty regardless of which controller actually disconnects.

What can be done?

In order to track controllers properly, we need a way to uniquely identify a physical controller from the time it is connected until it is disconnected. SDL provides a function that I believe provides such a value: SDL_JoystickGetDeviceInstanceID

https://wiki.libsdl.org/SDL2/SDL_JoystickGetDeviceInstanceID

The function is not currently exposed by libgdx/Jampad, but I believe it could be (sdl2gdx does so).

The gdx-controllers implementation on Android already seems to track controllers by the Android deviceId, so we would just be doing something similar on Desktop.

However, we still need the ControllerIndex objects, since we get our information about controllers from them. If we're trying to keep each Controller instance associated with the same physical controller for its lifetime, we'll actually need to shuffle the ControllerIndex objects between them when controllers are disconnected or connected.

Additional note about Windows specifically

Jamepad lists the following under its Current Limitations section:

"The order of gamepads on Windows is not necessarily the order they were plugged in. XInput controllers will always appear before DirectInput controllers, regardless of when they were plugged in. This means that the player numbers associated with each controller can change unexpectedly if XInput controllers are plugged in or disconnected while DirectInput controllers are present."

What this means for us is that we need to verify that each controller is with the correct ControllerIndex object not only when controllers are disconnected, but also when they are connected.

Although the above note says that XInput controllers appear first, this seems to refer to the playerIndex value. In my testing, DirectInput controllers always take the lower SDL index number. Currently, connecting a DirectInput controller can cause it to "steal" an existing instance of Controller from an existing XInput controller. A new instance is then reported as connected, holding a controller that was already present. The DirectInput controller takes over the old controller's uniqueId and maxButtonIndex.

Final comments

Let me know if my explanation wasn't clear enough or you have additional questions. It would be helpful if someone could test more platforms and operating systems (or verify my results). Do you agree with my understanding of the situation?

Mapping doesn't include LT and RT axis

The getMapping() is pretty useful, but it only includes any buttons that might be mapped to L2/R2, but for those gamepads that have triggers the mapping should also include the axis for both the left and right trigger (LT/RT).

At least on desktop the trigger seem to be properly mapped to their axis. So instead of using the mapping I've currently just hardcoded LT to axis 4 and RT to axis 5.

If it's difficult to determine what's the axis on other platforms, maybe those would just have -1 in there until someone implements it.

Getting ArrayIndexOutOfBoundsException from ControllerManager.java

I'm using the current version of gdx-controllers (2.1.0) and trying to use this library. When using a gamecube splitter adapter (USB to four gamecube ports) and a pro controller connected wirelessly, I get the following stack trace. I switched over to sdl2gdx and the problem went away, but then realized I wanted the sweet sweet functionality of controller.getMapping(), so here I am again. Right now I'm just getting around it by not using the gamecube splitter, but this is probably something to look at.

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Error creating controller manager: com.badlogic.gdx.controllers.desktop.JamepadControllerManager
at com.badlogic.gdx.controllers.Controllers.initialize(Controllers.java:110)
at com.badlogic.gdx.controllers.Controllers.getControllers(Controllers.java:48)
at com.agueliethun.vs2018.ui.MainMenu.initControllers(MainMenu.java:193)
at com.agueliethun.vs2018.ui.MainMenu.(MainMenu.java:61)
at com.agueliethun.vs2018.ui.VillainSimulator.create(VillainSimulator.java:29)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:150)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
at com.studiohartman.jamepad.ControllerManager.getControllerIndex(ControllerManager.java:236)
at com.badlogic.gdx.controllers.desktop.support.JamepadControllerMonitor.checkForNewControllers(JamepadControllerMonitor.java:33)
at com.badlogic.gdx.controllers.desktop.support.JamepadControllerMonitor.run(JamepadControllerMonitor.java:24)
at com.badlogic.gdx.controllers.desktop.JamepadControllerManager.(JamepadControllerManager.java:32)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:166)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:404)
at java.base/java.lang.Class.newInstance(Class.java:590)
at com.badlogic.gdx.utils.reflect.ClassReflection.newInstance(ClassReflection.java:93)
at com.badlogic.gdx.controllers.Controllers.initialize(Controllers.java:108)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4

Incompatible with RoboVM 2.3.19

Gdx-Controllers is currently incompatible with RoboVM 2.3.19. Using Gdx-Controllers 2.2.3 with RoboVM 2.3.19 will yield the following exception:

java.lang.NoSuchMethodError: org.robovm.apple.gamecontroller.GCController$Notifications.observeDidConnect(Lorg/robovm/objc/block/VoidBlock1;)Lorg/robovm/apple/foundation/NSObjectProtocol;
at com.badlogic.gdx.controllers.IosControllerManager.initializeControllerArray(IosControllerManager.java:86)

Due to the following changes in RoboVM: MobiVM/robovm#683

MobiVM/RoboVM dependency needs to be upgraded to 2.3.19 to resolve this.

OS X dyld: lazy symbol binding failed

Getting the following exception when running on Mac OS X 10.13.6

dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin
  Referenced from: /private/var/folders/6t/wtv2jc85473g4fq8023tpr7r0000gn/T/libgdxthomas/a2d22f08/libjamepad64.dylib
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ____chkstk_darwin
  Referenced from: /private/var/folders/6t/wtv2jc85473g4fq8023tpr7r0000gn/T/libgdxthomas/a2d22f08/libjamepad64.dylib
  Expected in: /usr/lib/libSystem.B.dylib

However, when I checked in that folder, the file is there:

libjamepad64.dylib

Seems like its due to Github Actions running on Mac OS latest according to this issue with a similar error.

Couldn't load shared library 'libjamepadarm64.dylib'

The last release doesn't work in macos with the new arm processors.

The latest version of Jamepad includes the library for macos arm, so to fix this error, we only have to update the Jamepad dependency to 2.0.14.2.

This is the error:

Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Error creating controller manager: com.badlogic.gdx.controllers.desktop.JamepadControllerManager
        at com.badlogic.gdx.controllers.Controllers.initialize(Controllers.java:119)
        at com.badlogic.gdx.controllers.Controllers.getControllers(Controllers.java:48)
        at com.bladecoder.engine.ui.UI.<init>(UI.java:78)
        at com.bladecoder.engine.BladeEngine.loadGame(BladeEngine.java:101)
        at com.bladecoder.engine.BladeEngine.create(BladeEngine.java:123)
        at com.bladecoder.engine.DesktopLauncher.create(DesktopLauncher.java:147)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.initializeListener(Lwjgl3Window.java:416)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:366)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:190)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:164)
        at com.bladecoder.engine.DesktopLauncher.run(DesktopLauncher.java:60)
        at com.bladecoder.engine.DesktopLauncher.main(DesktopLauncher.java:160)
Caused by: com.badlogic.gdx.utils.SharedLibraryLoadRuntimeException: Couldn't load shared library 'libjamepadarm64.dylib' for target: Mac OS X, 64-bit
        at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:128)
        at com.studiohartman.jamepad.ControllerManager.<init>(ControllerManager.java:66)

haptic support on iOS

Lost controller support in my games on iOS15 (and 14) and traced it back to this code:

        if (Foundation.getMajorSystemVersion() >= 14) try {
            hapticEngine = controller.getHaptics().createEngine(GCHapticsLocality.Default);
            hapticEngine.retain();
        } catch (Throwable t) {
            Gdx.app.error("Controllers", "Failed to create haptics engine", t);
        }

Tried various controllers, and I'm guessing they just don't have haptic support (or don't provide it to iOS).
And from the Apple documents it says that getHaptics() might return nil if not available.

So should this get a check first? Because right now the controller isn't created because it throws the error for the haptics engine, even tho the controller will work just fine (it does on iOS<14 when this code is skipped)

(for completeness, error given on ios15:
Controllers: Failed to create haptics engine
java.lang.NullPointerException
at com.badlogic.gdx.controllers.IosController.(IosController.java:83)
at com.badlogic.gdx.controllers.IosControllerManager.onControllerConnect(IosControllerManager.java:116)
at com.badlogic.gdx.controllers.IosControllerManager$1.invoke(IosControllerManager.java:89)
at com.badlogic.gdx.controllers.IosControllerManager$1.invoke(IosControllerManager.java:86)
at org.robovm.apple.gamecontroller.GCController$Notifications$1.invoke(GCController.java:49)
at org.robovm.apple.gamecontroller.GCController$Notifications$1.invoke(GCController.java:46)
at org.robovm.apple.foundation.NSNotificationCenter$$BlockMarshaler0.invoked(Unknown Source)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:433)
at com.orangepixel.residual.IOSLauncher.main(IOSLauncher.java:35)
)

tested with a MadCatz mfi controller but also a standard PS4 - both work fine if running on iOS13

gdx-controllers 2.2.2 requires unnecessary Android permissions due to low target SDK

Apologies, as I was the one who pushed for the release of 2.2.2, and there seems to be an issue with it.

When attempting to release an update to my app which now uses controllers 2.2.2, I was given a warning by Google Play about new permission usage.

After digging into the merged manifest I found three new permissions: READ_PHONE_STATE, READ_EXTERNAL_STORAGE, and WRITE_EXTERNAL_STORAGE. All of these have the reason: "Implied from the shattered-pixel-dungeon.android main manifest (this file), line 1; reason: com.badlogicgames.gdx.controllers has a targetSdkVersion < 4"

When comparing the manifests of the gdx-controllers-android AAR, 2.2.2 has:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.badlogicgames.gdx.controllers" >

    <uses-sdk android:minSdkVersion="1" />

    <application />

</manifest>

Tested this locally and It seems this was caused by the AGP plugin update, for some reason the gradle properties 'minSdk' and 'targetSdk' aren't sticking, but changing the variable names to anything else (e.g. "androidMinSdk and androidTargetSdk') works properly.

For the moment this can be circumvented by adding these lines to my app's manifest. Controllers 2.2.2 works just fine with the permissions removed:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>

bug in navigating up and down

I think I found a bug in ControllerMenuStage for the case where I want to use UP and DOWN keys to navigate buttons placed above each other for a jam game. And I found it was skipping some buttons on the way down, and other buttons on the way up. The buttons have different width.

In line 484 it should read 'north' because 'south' is already covered in the previous line.

                        new Vector2(direction == MoveFocusDirection.west ? currentActor.getWidth() :
                                direction == MoveFocusDirection.east ? 0 : currentActor.getWidth() / 2,
                                direction == MoveFocusDirection.south ? currentActor.getHeight() :
                                        direction == MoveFocusDirection.south ? 0 : currentActor.getHeight() / 2));

In line 519 the horizontal distance is emphasized if you are moving north or south. This should probably read east or west.

        if (direction == MoveFocusDirection.south || direction == MoveFocusDirection.north)
            horizontalDist = horizontalDist * directionEmphFactor;
        else
            verticalDist = verticalDist * directionEmphFactor;

gdx-controllers/Jamepad depends on a snapshot of gdx-jnigen-loader

I've added gdx-controllers 2.0.0 into my project but got the following error due to gdx-controllers/jamepad depending on gdx-jnigen-loader 2.0.0-SNAPSHOT.

Could not find com.badlogicgames.gdx:gdx-jnigen-loader:2.0.0-SNAPSHOT.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.pom
       - https://repo.maven.apache.org/maven2/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.jar
       - https://jcenter.bintray.com/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/maven-metadata.xml
       - https://jcenter.bintray.com/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.pom
       - https://jcenter.bintray.com/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.jar
       - https://jitpack.io/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/maven-metadata.xml
       - https://jitpack.io/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.pom
       - https://jitpack.io/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.jar
       - https://oss.sonatype.org/service/local/repositories/releases/content/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/maven-metadata.xml
       - https://oss.sonatype.org/service/local/repositories/releases/content/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.pom
       - https://oss.sonatype.org/service/local/repositories/releases/content/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.jar
       - https://maven.google.com/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/maven-metadata.xml
       - https://maven.google.com/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.pom
       - https://maven.google.com/com/badlogicgames/gdx/gdx-jnigen-loader/2.0.0-SNAPSHOT/gdx-jnigen-loader-2.0.0-SNAPSHOT.jar
     Required by:
         project :desktop-lwjgl3 > project :desktop-lwjgl3 > com.badlogicgames.gdx-controllers:gdx-controllers-desktop:2.0.0 > com.badlogicgames.jamepad:jamepad:2.0.12.1

GDX init failed: Could not load shared library libgdxdclib64.dylib: dlopen(libgdxdclib64.dylib, 2): image not found

I am using Matlab 2022a and GAMS 42.0 and the following error is displayed when running the trnsport problem:
Error using gt_cmex_gdx_write
GDX init failed: Could not load shared library libgdxdclib64.dylib:
dlopen(libgdxdclib64.dylib, 2): image not found

Error in GAMSTransfer.Container/write (line 551)
GAMSTransfer.gt_cmex_gdx_write(obj.gams_dir, filename, obj.data, ...

Error in setpath (line 49)
m.write('trnsport.gdx');
Here is the code of the trnsport problem:
addpath("/Library/Frameworks/GAMS.framework/Versions/42/Resources/apifiles/Matlab/api")

import GAMSTransfer.*

% create an empty container
m = Container();

% add sets
i = Set(m, 'i', 'records', {'seattle', 'san-diego'}, 'description', 'canning plants');
j = Set(m, 'j', 'records', {'new-york', 'chicago', 'topeka'}, 'description', 'markets');

% add parameters
a = Parameter(m, 'a', i, 'description', 'capacity of plant i in cases');
b = Parameter(m, 'b', j, 'description', 'demand at market j in cases');
d = Parameter(m, 'd', {i,j}, 'description', 'distance in thousands of miles');
f = Parameter(m, 'f', 'description', 'freight in dollars per case per thousand miles');
c = Parameter(m, 'c', {i,j}, 'description', 'transport cost in thousands of dollars per case');

% set parameter records
a.setRecords([350, 600]);
b.setRecords([325, 300, 275]);
d.setRecords([2.5, 1.7, 1.8; 2.5, 1.8, 1.4]);
f.setRecords(90);
c.setRecords([0.225, 0.153, 0.162; 0.225, 0.162, 0.126]);

% add variables
x = Variable(m, 'x', 'positive', {i,j}, 'description', 'shipment quantities in cases');
z = Variable(m, 'z', 'description', 'total transportation costs in thousands of dollars');

% set variable records
% Note: Argument order is: level, marginal, lower, upper, scale.
x.setRecords([50, 300, 0; 275, 0, 275], [0, 0, 0.036; 0, 0.009, 0]);
z.setRecords(153.675);

% (optional) transform records into different format
x.transformRecords('table');

% add equations
cost = Equation(m, 'cost', 'e', 'description', 'define objective function');
supply = Equation(m, 'supply', 'l', i, 'description', 'observe supply limit at plant i');
demand = Equation(m, 'demand', 'g', j, 'description', 'satisfy demand at market j');

% set equation records
cost.setRecords(0, 1, 0, 0);
supply.setRecords(struct('level', [350, 550], 'marginal', [SpecialValues.EPS, 0], 'upper', [350, 600]));
demand.setRecords([325, 300, 275], [0.225, 0.153, 0.126], [325, 300, 275]);

% write data to a GDX file
m.write('trnsport.gdx');

Nexilus GC Adapter not working

Exact model: https://www.amazon.ca/gp/product/B00S7CZWUQ/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

Controller used with the adapter is an original GC controller.

Note that I have another controller (Logitech gamepad) with which I can confirm my game code works properly. The issues are only with this specific GC adapter.

Behavior with version 2.2.0
Windows: Controller is neither detected or startup nor when plugged in but plugging it in doesn't cause any slowdown
Linux: Controller is not detected but upon plugging it in the game takes ~100 ms to tick for every frame instead of the usual 1-2 ms.

Another note is that there is a Wii U / PC switch on the device. All the tests were done in "PC" mode rather than Wii U mode as Wii U isn't detected as a controller on a PC. There is no slowdown on Linux in Wii U mode.

Behavior prior to version 2 (legacy gdx controllers)
Windows and Linux works perfectly fine. The only difference is on windows it detects 4 controllers even if only one controller is plugged into the adapter while on Linux it detects 1 when 1 is plugged.

The adapter works great with Dolphin (Windows and Linux), mupen64plus with the SDL controller plugin (Linux), Project 64, etc.

If you want me to try the adapter on a specific SDL application, please send it to me so I can test. I'm pretty sure mupen uses SDL for controllers though but there is also a difference between SDL 1 and 2 which might come into play?

Other weird problem with the controller adapter: if I let it plugged in into my computer it cannot boot, the bios get stucks infinitely trying to figure out what this USB is. Happens on multiple computers with different motherboards. This is the only controller/adapter I own that does this.

IntArray object spam in JamepadControllerMonitor

Method JamepadControllerMonitor#update() has line
IntArray disconnectedControllers = new IntArray(indexToController.size);

This IntArray is created every time (200-300 numbers per second). I want to suggest use some private IntArray variable for same reason.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.