From b67188cc442d4b2d38cfb95b83cbeb0525ca257e Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 27 Jun 2026 08:43:25 +0200 Subject: Android: Make vibration length variable Previously we would vibrate for 100 ms on every vibration, which was especially annoying if a game was doing a bunch of vibrations that were supposed to be much shorter than that. Now we tell Android to vibrate for 10 s, then cancel the vibration as soon as the game turns the vibration off. --- .../dolphinemu/features/input/model/ControllerInterface.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Source/Android/app/src/main/java') diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt index b412b6ef9b..bcd47781a0 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt @@ -186,7 +186,7 @@ object ControllerInterface { private fun vibrate(vibrator: Vibrator) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { vibrator.vibrate( - VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE), + VibrationEffect.createOneShot(10000, VibrationEffect.DEFAULT_AMPLITUDE), VibrationAttributes.Builder().setUsage(VibrationAttributes.USAGE_MEDIA).build() ) } else { @@ -194,16 +194,22 @@ object ControllerInterface { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @Suppress("DEPRECATION") vibrator.vibrate( - VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE), + VibrationEffect.createOneShot(10000, VibrationEffect.DEFAULT_AMPLITUDE), attributes ) } else { @Suppress("DEPRECATION") - vibrator.vibrate(100, attributes) + vibrator.vibrate(10000, attributes) } } } + @Keep + @JvmStatic + private fun cancelVibration(vibrator: Vibrator) { + vibrator.cancel() + } + private class InputDeviceListener : InputManager.InputDeviceListener { override external fun onInputDeviceAdded(deviceId: Int) -- cgit v1.2.3