xbmc
IButtonMap.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 
11 #include "input/joysticks/DriverPrimitive.h"
13 
14 #include <string>
15 #include <vector>
16 
17 namespace KODI
18 {
19 namespace JOYSTICK
20 {
29 {
30 public:
31  virtual ~IButtonMap() = default;
32 
41  virtual std::string ControllerID(void) const = 0;
42 
48  virtual std::string Location(void) const = 0;
49 
55  virtual bool Load(void) = 0;
56 
60  virtual void Reset(void) = 0;
61 
67  virtual bool IsEmpty(void) const = 0;
68 
75  virtual std::string GetAppearance() const = 0;
76 
85  virtual bool SetAppearance(const std::string& controllerId) const = 0;
86 
99  virtual bool GetFeature(const CDriverPrimitive& primitive, FeatureName& feature) = 0;
100 
108  virtual FEATURE_TYPE GetFeatureType(const FeatureName& feature) = 0;
109 
129  virtual bool GetScalar(const FeatureName& feature, CDriverPrimitive& primitive) = 0;
130 
140  virtual void AddScalar(const FeatureName& feature, const CDriverPrimitive& primitive) = 0;
141 
151  virtual bool GetAnalogStick(const FeatureName& feature,
152  ANALOG_STICK_DIRECTION direction,
153  CDriverPrimitive& primitive) = 0;
154 
164  virtual void AddAnalogStick(const FeatureName& feature,
165  ANALOG_STICK_DIRECTION direction,
166  const CDriverPrimitive& primitive) = 0;
167 
177  virtual bool GetRelativePointer(const FeatureName& feature,
178  RELATIVE_POINTER_DIRECTION direction,
179  CDriverPrimitive& primitive) = 0;
180 
190  virtual void AddRelativePointer(const FeatureName& feature,
191  RELATIVE_POINTER_DIRECTION direction,
192  const CDriverPrimitive& primitive) = 0;
193 
204  virtual bool GetAccelerometer(const FeatureName& feature,
205  CDriverPrimitive& positiveX,
206  CDriverPrimitive& positiveY,
207  CDriverPrimitive& positiveZ) = 0;
208 
221  virtual void AddAccelerometer(const FeatureName& feature,
222  const CDriverPrimitive& positiveX,
223  const CDriverPrimitive& positiveY,
224  const CDriverPrimitive& positiveZ) = 0;
225 
235  virtual bool GetWheel(const FeatureName& feature,
236  WHEEL_DIRECTION direction,
237  CDriverPrimitive& primitive) = 0;
238 
248  virtual void AddWheel(const FeatureName& feature,
249  WHEEL_DIRECTION direction,
250  const CDriverPrimitive& primitive) = 0;
251 
261  virtual bool GetThrottle(const FeatureName& feature,
262  THROTTLE_DIRECTION direction,
263  CDriverPrimitive& primitive) = 0;
264 
274  virtual void AddThrottle(const FeatureName& feature,
275  THROTTLE_DIRECTION direction,
276  const CDriverPrimitive& primitive) = 0;
277 
287  virtual bool GetKey(const FeatureName& feature, CDriverPrimitive& primitive) = 0;
288 
298  virtual void AddKey(const FeatureName& feature, const CDriverPrimitive& primitive) = 0;
299 
309  virtual void SetIgnoredPrimitives(const std::vector<CDriverPrimitive>& primitives) = 0;
310 
318  virtual bool IsIgnored(const CDriverPrimitive& primitive) = 0;
319 
329  virtual bool GetAxisProperties(unsigned int axisIndex, int& center, unsigned int& range) = 0;
330 
334  virtual void SaveButtonMap() = 0;
335 
340  virtual void RevertButtonMap() = 0;
341 };
342 } // namespace JOYSTICK
343 } // namespace KODI
THROTTLE_DIRECTION
Directions on a throttle.
Definition: JoystickTypes.h:130
virtual void AddAnalogStick(const FeatureName &feature, ANALOG_STICK_DIRECTION direction, const CDriverPrimitive &primitive)=0
Add or update an analog stick direction.
virtual bool GetRelativePointer(const FeatureName &feature, RELATIVE_POINTER_DIRECTION direction, CDriverPrimitive &primitive)=0
Get a relative pointer direction from the button map.
virtual bool GetWheel(const FeatureName &feature, WHEEL_DIRECTION direction, CDriverPrimitive &primitive)=0
Get a wheel direction from the button map.
virtual bool SetAppearance(const std::string &controllerId) const =0
Set the ID of the controller that best represents the appearance of the peripheral.
virtual bool GetFeature(const CDriverPrimitive &primitive, FeatureName &feature)=0
Get the feature associated with a driver primitive.
virtual void AddAccelerometer(const FeatureName &feature, const CDriverPrimitive &positiveX, const CDriverPrimitive &positiveY, const CDriverPrimitive &positiveZ)=0
Get or update an accelerometer.
virtual bool GetAxisProperties(unsigned int axisIndex, int &center, unsigned int &range)=0
Get the properties of an axis.
virtual bool GetKey(const FeatureName &feature, CDriverPrimitive &primitive)=0
Get the driver primitive for a keyboard key.
virtual bool GetAccelerometer(const FeatureName &feature, CDriverPrimitive &positiveX, CDriverPrimitive &positiveY, CDriverPrimitive &positiveZ)=0
Get an accelerometer from the button map.
FEATURE_TYPE
Types of features used in the joystick library.
Definition: JoystickTypes.h:49
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:28
virtual void SetIgnoredPrimitives(const std::vector< CDriverPrimitive > &primitives)=0
Set a list of driver primitives to be ignored.
virtual void AddKey(const FeatureName &feature, const CDriverPrimitive &primitive)=0
Add or update a key.
virtual bool Load(void)=0
Load the button map into memory.
WHEEL_DIRECTION
Directions on a wheel.
Definition: JoystickTypes.h:120
Definition: AudioDecoder.h:18
virtual bool IsIgnored(const CDriverPrimitive &primitive)=0
Check if a primitive is in the list of primitives to be ignored.
Basic driver element associated with input events.
Definition: DriverPrimitive.h:69
virtual void AddRelativePointer(const FeatureName &feature, RELATIVE_POINTER_DIRECTION direction, const CDriverPrimitive &primitive)=0
Add or update a relative pointer direction.
virtual void AddScalar(const FeatureName &feature, const CDriverPrimitive &primitive)=0
Add or update a scalar feature.
std::string FeatureName
Name of a physical feature belonging to the joystick.
Definition: JoystickTypes.h:28
virtual std::string GetAppearance() const =0
Get the ID of the controller profile that best represents the appearance of the peripheral.
virtual FEATURE_TYPE GetFeatureType(const FeatureName &feature)=0
Get the type of the feature for the given name.
virtual void SaveButtonMap()=0
Save the button map.
virtual bool GetThrottle(const FeatureName &feature, THROTTLE_DIRECTION direction, CDriverPrimitive &primitive)=0
Get a throttle direction from the button map.
virtual void RevertButtonMap()=0
Revert changes to the button map since the last time it was loaded or committed to disk...
virtual std::string Location(void) const =0
The Location of the peripheral associated with this button map.
virtual void Reset(void)=0
Reset the button map to its defaults, or clear button map if no defaults.
virtual bool IsEmpty(void) const =0
Check if the button map is empty.
virtual void AddThrottle(const FeatureName &feature, THROTTLE_DIRECTION direction, const CDriverPrimitive &primitive)=0
Add or update a throttle direction.
virtual void AddWheel(const FeatureName &feature, WHEEL_DIRECTION direction, const CDriverPrimitive &primitive)=0
Add or update a wheel direction.
virtual bool GetScalar(const FeatureName &feature, CDriverPrimitive &primitive)=0
Get the driver primitive for a scalar feature.
virtual bool GetAnalogStick(const FeatureName &feature, ANALOG_STICK_DIRECTION direction, CDriverPrimitive &primitive)=0
Get an analog stick direction from the button map.
virtual std::string ControllerID(void) const =0
The add-on ID of the game controller associated with this button map.