Debian Codegraph @

xbmc/games/addons/input/GameClientPort.h

raw
1 /*
2 * Copyright (C) 2017-2018 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 "games/GameTypes.h"
12 #include "games/controllers/ControllerTypes.h"
13
14 #include <string>
15
16 struct game_input_device;
17 struct game_input_port;
18
19 namespace KODI
20 {
21 namespace GAME
22 {
23 class CPhysicalPort;
24
25 /*!
26 * \ingroup games
27 *
28 * \brief Represents a port that devices can connect to
29 */
30 class CGameClientPort
31 {
32 public:
33 /*!
34 * \brief Construct a hardware port
35 *
36 * \param port The hardware port Game API struct
37 */
38 CGameClientPort(const game_input_port& port);
39
40 /*!
41 * \brief Construct a hardware port that accepts the given controllers
42 *
43 * \param controllers List of accepted controller profiles
44 *
45 * The port is given the ID specified by DEFAULT_PORT_ID.
46 */
47 CGameClientPort(const ControllerVector& controllers);
48
49 /*!
50 * \brief Construct a controller port
51 *
52 * \param logicalPort The logical port Game API struct
53 * \param physicalPort The physical port definition
54 *
55 * The physical port is defined by the controller profile. This definition
56 * specifies which controllers the port is physically compatible with.
57 *
58 * The logical port is defined by the emulator's input topology. This
59 * definition specifies which controllers the emulator's logic can handle.
60 *
61 * Obviously, the controllers specified by the logical port must be a subset
62 * of the controllers supported by the physical port.
63 */
64 CGameClientPort(const game_input_port& logicalPort, const CPhysicalPort& physicalPort);
65
66 /*!
67 * \brief Destructor
68 */
69 ~CGameClientPort();
70
71 /*!
72 * \brief Get the port type
73 *
74 * The port type identifies if this port is for a keyboard, mouse, or
75 * controller.
76 */
77 PORT_TYPE PortType() const { return m_type; }
78
79 /*!
80 * \brief Get the ID of the port
81 *
82 * The ID is used when creating a toplogical address for the port.
83 */
84 const std::string& ID() const { return m_portId; }
85
86 /*!
87 * \brief True if a controller must be connected, preventing the disconnected
88 * option from being shown to the user
89 */
90 bool ForceConnected() const { return m_forceConnected; }
91
92 /*!
93 * \brief Get the list of devices accepted by this port
94 */
95 const GameClientDeviceVec& Devices() const { return m_acceptedDevices; }
96
97 private:
98 PORT_TYPE m_type;
99 std::string m_portId;
100 bool m_forceConnected{false};
101 GameClientDeviceVec m_acceptedDevices;
102 };
103 } // namespace GAME
104 } // namespace KODI