Skip to content

Fix Input.get_joy_info() regression after the SDL input driver PR#108214

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
Nintorch:fix-joypad-vendor-product
Sep 1, 2025
Merged

Fix Input.get_joy_info() regression after the SDL input driver PR#108214
Repiteo merged 1 commit intogodotengine:masterfrom
Nintorch:fix-joypad-vendor-product

Conversation

@Nintorch
Copy link
Contributor

@Nintorch Nintorch commented Jul 2, 2025

While making the SDL input driver PR I didn't check what dictionary fields Input.get_joy_info() should return, so they went unnoticed until now.
The fields in question are "xinput_index", "raw_name", "vendor_id", "product_id" and "steam_input_index", and my PR also exposed an additional, essentially useless for the users "mapping_handled" field, that is used internally to skip Godot's gamepad mapping system (because SDL already handles that for us).
This PR should fix these issues.

Production edit: Fixes #110067

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, I found some issues.

Comment on lines 170 to 173
if (SDL_GetJoystickPlayerIndex(joy) >= 0) {
// For XInput controllers SDL_GetJoystickPlayerIndex returns the XInput user index.
joypad_info["xinput_index"] = itos(SDL_GetJoystickPlayerIndex(joy));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we name the key to be player_index instead, as it is named by SDL? I wonder if we could do like SDL and just return 0 on platforms that it doesn't work on.

Suggested change
if (SDL_GetJoystickPlayerIndex(joy) >= 0) {
// For XInput controllers SDL_GetJoystickPlayerIndex returns the XInput user index.
joypad_info["xinput_index"] = itos(SDL_GetJoystickPlayerIndex(joy));
}
joypad_info["player_index"] = itos(SDL_GetJoystickPlayerIndex(joy));

Copy link
Member

@adamscott adamscott Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that's because it was named like this before. Could we add both for the time, marking xinput_index as deprecated?

cc. @clayjohn @mhilbrunner

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of renaming it? Just to match the naming in SDL?

Copy link
Member

@adamscott adamscott Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's not that urgent. I just felt that if SDL has a different name, then it would maybe make more sense to follow its standard. (i.e. they must know what they're doing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll note that the SDL documentation specifies an unsupported value as -1 (zero-based index), while our original implementation for xinput_index only assigned a value for XInput devices. That is: if it didn't use the value, it was simply excluded

I think we should leave the name alone, and keep the SDL_GetJoystickPlayerIndex(joy) >= 0 conditional as-is, as that reflects the 4.4 behavior. We can investigate a rename in 4.6, alongside possibly passing all generic attributes in the call (unsupported platforms would have them all set to -1, or whatever SDL defines as default)

@adamscott adamscott changed the title Fix Input.get_joy_info() regression after the SDL input driver PR Fix Input.get_joy_info() regression after the SDL input driver PR Aug 28, 2025
@adamscott
Copy link
Member

I'm testing your PR on macOS and it seems that the dictionary returned by Input.get_joy_info() still empty, for some reason.

@Nintorch
Copy link
Contributor Author

Thank you for your review, adamscott!

@Nintorch Nintorch force-pushed the fix-joypad-vendor-product branch from 626e7f8 to 9848f2e Compare August 29, 2025 09:23
@Nintorch
Copy link
Contributor Author

Thank you for your review, AThousandShips! I fixed the documentation according to your changes!

@Nintorch Nintorch force-pushed the fix-joypad-vendor-product branch from 9848f2e to e9386bd Compare August 29, 2025 10:19
SDL input driver did not have the "xinput_index", "raw_name", "vendor_id" and "product_id" fields for this method and exposed an additional, essentially useless for the users "mapping_handled" field. This commit fixes these issues.
@Nintorch Nintorch force-pushed the fix-joypad-vendor-product branch from e9386bd to f28acf9 Compare August 29, 2025 17:14
@Nintorch
Copy link
Contributor Author

Thank you for your review, Repiteo!

Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good!

@Repiteo Repiteo merged commit 52a5644 into godotengine:master Sep 1, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Sep 1, 2025

Thanks!

@Nintorch Nintorch deleted the fix-joypad-vendor-product branch September 1, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing fields in Input.get_joy_info()

6 participants

Comments