diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2024-01-28 20:57:58 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2024-02-02 08:44:55 -0800 |
commit | 55f207cc219e9cdac9420a837c05fa1ee97c1aed (patch) | |
tree | 51d0b726fcebabf323d954b09ce8ae297c708667 | |
parent | 92a3c237e8e31a9c17ed2a186bd6ae05e1ffca0a (diff) |
[Android][Peripherals] Fix input for controllers with only mouse source
-rw-r--r-- | xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp index 6564c968f1..eed225d755 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp @@ -382,8 +382,59 @@ bool CPeripheralBusAndroid::ConvertToPeripheralScanResult( if (!inputDevice.supportsSource(CJNIViewInputDevice::SOURCE_JOYSTICK) && !inputDevice.supportsSource(CJNIViewInputDevice::SOURCE_GAMEPAD)) { - CLog::Log(LOGDEBUG, "CPeripheralBusAndroid: ignoring non-joystick device"); - return false; + // Observed an anomylous PS4 controller with only SOURCE_MOUSE + if (!inputDevice.supportsSource(CJNIViewInputDevice::SOURCE_MOUSE)) + { + CLog::Log(LOGDEBUG, "CPeripheralBusAndroid: ignoring non-joystick device"); + return false; + } + + // Make sure the anomylous controller has buttons + // clang-format off + std::vector<int> buttons{ + AKEYCODE_BUTTON_A, + AKEYCODE_BUTTON_B, + AKEYCODE_BUTTON_C, + AKEYCODE_BUTTON_X, + AKEYCODE_BUTTON_Y, + AKEYCODE_BUTTON_Z, + AKEYCODE_BUTTON_L1, + AKEYCODE_BUTTON_R1, + AKEYCODE_BUTTON_L2, + AKEYCODE_BUTTON_R2, + AKEYCODE_BUTTON_THUMBL, + AKEYCODE_BUTTON_THUMBR, + AKEYCODE_BUTTON_START, + AKEYCODE_BUTTON_SELECT, + AKEYCODE_BUTTON_MODE, + AKEYCODE_BUTTON_1, + AKEYCODE_BUTTON_2, + AKEYCODE_BUTTON_3, + AKEYCODE_BUTTON_4, + AKEYCODE_BUTTON_5, + AKEYCODE_BUTTON_6, + AKEYCODE_BUTTON_7, + AKEYCODE_BUTTON_8, + AKEYCODE_BUTTON_9, + AKEYCODE_BUTTON_10, + AKEYCODE_BUTTON_11, + AKEYCODE_BUTTON_12, + AKEYCODE_BUTTON_13, + AKEYCODE_BUTTON_14, + AKEYCODE_BUTTON_15, + AKEYCODE_BUTTON_16, + }; + // clang-format on + + auto result = inputDevice.hasKeys(buttons); + + if (std::find(result.begin(), result.end(), true) == result.end()) + { + CLog::Log(LOGDEBUG, "CPeripheralBusAndroid: ignoring non-joystick device with mouse source"); + return false; + } + + CLog::Log(LOGDEBUG, "CPeripheralBusAndroid: adding non-joystick device with mouse source"); } peripheralScanResult.m_type = PERIPHERAL_JOYSTICK; |