summaryrefslogtreecommitdiffstats
path: root/src/core/hid/input_converter.h
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-09-20 23:29:43 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:22 +0100
commit449576df93f6beb70cff0e009ccb2dd8bce1e085 (patch)
treefae04e0d292da6128a074cbe046de6169019774c /src/core/hid/input_converter.h
parentcore/hid: Move input_interpreter to hid (diff)
downloadyuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.tar
yuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.tar.gz
yuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.tar.bz2
yuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.tar.lz
yuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.tar.xz
yuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.tar.zst
yuzu-449576df93f6beb70cff0e009ccb2dd8bce1e085.zip
Diffstat (limited to 'src/core/hid/input_converter.h')
-rw-r--r--src/core/hid/input_converter.h77
1 files changed, 77 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..3cc32e26a
--- /dev/null
+++ b/src/core/hid/input_converter.h
@@ -0,0 +1,77 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included
+
+#pragma once
+
+namespace Input {
+struct CallbackStatus;
+};
+
+namespace Core::HID {
+
+/**
+ * Converts raw input data into a valid battery status.
+ *
+ * @param Supported callbacks: Analog, Battery, Trigger.
+ * @return A valid BatteryStatus object.
+ */
+Input::BatteryStatus TransformToBattery(const Input::CallbackStatus& callback);
+
+/**
+ * Converts raw input data into a valid button status. Applies invert properties to the output.
+ *
+ * @param Supported callbacks: Analog, Button, Trigger.
+ * @return A valid TouchStatus object.
+ */
+Input::ButtonStatus TransformToButton(const Input::CallbackStatus& callback);
+
+/**
+ * Converts raw input data into a valid motion status.
+ *
+ * @param Supported callbacks: Motion.
+ * @return A valid TouchStatus object.
+ */
+Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback);
+
+/**
+ * Converts raw input data into a valid stick status. Applies offset, deadzone, range and invert
+ * properties to the output.
+ *
+ * @param Supported callbacks: Stick.
+ * @return A valid StickStatus object.
+ */
+Input::StickStatus TransformToStick(const Input::CallbackStatus& callback);
+
+/**
+ * Converts raw input data into a valid touch status.
+ *
+ * @param Supported callbacks: Touch.
+ * @return A valid TouchStatus object.
+ */
+Input::TouchStatus TransformToTouch(const Input::CallbackStatus& callback);
+
+/**
+ * Converts raw input data into a valid trigger status. Applies offset, deadzone, range and
+ * invert properties to the output. Button status uses the threshold property if necessary.
+ *
+ * @param Supported callbacks: Analog, Button, Trigger.
+ * @return A valid TriggerStatus object.
+ */
+Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback);
+
+/**
+ * Converts raw analog data into a valid analog value
+ * @param An analog object containing raw data and properties, bool that determines if the value
+ * needs to be clamped between -1.0f and 1.0f.
+ */
+void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value);
+
+/**
+ * Converts raw stick data into a valid stick value
+ * @param Two analog objects containing raw data and properties, bool that determines if the value
+ * needs to be clamped into the unit circle.
+ */
+void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value);
+
+} // namespace Core::HID