From e55b8ee14f09d9959c58132ee7c3fa0f04041263 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Mon, 5 Feb 2024 07:04:09 -0800 Subject: [Agents] Constructors shouldn't have side effects --- xbmc/games/agents/input/AgentController.cpp | 2 -- xbmc/games/agents/input/AgentInput.cpp | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xbmc/games/agents/input/AgentController.cpp b/xbmc/games/agents/input/AgentController.cpp index a52921979c..e70f4fa10c 100644 --- a/xbmc/games/agents/input/AgentController.cpp +++ b/xbmc/games/agents/input/AgentController.cpp @@ -43,8 +43,6 @@ CAgentController::CAgentController(PERIPHERALS::PeripheralPtr peripheral) default: break; } - - Initialize(); } CAgentController::~CAgentController() diff --git a/xbmc/games/agents/input/AgentInput.cpp b/xbmc/games/agents/input/AgentInput.cpp index afef2afe8d..099f0a7cce 100644 --- a/xbmc/games/agents/input/AgentInput.cpp +++ b/xbmc/games/agents/input/AgentInput.cpp @@ -439,7 +439,11 @@ void CAgentInput::ProcessAgentControllers(const PERIPHERALS::PeripheralVector& p if (it == m_controllers.end()) { // Handle new controller - m_controllers.emplace_back(std::make_shared(peripheral)); + std::shared_ptr agentController = + std::make_shared(peripheral); + agentController->Initialize(); + m_controllers.emplace_back(std::move(agentController)); + SetChanged(true); } else -- cgit v1.2.3 From 6ad3c39ee15f13dee9f05ca4085e9f2f3dcb7eca Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Mon, 5 Feb 2024 07:07:21 -0800 Subject: [Controllers] Improve error logging for default buttonmaps --- xbmc/games/controllers/input/DefaultButtonMap.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xbmc/games/controllers/input/DefaultButtonMap.cpp b/xbmc/games/controllers/input/DefaultButtonMap.cpp index 54cdac026e..ddf315d734 100644 --- a/xbmc/games/controllers/input/DefaultButtonMap.cpp +++ b/xbmc/games/controllers/input/DefaultButtonMap.cpp @@ -37,15 +37,23 @@ bool CDefaultButtonMap::Load() switch (m_device->Type()) { case PERIPHERALS::PERIPHERAL_KEYBOARD: - return m_strControllerId == DEFAULT_KEYBOARD_ID; + { + if (m_strControllerId == DEFAULT_KEYBOARD_ID) + return true; + break; + } case PERIPHERALS::PERIPHERAL_MOUSE: - return m_strControllerId == DEFAULT_MOUSE_ID; + { + if (m_strControllerId == DEFAULT_MOUSE_ID) + return true; + break; + } default: break; } - CLog::Log(LOGDEBUG, "Failed to load button map for \"{}\" with profile {}", m_device->Location(), - m_strControllerId); + CLog::Log(LOGDEBUG, "Failed to load default button map for \"{}\" with profile {}", + m_device->Location(), m_strControllerId); return false; } -- cgit v1.2.3 From b87025ec9758468a13b74ddd3c672399698af316 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Fri, 19 Jan 2024 14:48:30 -0800 Subject: [Port Manager] Fix unredacted path in log --- xbmc/games/ports/input/PortManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbmc/games/ports/input/PortManager.cpp b/xbmc/games/ports/input/PortManager.cpp index 4bf9309c45..fb664b7ebc 100644 --- a/xbmc/games/ports/input/PortManager.cpp +++ b/xbmc/games/ports/input/PortManager.cpp @@ -67,7 +67,8 @@ void CPortManager::LoadXML() { if (!CFileUtils::Exists(m_xmlPath)) { - CLog::Log(LOGDEBUG, "Can't load port config, file doesn't exist: {}", m_xmlPath); + CLog::Log(LOGDEBUG, "Can't load port config, file doesn't exist: {}", + CURL::GetRedacted(m_xmlPath)); return; } -- cgit v1.2.3 From be11edd0da7506db98300ad2e27fdbc07848663b Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Thu, 1 Feb 2024 16:22:50 -0800 Subject: [Games][Strings] Improve documentation for stretch modes --- addons/resource.language.en_gb/resources/strings.po | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index c7d5b49cb6..fbd7045cd3 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -2947,7 +2947,9 @@ msgctxt "#629" msgid "View mode" msgstr "" +#. Label for stretching the displayed video to its normal size #: system/settings/settings.xml +#: xbmc/games/dialogs/osd/DialogGameStretchMode.cpp #: xbmc/video/dialogs/GUIDialogVideoSettings.cpp msgctxt "#630" msgid "Normal" @@ -2959,6 +2961,8 @@ msgctxt "#631" msgid "Zoom" msgstr "" +#. Label for stretching the displayed video to a 4:3 aspect ratio +#: xbmc/games/dialogs/osd/DialogGameStretchMode.cpp #: xbmc/video/dialogs/GUIDialogVideoSettings.cpp msgctxt "#632" msgid "Stretch 4:3" @@ -2970,12 +2974,15 @@ msgctxt "#633" msgid "Wide zoom" msgstr "" +#. Label for stretching the displayed video to a 16:9 aspect ratio #: system/settings/settings.xml #: xbmc/video/dialogs/GUIDialogVideoSettings.cpp msgctxt "#634" msgid "Stretch 16:9" msgstr "" +#. Label for stretching the displayed video to the original size of the video stream +#: xbmc/games/dialogs/osd/DialogGameStretchMode.cpp #: xbmc/video/dialogs/GUIDialogVideoSettings.cpp msgctxt "#635" msgid "Original size" @@ -18622,14 +18629,14 @@ msgid "270°" msgstr "" #. Label of thumbnail in the in-game menu for stretching the video to fullscreen -#: xbmc/games/dialogs/osd/DialogGameViewMode.h +#: xbmc/games/dialogs/osd/DialogGameStretchMode.cpp msgctxt "#35232" msgid "Fullscreen" msgstr "" #. Label of the setting in the in-game menu for stretching the game to fit the monitor #: addons/skin.estuary/xml/Custom_1101_SettingsList.xml -#: xbmc/games/dialogs/osdDialogGameViewMode.cpp +#: xbmc/games/dialogs/osd/DialogGameStretchMode.cpp msgctxt "#35233" msgid "Stretch mode" msgstr "" -- cgit v1.2.3 From d1f4c85f87d3bc8f5187e84103247e170e704bb4 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Sat, 20 Jan 2024 21:34:52 -0800 Subject: [Game Clients] Move #define to constexpr in the Types header --- xbmc/games/GameTypes.h | 6 ++++++ xbmc/games/addons/GameClientProperties.cpp | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xbmc/games/GameTypes.h b/xbmc/games/GameTypes.h index 76881aa00a..b0cca6c250 100644 --- a/xbmc/games/GameTypes.h +++ b/xbmc/games/GameTypes.h @@ -77,5 +77,11 @@ using GameAgentPtr = std::shared_ptr; */ using GameAgentVec = std::vector; +/*! + * \ingroup games + * + * \brief Name of the resources directory for game clients + */ +constexpr auto GAME_CLIENT_RESOURCES_DIRECTORY = "resources"; } // namespace GAME } // namespace KODI diff --git a/xbmc/games/addons/GameClientProperties.cpp b/xbmc/games/addons/GameClientProperties.cpp index 4f7273a913..f3d97858bd 100644 --- a/xbmc/games/addons/GameClientProperties.cpp +++ b/xbmc/games/addons/GameClientProperties.cpp @@ -32,8 +32,6 @@ using namespace ADDON; using namespace GAME; using namespace XFILE; -#define GAME_CLIENT_RESOURCES_DIRECTORY "resources" - CGameClientProperties::CGameClientProperties(const CGameClient& parent, AddonProps_Game& props) : m_parent(parent), m_properties(props) { -- cgit v1.2.3 From 5f3112f09762773dbc8d7e98f6bef6083ee71e49 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Sat, 20 Jan 2024 15:25:22 -0800 Subject: [Peripherals] Move #define to constexpr in the Types header --- xbmc/peripherals/PeripheralTypes.h | 5 +++++ xbmc/peripherals/devices/PeripheralJoystick.h | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xbmc/peripherals/PeripheralTypes.h b/xbmc/peripherals/PeripheralTypes.h index 0a7f74c89f..f5785d0cf1 100644 --- a/xbmc/peripherals/PeripheralTypes.h +++ b/xbmc/peripherals/PeripheralTypes.h @@ -26,6 +26,11 @@ namespace PERIPHERALS /// \ingroup peripherals /// \{ +/*! + * \brief Indicates a joystick has no preference for port number + */ +constexpr auto JOYSTICK_NO_PORT_REQUESTED = -1; + enum PeripheralBusType { PERIPHERAL_BUS_UNKNOWN = 0, diff --git a/xbmc/peripherals/devices/PeripheralJoystick.h b/xbmc/peripherals/devices/PeripheralJoystick.h index 8dd87ed464..6dcacef4c8 100644 --- a/xbmc/peripherals/devices/PeripheralJoystick.h +++ b/xbmc/peripherals/devices/PeripheralJoystick.h @@ -21,8 +21,6 @@ #include #include -#define JOYSTICK_PORT_UNKNOWN (-1) - namespace KODI { namespace JOYSTICK @@ -132,7 +130,7 @@ protected: // State parameters std::string m_strProvider; - int m_requestedPort = JOYSTICK_PORT_UNKNOWN; + int m_requestedPort{JOYSTICK_NO_PORT_REQUESTED}; unsigned int m_buttonCount = 0; unsigned int m_hatCount = 0; unsigned int m_axisCount = 0; -- cgit v1.2.3 From 7e411667cf8295e56d7cc0b499682471a4b62710 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Fri, 19 Jan 2024 23:22:10 -0800 Subject: [Peripherals] Improve const-correctness --- xbmc/peripherals/devices/Peripheral.cpp | 2 +- xbmc/peripherals/devices/Peripheral.h | 2 +- xbmc/peripherals/devices/PeripheralJoystick.h | 2 +- xbmc/peripherals/devices/PeripheralKeyboard.h | 2 +- xbmc/peripherals/devices/PeripheralMouse.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xbmc/peripherals/devices/Peripheral.cpp b/xbmc/peripherals/devices/Peripheral.cpp index 671f8d4f52..ce5b93176e 100644 --- a/xbmc/peripherals/devices/Peripheral.cpp +++ b/xbmc/peripherals/devices/Peripheral.cpp @@ -786,7 +786,7 @@ bool CPeripheral::operator!=(const PeripheralScanResult& right) const return !(*this == right); } -CDateTime CPeripheral::LastActive() +CDateTime CPeripheral::LastActive() const { return CDateTime(); } diff --git a/xbmc/peripherals/devices/Peripheral.h b/xbmc/peripherals/devices/Peripheral.h index 3e7bb99d6e..2e24e0e176 100644 --- a/xbmc/peripherals/devices/Peripheral.h +++ b/xbmc/peripherals/devices/Peripheral.h @@ -259,7 +259,7 @@ public: * * \return The time of last activation, or invalid if unknown/never active */ - virtual CDateTime LastActive(); + virtual CDateTime LastActive() const; /*! * \brief Get the controller profile that best represents this peripheral diff --git a/xbmc/peripherals/devices/PeripheralJoystick.h b/xbmc/peripherals/devices/PeripheralJoystick.h index 6dcacef4c8..916125b9a8 100644 --- a/xbmc/peripherals/devices/PeripheralJoystick.h +++ b/xbmc/peripherals/devices/PeripheralJoystick.h @@ -64,7 +64,7 @@ public: void UnregisterJoystickDriverHandler(KODI::JOYSTICK::IDriverHandler* handler) override; KODI::JOYSTICK::IDriverReceiver* GetDriverReceiver() override { return this; } KODI::KEYMAP::IKeymap* GetKeymap(const std::string& controllerId) override; - CDateTime LastActive() override { return m_lastActive; } + CDateTime LastActive() const override { return m_lastActive; } KODI::GAME::ControllerPtr ControllerProfile() const override; void SetControllerProfile(const KODI::GAME::ControllerPtr& controller) override; diff --git a/xbmc/peripherals/devices/PeripheralKeyboard.h b/xbmc/peripherals/devices/PeripheralKeyboard.h index 2c5dea6c68..f1c3927544 100644 --- a/xbmc/peripherals/devices/PeripheralKeyboard.h +++ b/xbmc/peripherals/devices/PeripheralKeyboard.h @@ -34,7 +34,7 @@ public: void RegisterKeyboardDriverHandler(KODI::KEYBOARD::IKeyboardDriverHandler* handler, bool bPromiscuous) override; void UnregisterKeyboardDriverHandler(KODI::KEYBOARD::IKeyboardDriverHandler* handler) override; - CDateTime LastActive() override { return m_lastActive; } + CDateTime LastActive() const override { return m_lastActive; } KODI::GAME::ControllerPtr ControllerProfile() const override; // implementation of IKeyboardDriverHandler diff --git a/xbmc/peripherals/devices/PeripheralMouse.h b/xbmc/peripherals/devices/PeripheralMouse.h index e93ba0abe5..8735a32ffa 100644 --- a/xbmc/peripherals/devices/PeripheralMouse.h +++ b/xbmc/peripherals/devices/PeripheralMouse.h @@ -34,7 +34,7 @@ public: void RegisterMouseDriverHandler(KODI::MOUSE::IMouseDriverHandler* handler, bool bPromiscuous) override; void UnregisterMouseDriverHandler(KODI::MOUSE::IMouseDriverHandler* handler) override; - CDateTime LastActive() override { return m_lastActive; } + CDateTime LastActive() const override { return m_lastActive; } KODI::GAME::ControllerPtr ControllerProfile() const override; // implementation of IMouseDriverHandler -- cgit v1.2.3