summaryrefslogtreecommitdiffstats
path: root/src/core/hid/input_converter.h
blob: 1492489d7315d925775db0969efbb44392cf3999 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included

#pragma once

namespace Common::Input {
struct CallbackStatus;
enum class BatteryLevel : u32;
using BatteryStatus = BatteryLevel;
struct AnalogStatus;
struct ButtonStatus;
struct MotionStatus;
struct StickStatus;
struct TouchStatus;
struct TriggerStatus;
}; // namespace Common::Input

namespace Core::HID {

/**
 * Converts raw input data into a valid battery status.
 *
 * @param Supported callbacks: Analog, Battery, Trigger.
 * @return A valid BatteryStatus object.
 */
Common::Input::BatteryStatus TransformToBattery(const Common::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.
 */
Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatus& callback);

/**
 * Converts raw input data into a valid motion status.
 *
 * @param Supported callbacks: Motion.
 * @return A valid TouchStatus object.
 */
Common::Input::MotionStatus TransformToMotion(const Common::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.
 */
Common::Input::StickStatus TransformToStick(const Common::Input::CallbackStatus& callback);

/**
 * Converts raw input data into a valid touch status.
 *
 * @param Supported callbacks: Touch.
 * @return A valid TouchStatus object.
 */
Common::Input::TouchStatus TransformToTouch(const Common::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.
 */
Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback);

/**
 * Converts raw input data into a valid analog status. Applies offset, deadzone, range and
 * invert properties to the output.
 *
 * @param Supported callbacks: Analog.
 * @return A valid AnalogStatus object.
 */
Common::Input::AnalogStatus TransformToAnalog(const Common::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(Common::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(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogStatus& analog_y,
                   bool clamp_value);

} // namespace Core::HID