diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2024-07-05 17:36:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 17:36:17 -0700 |
commit | d212b0a65700fdfa958f87c9617be3117bd89f16 (patch) | |
tree | e0ee14f52e76e99c95911338e188615813fd91c8 | |
parent | 806bf32a9cddd8bb1c3d7ac59a818c14b81da38b (diff) | |
parent | 04b710232ea16ec1ccf4f9a40b66bedf535ccef1 (diff) |
Merge pull request #25388 from garbear/android-fix-map
Android: Improve default button maps slightly
3 files changed, 13 insertions, 2 deletions
diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp index 9e622d4d73..3b1099dd3b 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp @@ -469,6 +469,10 @@ bool CAndroidJoystickState::MapButton(JOYSTICK::IButtonMap& buttonMap, int butto if (controllerButton.empty()) return false; + // Check if feature is already mapped + if (buttonMap.GetFeatureType(controllerButton) != JOYSTICK::FEATURE_TYPE::UNKNOWN) + return false; + // Map the button CLog::Log(LOGDEBUG, "Automatically mapping {} to {}", controllerButton, buttonPrimitive.ToString()); diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp index f8282eeb55..a785c9043b 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp @@ -112,6 +112,8 @@ bool CPeripheralBusAndroid::InitializeProperties(CPeripheral& peripheral) joystick.SetButtonCount(state.GetButtonCount()); joystick.SetAxisCount(state.GetAxisCount()); + std::unique_lock<CCriticalSection> lock(m_critSectionStates); + // remember the joystick state m_joystickStates.insert(std::make_pair(deviceId, std::move(state))); @@ -134,6 +136,8 @@ bool CPeripheralBusAndroid::InitializeButtonMap(const CPeripheral& peripheral, return false; } + std::unique_lock<CCriticalSection> lock(m_critSectionStates); + // get the joystick state auto it = m_joystickStates.find(deviceId); if (it == m_joystickStates.end()) @@ -325,7 +329,10 @@ void CPeripheralBusAndroid::OnInputDeviceRemoved(int deviceId) if (removed) { - m_joystickStates.erase(deviceId); + { + std::unique_lock<CCriticalSection> lock(m_critSectionStates); + m_joystickStates.erase(deviceId); + } OnDeviceRemoved(deviceLocation); } diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.h b/xbmc/platform/android/peripherals/PeripheralBusAndroid.h index 5ee9480970..59bc261e54 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.h +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.h @@ -66,7 +66,7 @@ private: mutable std::map<int, CAndroidJoystickState> m_joystickStates; PeripheralScanResults m_scanResults; - CCriticalSection m_critSectionStates; + mutable CCriticalSection m_critSectionStates; CCriticalSection m_critSectionResults; }; using PeripheralBusAndroidPtr = std::shared_ptr<CPeripheralBusAndroid>; |