isXander / Controlify

Another controller mod - for fabric!
https://www.isxander.dev/mods/controlify
GNU Lesser General Public License v3.0
138 stars 29 forks source link

[Bug] Controller Reconnection Issue #172

Open Dan12Aqua opened 11 months ago

Dan12Aqua commented 11 months ago

Current Behaviour

Whenever I tried to reconnect my controller after turning it back on again while the game is running, it refused to do anything. It did recognize, but the controller refused to work.

Expected Behaviour

Usually, my controller is supposed to show a purple light on the indicator, all of the inputs does respond. But whenever I tried to reconnect it, it turned cyan(?), it did recognize it and the toast showed up, but none of the inputs does anything.

Screenshots

No response

Reproduction Steps

  1. Turn on Minecraft with the PS4 controller already recognized, the controller needs to be closed first
  2. After it loads, turn on the controller.
  3. Wait until the controller toast to show up
  4. Tap any keys, if it didn't respond, then it's not working

Logs

No response

Mod Version

1.6.0+1.20.1

Controller

PS4 Controller

Bluetooth

Operating System

Windows

ARM

Additional Information

Modpack: Fabulously Optimized 5.3.3+1.20.1 (Fabric)

Just to make sure...

isXander commented 10 months ago

Send logs of controlify after repeating those steps.

isXander commented 10 months ago

I have repeated and will put the solution here for future-me:

Cause Currently, Controlify completely relies on GLFW callbacks for controller hotplugging/disconnecting. There is a race condition between GLFW and SDL for this. If GLFW gets there first, the SDL gamecontroller is immediately opened with the joystick index, and fails because SDL has not yet recognised the device.

Solution Implement hotplug events with SDL if SDL is loaded. Abstract GLFW/SDL callback system.