summaryrefslogtreecommitdiffstats
path: root/platform/android/java/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/java/lib/src')
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.kt21
1 files changed, 15 insertions, 6 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
index ce53aeebcb..fbdf07e6c2 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
@@ -894,16 +894,25 @@ class Godot(private val context: Context) : SensorEventListener {
*/
@SuppressLint("MissingPermission")
@Keep
- private fun vibrate(durationMs: Int) {
+ private fun vibrate(durationMs: Int, amplitude: Int) {
if (durationMs > 0 && requestPermission("VIBRATE")) {
val vibratorService = getActivity()?.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator? ?: return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- vibratorService.vibrate(
- VibrationEffect.createOneShot(
- durationMs.toLong(),
- VibrationEffect.DEFAULT_AMPLITUDE
+ if (amplitude <= -1) {
+ vibratorService.vibrate(
+ VibrationEffect.createOneShot(
+ durationMs.toLong(),
+ VibrationEffect.DEFAULT_AMPLITUDE
+ )
)
- )
+ } else {
+ vibratorService.vibrate(
+ VibrationEffect.createOneShot(
+ durationMs.toLong(),
+ amplitude
+ )
+ )
+ }
} else {
// deprecated in API 26
vibratorService.vibrate(durationMs.toLong())