kodi
IButtonMapper.h
1 /*
2  * Copyright (C) 2014-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 
13 #include <map>
14 #include <string>
15 
16 namespace KODI
17 {
18 namespace KEYMAP
19 {
20 class IKeymap;
21 } // namespace KEYMAP
22 
23 namespace JOYSTICK
24 {
25 class CDriverPrimitive;
26 class IButtonMap;
27 class IButtonMapCallback;
28 
38 {
39 public:
40  IButtonMapper() = default;
41 
42  virtual ~IButtonMapper() = default;
43 
49  virtual std::string ControllerID(void) const = 0;
50 
58  virtual bool NeedsCooldown(void) const = 0;
59 
67  virtual bool AcceptsPrimitive(PRIMITIVE_TYPE type) const = 0;
68 
80  virtual bool MapPrimitive(IButtonMap* buttonMap,
81  KEYMAP::IKeymap* keyMap,
82  const CDriverPrimitive& primitive) = 0;
83 
103  virtual void OnEventFrame(const IButtonMap* buttonMap, bool bMotion) = 0;
104 
114  virtual void OnLateAxis(const IButtonMap* buttonMap, unsigned int axisIndex) = 0;
115 
116  // Button map callback interface
117  void SetButtonMapCallback(const std::string& deviceLocation, IButtonMapCallback* callback)
118  {
119  m_callbacks[deviceLocation] = callback;
120  }
121  void ResetButtonMapCallbacks(void) { m_callbacks.clear(); }
122  std::map<std::string, IButtonMapCallback*>& ButtonMapCallbacks(void) { return m_callbacks; }
123 
124 private:
125  std::map<std::string, IButtonMapCallback*> m_callbacks; // Device location -> callback
126 };
127 } // namespace JOYSTICK
128 } // namespace KODI
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:29
Definition: AudioDecoder.h:18
Basic driver element associated with input events.
Definition: DriverPrimitive.h:70
Button mapper interface to assign the driver&#39;s raw button/hat/axis elements to physical joystick feat...
Definition: IButtonMapper.h:37
Interface for handling button maps.
Definition: IButtonMapCallback.h:20
Interface for mapping buttons to Kodi actions.
Definition: IKeymap.h:28