libgdx / Jamepad

A better way to use gamepads in Java
Apache License 2.0
20 stars 13 forks source link

Changes necessary for gdx-controllers Desktop hotplugging changes. #16

Closed Yontipon closed 1 year ago

Yontipon commented 1 year ago

Preparation for a fix to libgdx/gdx-controllers#29

Adds ControllerIndex#getDeviceInstanceID() to return the SDL instance ID, which uniquely identifies the controller while connected. This is the necessary change of this PR. It gives us access to the information we need to track controllers properly.

ControllerManager#update() now returns a boolean that identifies if the controller list changed as a result of the call. This change is more optional, but I think it will allow us to improve performance. Instead of having to manually verify that the controller list is correct each frame, we can use this to detect when Jamepad updates its list, so we can update ours in response.

Updates SDL to 2.26.4. Updates version number to match.

Yontipon commented 1 year ago

On a related note, I've noticed another problem. The Github workflow runs on on ubuntu-18.04, but that platform was discontinued last week. I tried simply changing it to ubuntu-20.04, but it didn't seem to be enough to make it work.

MrStahlfelge commented 1 year ago

What are the problems? I can't see it because you cancelled the workflow run on your fork. Would be good to have a look at the job.

Yontipon commented 1 year ago

Last week, before ubuntu-18.04 was removed, it succeeded as far as it should have, with this warning (among others)

Compile and deploy snapshot artifacts: .github#L1 The ubuntu-18.04 environment is deprecated, consider switching to ubuntu-20.04(ubuntu-latest), or ubuntu-22.04 instead. For more details see https://github.com/actions/virtual-environments/issues/6002

Following the link shows that the timing of the image becoming unsupported coincides with the workflow breaking.

Now, trying to run on ubuntu-18.04 has the macos section finish normally, but the linux section never starts. A previous run hung for 50 minutes before I cancelled it.

I just committed the switch to 20.04, so there should be a new run to look at. It fails with this message:

Install Linux x86 compilers/libraries Run sudo apt-get -yq install gcc-multilib g++-multilib linux-libc-dev:i386 libstdc++-5-dev:i386 sudo apt-get -yq install gcc-multilib g++-multilib linux-libc-dev:i386 libstdc++-5-dev:i386 shell: /usr/bin/bash -e {0} env: GRADLE_USER_HOME: .gradle ORG_GRADLE_PROJECT_GITHUB_USERNAME: ORG_GRADLE_PROJECT_GITHUB_API_TOKEN: JAVA_HOME_8.0.362_x64: /opt/hostedtoolcache/jdk/8.0.362/x64 JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.362/x64 JAVA_HOME_8_0_362_X64: /opt/hostedtoolcache/jdk/8.0.362/x64 Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package libstdc++-5-dev:i386 E: Couldn't find any package by regex 'libstdc++-5-dev' Error: Process completed with exit code 100.

So it appears that the version of the c++ standard library we were using doesn't exist on the new ubuntu image.

Yontipon commented 1 year ago

I'm not sure what workflow runs you can see, but the last one on the main branch is the one I referenced above. Any on the WorkflowTest branch will be my attempts to improve things. I got it to progress further, but it still fails eventually, so I'm not sure if the change is useful.

It's also noteworthy that ubuntu-22.04 is also available, so we could target that instead if we want to buy ourselves more time before we have to do this again.

MrStahlfelge commented 1 year ago

Problem with switching to later versions is that it breaks compatibility, that's why we usually stay on the oldest version possible.

@PokeMMO is the expert here with these type of problems as I am not experienced with C myself. Do you think you can fix the compile on 20.04?

Yontipon commented 1 year ago

I believe I've fixed the workflow issue. I simply removed the install that was failing, and it seems to work fine without it.

Additionally, I've tested a fix for the other deprecation warnings, which may cause problems in a few months. Would you like me to apply those changes as well?

MrStahlfelge commented 1 year ago

Sure, that would be great. Thank you so much!

MrStahlfelge commented 1 year ago

We can do the changes on another PR, merged to be able to test the changes