xbmc
ControllerManager.h
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 "ControllerTypes.h"
12 #include "addons/IAddon.h"
13 #include "threads/CriticalSection.h"
14 
15 #include <map>
16 #include <set>
17 #include <string>
18 
19 namespace ADDON
20 {
21 struct AddonEvent;
22 } // namespace ADDON
23 
24 namespace KODI
25 {
26 namespace GAME
27 {
32 {
33 public:
34  CControllerManager(ADDON::CAddonMgr& addonManager);
36 
48  ControllerPtr GetController(const std::string& controllerId);
49 
55  ControllerPtr GetDefaultController();
56 
62  ControllerPtr GetDefaultKeyboard();
63 
69  ControllerPtr GetDefaultMouse();
70 
76  ControllerVector GetControllers();
77 
87  std::string TranslateFeature(const std::string& controllerId, const std::string& featureName);
88 
89 private:
90  // Add-on event handler
91  void OnEvent(const ADDON::AddonEvent& event);
92 
93  // Utility functions
94  ControllerPtr LoadController(const ADDON::AddonPtr& addon);
95 
96  // Construction parameters
97  ADDON::CAddonMgr& m_addonManager;
98 
99  // Controller state
100  std::map<std::string, ControllerPtr> m_cache;
101  std::set<std::string> m_failedControllers; // Controllers that failed to load
102 
103  // Synchronization parameters
104  CCriticalSection m_mutex;
105 };
106 } // namespace GAME
107 } // namespace KODI
Class - CAddonMgr Holds references to all addons, enabled or otherwise.
Definition: AddonManager.h:79
Definition: ControllerManager.h:31
Definition: AudioDecoder.h:18
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
Definition: AddonEvents.h:18
Definition: Addon.cpp:39
std::vector< ControllerPtr > ControllerVector
Vector of smart pointers to a game controller (CController)
Definition: ControllerTypes.h:32