-
-
Notifications
You must be signed in to change notification settings - Fork 23.9k
Add support for SDL-compatible joypad GUID on Android #114338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
platform/android/java/lib/src/main/java/org/godotengine/godot/input/GodotInputHandler.java
Outdated
Show resolved
Hide resolved
de7dcb7 to
07288ea
Compare
platform/android/java/lib/src/main/java/org/godotengine/godot/input/GodotInputHandler.java
Outdated
Show resolved
Hide resolved
platform/android/java/lib/src/main/java/org/godotengine/godot/input/GodotInputHandler.java
Outdated
Show resolved
Hide resolved
platform/android/java/lib/src/main/java/org/godotengine/godot/input/GodotInputHandler.java
Outdated
Show resolved
Hide resolved
platform/android/java/lib/src/main/java/org/godotengine/godot/input/GodotInputHandler.java
Outdated
Show resolved
Hide resolved
platform/android/java/lib/src/main/java/org/godotengine/godot/input/GodotInputHandler.java
Outdated
Show resolved
Hide resolved
m4gr3d
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
bc31ec9 to
60d7a23
Compare
60d7a23 to
c258401
Compare
| mJoysticksDevices.put(deviceId, joystick); | ||
|
|
||
| handleJoystickConnectionChangedEvent(id, true, joystick.name); | ||
| if (Build.VERSION.SDK_INT >= 19) { // device.getVendorId() and device.getProductId() are only present in API 19 and above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (Build.VERSION.SDK_INT >= 19) { // device.getVendorId() and device.getProductId() are only present in API 19 and above. | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // InputDevice#getVendorId() and InputDevice#getProductId() are only present in API 19 and above. |
| mJoystickIds.delete(deviceId); | ||
| mJoysticksDevices.delete(deviceId); | ||
| handleJoystickConnectionChangedEvent(godotJoyId, false, ""); | ||
| handleJoystickConnectionChangedEvent(godotJoyId, false, "", 0, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the update above the button_mask and axis_mask were defaulted to -1; is there a difference with using 0 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They aren't used when a device gets disconnected
| //Helps with creating new joypad mappings. | ||
| Log.i(TAG, "=== New Input Device: " + joystick.name); | ||
|
|
||
| ArrayList<InputDevice.MotionRange> axes_motion_ranges = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ArrayList<InputDevice.MotionRange> axes_motion_ranges = new ArrayList<>(); | |
| ArrayList<InputDevice.MotionRange> axesMotionRanges = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in the updates below, parameters and variables names should use the camelCase style. snake_case is only used in the C++ codebase.
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'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()