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