| 1 | // Copyright 2019 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "InputCommon/ControllerEmu/ControlGroup/IMUCursor.h" |
| 5 | |
| 6 | #include <string> |
| 7 | |
| 8 | #include "Common/Common.h" |
| 9 | #include "Common/MathUtil.h" |
| 10 | |
| 11 | #include "InputCommon/ControllerEmu/Control/Control.h" |
| 12 | |
| 13 | namespace ControllerEmu |
| 14 | { |
| 15 | IMUCursor::IMUCursor(std::string name_, std::string ui_name_) |
| 16 | : ControlGroup( |
| 17 | std::move(name_), std::move(ui_name_), GroupType::IMUCursor, |
| 18 | #ifdef ANDROID |
| 19 | // Enabling this on Android devices which have an accelerometer and gyroscope prevents |
| 20 | // touch controls from being used for pointing, and touch controls generally work better |
| 21 | ControlGroup::DefaultValue::Disabled) |
| 22 | #else |
| 23 | ControlGroup::DefaultValue::Enabled) |
| 24 | #endif |
| 25 | { |
| 26 | AddInput(Translatability::Translate, _trans("Recenter")); |
| 27 | |
| 28 | // Default values chosen to reach screen edges in most games including the Wii Menu. |
| 29 | |
| 30 | AddSetting(&m_yaw_setting, |
| 31 | // i18n: Refers to an amount of rotational movement about the "yaw" axis. |
| 32 | {_trans("Total Yaw"), |
| 33 | // i18n: The symbol/abbreviation for degrees (unit of angular measure). |
| 34 | _trans("°"), |
| 35 | // i18n: Refers to emulated wii remote movements. |
| 36 | _trans("Clamping of rotation about the yaw axis.")}, |
| 37 | 25, 0, 360); |
| 38 | |
| 39 | AddSetting(&m_accel_weight_setting, |
| 40 | {// i18n: Percentage value of accelerometer data (complementary filter coefficient). |
| 41 | _trans("Accelerometer Influence"), |
| 42 | // i18n: The symbol/abbreviation for percent. |
| 43 | _trans("%"), |
| 44 | // i18n: Refers to a setting controling the influence of accelerometer data. |
| 45 | _trans("Influence of accelerometer data on pitch and roll. Higher values will reduce " |
| 46 | "drift at the cost of noise. Consider values between 1% and 3%.")}, |
| 47 | 2, 0, 100); |
| 48 | } |
| 49 | |
| 50 | ControlState IMUCursor::GetTotalYaw() const |
| 51 | { |
| 52 | return m_yaw_setting.GetValue() * MathUtil::TAU / 360; |
| 53 | } |
| 54 | |
| 55 | ControlState IMUCursor::GetAccelWeight() const |
| 56 | { |
| 57 | return m_accel_weight_setting.GetValue() / 100; |
| 58 | } |
| 59 | |
| 60 | } // namespace ControllerEmu |