xbmc
Controller.h
1 /*
2  * Copyright (C) 2015-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 "ControllerTypes.h"
12 #include "addons/Addon.h"
13 #include "games/controllers/input/PhysicalFeature.h"
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 namespace KODI
22 {
23 namespace GAME
24 {
25 class CControllerLayout;
26 class CPhysicalTopology;
27 
28 using JOYSTICK::FEATURE_TYPE;
29 
30 class CController : public ADDON::CAddon
31 {
32 public:
33  explicit CController(const ADDON::AddonInfoPtr& addonInfo);
34 
35  ~CController() override;
36 
37  static const ControllerPtr EmptyPtr;
38 
44  const std::vector<CPhysicalFeature>& Features(void) const { return m_features; }
45 
53  const CPhysicalFeature& GetFeature(const std::string& name) const;
54 
63  unsigned int FeatureCount(FEATURE_TYPE type = FEATURE_TYPE::UNKNOWN,
64  JOYSTICK::INPUT_TYPE inputType = JOYSTICK::INPUT_TYPE::UNKNOWN) const;
65 
71  void GetFeatures(std::vector<std::string>& features,
72  FEATURE_TYPE type = FEATURE_TYPE::UNKNOWN) const;
73 
81  FEATURE_TYPE FeatureType(const std::string& feature) const;
82 
90  JOYSTICK::INPUT_TYPE GetInputType(const std::string& feature) const;
91 
97  bool LoadLayout(void);
98 
102  const CControllerLayout& Layout(void) const { return *m_layout; }
103 
111  const CPhysicalTopology& Topology() const;
112 
113 private:
114  std::unique_ptr<CControllerLayout> m_layout;
115  std::vector<CPhysicalFeature> m_features;
116  bool m_bLoaded = false;
117 };
118 
119 } // namespace GAME
120 } // namespace KODI
INPUT_TYPE
Types of input available for scalar features.
Definition: JoystickTypes.h:140
Represents the physical topology of controller add-ons.
Definition: PhysicalTopology.h:29
unsigned int FeatureCount(FEATURE_TYPE type=FEATURE_TYPE::UNKNOWN, JOYSTICK::INPUT_TYPE inputType=JOYSTICK::INPUT_TYPE::UNKNOWN) const
Get the count of controller features matching the specified types.
Definition: Controller.cpp:78
Definition: ControllerLayout.h:25
const CControllerLayout & Layout(void) const
Get the controller layout.
Definition: Controller.h:102
void GetFeatures(std::vector< std::string > &features, FEATURE_TYPE type=FEATURE_TYPE::UNKNOWN) const
Get the features matching the specified type.
Definition: Controller.cpp:87
bool LoadLayout(void)
Load the controller layout.
Definition: Controller.cpp:117
Controller configuration window.
Definition: AudioDecoder.h:18
JOYSTICK::INPUT_TYPE GetInputType(const std::string &feature) const
Get the input type of the specified feature.
Definition: Controller.cpp:107
Definition: Controller.h:30
const CPhysicalFeature & GetFeature(const std::string &name) const
Get a feature by its name.
Definition: Controller.cpp:65
const CPhysicalTopology & Topology() const
Get the controller&#39;s physical topology.
Definition: Controller.cpp:154
Definition: PhysicalFeature.h:24
const std::vector< CPhysicalFeature > & Features(void) const
Get all controller features.
Definition: Controller.h:44
FEATURE_TYPE FeatureType(const std::string &feature) const
Get the type of the specified feature.
Definition: Controller.cpp:97
Definition: Addon.h:34