xbmc
IButtonMapper.h
1 /*
2  * Copyright (C) 2014-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 
12 
13 #include <map>
14 #include <string>
15 
16 class IKeymap;
17 
18 namespace KODI
19 {
20 namespace JOYSTICK
21 {
22 class CDriverPrimitive;
23 class IButtonMap;
24 class IButtonMapCallback;
25 
34 {
35 public:
36  IButtonMapper() = default;
37 
38  virtual ~IButtonMapper() = default;
39 
45  virtual std::string ControllerID(void) const = 0;
46 
54  virtual bool NeedsCooldown(void) const = 0;
55 
63  virtual bool AcceptsPrimitive(PRIMITIVE_TYPE type) const = 0;
64 
76  virtual bool MapPrimitive(IButtonMap* buttonMap,
77  IKeymap* keyMap,
78  const CDriverPrimitive& primitive) = 0;
79 
99  virtual void OnEventFrame(const IButtonMap* buttonMap, bool bMotion) = 0;
100 
110  virtual void OnLateAxis(const IButtonMap* buttonMap, unsigned int axisIndex) = 0;
111 
112  // Button map callback interface
113  void SetButtonMapCallback(const std::string& deviceName, IButtonMapCallback* callback)
114  {
115  m_callbacks[deviceName] = callback;
116  }
117  void ResetButtonMapCallbacks(void) { m_callbacks.clear(); }
118  std::map<std::string, IButtonMapCallback*>& ButtonMapCallbacks(void) { return m_callbacks; }
119 
120 private:
121  std::map<std::string, IButtonMapCallback*> m_callbacks;
122 };
123 } // namespace JOYSTICK
124 } // namespace KODI
virtual bool MapPrimitive(IButtonMap *buttonMap, IKeymap *keyMap, const CDriverPrimitive &primitive)=0
Handle button/hat press or axis threshold.
virtual std::string ControllerID(void) const =0
The add-on ID of the game controller associated with this button mapper.
virtual bool AcceptsPrimitive(PRIMITIVE_TYPE type) const =0
Return true if the button mapper accepts primitives of the given type.
Interface for mapping buttons to Kodi actions.
Definition: IKeymap.h:22
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:28
virtual bool NeedsCooldown(void) const =0
Return true if the button mapper wants a cooldown between button mapping commands.
virtual void OnEventFrame(const IButtonMap *buttonMap, bool bMotion)=0
Called once per event frame to notify the implementation of motion status.
PRIMITIVE_TYPE
Type of driver primitive.
Definition: JoystickTypes.h:150
Controller configuration window.
Definition: AudioDecoder.h:18
virtual void OnLateAxis(const IButtonMap *buttonMap, unsigned int axisIndex)=0
Called when an axis has been detected after mapping began.
Basic driver element associated with input events.
Definition: DriverPrimitive.h:69
Button mapper interface to assign the driver&#39;s raw button/hat/axis elements to physical joystick feat...
Definition: IButtonMapper.h:33
Interface for handling button maps.
Definition: IButtonMapCallback.h:18