[Bug] Incompatible controllers cause failures in compatible controllers #657

Open
opened 2025-02-13 04:05:39 +00:00 by hugleo · 0 comments
hugleo commented 2025-02-13 04:05:39 +00:00 (Migrated from github.com)

Description of the issue

Suppose I have one invalid gamepad. The faulty incompatible is at SDL index 0, while the functional gamepad is at SDL index 1.

For the incompatible controller this part of the code will not be executed:

https://github.com/Ryubing/Ryujinx/blob/master/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs#L99

Then, for the compatible controller, the Add method will be executed, creating a valid gamepad at SDL index 0, which should actually be at SDL index 1.

https://github.com/Ryubing/Ryujinx/blob/master/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs#L122

This will fail here, trying to read from SDL index 0, which is invalid, instead of index 1:

https://github.com/Ryubing/Ryujinx/blob/master/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs#L167

Maybe using different logic or a dictionary instead of a list would be better since the joystickDeviceId matters.

Reproduction steps

Plug a Incompatible gamepad, then plug a good gamepad together (or, of course, fix the Incompatible gamepad with xboxdrv, will be available two devices in system, the in kernel incompatible and the compatible xboxdrv in userspace). Neither gamepad will be added to the configuration because SDL will try to read the wrong index.

Log file

Some addtionao comments added on code.


00:00:00.567 |E| .NET TP Worker ATTENTION: default value of option mesa_glthread overridden by environment.
00:00:00.606 |E| .NET TP Worker ATTENTION: default value of option mesa_glthread overridden by environment.
00:00:00.608 |E| .NET TP Worker ATTENTION: default value of option mesa_glthread overridden by environment.
Number of connected joysticks at initialization: 3
Joystick 0 is not a valid game controller, proceeding to check next.
Handling joystick 1, generated ID 0-b8810003-045e-0000-8e02-000014010000
Added joystick 1 0-b8810003-045e-0000-8e02-000014010000 to the list of gamepads.
Handling joystick 2, generated ID 0-b8810003-045e-0000-8e02-000010010000
Added joystick 2 0-b8810003-045e-0000-8e02-000010010000 to the list of gamepads.
Joystick 0 is not a valid game controller, proceeding to check next.
Joystick 1 is already connected.
Joystick 2 is already connected.
Failed to open gamepad 0-b8810003-045e-0000-8e02-000014010000 with index 0.

OS

Arch Linux

Ryujinx version

1.2.81

Game version

No response

CPU

No response

GPU

No response

RAM

No response

List of applied mods

No response

Additional context?

No response

### Description of the issue Suppose I have one invalid gamepad. The faulty incompatible is at SDL index 0, while the functional gamepad is at SDL index 1. For the incompatible controller this part of the code will not be executed: https://github.com/Ryubing/Ryujinx/blob/master/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs#L99 Then, for the compatible controller, the Add method will be executed, creating a valid gamepad at SDL index 0, which should actually be at SDL index 1. https://github.com/Ryubing/Ryujinx/blob/master/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs#L122 This will fail here, trying to read from SDL index 0, which is invalid, instead of index 1: https://github.com/Ryubing/Ryujinx/blob/master/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs#L167 Maybe using different logic or a dictionary instead of a list would be better since the joystickDeviceId matters. ### Reproduction steps Plug a Incompatible gamepad, then plug a good gamepad together (or, of course, fix the Incompatible gamepad with xboxdrv, will be available two devices in system, the in kernel incompatible and the compatible xboxdrv in userspace). Neither gamepad will be added to the configuration because SDL will try to read the wrong index. ### Log file Some addtionao comments added on code. ``` 00:00:00.567 |E| .NET TP Worker ATTENTION: default value of option mesa_glthread overridden by environment. 00:00:00.606 |E| .NET TP Worker ATTENTION: default value of option mesa_glthread overridden by environment. 00:00:00.608 |E| .NET TP Worker ATTENTION: default value of option mesa_glthread overridden by environment. Number of connected joysticks at initialization: 3 Joystick 0 is not a valid game controller, proceeding to check next. Handling joystick 1, generated ID 0-b8810003-045e-0000-8e02-000014010000 Added joystick 1 0-b8810003-045e-0000-8e02-000014010000 to the list of gamepads. Handling joystick 2, generated ID 0-b8810003-045e-0000-8e02-000010010000 Added joystick 2 0-b8810003-045e-0000-8e02-000010010000 to the list of gamepads. Joystick 0 is not a valid game controller, proceeding to check next. Joystick 1 is already connected. Joystick 2 is already connected. Failed to open gamepad 0-b8810003-045e-0000-8e02-000014010000 with index 0. ``` ### OS Arch Linux ### Ryujinx version 1.2.81 ### Game version _No response_ ### CPU _No response_ ### GPU _No response_ ### RAM _No response_ ### List of applied mods _No response_ ### Additional context? _No response_
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MeloNX/Ryujinx-ryubing#657
No description provided.