mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-07-11 01:24:22 +02:00
Android: Set USAGE_MEDIA for rumble
This lets rumble work even if the user has turned off the Android setting Sound and vibration > Vibration and haptics > Interactive haptics > Touch feedback. Rumble can still be disabled through Dolphin's controller bindings and through in-game settings (GameCube) or SYSCONF (Wii).
This commit is contained in:
+16
-3
@@ -4,10 +4,12 @@ package org.dolphinemu.dolphinemu.features.input.model
|
||||
|
||||
import android.content.Context
|
||||
import android.hardware.input.InputManager
|
||||
import android.media.AudioAttributes
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Looper
|
||||
import android.os.VibrationAttributes
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import android.os.VibratorManager
|
||||
@@ -180,10 +182,21 @@ object ControllerInterface {
|
||||
@Keep
|
||||
@JvmStatic
|
||||
private fun vibrate(vibrator: Vibrator) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE))
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
vibrator.vibrate(
|
||||
VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE),
|
||||
VibrationAttributes.Builder().setUsage(VibrationAttributes.USAGE_MEDIA).build()
|
||||
)
|
||||
} else {
|
||||
vibrator.vibrate(100)
|
||||
val attributes = AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).build()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
vibrator.vibrate(
|
||||
VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE),
|
||||
attributes
|
||||
)
|
||||
} else {
|
||||
vibrator.vibrate(100, attributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user