Debian Codegraph @

xbmc/games/controllers/ControllerLayout.h

raw
1 /*
2 * Copyright (C) 2015-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 <memory>
12 #include <string>
13 #include <vector>
14
15 namespace tinyxml2
16 {
17 class XMLElement;
18 }
19
20 namespace KODI
21 {
22 namespace GAME
23 {
24 class CController;
25 class CPhysicalFeature;
26 class CPhysicalTopology;
27
28 /*!
29 * \ingroup games
30 */
31 class CControllerLayout
32 {
33 public:
34 CControllerLayout();
35 CControllerLayout(const CControllerLayout& other);
36 ~CControllerLayout();
37
38 void Reset(void);
39
40 int LabelID(void) const { return m_labelId; }
41 const std::string& Icon(void) const { return m_icon; }
42 const std::string& Image(void) const { return m_strImage; }
43
44 /*!
45 * \brief Ensures the layout was deserialized correctly, and optionally logs if not
46 *
47 * \param bLog If true, output the cause of invalidness to the log
48 *
49 * \return True if the layout is valid and can be used in the GUI, false otherwise
50 */
51 bool IsValid(bool bLog) const;
52
53 /*!
54 * \brief Get the label of the primary layout used when mapping the controller
55 *
56 * \return The label, or empty if unknown
57 */
58 std::string Label(void) const;
59
60 /*!
61 * \brief Get the image path of the primary layout used when mapping the controller
62 *
63 * \return The image path, or empty if unknown
64 */
65 std::string ImagePath(void) const;
66
67 /*!
68 * \brief Get the physical topology of this controller
69 *
70 * The topology of a controller defines its ports and which controllers can
71 * physically be connected to them. Also, the topology defines if the
72 * controller can provide player input, which is false in the case of hubs.
73 *
74 * \return The physical topology of the controller
75 */
76 const CPhysicalTopology& Topology(void) const { return *m_topology; }
77
78 /*!
79 * \brief Deserialize the specified XML element
80 *
81 * \param pLayoutElement The XML element
82 * \param controller The controller, used to obtain read-only properties
83 * \param features The deserialized features, if any
84 */
85 void Deserialize(const tinyxml2::XMLElement* pLayoutElement,
86 const CController* controller,
87 std::vector<CPhysicalFeature>& features);
88
89 private:
90 const CController* m_controller = nullptr;
91 int m_labelId = -1;
92 std::string m_icon;
93 std::string m_strImage;
94 std::unique_ptr<CPhysicalTopology> m_topology;
95 };
96
97 } // namespace GAME
98 } // namespace KODI