diff options
author | german77 <juangerman-13@hotmail.com> | 2021-11-04 05:35:45 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2021-11-25 03:30:27 +0100 |
commit | 84c58666a4dbb6d46e132514e4d91437fb689fa0 (patch) | |
tree | 4d6196522922374c927f9139bd22c28ea8cad279 /src/common | |
parent | input_common: Fix motion from 3 axis (diff) | |
download | yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.tar yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.tar.gz yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.tar.bz2 yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.tar.lz yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.tar.xz yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.tar.zst yuzu-84c58666a4dbb6d46e132514e4d91437fb689fa0.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/input.h | 34 | ||||
-rw-r--r-- | src/common/settings.h | 3 |
2 files changed, 31 insertions, 6 deletions
diff --git a/src/common/input.h b/src/common/input.h index f21872b0a..d997853c6 100644 --- a/src/common/input.h +++ b/src/common/input.h @@ -15,6 +15,7 @@ namespace Common::Input { +// Type of data that is expected to recieve or send enum class InputType { None, Battery, @@ -30,6 +31,7 @@ enum class InputType { Ir, }; +// Internal battery charge level enum class BatteryLevel : u32 { None, Empty, @@ -41,13 +43,17 @@ enum class BatteryLevel : u32 { }; enum class PollingMode { + // Constant polling of buttons, analogs and motion data Active, + // Only update on button change, digital analogs Pasive, - Camera, - NCF, + // Enable near field communication polling + NFC, + // Enable infrared camera polling IR, }; +// Vibration reply from the controller enum class VibrationError { None, NotSupported, @@ -55,6 +61,7 @@ enum class VibrationError { Unknown, }; +// Polling mode reply from the controller enum class PollingError { None, NotSupported, @@ -67,20 +74,28 @@ enum class VibrationAmplificationType { Exponential, }; +// Analog properties for calibration struct AnalogProperties { + // Anything below this value will be detected as zero float deadzone{}; + // Anyting above this values will be detected as one float range{1.0f}; + // Minimum value to be detected as active float threshold{0.5f}; + // Drift correction applied to the raw data float offset{}; + // Invert direction of the sensor data bool inverted{}; }; +// Single analog sensor data struct AnalogStatus { float value{}; float raw_value{}; AnalogProperties properties{}; }; +// Button data struct ButtonStatus { Common::UUID uuid{}; bool value{}; @@ -89,8 +104,10 @@ struct ButtonStatus { bool locked{}; }; +// Internal battery data using BatteryStatus = BatteryLevel; +// Analog and digital joystick data struct StickStatus { Common::UUID uuid{}; AnalogStatus x{}; @@ -101,18 +118,21 @@ struct StickStatus { bool down{}; }; +// Analog and digital trigger data struct TriggerStatus { Common::UUID uuid{}; AnalogStatus analog{}; ButtonStatus pressed{}; }; +// 3D vector representing motion input struct MotionSensor { AnalogStatus x{}; AnalogStatus y{}; AnalogStatus z{}; }; +// Motion data used to calculate controller orientation struct MotionStatus { // Gyroscope vector measurement in radians/s. MotionSensor gyro{}; @@ -124,6 +144,7 @@ struct MotionStatus { bool force_update{}; }; +// Data of a single point on a touch screen struct TouchStatus { ButtonStatus pressed{}; AnalogStatus x{}; @@ -131,11 +152,13 @@ struct TouchStatus { int id{}; }; +// Physical controller color in RGB format struct BodyColorStatus { u32 body{}; u32 buttons{}; }; +// HD rumble data struct VibrationStatus { f32 low_amplitude{}; f32 low_frequency{}; @@ -144,6 +167,7 @@ struct VibrationStatus { VibrationAmplificationType type; }; +// Physical controller LED pattern struct LedStatus { bool led_1{}; bool led_2{}; @@ -151,6 +175,7 @@ struct LedStatus { bool led_4{}; }; +// Callback data consisting of an input type and the equivalent data status struct CallbackStatus { InputType type{InputType::None}; ButtonStatus button_status{}; @@ -164,6 +189,7 @@ struct CallbackStatus { VibrationStatus vibration_status{}; }; +// Triggered once every input change struct InputCallback { std::function<void(CallbackStatus)> on_change; }; @@ -178,15 +204,17 @@ public: return; } - // Force input device to update data regarless of the current state + // Force input device to update data regardless of the current state virtual void ForceUpdate() { return; } + // Sets the function to be triggered when input changes void SetCallback(InputCallback callback_) { callback = std::move(callback_); } + // Triggers the function set in the callback void TriggerOnChange(CallbackStatus status) { if (callback.on_change) { callback.on_change(status); diff --git a/src/common/settings.h b/src/common/settings.h index 95225fba7..b52d0d1d0 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -559,8 +559,6 @@ struct Values { Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; Setting<bool> motion_enabled{true, "motion_enabled"}; - BasicSetting<std::string> motion_device{"engine:motion_emu,update_period:100,sensitivity:0.01", - "motion_device"}; BasicSetting<std::string> udp_input_servers{"127.0.0.1:26760", "udp_input_servers"}; BasicSetting<bool> pause_tas_on_load{true, "pause_tas_on_load"}; @@ -583,7 +581,6 @@ struct Values { TouchscreenInput touchscreen; - BasicSetting<bool> use_touch_from_button{false, "use_touch_from_button"}; BasicSetting<std::string> touch_device{"min_x:100,min_y:50,max_x:1800,max_y:850", "touch_device"}; BasicSetting<int> touch_from_button_map_index{0, "touch_from_button_map"}; |