Add support for SDL-compatible joypad GUID and Input.get_joy_info() on Android#114338
Add support for SDL-compatible joypad GUID and Input.get_joy_info() on Android#114338Nintorch wants to merge 1 commit intogodotengine:masterfrom
Input.get_joy_info() on Android#114338Conversation
de7dcb7 to
07288ea
Compare
m4gr3d
left a comment
There was a problem hiding this comment.
Alongside manual testing, can you add unit tests to validate the added logic.
|
Thank you for your review, m4gr3d! I will be able to fix the code later today! |
07288ea to
d7bbdc3
Compare
60d7a23 to
c258401
Compare
c258401 to
0200b51
Compare
f2de833 to
39bc943
Compare
39bc943 to
dadf887
Compare
|
I'll probably have time again on Monday when an Xbox controller needs to be tested on Android. https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_MEDIA_RECORD I don't see |
|
I think adding a new key in |
e83ff26 to
1313dfe
Compare
There was a problem hiding this comment.
All keys are recognized, but LT and RT are swapped.
Godot Engine v4.7.dev.gh-114338.b25248d22 (2026-02-06 11:08:17 UTC) - https://godotengine.org
OpenGL API OpenGL ES 3.2 V@0502.0 (GIT@193b2ee, I593c16c433, 1633593732) (Date:10/07/21) - Compatibility - Using Device: Qualcomm - Adreno (TM) 650
+ Found newly connected joypad #0: Xbox Series X Controller - 050000005e040000130b0000ffff3f00
{ "raw_name": "Xbox Wireless Controller 4416", "vendor_id": "1118", "product_id": "2835" }
I think this is coming from the header file, but when I tested your SDL-PR a few days ago using the Android SDL test app, everything was OK, so it seems it's not compatible with Godot.
"050000005e040000130b0000ffff3f00,Xbox Series X Controller,a:b0,b:b1,back:b4,misc1:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
And I think we need to change the order; godotcontrollerdb.txt needs to be at the very bottom, right? So that we can override it properly.
controller_databases = [
"gamecontrollerdb.txt",
"godotcontrollerdb.txt",
"../../thirdparty/sdl/joystick/SDL_gamepad_db.h",
]|
Thank you for your review! I will see what I can do to fix this issue later when I can! |
|
That does sound like a good solution that doesn't introduce any more regressions (besides, well, what this PR does for controller mappings that don't start with |
|
I just noticed that the triggers for the older GUID for your controller are mapped with I will see what I can do. |
In my PR I used this to solve a different problem; that shouldn't be necessary anymore. Issue #99191 (lefttrigger:+a4,righttrigger:+a5)
|
|
But that's still strange that the trigger mapping hasn't changed between the previous used mapping and the current one aside of the +, but now they're swapped 😅 |
|
Ohh I see, thank you for testing! :D EDIT: The triggers are not swapped on my controller, but they are mapped to [-1;1], this will also need to be fixed without breaking my Dualshock 4 triggers |
|
So I found some differences between how Godot handles Android joypad axes and how SDL handles them. List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
Collections.sort(ranges, new RangeComparator());
for (InputDevice.MotionRange range : ranges) {
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
if (range.getAxis() == MotionEvent.AXIS_HAT_X || range.getAxis() == MotionEvent.AXIS_HAT_Y) {
joystick.hats.add(range);
} else {
joystick.axes.add(range);
}
}
}Currently in master my Xbox triggers are mapped to [-1;1]. If I remove the duplicate checking functionality, they work just fine (Dualshock 4 triggers too). This functionality was added in #45771 to fix #45712 , but to me the original issue looks more like a mapping issue that needs to be checked in SDL testcontroller too, just in case. It also provides a way to setup a mapping for the device, maybe that would be helpful too! Or if it doesn't help, we can leave the duplicate checking functionality only for Nvidia Shield controller. I'm gonna add a commit to remove the duplicate checking functionality here. May I ask if you can test your controller with that commit too, please? And I also just checked and #56181 was reported only after #45771 was merged. It may be a coincidence, or may be not :D |
a386f60 to
83fa59a
Compare
a211339 to
fb27976
Compare
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.
fb27976 to
3bdd5b3
Compare
|
I came up with a way to keep the joypad mapping system backwards-compatible with the old GUID format, see the changes in |
|
I feel like the triggers issues should be fixed in a separate PR since this PR is about the mappings and GUID, but I feel like it should still be easy enough to fix. |


Related to #56181 (if this PR doesn't fix this issue, 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 the mappings from SDL controller mapping database for Android controllers that start with
0500, while still keeping the compatibility with mappings that use the older GUID format (if a mapping with the new format can't be found, the code tries to find one with the old format).This PR adds support for
Input.get_joy_info()for Android as well.See also SDL's
Android_AddJoystick, SDL'sSDLControllerManager, 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)

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