kodi
IButtonMap.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/DriverPrimitive.h"
12 #include "input/joysticks/JoystickTypes.h"
13 
14 #include <string>
15 #include <vector>
16 
17 namespace KODI
18 {
19 namespace JOYSTICK
20 {
30 {
31 public:
32  virtual ~IButtonMap() = default;
33 
42  virtual std::string ControllerID(void) const = 0;
43 
49  virtual std::string Location(void) const = 0;
50 
56  virtual bool Load(void) = 0;
57 
61  virtual void Reset(void) = 0;
62 
68  virtual bool IsEmpty(void) const = 0;
69 
76  virtual std::string GetAppearance() const = 0;
77 
86  virtual bool SetAppearance(const std::string& controllerId) const = 0;
87 
100  virtual bool GetFeature(const CDriverPrimitive& primitive, FeatureName& feature) = 0;
101 
109  virtual FEATURE_TYPE GetFeatureType(const FeatureName& feature) = 0;
110 
130  virtual bool GetScalar(const FeatureName& feature, CDriverPrimitive& primitive) = 0;
131 
141  virtual void AddScalar(const FeatureName& feature, const CDriverPrimitive& primitive) = 0;
142 
152  virtual bool GetAnalogStick(const FeatureName& feature,
153  ANALOG_STICK_DIRECTION direction,
154  CDriverPrimitive& primitive) = 0;
155 
165  virtual void AddAnalogStick(const FeatureName& feature,
166  ANALOG_STICK_DIRECTION direction,
167  const CDriverPrimitive& primitive) = 0;
168 
178  virtual bool GetRelativePointer(const FeatureName& feature,
179  RELATIVE_POINTER_DIRECTION direction,
180  CDriverPrimitive& primitive) = 0;
181 
191  virtual void AddRelativePointer(const FeatureName& feature,
192  RELATIVE_POINTER_DIRECTION direction,
193  const CDriverPrimitive& primitive) = 0;
194 
205  virtual bool GetAccelerometer(const FeatureName& feature,
206  CDriverPrimitive& positiveX,
207  CDriverPrimitive& positiveY,
208  CDriverPrimitive& positiveZ) = 0;
209 
222  virtual void AddAccelerometer(const FeatureName& feature,
223  const CDriverPrimitive& positiveX,
224  const CDriverPrimitive& positiveY,
225  const CDriverPrimitive& positiveZ) = 0;
226 
236  virtual bool GetWheel(const FeatureName& feature,
237  WHEEL_DIRECTION direction,
238  CDriverPrimitive& primitive) = 0;
239 
249  virtual void AddWheel(const FeatureName& feature,
250  WHEEL_DIRECTION direction,
251  const CDriverPrimitive& primitive) = 0;
252 
262  virtual bool GetThrottle(const FeatureName& feature,
263  THROTTLE_DIRECTION direction,
264  CDriverPrimitive& primitive) = 0;
265 
275  virtual void AddThrottle(const FeatureName& feature,
276  THROTTLE_DIRECTION direction,
277  const CDriverPrimitive& primitive) = 0;
278 
288  virtual bool GetKey(const FeatureName& feature, CDriverPrimitive& primitive) = 0;
289 
299  virtual void AddKey(const FeatureName& feature, const CDriverPrimitive& primitive) = 0;
300 
310  virtual void SetIgnoredPrimitives(const std::vector<CDriverPrimitive>& primitives) = 0;
311 
319  virtual bool IsIgnored(const CDriverPrimitive& primitive) = 0;
320 
330  virtual bool GetAxisProperties(unsigned int axisIndex, int& center, unsigned int& range) = 0;
331 
335  virtual void SaveButtonMap() = 0;
336 
341  virtual void RevertButtonMap() = 0;
342 };
343 } // namespace JOYSTICK
344 } // namespace KODI
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.
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:29
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.
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:70
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.
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.