From efb5e02c15c80424b22acc6fa5e777e632130c86 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Mon, 1 Jan 2024 19:18:03 -0800 Subject: [PATCH 1/2] Peripheral API v3.0.2: Add comparison operators --- .../peripheral/PeripheralUtils.h | 29 +++++++++++++++++++ .../kodi-dev-kit/include/kodi/versions.h | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h index 4e1396ffa5448..3a91210b4ddaa 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h @@ -258,6 +258,20 @@ class Peripheral /// @brief Destructor. virtual ~Peripheral(void) = default; + /// @brief Comparison operator + /// + /// @note The index is not included in the comparison because it is affected + /// by the presence of other peripherals + bool operator==(const Peripheral& rhs) const + { + // clang-format off + return m_type == rhs.m_type && + m_strName == rhs.m_strName && + m_vendorId == rhs.m_vendorId && + m_productId == rhs.m_productId; + // clang-format on + } + /// @brief Get peripheral type. /// /// @return Type defined with @ref PERIPHERAL_TYPE @@ -637,6 +651,21 @@ class Joystick : public Peripheral return *this; } + /// @brief Comparison operator + bool operator==(const Joystick& rhs) const + { + // clang-format off + return Peripheral::operator==(rhs) && + m_provider == rhs.m_provider && + m_requestedPort == rhs.m_requestedPort && + m_buttonCount == rhs.m_buttonCount && + m_hatCount == rhs.m_hatCount && + m_axisCount == rhs.m_axisCount && + m_motorCount == rhs.m_motorCount && + m_supportsPowerOff == rhs.m_supportsPowerOff; + // clang-format on + } + /// @brief Get provider name. /// /// @return Name of provider diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h index 2ff397d9bbee8..4be9f5229bb24 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h @@ -124,7 +124,7 @@ "addon-instance/inputstream/StreamCrypto.h" \ "addon-instance/inputstream/TimingConstants.h" -#define ADDON_INSTANCE_VERSION_PERIPHERAL "3.0.1" +#define ADDON_INSTANCE_VERSION_PERIPHERAL "3.0.2" #define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "3.0.0" #define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" #define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ From 53bc4a92d656ab1758eb793d2488969545b244c5 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Mon, 1 Jan 2024 19:43:33 -0800 Subject: [PATCH 2/2] Peripheral API: Fix typo --- .../include/kodi/addon-instance/peripheral/PeripheralUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h index 3a91210b4ddaa..7510cc3be0381 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h @@ -1263,7 +1263,7 @@ class JoystickFeature /// @brief Get all primitives on this class (as constant). /// - /// @return Constant a´rray list of primitives + /// @return Constant array list of primitives const std::array& Primitives() const { return m_primitives;