diff options
author | Garrett Brown <themagnificentmrb@gmail.com> | 2024-01-28 23:18:47 -0800 |
---|---|---|
committer | Garrett Brown <themagnificentmrb@gmail.com> | 2024-02-02 08:44:08 -0800 |
commit | 0b01317963b8e61ccae31aa979de5f6603933c9c (patch) | |
tree | d873c101876098c8170d112242eb30c87a8aa099 | |
parent | 60c9e11f23c4fb131997936d42233b7afc56dece (diff) |
[Joysticks] Improve logging while button mapping
-rw-r--r-- | xbmc/games/controllers/windows/GUIConfigurationWizard.cpp | 4 | ||||
-rw-r--r-- | xbmc/input/joysticks/DriverPrimitive.cpp | 70 | ||||
-rw-r--r-- | xbmc/input/joysticks/DriverPrimitive.h | 7 |
3 files changed, 79 insertions, 2 deletions
diff --git a/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp b/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp index ff5f8d8e9d..c2ac2f560f 100644 --- a/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp +++ b/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp @@ -290,8 +290,8 @@ bool CGUIConfigurationWizard::MapPrimitive(JOYSTICK::IButtonMap* buttonMap, } else { - CLog::Log(LOGDEBUG, "{}: mapping feature \"{}\" for device {}", m_strControllerId, - feature.Name(), buttonMap->Location()); + CLog::Log(LOGDEBUG, "{}: mapping feature \"{}\" for device {} to \"{}\"", + m_strControllerId, feature.Name(), buttonMap->Location(), primitive.ToString()); switch (feature.Type()) { diff --git a/xbmc/input/joysticks/DriverPrimitive.cpp b/xbmc/input/joysticks/DriverPrimitive.cpp index 9540dfd2ed..166e9268ea 100644 --- a/xbmc/input/joysticks/DriverPrimitive.cpp +++ b/xbmc/input/joysticks/DriverPrimitive.cpp @@ -8,6 +8,9 @@ #include "DriverPrimitive.h" +#include "games/controllers/ControllerTranslator.h" +#include "utils/StringUtils.h" + #include <utility> using namespace KODI; @@ -199,3 +202,70 @@ bool CDriverPrimitive::IsValid(void) const return false; } + +std::string CDriverPrimitive::ToString() const +{ + switch (m_type) + { + case PRIMITIVE_TYPE::BUTTON: + return StringUtils::Format("button {}", m_driverIndex); + case PRIMITIVE_TYPE::MOTOR: + return StringUtils::Format("motor {}", m_driverIndex); + case PRIMITIVE_TYPE::MOUSE_BUTTON: + return StringUtils::Format("mouse button {}", m_driverIndex); + case PRIMITIVE_TYPE::HAT: + { + switch (m_hatDirection) + { + case HAT_DIRECTION::UP: + return StringUtils::Format("hat {} up", m_driverIndex); + case HAT_DIRECTION::DOWN: + return StringUtils::Format("hat {} down", m_driverIndex); + case HAT_DIRECTION::RIGHT: + return StringUtils::Format("hat {} right", m_driverIndex); + case HAT_DIRECTION::LEFT: + return StringUtils::Format("hat {} left", m_driverIndex); + default: + break; + } + break; + } + case PRIMITIVE_TYPE::SEMIAXIS: + { + switch (m_semiAxisDirection) + { + case SEMIAXIS_DIRECTION::POSITIVE: + return StringUtils::Format("semiaxis +{}", m_driverIndex); + case SEMIAXIS_DIRECTION::NEGATIVE: + return StringUtils::Format("semiaxis -{}", m_driverIndex); + default: + break; + } + break; + } + case PRIMITIVE_TYPE::KEY: + return StringUtils::Format("key {}", + GAME::CControllerTranslator::TranslateKeycode(m_keycode)); + case PRIMITIVE_TYPE::RELATIVE_POINTER: + { + switch (m_pointerDirection) + { + case RELATIVE_POINTER_DIRECTION::UP: + return StringUtils::Format("pointer {} up", m_driverIndex); + case RELATIVE_POINTER_DIRECTION::DOWN: + return StringUtils::Format("pointer {} down", m_driverIndex); + case RELATIVE_POINTER_DIRECTION::RIGHT: + return StringUtils::Format("pointer {} right", m_driverIndex); + case RELATIVE_POINTER_DIRECTION::LEFT: + return StringUtils::Format("pointer {} left", m_driverIndex); + default: + break; + } + break; + } + default: + break; + } + + return ""; +} diff --git a/xbmc/input/joysticks/DriverPrimitive.h b/xbmc/input/joysticks/DriverPrimitive.h index abe372411d..11d391b59a 100644 --- a/xbmc/input/joysticks/DriverPrimitive.h +++ b/xbmc/input/joysticks/DriverPrimitive.h @@ -179,6 +179,13 @@ public: */ bool IsValid(void) const; + /*! + * \brief Convert primitive to a string suitable for logging + * + * \return The primitive as described by a short string, or empty if invalid + */ + std::string ToString() const; + private: PRIMITIVE_TYPE m_type = PRIMITIVE_TYPE::UNKNOWN; unsigned int m_driverIndex = 0; |