diff options
| author | JosJuice <josjuice@gmail.com> | 2026-06-26 22:10:16 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2026-06-26 22:10:16 +0200 |
| commit | 64a73e56361cbc65e35d9a3fd03d33f6103a04a4 (patch) | |
| tree | 7df095764a4da149476125cad898c4c7d95aa585 /Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | |
| parent | 32ee8ad7ca618669f595f845aff4d59e1eb20511 (diff) | |
Android: Fix mixup between Vibrator id and index
This fixes https://bugs.dolphin-emu.org/issues/14076. The issue report
more or less already says it all, but to provide a shorter summary:
We were fetching a list of vibrator IDs, but instead of passing the
vibrator ID to the vibrator manager, we passed the index of the ID in
the list. This happened to work fine on many devices, including all
devices that use DolphinVibratorManagerCompat, due to the only Vibrator
having both an index and ID of 0. But on some devices, it failed due to
the ID of the Vibrator being 1.
This fix makes us correctly pass the ID to the vibrator manager. We
still use indices in controller INI files, both for compatibility with
the controller mappings shipped with Dolphin (which use index 0) and for
backwards compatibility with older controller INI files.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Android/Android.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index 0b0609f010..40f1e2b096 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -584,14 +584,14 @@ private: class AndroidMotor : public Core::Device::Output { public: - AndroidMotor(JNIEnv* env, jobject vibrator, jint id) - : m_vibrator(env->NewGlobalRef(vibrator)), m_id(id) + AndroidMotor(JNIEnv* env, jobject vibrator, jint index) + : m_vibrator(env->NewGlobalRef(vibrator)), m_index(index) { } ~AndroidMotor() { IDCache::GetEnvForThread()->DeleteGlobalRef(m_vibrator); } - std::string GetName() const override { return "Motor " + std::to_string(m_id); } + std::string GetName() const override { return "Motor " + std::to_string(m_index); } void SetState(ControlState state) override { @@ -606,7 +606,7 @@ public: private: const jobject m_vibrator; - const jint m_id; + const jint m_index; std::atomic<ControlState> m_state = 0; }; @@ -793,8 +793,8 @@ private: jint size = env->GetArrayLength(j_vibrator_ids); for (jint i = 0; i < size; ++i) { - jobject vibrator = - env->CallObjectMethod(vibrator_manager, s_dolphin_vibrator_manager_get_vibrator, i); + jobject vibrator = env->CallObjectMethod( + vibrator_manager, s_dolphin_vibrator_manager_get_vibrator, vibrator_ids[i]); AddOutput(new AndroidMotor(env, vibrator, i)); env->DeleteLocalRef(vibrator); } |
