MCPcopy Create free account
hub / github.com/cemu-project/Cemu / apply_axis_setting

Method apply_axis_setting

src/input/api/Controller.cpp:74–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void ControllerBase::apply_axis_setting(glm::vec2& axis, const glm::vec2& default_value,
75 const AxisSetting& setting) const
76{
77 constexpr float kMaxValue = 1.0f + ControllerState::kMinAxisValue;
78 if (setting.deadzone < 1.0f)
79 {
80 if (axis.x < default_value.x)
81 axis.x = (axis.x - default_value.x) / (kMaxValue + default_value.x);
82 else
83 axis.x = (axis.x - default_value.x) / (kMaxValue - default_value.x);
84
85 if (axis.y < default_value.y)
86 axis.y = (axis.y - default_value.y) / (kMaxValue + default_value.y);
87 else
88 axis.y = (axis.y - default_value.y) / (kMaxValue - default_value.y);
89
90 auto len = length(axis);
91 if (len >= setting.deadzone)
92 {
93 axis *= setting.range;
94 len = length(axis);
95
96 // Scaled Radial Dead Zone: stickInput = stickInput.normalized * ((stickInput.magnitude - deadzone) / (1 - deadzone));
97 if (len > 0)
98 {
99 axis = normalize(axis);
100 axis *= ((len - setting.deadzone) / (kMaxValue - setting.deadzone));
101
102 if (length(axis) > 1.0f)
103 axis = normalize(axis);
104 }
105
106 if (axis.x != 0 || axis.y != 0)
107 {
108 if (std::abs(axis.x) < ControllerState::kMinAxisValue)
109 axis.x = ControllerState::kMinAxisValue;
110
111 if (std::abs(axis.y) < ControllerState::kMinAxisValue)
112 axis.y = ControllerState::kMinAxisValue;
113 }
114
115 return;
116 }
117 }
118
119 axis = {0, 0};
120}
121
122bool ControllerBase::operator==(const ControllerBase& c) const
123{

Callers 2

on_timerMethod · 0.80
on_timerMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected