Skip to content

Conversation

@Nintorch
Copy link
Contributor

@Nintorch Nintorch commented Dec 25, 2025

Hopefully fixes #56181 (if not, then we need to create a mapping for Xbox controllers ourselves)

This PR adds support for SDL-compatible joypad GUIDs on Android, so now we should be able to use SDL controller mapping database for Android controllers.
This PR adds support for Input.get_joy_info() for Android as well.

See also SDL's Android_AddJoystick, SDL's SDLControllerManager, and the way GUID was constructed in Godot's Linux joypad driver prior to the SDL3 joystick driver PR here.

DualShock 4 GUID before this PR

(Ignore that there's no fingerprint sensor here, it's a screenshot with a different PR applied)
Screenshot_2025-12-25-18-17-15-579_org godotengine editor v4 debug

DualShock 4 GUID after this PR + Input.get_joy_info()

Screenshot_2025-12-25-21-29-55-945_org godotengine editor v4 debug

@Nintorch Nintorch requested review from a team as code owners December 25, 2025 16:40
@Nintorch Nintorch changed the title Add support for SDL-compatible joypad GUID Add support for SDL-compatible joypad GUID on Android Dec 25, 2025
if (p_connected) {
if (p_vendor_id != 0 && p_product_id != 0) {
// Generate GUID for compatibility with SDL controller mappings.
sprintf(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", BSWAP16(5), 0, BSWAP16(p_vendor_id), 0, BSWAP16(p_product_id), 0, BSWAP16(p_button_mask), BSWAP16(p_axis_mask));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
sprintf(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", BSWAP16(5), 0, BSWAP16(p_vendor_id), 0, BSWAP16(p_product_id), 0, BSWAP16(p_button_mask), BSWAP16(p_axis_mask));
sprintf(uid, "05000000%04x0000%04x0000%04x%04x", BSWAP16(p_vendor_id), BSWAP16(p_product_id), BSWAP16(p_button_mask), BSWAP16(p_axis_mask));

}
}

int getAxisMask(List<InputDevice.MotionRange> ranges) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

// getAxisMask() and getButtonMask() were taken from SDL source code to make joypad GUIDs compatible with SDL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Xbox controller L2 and R2 inputs swapped on Android

1 participant