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 
33 class CController : public ADDON::CAddon
34 {
35 public:
36  explicit CController(const ADDON::AddonInfoPtr& addonInfo);
37 
38  ~CController() override;
39 
40  static const ControllerPtr EmptyPtr;
41 
42  // Implementation of IAddon
43  bool CanHaveAddonOrInstanceSettings() override { return true; }
44 
50  const std::vector<CPhysicalFeature>& Features(void) const { return m_features; }
51 
59  const CPhysicalFeature& GetFeature(const std::string& name) const;
60 
69  unsigned int FeatureCount(FEATURE_TYPE type = FEATURE_TYPE::UNKNOWN,
70  JOYSTICK::INPUT_TYPE inputType = JOYSTICK::INPUT_TYPE::UNKNOWN) const;
71 
77  void GetFeatures(std::vector<std::string>& features,
78  FEATURE_TYPE type = FEATURE_TYPE::UNKNOWN) const;
79 
87  FEATURE_TYPE FeatureType(const std::string& feature) const;
88 
96  JOYSTICK::INPUT_TYPE GetInputType(const std::string& feature) const;
97 
103  bool LoadLayout(void);
104 
108  const CControllerLayout& Layout(void) const { return *m_layout; }
109 
117  const CPhysicalTopology& Topology() const;
118 
119 private:
120  std::unique_ptr<CControllerLayout> m_layout;
121  std::vector<CPhysicalFeature> m_features;
122  bool m_bLoaded = false;
123 };
124 
125 } // namespace GAME
126 } // 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:34
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:79
Definition: ControllerLayout.h:31
const CControllerLayout & Layout(void) const
Get the controller layout.
Definition: Controller.h:108
void GetFeatures(std::vector< std::string > &features, FEATURE_TYPE type=FEATURE_TYPE::UNKNOWN) const
Get the features matching the specified type.
Definition: Controller.cpp:88
bool LoadLayout(void)
Load the controller layout.
Definition: Controller.cpp:118
Definition: AudioDecoder.h:18
JOYSTICK::INPUT_TYPE GetInputType(const std::string &feature) const
Get the input type of the specified feature.
Definition: Controller.cpp:108
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
Definition: Controller.h:33
const CPhysicalFeature & GetFeature(const std::string &name) const
Get a feature by its name.
Definition: Controller.cpp:66
const CPhysicalTopology & Topology() const
Get the controller&#39;s physical topology.
Definition: Controller.cpp:156
Definition: PhysicalFeature.h:30
const std::vector< CPhysicalFeature > & Features(void) const
Get all controller features.
Definition: Controller.h:50
bool CanHaveAddonOrInstanceSettings() override
Check whether this add-on can be configured by the user.
Definition: Controller.h:43
FEATURE_TYPE FeatureType(const std::string &feature) const
Get the type of the specified feature.
Definition: Controller.cpp:98
Definition: Addon.h:34