summaryrefslogtreecommitdiffstats
path: root/xbmc/games/controllers/input/PhysicalTopology.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/games/controllers/input/PhysicalTopology.cpp')
-rw-r--r--xbmc/games/controllers/input/PhysicalTopology.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/xbmc/games/controllers/input/PhysicalTopology.cpp b/xbmc/games/controllers/input/PhysicalTopology.cpp
new file mode 100644
index 0000000..2fecb5a
--- /dev/null
+++ b/xbmc/games/controllers/input/PhysicalTopology.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "PhysicalTopology.h"
+
+#include "games/controllers/ControllerDefinitions.h"
+#include "utils/XMLUtils.h"
+#include "utils/log.h"
+
+#include <utility>
+
+using namespace KODI;
+using namespace GAME;
+
+CPhysicalTopology::CPhysicalTopology(bool bProvidesInput, std::vector<CPhysicalPort> ports)
+ : m_bProvidesInput(bProvidesInput), m_ports(std::move(ports))
+{
+}
+
+void CPhysicalTopology::Reset()
+{
+ CPhysicalTopology defaultTopology;
+ *this = std::move(defaultTopology);
+}
+
+bool CPhysicalTopology::Deserialize(const TiXmlElement* pElement)
+{
+ Reset();
+
+ if (pElement == nullptr)
+ return false;
+
+ m_bProvidesInput = (XMLUtils::GetAttribute(pElement, LAYOUT_XML_ATTR_PROVIDES_INPUT) != "false");
+
+ for (const TiXmlElement* pChild = pElement->FirstChildElement(); pChild != nullptr;
+ pChild = pChild->NextSiblingElement())
+ {
+ if (pChild->ValueStr() == LAYOUT_XML_ELM_PORT)
+ {
+ CPhysicalPort port;
+ if (port.Deserialize(pChild))
+ m_ports.emplace_back(std::move(port));
+ }
+ else
+ {
+ CLog::Log(LOGDEBUG, "Unknown physical topology tag: <{}>", pChild->ValueStr());
+ }
+ }
+
+ return true;
+}