summaryrefslogtreecommitdiffstats
path: root/platform/android/java/lib/src
diff options
context:
space:
mode:
authorRadiant <i.like.using.discord@gmail.com>2024-05-02 16:15:42 +0300
committerRadiant <i.like.using.discord@gmail.com>2024-05-02 19:09:42 +0300
commit789c6ebdfd72ec9141e04ef162471983e7fdee94 (patch)
tree9a3e429a54fee6bed2cd405f3ed4ad5d4bdfd8ca /platform/android/java/lib/src
parent4e9543d8494f175bc0e772541a15c059bf6d6835 (diff)
downloadredot-engine-789c6ebdfd72ec9141e04ef162471983e7fdee94.tar.gz
Implement `amplitude` to Input.vibrate_handheld
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: m4gr3d <m4gr3d@users.noreply.github.com>
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())