mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-09-18 10:50:05 +00:00
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.
This commit is contained in:
+9
-3
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user