blob: 25ffe0fc888b61a866a63c9066e2ef7afed076c2 (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* 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 "ControllerTypes.h"
#include "addons/IAddon.h"
#include "threads/CriticalSection.h"
#include <map>
#include <set>
#include <string>
namespace ADDON
{
struct AddonEvent;
} // namespace ADDON
namespace KODI
{
namespace GAME
{
class CControllerManager
{
public:
CControllerManager(ADDON::CAddonMgr& addonManager);
~CControllerManager();
/*!
* \brief Get a controller
*
* A cache is used to avoid reloading controllers each time they are
* requested.
*
* \param controllerId The controller's ID
*
* \return The controller, or empty if the controller isn't installed or
* can't be loaded
*/
ControllerPtr GetController(const std::string& controllerId);
/*!
* \brief Get the default controller
*
* \return The default controller, or empty if the controller failed to load
*/
ControllerPtr GetDefaultController();
/*!
* \brief Get the default keyboard
*
* \return The keyboard controller, or empty if the controller failed to load
*/
ControllerPtr GetDefaultKeyboard();
/*!
* \brief Get the default mouse
*
* \return The mouse controller, or empty if the controller failed to load
*/
ControllerPtr GetDefaultMouse();
/*!
* \brief Get installed controllers
*
* \return The installed controllers that loaded successfully
*/
ControllerVector GetControllers();
private:
// Add-on event handler
void OnEvent(const ADDON::AddonEvent& event);
// Utility functions
ControllerPtr LoadController(const ADDON::AddonPtr& addon);
// Construction parameters
ADDON::CAddonMgr& m_addonManager;
// Controller state
std::map<std::string, ControllerPtr> m_cache;
std::set<std::string> m_failedControllers; // Controllers that failed to load
// Synchronization parameters
CCriticalSection m_mutex;
};
} // namespace GAME
} // namespace KODI
|