xbmc
ControllerHub.h
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 "games/controllers/ControllerTypes.h"
12 #include "games/ports/types/PortNode.h"
13 
14 #include <string>
15 
16 namespace KODI
17 {
18 namespace GAME
19 {
24 {
25 public:
26  CControllerHub() = default;
27  CControllerHub(const CControllerHub& other) { *this = other; }
28  CControllerHub(CControllerHub&& other) = default;
29  CControllerHub& operator=(const CControllerHub& rhs);
30  CControllerHub& operator=(CControllerHub&& rhs) noexcept;
31  ~CControllerHub();
32 
33  void Clear();
34 
35  bool HasPorts() const { return !m_ports.empty(); }
36  PortVec& GetPorts() { return m_ports; }
37  const PortVec& GetPorts() const { return m_ports; }
38  void SetPorts(PortVec ports);
39 
40  bool IsControllerAccepted(const std::string& controllerId) const;
41  bool IsControllerAccepted(const std::string& portAddress, const std::string& controllerId) const;
42  ControllerVector GetControllers() const;
43  void GetControllers(ControllerVector& controllers) const;
44 
45  const CPortNode& GetPort(const std::string& address) const;
46 
47 private:
48  static const CPortNode& GetPortInternal(const PortVec& ports, const std::string& address);
49 
50  PortVec m_ports;
51 };
52 } // namespace GAME
53 } // namespace KODI
Collection of nodes that can be connected to this port.
Definition: PortNode.h:26
Controller configuration window.
Definition: AudioDecoder.h:18
A branch in the controller tree.
Definition: ControllerHub.h:23