diff options
Diffstat (limited to 'src/core/hid/input_converter.cpp')
| -rw-r--r-- | src/core/hid/input_converter.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 480b862fd..c4e653956 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -242,6 +242,27 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta | |||
| 242 | return status; | 242 | return status; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback) { | ||
| 246 | Common::Input::AnalogStatus status{}; | ||
| 247 | |||
| 248 | switch (callback.type) { | ||
| 249 | case Common::Input::InputType::Analog: | ||
| 250 | status.properties = callback.analog_status.properties; | ||
| 251 | status.raw_value = callback.analog_status.raw_value; | ||
| 252 | break; | ||
| 253 | default: | ||
| 254 | LOG_ERROR(Input, "Conversion from type {} to analog not implemented", callback.type); | ||
| 255 | break; | ||
| 256 | } | ||
| 257 | |||
| 258 | SanitizeAnalog(status, false); | ||
| 259 | |||
| 260 | // Adjust if value is inverted | ||
| 261 | status.value = status.properties.inverted ? -status.value : status.value; | ||
| 262 | |||
| 263 | return status; | ||
| 264 | } | ||
| 265 | |||
| 245 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { | 266 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { |
| 246 | const auto& properties = analog.properties; | 267 | const auto& properties = analog.properties; |
| 247 | float& raw_value = analog.raw_value; | 268 | float& raw_value = analog.raw_value; |