| 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 |
{ |
| 20 |
/*! |
| 21 |
* \ingroup games |
| 22 |
* |
| 23 |
* \brief A branch in the controller tree |
| 24 |
*/ |
| 25 |
class CControllerHub |
| 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 |
|
| 49 |
/*! |
| 50 |
* \brief Get a list of ports that accept player input |
| 51 |
* |
| 52 |
* \param[out] inputPorts The list of input ports |
| 53 |
*/ |
| 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 |