diff options
Diffstat (limited to 'src/core/hid/input_converter.h')
| -rw-r--r-- | src/core/hid/input_converter.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/core/hid/input_converter.h b/src/core/hid/input_converter.h new file mode 100644 index 000000000..d24582226 --- /dev/null +++ b/src/core/hid/input_converter.h | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | namespace Common::Input { | ||
| 8 | struct CallbackStatus; | ||
| 9 | enum class BatteryLevel : u32; | ||
| 10 | using BatteryStatus = BatteryLevel; | ||
| 11 | struct AnalogStatus; | ||
| 12 | struct ButtonStatus; | ||
| 13 | struct MotionStatus; | ||
| 14 | struct StickStatus; | ||
| 15 | struct TouchStatus; | ||
| 16 | struct TriggerStatus; | ||
| 17 | }; // namespace Common::Input | ||
| 18 | |||
| 19 | namespace Core::HID { | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Converts raw input data into a valid battery status. | ||
| 23 | * | ||
| 24 | * @param callback Supported callbacks: Analog, Battery, Trigger. | ||
| 25 | * @return A valid BatteryStatus object. | ||
| 26 | */ | ||
| 27 | Common::Input::BatteryStatus TransformToBattery(const Common::Input::CallbackStatus& callback); | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Converts raw input data into a valid button status. Applies invert properties to the output. | ||
| 31 | * | ||
| 32 | * @param callback Supported callbacks: Analog, Button, Trigger. | ||
| 33 | * @return A valid TouchStatus object. | ||
| 34 | */ | ||
| 35 | Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatus& callback); | ||
| 36 | |||
| 37 | /** | ||
| 38 | * Converts raw input data into a valid motion status. | ||
| 39 | * | ||
| 40 | * @param callback Supported callbacks: Motion. | ||
| 41 | * @return A valid TouchStatus object. | ||
| 42 | */ | ||
| 43 | Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatus& callback); | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Converts raw input data into a valid stick status. Applies offset, deadzone, range and invert | ||
| 47 | * properties to the output. | ||
| 48 | * | ||
| 49 | * @param callback Supported callbacks: Stick. | ||
| 50 | * @return A valid StickStatus object. | ||
| 51 | */ | ||
| 52 | Common::Input::StickStatus TransformToStick(const Common::Input::CallbackStatus& callback); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Converts raw input data into a valid touch status. | ||
| 56 | * | ||
| 57 | * @param callback Supported callbacks: Touch. | ||
| 58 | * @return A valid TouchStatus object. | ||
| 59 | */ | ||
| 60 | Common::Input::TouchStatus TransformToTouch(const Common::Input::CallbackStatus& callback); | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Converts raw input data into a valid trigger status. Applies offset, deadzone, range and | ||
| 64 | * invert properties to the output. Button status uses the threshold property if necessary. | ||
| 65 | * | ||
| 66 | * @param callback Supported callbacks: Analog, Button, Trigger. | ||
| 67 | * @return A valid TriggerStatus object. | ||
| 68 | */ | ||
| 69 | Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback); | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Converts raw input data into a valid analog status. Applies offset, deadzone, range and | ||
| 73 | * invert properties to the output. | ||
| 74 | * | ||
| 75 | * @param callback Supported callbacks: Analog. | ||
| 76 | * @return A valid AnalogStatus object. | ||
| 77 | */ | ||
| 78 | Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback); | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Converts raw analog data into a valid analog value | ||
| 82 | * @param analog An analog object containing raw data and properties | ||
| 83 | * @param clamp_value determines if the value needs to be clamped between -1.0f and 1.0f. | ||
| 84 | */ | ||
| 85 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value); | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Converts raw stick data into a valid stick value | ||
| 89 | * @param analog_x raw analog data and properties for the x-axis | ||
| 90 | * @param analog_y raw analog data and properties for the y-axis | ||
| 91 | * @param clamp_value bool that determines if the value needs to be clamped into the unit circle. | ||
| 92 | */ | ||
| 93 | void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogStatus& analog_y, | ||
| 94 | bool clamp_value); | ||
| 95 | |||
| 96 | } // namespace Core::HID | ||