summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-07-11 08:11:33 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-07-11 13:32:57 -0400
commit0d11081a3bb00d749cc73fa4a611f87513077a36 (patch)
tree7d4e2672b69752cab25262300cbea0bdc53e40bf /Source/Core/InputCommon
parentc29d5ff989e16dc15cdf03de19ba44a0ae8b0e7c (diff)
ControllerEmu: Clean up the code that applies the modifier
This makes it more clear and pretty much the analog stick code bog standard.
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/ControllerEmu.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu.h
index 4881832243..4f883c9cb8 100644
--- a/Source/Core/InputCommon/ControllerEmu.h
+++ b/Source/Core/InputCommon/ControllerEmu.h
@@ -124,8 +124,6 @@ public:
template <typename C>
void GetState(C* const x, C* const y, const unsigned int base, const unsigned int range)
{
- // this is all a mess
-
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
@@ -133,13 +131,6 @@ public:
ControlState deadzone = settings[SETTING_DEADZONE]->value;
ControlState m = controls[4]->control_ref->State();
- // modifier code
- if (m)
- {
- yy = (fabsf(yy)>deadzone) * sign(yy) * (m + deadzone/2);
- xx = (fabsf(xx)>deadzone) * sign(xx) * (m + deadzone/2);
- }
-
ControlState ang = atan2(yy, xx);
ControlState ang_sin = sin(ang);
ControlState ang_cos = cos(ang);
@@ -153,6 +144,11 @@ public:
// radius
dist *= radius;
+ // The modifier halves the distance by 50%, which is useful
+ // for keyboard controls.
+ if (m)
+ dist *= 0.5;
+
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
@@ -281,13 +277,6 @@ public:
auto const angle = settings[2]->value / 1.8f;
ControlState m = controls[4]->control_ref->State();
- // modifier code
- if (m)
- {
- yy = (fabsf(yy)>deadzone) * sign(yy) * (m + deadzone/2);
- xx = (fabsf(xx)>deadzone) * sign(xx) * (m + deadzone/2);
- }
-
// deadzone / circle stick code
// this section might be all wrong, but its working good enough, I think
@@ -312,6 +301,9 @@ public:
ControlState amt = dist / stick_full;
dist += (square_full - 1) * amt * circle;
+ if (m)
+ dist *= 0.5;
+
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));