Skip to content

CHANGE: Add AndroidDeviceCapabilities.vibratorCount#2410

Open
todi1856 wants to merge 2 commits intodevelopfrom
android/device-capabilities-add-vibrator-count
Open

CHANGE: Add AndroidDeviceCapabilities.vibratorCount#2410
todi1856 wants to merge 2 commits intodevelopfrom
android/device-capabilities-add-vibrator-count

Conversation

@todi1856
Copy link
Copy Markdown
Member

@todi1856 todi1856 commented Apr 20, 2026

Description

Android team is adding rumble support for gamepads - https://jira.unity3d.com/browse/PLAT-19228 (The changes will be done mainly in Android's backend). One of the changes is DeviceCapabilities expansion - https://github.cds.internal.unity3d.com/unity/unity/pull/102096/commits/f682823cc6640dddb48d172bb57cb1f2bdd2b460

Basically it allows you to query how many motors (a.k.a vibrators in Android term) the device has.

This PR simply mirrors the change on input system package.

Note AndroidDeviceCapabilities is an internal class, so no user facing changes, additionally if backend doesn't report vibratorCount, it will simply default to 0.

@todi1856 todi1856 changed the title Add AndroidDeviceCapabilities.vibratorCount CHANGE: Add AndroidDeviceCapabilities.vibratorCount Apr 20, 2026
@todi1856 todi1856 requested a review from jfreire-unity April 20, 2026 13:00
Copy link
Copy Markdown
Contributor

@u-pr u-pr bot left a comment

Choose a reason for hiding this comment

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

Great
The review identified a potential missing field in serialization and minor performance concerns regarding string allocations and joining logic.

🤖 Helpful? 👍/👎

@codecov-github-com
Copy link
Copy Markdown

codecov-github-com bot commented Apr 20, 2026

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...putSystem/Plugins/Android/AndroidGameController.cs 0.00% 3 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2410      +/-   ##
===========================================
- Coverage    78.13%   78.12%   -0.01%     
===========================================
  Files          483      483              
  Lines        98770    98771       +1     
===========================================
- Hits         77169    77166       -3     
- Misses       21601    21605       +4     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.34% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_2022.3_project 75.38% <0.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.27% <0.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.27% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.28% <0.00%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6_project 77.31% <0.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_2022.3_project 75.28% <0.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.18% <0.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.17% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.22% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.22% <0.00%> (+<0.01%) ⬆️
inputsystem_Windows_2022.3 5.34% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_2022.3_project 75.50% <0.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.40% <0.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.39% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.40% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.44% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6_project 77.45% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...putSystem/Plugins/Android/AndroidGameController.cs 77.41% <0.00%> (-2.59%) ⬇️

... and 1 file with indirect coverage changes

ℹ️ Need help interpreting these results?

public bool isVirtual;
public AndroidAxis[] motionAxes;
public AndroidInputSource inputSources;
public int vibratorCount;
Copy link
Copy Markdown
Collaborator

@jfreire-unity jfreire-unity Apr 20, 2026

Choose a reason for hiding this comment

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

Is this only gamepad specific?

AFAIK, the Android vibrator API you mentioned is not compatible with our rumble API.
The vibrator API, at least for the android device itself, usually allows you to control the duration and, in some devices, the amplitude of vibrations, and doesn't match the concepts of motor speed in a controller.

From the Jira comments, I got a bit confused, and I believe you need to use these gamepad specific APIs instead to match our rumble interface https://developer.android.com/games/sdk/game-controller/controller-features#java ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this only gamepad specific?

Yes and no, https://developer.android.com/reference/android/view/InputDevice#public-methods is heavily abstracted class, thus in theory and input device can have a vibrator. Though so far, I saw vibrators only available on gamepads

AFAIK, the Android vibrator API you mentioned is not compatible with our rumble API.
The vibrator API, at least for the android device itself, usually allows you to control the duration and, in some devices, the amplitude of vibrations, and doesn't match the concepts of motor speed in a controller.

it's compatible enough, connecting Android vibration API to https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.Haptics.IDualMotorRumble.html is not that hard. Sure we could go further and have Android specific vibrator APIs to expose everything Android provides, but this is outside of that scope.

From the Jira comments, I got a bit confused, and I believe you need to use these gamepad specific APIs instead to match our rumble interface https://developer.android.com/games/sdk/game-controller/controller-features#java ?

There are not plans to use game-controller library in Unity , having access to https://developer.android.com/reference/android/view/InputDevice#public-methods is good enough for us.

@todi1856 todi1856 requested a review from jfreire-unity April 21, 2026 05:07
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.

2 participants