godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.53k stars 20.27k forks source link

Second gamepad stops working after first is disconnected #84737

Open yhwhey opened 10 months ago

yhwhey commented 10 months ago

Godot version

4.1.3.stable

System information

Windows 10, Dualsense Controllers

Issue description

If the first gamepad (deviceId 0) connected to the machine is disconnected, the second controller (deviceId 1) stops registering input. However if the second controller disconnects, the first will continue to work.

Reconnecting the first controller causes only this controller to work and have the ID 1. The second controller still does not register

Steps to reproduce

  1. Connect a gamepad
  2. Connect a second gamepad
  3. Disconnect first gamepad
  4. Test second gamepad and note that it is no longer registering input

Also note that device ID for second gamepad has changed from 1 to 0 which I don't believe is or should be the intended behavior

Minimal reproduction project

test_controller_issue.zip

Deozaan commented 10 months ago

I can't reproduce using the MRP on 4.1.3 on Windows 10 with an Xbox 360 and Xbox One controller connected via USB. I've annotated the output from the MRP to explain what I'm doing to produce the output:

# no devices connected
[]
# connect the first device (device 0)
[0]
# press a button
d0
# connect a second device (device 1)
[0, 1]
# press buttons on each device
d1
d0
# disconnect device 0
[1] # only device 1 remains
# press a button on device 1
d1
# reconnect device 0
[0, 1]
# press buttons on each device
d0
d1
# disconnect device 1
[0] # only device 0 remains
# press a button on device 0
d0
# reconnect device 1
[0, 1]
# press a button on both devices
d1
d0

Everything appears to be working as it should.

Red-dog95 commented 4 months ago

I've noted similar behaviour as @yhwhey when disconnecting gamepads, I had the same issue with DualShock 4 controllers. Seems like disconnecting causes all the other gamepads to reassign a new device ID, which in my local multiplayer game then causes players 2 and 3 to control the characters for player 1 and 2 instead.

I'll see if I can test this out using Xinput gamepads instead to get the same result as @Deozaan.