[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / games / ports / input / PhysicalPort.cpp
blob9c53c761999cd15dcfd02999bdc43fc3cad98a15
1 /*
2 * Copyright (C) 2017-2021 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "PhysicalPort.h"
11 #include "games/controllers/ControllerDefinitions.h"
12 #include "utils/XMLUtils.h"
13 #include "utils/log.h"
15 #include <algorithm>
16 #include <utility>
18 using namespace KODI;
19 using namespace GAME;
21 CPhysicalPort::CPhysicalPort(std::string portId, std::vector<std::string> accepts)
22 : m_portId(std::move(portId)), m_accepts(std::move(accepts))
26 void CPhysicalPort::Reset()
28 CPhysicalPort defaultPort;
29 *this = std::move(defaultPort);
32 bool CPhysicalPort::IsCompatible(const std::string& controllerId) const
34 return std::find(m_accepts.begin(), m_accepts.end(), controllerId) != m_accepts.end();
37 bool CPhysicalPort::Deserialize(const TiXmlElement* pElement)
39 if (pElement == nullptr)
40 return false;
42 Reset();
44 m_portId = XMLUtils::GetAttribute(pElement, LAYOUT_XML_ATTR_PORT_ID);
46 for (const TiXmlElement* pChild = pElement->FirstChildElement(); pChild != nullptr;
47 pChild = pChild->NextSiblingElement())
49 if (pChild->ValueStr() == LAYOUT_XML_ELM_ACCEPTS)
51 std::string controller = XMLUtils::GetAttribute(pChild, LAYOUT_XML_ATTR_CONTROLLER);
53 if (!controller.empty())
54 m_accepts.emplace_back(std::move(controller));
55 else
56 CLog::Log(LOGWARNING, "<{}> tag is missing \"{}\" attribute", LAYOUT_XML_ELM_ACCEPTS,
57 LAYOUT_XML_ATTR_CONTROLLER);
59 else
61 CLog::Log(LOGDEBUG, "Unknown physical topology port tag: <{}>", pChild->ValueStr());
65 return true;