blob: 9c53c761999cd15dcfd02999bdc43fc3cad98a15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* Copyright (C) 2017-2021 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 "PhysicalPort.h"
#include "games/controllers/ControllerDefinitions.h"
#include "utils/XMLUtils.h"
#include "utils/log.h"
#include <algorithm>
#include <utility>
using namespace KODI;
using namespace GAME;
CPhysicalPort::CPhysicalPort(std::string portId, std::vector<std::string> accepts)
: m_portId(std::move(portId)), m_accepts(std::move(accepts))
{
}
void CPhysicalPort::Reset()
{
CPhysicalPort defaultPort;
*this = std::move(defaultPort);
}
bool CPhysicalPort::IsCompatible(const std::string& controllerId) const
{
return std::find(m_accepts.begin(), m_accepts.end(), controllerId) != m_accepts.end();
}
bool CPhysicalPort::Deserialize(const TiXmlElement* pElement)
{
if (pElement == nullptr)
return false;
Reset();
m_portId = XMLUtils::GetAttribute(pElement, LAYOUT_XML_ATTR_PORT_ID);
for (const TiXmlElement* pChild = pElement->FirstChildElement(); pChild != nullptr;
pChild = pChild->NextSiblingElement())
{
if (pChild->ValueStr() == LAYOUT_XML_ELM_ACCEPTS)
{
std::string controller = XMLUtils::GetAttribute(pChild, LAYOUT_XML_ATTR_CONTROLLER);
if (!controller.empty())
m_accepts.emplace_back(std::move(controller));
else
CLog::Log(LOGWARNING, "<{}> tag is missing \"{}\" attribute", LAYOUT_XML_ELM_ACCEPTS,
LAYOUT_XML_ATTR_CONTROLLER);
}
else
{
CLog::Log(LOGDEBUG, "Unknown physical topology port tag: <{}>", pChild->ValueStr());
}
}
return true;
}
|