summaryrefslogtreecommitdiffstats
path: root/xbmc/games/addons/input/GameClientDevice.h
blob: 403d76c8534fe35eebe9261bda1e8045e05aecc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 *  Copyright (C) 2017-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "games/GameTypes.h"
#include "games/controllers/ControllerTypes.h"

#include <string>

struct game_input_device;
struct game_input_port;

namespace KODI
{
namespace GAME
{
class CPhysicalPort;

/*!
 * \ingroup games
 * \brief Represents a device connected to a port
 */
class CGameClientDevice
{
public:
  /*!
   * \brief Construct a device
   *
   * \param device The device Game API struct
   */
  CGameClientDevice(const game_input_device& device);

  /*!
   * \brief Construct a device from a controller add-on
   *
   * \param controller The controller add-on
   */
  CGameClientDevice(const ControllerPtr& controller);

  /*!
   * \brief Destructor
   */
  ~CGameClientDevice();

  /*!
   * \brief The controller profile
   */
  const ControllerPtr& Controller() const { return m_controller; }

  /*!
   * \brief The ports on this device
   */
  const GameClientPortVec& Ports() const { return m_ports; }

private:
  /*!
   * \brief Add a controller port
   *
   * \param logicalPort The logical port Game API struct
   * \param physicalPort The physical port definition
   */
  void AddPort(const game_input_port& logicalPort, const CPhysicalPort& physicalPort);

  // Helper function
  static ControllerPtr GetController(const char* controllerId);

  ControllerPtr m_controller;
  GameClientPortVec m_ports;
};
} // namespace GAME
} // namespace KODI