-
Notifications
You must be signed in to change notification settings - Fork 333
CHANGE: Add AndroidDeviceCapabilities.vibratorCount #2410
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,7 @@ | |
| public bool isVirtual; | ||
| public AndroidAxis[] motionAxes; | ||
| public AndroidInputSource inputSources; | ||
| public int vibratorCount; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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 ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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
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.
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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK thanks for the context. The only concern I have is that is that this might be too generic field. Like if the value is 3 is it the device + 2 rumble motors? Last point:
I understand it's not hard. But I think it won't be the same experience. I'd suggest this (if you are not planning it already): with the same gamepad on say, Windows, and Android, can you get the same "haptics experience" on both platforms with this approach?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AndroidDeviceCapabilities describes capabilities of input device (not the Android device itself) and AndroidDeviceCapabilities is per input device. Meaning:
if AndroidDeviceCapabilities class name is misleading, maybe we could change it ? But in input system package there are class names like:
that's why AndroidDeviceCapabilities was named like this, but if it would make it clearer, we could name it AndroidInputDeviceCapabilities ?
So if vibrator count 3, that would mean input device (for ex., Gamepad) has 3 vibrators. P.S I chose "vibratorCount" name, because in Android API "vibrator" word (and not motor) is used - https://developer.android.com/reference/android/os/VibratorManager#getVibratorIds()
you mean - does gamepad vibrate in the same manner both when connected to Windows machine or Android phone ? yes, that's the idea, it should vibrate in the same way. I'll ask our QA to double check on this, when https://github.cds.internal.unity3d.com/unity/unity/pull/102096 will be ready. |
||
|
|
||
| public string ToJson() | ||
| { | ||
|
|
@@ -132,8 +133,19 @@ | |
|
|
||
| public override string ToString() | ||
| { | ||
| return | ||
| $"deviceDescriptor = {deviceDescriptor}, productId = {productId}, vendorId = {vendorId}, isVirtual = {isVirtual}, motionAxes = {(motionAxes == null ? "<null>" : String.Join(",", motionAxes.Select(i => i.ToString()).ToArray()))}, inputSources = {inputSources}"; | ||
| var motionAxesString = motionAxes == null ? "<null>" : string.Join(",", motionAxes); | ||
| var entries = new[] | ||
|
Check warning on line 137 in Packages/com.unity.inputsystem/InputSystem/Plugins/Android/AndroidGameController.cs
|
||
| { | ||
| $"deviceDescriptor = {deviceDescriptor}", | ||
| $"productId = {productId}", | ||
| $"vendorId = {vendorId}", | ||
| $"isVirtual = {isVirtual}", | ||
| $"motionAxes = {motionAxesString}", | ||
| $"inputSources = {inputSources}", | ||
| $"vibratorCount = {vibratorCount}" | ||
| }; | ||
|
|
||
| return string.Join(", ", entries); | ||
|
Check warning on line 148 in Packages/com.unity.inputsystem/InputSystem/Plugins/Android/AndroidGameController.cs
|
||
|
todi1856 marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.