Debian Codegraph @

Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h

raw symbols SCIP
1 // Copyright 2017 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <chrono>
7 #include <string>
8
9 #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
10 #include "InputCommon/ControllerEmu/StickGate.h"
11
12 namespace ControllerEmu
13 {
14 class Cursor : public ReshapableInput
15 {
16 public:
17 struct StateData
18 {
19 ControlState x{};
20 ControlState y{};
21
22 bool IsVisible() const;
23 };
24
25 Cursor(std::string name, std::string ui_name);
26
27 ReshapeData GetReshapableState(bool adjusted) const final;
28 ControlState GetGateRadiusAtAngle(double ang) const override;
29
30 // Modifies the state
31 StateData GetState(bool adjusted);
32 StateData GetState(bool adjusted, const ControllerEmu::InputOverrideFunction& override_func);
33
34 // Yaw movement in radians.
35 ControlState GetTotalYaw() const;
36
37 // Pitch movement in radians.
38 ControlState GetTotalPitch() const;
39
40 // Vertical offset in meters.
41 ControlState GetVerticalOffset() const;
42
43 void SetRelativeInput(bool enabled);
44
45 private:
46 Cursor::StateData UpdateState(Cursor::ReshapeData input);
47
48 // This is used to reduce the cursor speed for relative input
49 // to something that makes sense with the default range.
50 static constexpr double STEP_PER_SEC = 0.01 * 200;
51
52 static constexpr int AUTO_HIDE_MS = 2500;
53 static constexpr double AUTO_HIDE_DEADZONE = 0.001;
54
55 // Not adjusted by width/height/center:
56 StateData m_state;
57
58 // Adjusted:
59 StateData m_prev_result;
60
61 int m_auto_hide_timer = AUTO_HIDE_MS;
62
63 using Clock = std::chrono::steady_clock;
64 Clock::time_point m_last_update;
65
66 SettingValue<double> m_yaw_setting;
67 SettingValue<double> m_pitch_setting;
68 SettingValue<double> m_vertical_offset_setting;
69
70 SettingValue<bool> m_relative_setting;
71 SettingValue<bool> m_autohide_setting;
72 };
73 } // namespace ControllerEmu