From b67188cc442d4b2d38cfb95b83cbeb0525ca257e Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 27 Jun 2026 08:43:25 +0200 Subject: Android: Make vibration length variable Previously we would vibrate for 100 ms on every vibration, which was especially annoying if a game was doing a bunch of vibrations that were supposed to be much shorter than that. Now we tell Android to vibrate for 10 s, then cancel the vibration as soon as the game turns the vibration off. --- Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Source/Core/InputCommon/ControllerInterface') diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index 40f1e2b096..1aa5275f30 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -69,6 +69,7 @@ jmethodID s_controller_interface_unregister_input_device_listener; jmethodID s_controller_interface_get_vibrator_manager; jmethodID s_controller_interface_get_system_vibrator_manager; jmethodID s_controller_interface_vibrate; +jmethodID s_controller_interface_cancel_vibration; jclass s_sensor_event_listener_class; jmethodID s_sensor_event_listener_constructor; @@ -602,6 +603,11 @@ public: IDCache::GetEnvForThread()->CallStaticVoidMethod(s_controller_interface_class, s_controller_interface_vibrate, m_vibrator); } + else if (old_state >= 0.5 && state < 0.5) + { + IDCache::GetEnvForThread()->CallStaticVoidMethod( + s_controller_interface_class, s_controller_interface_cancel_vibration, m_vibrator); + } } private: @@ -892,6 +898,8 @@ InputBackend::InputBackend(ControllerInterface* controller_interface) "()Lorg/dolphinemu/dolphinemu/features/input/model/DolphinVibratorManager;"); s_controller_interface_vibrate = env->GetStaticMethodID(s_controller_interface_class, "vibrate", "(Landroid/os/Vibrator;)V"); + s_controller_interface_cancel_vibration = env->GetStaticMethodID( + s_controller_interface_class, "cancelVibration", "(Landroid/os/Vibrator;)V"); env->DeleteLocalRef(controller_interface_class); const jclass sensor_event_listener_class = -- cgit v1.2.3