kodi
KeymapHandling.h
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 "utils/Observer.h"
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 namespace KODI
18 {
19 namespace JOYSTICK
20 {
21 class IInputHandler;
22 class IInputProvider;
23 class IInputReceiver;
24 } // namespace JOYSTICK
25 
26 namespace KEYMAP
27 {
28 class IKeymap;
29 class IKeymapEnvironment;
30 
34 class CKeymapHandling : public Observer
35 {
36 public:
38  bool pPromiscuous,
39  const IKeymapEnvironment* environment);
40 
41  ~CKeymapHandling() override;
42 
50  void UnregisterInputProvider() { m_inputProvider = nullptr; }
51 
55  JOYSTICK::IInputReceiver* GetInputReceiver(const std::string& controllerId) const;
56 
60  IKeymap* GetKeymap(const std::string& controllerId) const;
61 
62  // implementation of Observer
63  void Notify(const Observable& obs, const ObservableMessage msg) override;
64 
65 private:
66  void LoadKeymaps();
67  void UnloadKeymaps();
68 
69  // Construction parameter
70  JOYSTICK::IInputProvider* m_inputProvider;
71  const bool m_pPromiscuous;
72  const IKeymapEnvironment* const m_environment;
73 
74  std::vector<std::unique_ptr<IKeymap>> m_keymaps;
75  std::vector<std::unique_ptr<JOYSTICK::IInputHandler>> m_inputHandlers;
76 };
77 } // namespace KEYMAP
78 } // namespace KODI
Definition: IInputHandler.h:16
Interface for classes that can provide input.
Definition: IInputProvider.h:22
Customizes the environment in which keymapping is performed.
Definition: IKeymapEnvironment.h:27
Definition: KeymapHandling.h:34
Definition: AudioDecoder.h:18
Definition: Observer.h:31
Interface for sending input events to game controllers.
Definition: IInputReceiver.h:22
Definition: Observer.h:44
void UnregisterInputProvider()
Unregister the input provider.
Definition: KeymapHandling.h:50
Interface for mapping buttons to Kodi actions.
Definition: IKeymap.h:28