Debian Codegraph @

xbmc/input/keymaps/joysticks/JoystickMapper.h

raw
1 /*
2 * Copyright (C) 2017-2024 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 "input/joysticks/JoystickTypes.h"
12 #include "input/keymaps/interfaces/IKeyMapper.h"
13
14 #include <map>
15 #include <memory>
16 #include <set>
17 #include <string>
18 #include <vector>
19
20 namespace tinyxml2
21 {
22 class XMLElement;
23 class XMLNode;
24 } // namespace tinyxml2
25
26 namespace KODI
27 {
28 namespace KEYMAP
29 {
30 class IWindowKeymap;
31
32 /*!
33 * \ingroup keymap
34 */
35 class CJoystickMapper : public IKeyMapper
36 {
37 public:
38 CJoystickMapper() = default;
39 ~CJoystickMapper() override = default;
40
41 // implementation of IKeyMapper
42 void MapActions(int windowID, const tinyxml2::XMLNode* pDevice) override;
43 void Clear() override;
44
45 std::vector<std::shared_ptr<const KEYMAP::IWindowKeymap>> GetJoystickKeymaps() const;
46
47 private:
48 void DeserializeJoystickNode(const tinyxml2::XMLNode* pDevice, std::string& controllerId);
49 bool DeserializeButton(const tinyxml2::XMLElement* pButton,
50 std::string& feature,
51 KODI::JOYSTICK::ANALOG_STICK_DIRECTION& dir,
52 unsigned int& holdtimeMs,
53 std::set<std::string>& hotkeys,
54 std::string& actionStr);
55
56 using ControllerID = std::string;
57 std::map<ControllerID, std::shared_ptr<IWindowKeymap>> m_joystickKeymaps;
58
59 std::vector<std::string> m_controllerIds;
60 };
61 } // namespace KEYMAP
62 } // namespace KODI