Debian Codegraph @

xbmc/games/ports/input/PhysicalPort.h

raw
1 /*
2 * Copyright (C) 2017-2021 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include <string>
12 #include <vector>
13
14 namespace tinyxml2
15 {
16 class XMLElement;
17 }
18
19 namespace KODI
20 {
21 namespace GAME
22 {
23
24 /*!
25 * \ingroup games
26 */
27 class CPhysicalPort
28 {
29 public:
30 CPhysicalPort() = default;
31
32 /*!
33 * \brief Create a controller port
34 *
35 * \param portId The port's ID
36 * \param accepts A list of controller IDs that this port accepts
37 */
38 CPhysicalPort(std::string portId, std::vector<std::string> accepts);
39
40 void Reset();
41
42 /*!
43 * \brief Get the ID of the port
44 *
45 * \return The port's ID, e.g. "1", as a string
46 */
47 const std::string& ID() const { return m_portId; }
48
49 /*!
50 * \brief Get the controllers that can connect to this port
51 *
52 * \return A list of controllers that are physically compatible with this port
53 */
54 const std::vector<std::string>& Accepts() const { return m_accepts; }
55
56 /*!
57 * \brief Check if the controller is compatible with this port
58 *
59 * \return True if the controller is accepted, false otherwise
60 */
61 bool IsCompatible(const std::string& controllerId) const;
62
63 bool Deserialize(const tinyxml2::XMLElement* pElement);
64
65 private:
66 std::string m_portId;
67 std::vector<std::string> m_accepts;
68 };
69 } // namespace GAME
70 } // namespace KODI