diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2024-01-28 20:57:58 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2024-01-30 18:23:38 -0800 |
commit | d6e9f4144c5e4b0abe25bccceddf9acbb8134926 (patch) | |
tree | c428e4e8b090963bbf1a96e2a2b066392659ef11 | |
parent | aae5f620b1fefccffb7e83c189a79fa3df50fde7 (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; |