summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
diff options
context:
space:
mode:
authorrobopilot99 <jackson9130@gmail.com>2018-06-03 15:48:07 -0500
committerrobopilot99 <jackson9130@gmail.com>2018-06-04 17:58:21 -0500
commitab02499ce770262baacb44e829722e453db6e24a (patch)
tree9ff458e952d63f7bf17e5fa8108e2071f957a1fe /Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
parent8fce18e4ff2367eec9af767062d5266cc78541b8 (diff)
Add auto-hide option to Wii IR pointer
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
index a300a249f7..154b0ca862 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
@@ -36,6 +36,7 @@ Cursor::Cursor(const std::string& name_) : ControlGroup(name_, GroupType::Cursor
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Height"), 0.5));
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 20));
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Relative Input"), false));
+ boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Auto-Hide"), false));
}
void Cursor::GetState(ControlState* const x, ControlState* const y, ControlState* const z,
@@ -51,17 +52,31 @@ void Cursor::GetState(ControlState* const x, ControlState* const y, ControlState
*z = m_z;
+ if (m_autohide_timer > -1)
+ {
+ --m_autohide_timer;
+ }
+
+ ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
+ ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
+
+ const ControlState deadzone = numeric_settings[3]->GetValue();
+
+ // reset auto-hide timer
+ if (std::abs(m_prev_xx - xx) > deadzone || std::abs(m_prev_yy - yy) > deadzone)
+ {
+ m_autohide_timer = TIMER_VALUE;
+ }
+
// hide
- if (controls[6]->control_ref->State() > 0.5)
+ bool autohide = boolean_settings[1]->GetValue() && m_autohide_timer < 0;
+ if (controls[6]->control_ref->State() > 0.5 || autohide)
{
*x = 10000;
*y = 0;
}
else
{
- ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
- ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
-
// adjust cursor according to settings
if (adjusted)
{
@@ -73,7 +88,6 @@ void Cursor::GetState(ControlState* const x, ControlState* const y, ControlState
// relative input
if (boolean_settings[0]->GetValue())
{
- const ControlState deadzone = numeric_settings[3]->GetValue();
// deadzone to avoid the cursor slowly drifting
if (std::abs(xx) > deadzone)
m_x = MathUtil::Clamp(m_x + xx * SPEED_MULTIPLIER, -1.0, 1.0);
@@ -96,5 +110,8 @@ void Cursor::GetState(ControlState* const x, ControlState* const y, ControlState
*x = m_x;
*y = m_y;
}
+
+ m_prev_xx = xx;
+ m_prev_yy = yy;
}
} // namespace ControllerEmu