diff options
| author | John Peterson <john.s.peterson@live.com> | 2011-11-10 09:27:33 +0100 |
|---|---|---|
| committer | John Peterson <john.s.peterson@live.com> | 2013-06-06 09:28:59 +0200 |
| commit | b6e1127c8a14aac8c6f5c322809274977abdb2ae (patch) | |
| tree | d80f34ea88a50102768f60bf1e6e7f2c099e6570 /Source/Core/InputCommon | |
| parent | 7aae9ccbc0494cd468a37413d7199061bd1981d2 (diff) | |
Adding stick radius setting
because that makes it easier to adjust it
Adding visual aid for the hardware range because that makes it easier to adjust the radius relative to it
Diffstat (limited to 'Source/Core/InputCommon')
| -rw-r--r-- | Source/Core/InputCommon/Src/ControllerEmu.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/InputCommon/Src/ControllerEmu.h | 19 |
2 files changed, 16 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerEmu.cpp b/Source/Core/InputCommon/Src/ControllerEmu.cpp index b7eee1a143..328fcb8c2f 100644 --- a/Source/Core/InputCommon/Src/ControllerEmu.cpp +++ b/Source/Core/InputCommon/Src/ControllerEmu.cpp @@ -226,6 +226,7 @@ ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup( controls.push_back(new Input(_trans("Modifier"))); + settings.push_back(new Setting(_trans("Radius"), 0.7f, 0, 100)); settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); settings.push_back(new Setting(_trans("Square Stick"), 0)); diff --git a/Source/Core/InputCommon/Src/ControllerEmu.h b/Source/Core/InputCommon/Src/ControllerEmu.h index 33057434cd..cf87f2562e 100644 --- a/Source/Core/InputCommon/Src/ControllerEmu.h +++ b/Source/Core/InputCommon/Src/ControllerEmu.h @@ -35,6 +35,13 @@ enum GROUP_TYPE_SLIDER, }; +enum +{ + SETTING_RADIUS, + SETTING_DEADZONE, + SETTING_SQUARE, +}; + const char * const named_directions[] = { "Up", @@ -126,8 +133,9 @@ public: ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State(); ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State(); - ControlState deadzone = settings[0]->value; - ControlState square = settings[1]->value; + ControlState radius = settings[SETTING_RADIUS]->value; + ControlState deadzone = settings[SETTING_DEADZONE]->value; + ControlState square = settings[SETTING_SQUARE]->value; ControlState m = controls[4]->control_ref->State(); // modifier code @@ -138,11 +146,11 @@ public: } // deadzone / square stick code - if (deadzone || square) + if (radius != 1 || deadzone || square) { // this section might be all wrong, but its working good enough, I think - ControlState ang = atan2(yy, xx); + ControlState ang = atan2(yy, xx); ControlState ang_sin = sin(ang); ControlState ang_cos = cos(ang); @@ -163,6 +171,9 @@ public: ControlState amt = dist / stick_full; dist -= ((square_full - 1) * amt * square); + // radius + dist *= radius; + yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist)); xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist)); } |
