diff options
Diffstat (limited to 'src/input_common/input_engine.h')
| -rw-r--r-- | src/input_common/input_engine.h | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 02272b3f8..390581c94 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -23,15 +23,15 @@ struct PadIdentifier { | |||
| 23 | friend constexpr bool operator==(const PadIdentifier&, const PadIdentifier&) = default; | 23 | friend constexpr bool operator==(const PadIdentifier&, const PadIdentifier&) = default; |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | // Basic motion data containing data from the sensors and a timestamp in microsecons | 26 | // Basic motion data containing data from the sensors and a timestamp in microseconds |
| 27 | struct BasicMotion { | 27 | struct BasicMotion { |
| 28 | float gyro_x; | 28 | float gyro_x{}; |
| 29 | float gyro_y; | 29 | float gyro_y{}; |
| 30 | float gyro_z; | 30 | float gyro_z{}; |
| 31 | float accel_x; | 31 | float accel_x{}; |
| 32 | float accel_y; | 32 | float accel_y{}; |
| 33 | float accel_z; | 33 | float accel_z{}; |
| 34 | u64 delta_timestamp; | 34 | u64 delta_timestamp{}; |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | // Stages of a battery charge | 37 | // Stages of a battery charge |
| @@ -102,9 +102,7 @@ struct InputIdentifier { | |||
| 102 | 102 | ||
| 103 | class InputEngine { | 103 | class InputEngine { |
| 104 | public: | 104 | public: |
| 105 | explicit InputEngine(const std::string& input_engine_) : input_engine(input_engine_) { | 105 | explicit InputEngine(std::string input_engine_) : input_engine{std::move(input_engine_)} {} |
| 106 | callback_list.clear(); | ||
| 107 | } | ||
| 108 | 106 | ||
| 109 | virtual ~InputEngine() = default; | 107 | virtual ~InputEngine() = default; |
| 110 | 108 | ||
| @@ -116,14 +114,12 @@ public: | |||
| 116 | 114 | ||
| 117 | // Sets a led pattern for a controller | 115 | // Sets a led pattern for a controller |
| 118 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, | 116 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, |
| 119 | [[maybe_unused]] const Common::Input::LedStatus led_status) { | 117 | [[maybe_unused]] const Common::Input::LedStatus& led_status) {} |
| 120 | return; | ||
| 121 | } | ||
| 122 | 118 | ||
| 123 | // Sets rumble to a controller | 119 | // Sets rumble to a controller |
| 124 | virtual Common::Input::VibrationError SetRumble( | 120 | virtual Common::Input::VibrationError SetRumble( |
| 125 | [[maybe_unused]] const PadIdentifier& identifier, | 121 | [[maybe_unused]] const PadIdentifier& identifier, |
| 126 | [[maybe_unused]] const Common::Input::VibrationStatus vibration) { | 122 | [[maybe_unused]] const Common::Input::VibrationStatus& vibration) { |
| 127 | return Common::Input::VibrationError::NotSupported; | 123 | return Common::Input::VibrationError::NotSupported; |
| 128 | } | 124 | } |
| 129 | 125 | ||
| @@ -140,36 +136,36 @@ public: | |||
| 140 | /// Used for automapping features | 136 | /// Used for automapping features |
| 141 | virtual std::vector<Common::ParamPackage> GetInputDevices() const { | 137 | virtual std::vector<Common::ParamPackage> GetInputDevices() const { |
| 142 | return {}; | 138 | return {}; |
| 143 | }; | 139 | } |
| 144 | 140 | ||
| 145 | /// Retrieves the button mappings for the given device | 141 | /// Retrieves the button mappings for the given device |
| 146 | virtual InputCommon::ButtonMapping GetButtonMappingForDevice( | 142 | virtual ButtonMapping GetButtonMappingForDevice( |
| 147 | [[maybe_unused]] const Common::ParamPackage& params) { | 143 | [[maybe_unused]] const Common::ParamPackage& params) { |
| 148 | return {}; | 144 | return {}; |
| 149 | }; | 145 | } |
| 150 | 146 | ||
| 151 | /// Retrieves the analog mappings for the given device | 147 | /// Retrieves the analog mappings for the given device |
| 152 | virtual InputCommon::AnalogMapping GetAnalogMappingForDevice( | 148 | virtual AnalogMapping GetAnalogMappingForDevice( |
| 153 | [[maybe_unused]] const Common::ParamPackage& params) { | 149 | [[maybe_unused]] const Common::ParamPackage& params) { |
| 154 | return {}; | 150 | return {}; |
| 155 | }; | 151 | } |
| 156 | 152 | ||
| 157 | /// Retrieves the motion mappings for the given device | 153 | /// Retrieves the motion mappings for the given device |
| 158 | virtual InputCommon::MotionMapping GetMotionMappingForDevice( | 154 | virtual MotionMapping GetMotionMappingForDevice( |
| 159 | [[maybe_unused]] const Common::ParamPackage& params) { | 155 | [[maybe_unused]] const Common::ParamPackage& params) { |
| 160 | return {}; | 156 | return {}; |
| 161 | }; | 157 | } |
| 162 | 158 | ||
| 163 | /// Retrieves the name of the given input. | 159 | /// Retrieves the name of the given input. |
| 164 | virtual Common::Input::ButtonNames GetUIName( | 160 | virtual Common::Input::ButtonNames GetUIName( |
| 165 | [[maybe_unused]] const Common::ParamPackage& params) const { | 161 | [[maybe_unused]] const Common::ParamPackage& params) const { |
| 166 | return Common::Input::ButtonNames::Engine; | 162 | return Common::Input::ButtonNames::Engine; |
| 167 | }; | 163 | } |
| 168 | 164 | ||
| 169 | /// Retrieves the index number of the given hat button direction | 165 | /// Retrieves the index number of the given hat button direction |
| 170 | virtual u8 GetHatButtonId([[maybe_unused]] const std::string& direction_name) const { | 166 | virtual u8 GetHatButtonId([[maybe_unused]] const std::string& direction_name) const { |
| 171 | return 0; | 167 | return 0; |
| 172 | }; | 168 | } |
| 173 | 169 | ||
| 174 | void PreSetController(const PadIdentifier& identifier); | 170 | void PreSetController(const PadIdentifier& identifier); |
| 175 | void PreSetButton(const PadIdentifier& identifier, int button); | 171 | void PreSetButton(const PadIdentifier& identifier, int button); |
| @@ -194,7 +190,7 @@ protected: | |||
| 194 | void SetHatButton(const PadIdentifier& identifier, int button, u8 value); | 190 | void SetHatButton(const PadIdentifier& identifier, int button, u8 value); |
| 195 | void SetAxis(const PadIdentifier& identifier, int axis, f32 value); | 191 | void SetAxis(const PadIdentifier& identifier, int axis, f32 value); |
| 196 | void SetBattery(const PadIdentifier& identifier, BatteryLevel value); | 192 | void SetBattery(const PadIdentifier& identifier, BatteryLevel value); |
| 197 | void SetMotion(const PadIdentifier& identifier, int motion, BasicMotion value); | 193 | void SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value); |
| 198 | 194 | ||
| 199 | virtual std::string GetHatButtonName([[maybe_unused]] u8 direction_value) const { | 195 | virtual std::string GetHatButtonName([[maybe_unused]] u8 direction_value) const { |
| 200 | return "Unknown"; | 196 | return "Unknown"; |
| @@ -206,14 +202,15 @@ private: | |||
| 206 | std::unordered_map<int, u8> hat_buttons; | 202 | std::unordered_map<int, u8> hat_buttons; |
| 207 | std::unordered_map<int, float> axes; | 203 | std::unordered_map<int, float> axes; |
| 208 | std::unordered_map<int, BasicMotion> motions; | 204 | std::unordered_map<int, BasicMotion> motions; |
| 209 | BatteryLevel battery; | 205 | BatteryLevel battery{}; |
| 210 | }; | 206 | }; |
| 211 | 207 | ||
| 212 | void TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value); | 208 | void TriggerOnButtonChange(const PadIdentifier& identifier, int button, bool value); |
| 213 | void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value); | 209 | void TriggerOnHatButtonChange(const PadIdentifier& identifier, int button, u8 value); |
| 214 | void TriggerOnAxisChange(const PadIdentifier& identifier, int button, f32 value); | 210 | void TriggerOnAxisChange(const PadIdentifier& identifier, int axis, f32 value); |
| 215 | void TriggerOnBatteryChange(const PadIdentifier& identifier, BatteryLevel value); | 211 | void TriggerOnBatteryChange(const PadIdentifier& identifier, BatteryLevel value); |
| 216 | void TriggerOnMotionChange(const PadIdentifier& identifier, int motion, BasicMotion value); | 212 | void TriggerOnMotionChange(const PadIdentifier& identifier, int motion, |
| 213 | const BasicMotion& value); | ||
| 217 | 214 | ||
| 218 | bool IsInputIdentifierEqual(const InputIdentifier& input_identifier, | 215 | bool IsInputIdentifierEqual(const InputIdentifier& input_identifier, |
| 219 | const PadIdentifier& identifier, EngineInputType type, | 216 | const PadIdentifier& identifier, EngineInputType type, |