forked from dolphin-emu/dolphin
/
Cursor.h
68 lines (49 loc) · 1.59 KB
/
Cursor.h
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
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <chrono>
#include <string>
#include "InputCommon/ControllerEmu/StickGate.h"
#include "InputCommon/ControllerInterface/Device.h"
namespace ControllerEmu
{
class Cursor : public ReshapableInput
{
public:
struct StateData
{
ControlState x{};
ControlState y{};
bool IsVisible() const;
};
Cursor(std::string name, std::string ui_name);
ReshapeData GetReshapableState(bool adjusted) final override;
ControlState GetGateRadiusAtAngle(double ang) const override;
StateData GetState(bool adjusted);
// Yaw movement in radians.
ControlState GetTotalYaw() const;
// Pitch movement in radians.
ControlState GetTotalPitch() const;
// Vertical offset in meters.
ControlState GetVerticalOffset() const;
private:
// This is used to reduce the cursor speed for relative input
// to something that makes sense with the default range.
static constexpr double STEP_PER_SEC = 0.01 * 200;
static constexpr int AUTO_HIDE_MS = 2500;
static constexpr double AUTO_HIDE_DEADZONE = 0.001;
// Not adjusted by width/height/center:
StateData m_state;
// Adjusted:
StateData m_prev_result;
int m_auto_hide_timer = AUTO_HIDE_MS;
using Clock = std::chrono::steady_clock;
Clock::time_point m_last_update;
SettingValue<double> m_yaw_setting;
SettingValue<double> m_pitch_setting;
SettingValue<double> m_vertical_offset_setting;
SettingValue<bool> m_relative_setting;
SettingValue<bool> m_autohide_setting;
};
} // namespace ControllerEmu