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.
9 #include "PhysicalPort.h"
11 #include "games/controllers/ControllerDefinitions.h"
12 #include "utils/XMLUtils.h"
13 #include "utils/log.h"
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)
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
));
56 CLog::Log(LOGWARNING
, "<{}> tag is missing \"{}\" attribute", LAYOUT_XML_ELM_ACCEPTS
,
57 LAYOUT_XML_ATTR_CONTROLLER
);
61 CLog::Log(LOGDEBUG
, "Unknown physical topology port tag: <{}>", pChild
->ValueStr());