kodi
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 {
26 {
27 public:
28  CControllerHub() = default;
29  CControllerHub(const CControllerHub& other) { *this = other; }
30  CControllerHub(CControllerHub&& other) = default;
31  CControllerHub& operator=(const CControllerHub& rhs);
32  CControllerHub& operator=(CControllerHub&& rhs) noexcept;
33  ~CControllerHub();
34 
35  void Clear();
36 
37  bool HasPorts() const { return !m_ports.empty(); }
38  PortVec& GetPorts() { return m_ports; }
39  const PortVec& GetPorts() const { return m_ports; }
40  void SetPorts(PortVec ports);
41 
42  bool IsControllerAccepted(const std::string& controllerId) const;
43  bool IsControllerAccepted(const std::string& portAddress, const std::string& controllerId) const;
44  ControllerVector GetControllers() const;
45  void GetControllers(ControllerVector& controllers) const;
46 
47  const CPortNode& GetPort(const std::string& address) const;
48 
54  void GetInputPorts(std::vector<std::string>& inputPorts) const;
55 
56 private:
57  static const CPortNode& GetPortInternal(const PortVec& ports, const std::string& address);
58 
59  PortVec m_ports;
60 };
61 } // namespace GAME
62 } // namespace KODI
void GetInputPorts(std::vector< std::string > &inputPorts) const
Get a list of ports that accept player input.
Definition: ControllerHub.cpp:110
Collection of nodes that can be connected to this port.
Definition: PortNode.h:28
Definition: AudioDecoder.h:18
A branch in the controller tree.
Definition: ControllerHub.h:25
std::vector< ControllerPtr > ControllerVector
Vector of smart pointers to a game controller (CController)
Definition: ControllerTypes.h:32