kodi
DefaultButtonMap.h
1 /*
2  * Copyright (C) 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/interfaces/IButtonMap.h"
12 
13 #include <memory>
14 #include <string>
15 
16 namespace PERIPHERALS
17 {
18 class CPeripheral;
19 }
20 
21 namespace KODI
22 {
23 namespace GAME
24 {
31 {
32 public:
33  CDefaultButtonMap(PERIPHERALS::CPeripheral* device, std::string strControllerId);
34 
35  ~CDefaultButtonMap() override;
36 
37  // Implementation of IButtonMap
38  std::string ControllerID() const override { return m_strControllerId; }
39  std::string Location() const override;
40  bool Load() override;
41  void Reset() override {}
42  bool IsEmpty() const override { return false; }
43  std::string GetAppearance() const override;
44  bool SetAppearance(const std::string& controllerId) const override { return false; }
45  bool GetFeature(const JOYSTICK::CDriverPrimitive& primitive,
46  JOYSTICK::FeatureName& feature) override;
47  JOYSTICK::FEATURE_TYPE GetFeatureType(const JOYSTICK::FeatureName& feature) override
48  {
49  return JOYSTICK::FEATURE_TYPE::UNKNOWN;
50  }
51  bool GetScalar(const JOYSTICK::FeatureName& feature,
52  JOYSTICK::CDriverPrimitive& primitive) override
53  {
54  return false;
55  }
56  void AddScalar(const JOYSTICK::FeatureName& feature,
57  const JOYSTICK::CDriverPrimitive& primitive) override
58  {
59  }
60  bool GetAnalogStick(const JOYSTICK::FeatureName& feature,
61  JOYSTICK::ANALOG_STICK_DIRECTION direction,
62  JOYSTICK::CDriverPrimitive& primitive) override
63  {
64  return false;
65  }
66  void AddAnalogStick(const JOYSTICK::FeatureName& feature,
67  JOYSTICK::ANALOG_STICK_DIRECTION direction,
68  const JOYSTICK::CDriverPrimitive& primitive) override
69  {
70  }
71  bool GetRelativePointer(const JOYSTICK::FeatureName& feature,
72  JOYSTICK::RELATIVE_POINTER_DIRECTION direction,
73  JOYSTICK::CDriverPrimitive& primitive) override
74  {
75  return false;
76  }
77  void AddRelativePointer(const JOYSTICK::FeatureName& feature,
78  JOYSTICK::RELATIVE_POINTER_DIRECTION direction,
79  const JOYSTICK::CDriverPrimitive& primitive) override
80  {
81  }
82  bool GetAccelerometer(const JOYSTICK::FeatureName& feature,
83  JOYSTICK::CDriverPrimitive& positiveX,
84  JOYSTICK::CDriverPrimitive& positiveY,
85  JOYSTICK::CDriverPrimitive& positiveZ) override
86  {
87  return false;
88  }
89  void AddAccelerometer(const JOYSTICK::FeatureName& feature,
90  const JOYSTICK::CDriverPrimitive& positiveX,
91  const JOYSTICK::CDriverPrimitive& positiveY,
92  const JOYSTICK::CDriverPrimitive& positiveZ) override
93  {
94  }
95  bool GetWheel(const JOYSTICK::FeatureName& feature,
96  JOYSTICK::WHEEL_DIRECTION direction,
97  JOYSTICK::CDriverPrimitive& primitive) override
98  {
99  return false;
100  }
101  void AddWheel(const JOYSTICK::FeatureName& feature,
102  JOYSTICK::WHEEL_DIRECTION direction,
103  const JOYSTICK::CDriverPrimitive& primitive) override
104  {
105  }
106  bool GetThrottle(const JOYSTICK::FeatureName& feature,
107  JOYSTICK::THROTTLE_DIRECTION direction,
108  JOYSTICK::CDriverPrimitive& primitive) override
109  {
110  return false;
111  }
112  void AddThrottle(const JOYSTICK::FeatureName& feature,
113  JOYSTICK::THROTTLE_DIRECTION direction,
114  const JOYSTICK::CDriverPrimitive& primitive) override
115  {
116  }
117  bool GetKey(const JOYSTICK::FeatureName& feature, JOYSTICK::CDriverPrimitive& primitive) override
118  {
119  return false;
120  }
121  void AddKey(const JOYSTICK::FeatureName& feature,
122  const JOYSTICK::CDriverPrimitive& primitive) override
123  {
124  }
125  void SetIgnoredPrimitives(const std::vector<JOYSTICK::CDriverPrimitive>& primitives) override {}
126  bool IsIgnored(const JOYSTICK::CDriverPrimitive& primitive) override { return false; }
127  bool GetAxisProperties(unsigned int axisIndex, int& center, unsigned int& range) override
128  {
129  return false;
130  }
131  void SaveButtonMap() override {}
132  void RevertButtonMap() override {}
133 
134 private:
135  // Construction parameters
136  PERIPHERALS::CPeripheral* const m_device;
137  const std::string m_strControllerId;
138 };
139 } // namespace GAME
140 } // namespace KODI
void AddAnalogStick(const JOYSTICK::FeatureName &feature, JOYSTICK::ANALOG_STICK_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
Add or update an analog stick direction.
Definition: DefaultButtonMap.h:66
bool IsEmpty() const override
Check if the button map is empty.
Definition: DefaultButtonMap.h:42
bool GetThrottle(const JOYSTICK::FeatureName &feature, JOYSTICK::THROTTLE_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
Get a throttle direction from the button map.
Definition: DefaultButtonMap.h:106
JOYSTICK::FEATURE_TYPE GetFeatureType(const JOYSTICK::FeatureName &feature) override
Get the type of the feature for the given name.
Definition: DefaultButtonMap.h:47
bool GetRelativePointer(const JOYSTICK::FeatureName &feature, JOYSTICK::RELATIVE_POINTER_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
Get a relative pointer direction from the button map.
Definition: DefaultButtonMap.h:71
Definition: RetroPlayerInput.h:15
void AddScalar(const JOYSTICK::FeatureName &feature, const JOYSTICK::CDriverPrimitive &primitive) override
Add or update a scalar feature.
Definition: DefaultButtonMap.h:56
Button map interface to translate between the driver&#39;s raw button/hat/axis elements and physical joys...
Definition: IButtonMap.h:29
bool GetScalar(const JOYSTICK::FeatureName &feature, JOYSTICK::CDriverPrimitive &primitive) override
Get the driver primitive for a scalar feature.
Definition: DefaultButtonMap.h:51
void Reset() override
Reset the button map to its defaults, or clear button map if no defaults.
Definition: DefaultButtonMap.h:41
void AddAccelerometer(const JOYSTICK::FeatureName &feature, const JOYSTICK::CDriverPrimitive &positiveX, const JOYSTICK::CDriverPrimitive &positiveY, const JOYSTICK::CDriverPrimitive &positiveZ) override
Get or update an accelerometer.
Definition: DefaultButtonMap.h:89
bool IsIgnored(const JOYSTICK::CDriverPrimitive &primitive) override
Check if a primitive is in the list of primitives to be ignored.
Definition: DefaultButtonMap.h:126
void AddThrottle(const JOYSTICK::FeatureName &feature, JOYSTICK::THROTTLE_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
Add or update a throttle direction.
Definition: DefaultButtonMap.h:112
bool GetAnalogStick(const JOYSTICK::FeatureName &feature, JOYSTICK::ANALOG_STICK_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
Get an analog stick direction from the button map.
Definition: DefaultButtonMap.h:60
void RevertButtonMap() override
Revert changes to the button map since the last time it was loaded or committed to disk...
Definition: DefaultButtonMap.h:132
bool GetAccelerometer(const JOYSTICK::FeatureName &feature, JOYSTICK::CDriverPrimitive &positiveX, JOYSTICK::CDriverPrimitive &positiveY, JOYSTICK::CDriverPrimitive &positiveZ) override
Get an accelerometer from the button map.
Definition: DefaultButtonMap.h:82
void SetIgnoredPrimitives(const std::vector< JOYSTICK::CDriverPrimitive > &primitives) override
Set a list of driver primitives to be ignored.
Definition: DefaultButtonMap.h:125
Definition: AudioDecoder.h:18
void AddKey(const JOYSTICK::FeatureName &feature, const JOYSTICK::CDriverPrimitive &primitive) override
Add or update a key.
Definition: DefaultButtonMap.h:121
bool GetAxisProperties(unsigned int axisIndex, int &center, unsigned int &range) override
Get the properties of an axis.
Definition: DefaultButtonMap.h:127
bool GetKey(const JOYSTICK::FeatureName &feature, JOYSTICK::CDriverPrimitive &primitive) override
Get the driver primitive for a keyboard key.
Definition: DefaultButtonMap.h:117
Basic driver element associated with input events.
Definition: DriverPrimitive.h:70
bool SetAppearance(const std::string &controllerId) const override
Set the ID of the controller that best represents the appearance of the peripheral.
Definition: DefaultButtonMap.h:44
void SaveButtonMap() override
Save the button map.
Definition: DefaultButtonMap.h:131
std::string ControllerID() const override
The add-on ID of the game controller associated with this button map.
Definition: DefaultButtonMap.h:38
void AddWheel(const JOYSTICK::FeatureName &feature, JOYSTICK::WHEEL_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
Add or update a wheel direction.
Definition: DefaultButtonMap.h:101
Definition: Peripheral.h:71
A fallback buttonmap to be used with the default keyboard profile.
Definition: DefaultButtonMap.h:30
void AddRelativePointer(const JOYSTICK::FeatureName &feature, JOYSTICK::RELATIVE_POINTER_DIRECTION direction, const JOYSTICK::CDriverPrimitive &primitive) override
Add or update a relative pointer direction.
Definition: DefaultButtonMap.h:77
bool GetWheel(const JOYSTICK::FeatureName &feature, JOYSTICK::WHEEL_DIRECTION direction, JOYSTICK::CDriverPrimitive &primitive) override
Get a wheel direction from the button map.
Definition: DefaultButtonMap.h:95