diff --git a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp index 69bb689a95d27..0305ee175b1c0 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickState.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickState.cpp @@ -100,10 +100,11 @@ bool CAndroidJoystickState::Initialize(const CJNIViewInputDevice& inputDevice) !motionRange.isFromSource(CJNIViewInputDevice::SOURCE_GAMEPAD)) { CLog::Log(LOGDEBUG, - "CAndroidJoystickState: ignoring axis {} from source {} for input device \"{}\" " - "with ID {}", - motionRange.getAxis(), motionRange.getSource(), deviceName, m_deviceId); - continue; + "CAndroidJoystickState: axis {} has unexpected source {} ({}) for input device " + "\"{}\" with ID {}", + motionRange.getAxis(), + CAndroidJoystickTranslator::TranslateSource(motionRange.getSource()), + motionRange.getSource(), deviceName, m_deviceId); } int axisId = motionRange.getAxis(); @@ -115,15 +116,41 @@ bool CAndroidJoystickState::Initialize(const CJNIViewInputDevice& inputDevice) motionRange.getRange(), motionRange.getResolution()}; - // check if the axis ID belongs to a D-pad, analogue stick or trigger - if (axisId == AMOTION_EVENT_AXIS_HAT_X || axisId == AMOTION_EVENT_AXIS_HAT_Y || - axisId == AMOTION_EVENT_AXIS_X || axisId == AMOTION_EVENT_AXIS_Y || - axisId == AMOTION_EVENT_AXIS_Z || axisId == AMOTION_EVENT_AXIS_RX || - axisId == AMOTION_EVENT_AXIS_RY || axisId == AMOTION_EVENT_AXIS_RZ || - axisId == AMOTION_EVENT_AXIS_LTRIGGER || axisId == AMOTION_EVENT_AXIS_RTRIGGER || - axisId == AMOTION_EVENT_AXIS_GAS || axisId == AMOTION_EVENT_AXIS_BRAKE || - axisId == AMOTION_EVENT_AXIS_THROTTLE || axisId == AMOTION_EVENT_AXIS_RUDDER || - axisId == AMOTION_EVENT_AXIS_WHEEL) + // check if the axis ID belongs to a D-pad, analogue stick, trigger or + // generic axis + // clang-format off + if (axisId == AMOTION_EVENT_AXIS_HAT_X || + axisId == AMOTION_EVENT_AXIS_HAT_Y || + axisId == AMOTION_EVENT_AXIS_X || + axisId == AMOTION_EVENT_AXIS_Y || + axisId == AMOTION_EVENT_AXIS_Z || + axisId == AMOTION_EVENT_AXIS_RX || + axisId == AMOTION_EVENT_AXIS_RY || + axisId == AMOTION_EVENT_AXIS_RZ || + axisId == AMOTION_EVENT_AXIS_LTRIGGER || + axisId == AMOTION_EVENT_AXIS_RTRIGGER || + axisId == AMOTION_EVENT_AXIS_GAS || + axisId == AMOTION_EVENT_AXIS_BRAKE || + axisId == AMOTION_EVENT_AXIS_THROTTLE || + axisId == AMOTION_EVENT_AXIS_RUDDER || + axisId == AMOTION_EVENT_AXIS_WHEEL || + axisId == AMOTION_EVENT_AXIS_GENERIC_1 || + axisId == AMOTION_EVENT_AXIS_GENERIC_2 || + axisId == AMOTION_EVENT_AXIS_GENERIC_3 || + axisId == AMOTION_EVENT_AXIS_GENERIC_4 || + axisId == AMOTION_EVENT_AXIS_GENERIC_5 || + axisId == AMOTION_EVENT_AXIS_GENERIC_6 || + axisId == AMOTION_EVENT_AXIS_GENERIC_7 || + axisId == AMOTION_EVENT_AXIS_GENERIC_8 || + axisId == AMOTION_EVENT_AXIS_GENERIC_9 || + axisId == AMOTION_EVENT_AXIS_GENERIC_10 || + axisId == AMOTION_EVENT_AXIS_GENERIC_11 || + axisId == AMOTION_EVENT_AXIS_GENERIC_12 || + axisId == AMOTION_EVENT_AXIS_GENERIC_13 || + axisId == AMOTION_EVENT_AXIS_GENERIC_14 || + axisId == AMOTION_EVENT_AXIS_GENERIC_15 || + axisId == AMOTION_EVENT_AXIS_GENERIC_16) + // clang-format on { // check if this axis is already known if (ContainsAxis(axisId, m_axes)) diff --git a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp index a665f45a9c36c..7e58552e87d5f 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace PERIPHERALS; @@ -694,3 +695,33 @@ const char* CAndroidJoystickTranslator::TranslateKeyCode(int keyCode) return "unknown"; } + +const char* CAndroidJoystickTranslator::TranslateSource(int source) +{ + // clang-format off + static const std::vector> sources{ + {CJNIViewInputDevice::SOURCE_DPAD, "SOURCE_DPAD"}, + {CJNIViewInputDevice::SOURCE_GAMEPAD, "SOURCE_GAMEPAD"}, + {CJNIViewInputDevice::SOURCE_HDMI, "SOURCE_HDMI"}, + {CJNIViewInputDevice::SOURCE_JOYSTICK, "SOURCE_JOYSTICK"}, + {CJNIViewInputDevice::SOURCE_KEYBOARD, "SOURCE_KEYBOARD"}, + {CJNIViewInputDevice::SOURCE_MOUSE, "SOURCE_MOUSE"}, + {CJNIViewInputDevice::SOURCE_MOUSE_RELATIVE, "SOURCE_MOUSE_RELATIVE"}, + {CJNIViewInputDevice::SOURCE_ROTARY_ENCODER, "SOURCE_ROTARY_ENCODER"}, + {CJNIViewInputDevice::SOURCE_STYLUS, "SOURCE_STYLUS"}, + {CJNIViewInputDevice::SOURCE_TOUCHPAD, "SOURCE_TOUCHPAD"}, + {CJNIViewInputDevice::SOURCE_TOUCHSCREEN, "SOURCE_TOUCHSCREEN"}, + {CJNIViewInputDevice::SOURCE_TOUCH_NAVIGATION, "SOURCE_TOUCH_NAVIGATION"}, + {CJNIViewInputDevice::SOURCE_TRACKBALL, "SOURCE_TRACKBALL"}, + {CJNIViewInputDevice::SOURCE_UNKNOWN, "SOURCE_UNKNOWN"}, + }; + // clang-format on + + for (const auto& it : sources) + { + if (it.first != 0 && it.first == source) + return it.second; + } + + return "unknown"; +} diff --git a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h index a5bb8e33d5c4d..dc1f8fb020243 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h +++ b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.h @@ -30,5 +30,14 @@ class CAndroidJoystickTranslator * \return The translated enum label, or "unknown" if unknown */ static const char* TranslateKeyCode(int keyCode); + + /*! + * \brief Translate a key code to an Android enum suitable for logging + * + * \param keyCode The key code given in + * + * \return The translated enum label, or "unknown" if unknown + */ + static const char* TranslateSource(int source); }; } // namespace PERIPHERALS