From cfdb2abf9ed5447a70e5edefcad92996392231f1 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Tue, 26 Oct 2021 21:54:00 +0530 Subject: [PATCH] Fix Non-`builtin` Uncached `Vibrator` Getter If a non-builtin vibrator was attempted to be fetched, it'd insert it in the vibrator cache and return directly as opposed to playing the vibration on it prior to returning. This has now been fixed, the value is both put into the cache and the vibration is played on it. --- app/src/main/java/emu/skyline/EmulationActivity.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/emu/skyline/EmulationActivity.kt b/app/src/main/java/emu/skyline/EmulationActivity.kt index 9987295e..677b17ff 100644 --- a/app/src/main/java/emu/skyline/EmulationActivity.kt +++ b/app/src/main/java/emu/skyline/EmulationActivity.kt @@ -486,17 +486,18 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo for (id in InputDevice.getDeviceIds()) { val device = InputDevice.getDevice(id) if (device.descriptor == inputManager.controllers[index]!!.rumbleDeviceDescriptor) { - vibrators[index] = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { device.vibratorManager.defaultVibrator } else { @Suppress("DEPRECATION") - device.vibrator + device.vibrator!! } + vibrators[index] = vibrator + return@let vibrator } } } - } - return + } as Vibrator } val effect = VibrationEffect.createWaveform(timing, amplitude, 0)