| 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 device connected to a port |
| 29 |
*/ |
| 30 |
class CGameClientDevice |
| 31 |
{ |
| 32 |
public: |
| 33 |
/*! |
| 34 |
* \brief Construct a device |
| 35 |
* |
| 36 |
* \param device The device Game API struct |
| 37 |
*/ |
| 38 |
CGameClientDevice(const game_input_device& device); |
| 39 |
|
| 40 |
/*! |
| 41 |
* \brief Construct a device from a controller add-on |
| 42 |
* |
| 43 |
* \param controller The controller add-on |
| 44 |
*/ |
| 45 |
CGameClientDevice(const ControllerPtr& controller); |
| 46 |
|
| 47 |
/*! |
| 48 |
* \brief Destructor |
| 49 |
*/ |
| 50 |
~CGameClientDevice(); |
| 51 |
|
| 52 |
/*! |
| 53 |
* \brief The controller profile |
| 54 |
*/ |
| 55 |
const ControllerPtr& Controller() const { return m_controller; } |
| 56 |
|
| 57 |
/*! |
| 58 |
* \brief The ports on this device |
| 59 |
*/ |
| 60 |
const GameClientPortVec& Ports() const { return m_ports; } |
| 61 |
|
| 62 |
private: |
| 63 |
/*! |
| 64 |
* \brief Add a controller port |
| 65 |
* |
| 66 |
* \param logicalPort The logical port Game API struct |
| 67 |
* \param physicalPort The physical port definition |
| 68 |
*/ |
| 69 |
void AddPort(const game_input_port& logicalPort, const CPhysicalPort& physicalPort); |
| 70 |
|
| 71 |
// Helper function |
| 72 |
static ControllerPtr GetController(const char* controllerId); |
| 73 |
|
| 74 |
ControllerPtr m_controller; |
| 75 |
GameClientPortVec m_ports; |
| 76 |
}; |
| 77 |
} // namespace GAME |
| 78 |
} // namespace KODI |