Merge pull request #107385 from Alex2782/fix_vibrate_android

Fix `Input.vibrate_handheld` on Android.
This commit is contained in:
Rémi Verschelde 2025-06-12 22:48:54 +02:00
commit 6845898461
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -1011,6 +1011,7 @@ class Godot(private val context: Context) {
@Keep
private fun vibrate(durationMs: Int, amplitude: Int) {
if (durationMs > 0 && requestPermission("VIBRATE")) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (amplitude <= -1) {
vibratorService.vibrate(
@ -1031,6 +1032,9 @@ class Godot(private val context: Context) {
// deprecated in API 26
vibratorService.vibrate(durationMs.toLong())
}
} catch (e: SecurityException) {
Log.w(TAG, "SecurityException: VIBRATE permission not found. Make sure it is declared in the manifest or enabled in the export preset.")
}
}
}