From 995da23425d14366659a8a69fd3dca530f39836f Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 5 Sep 2014 23:31:25 +0200 Subject: [PATCH] XInput: Try a different mapping of circular stick values to square psp stick values. May help #6772 ? --- Windows/XinputDevice.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index e1a1cb0c9d..5452bb0096 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -1,4 +1,5 @@ #include +#include #include "base/NativeApp.h" #include "Core/Config.h" @@ -125,11 +126,20 @@ static Stick NormalizedDeadzoneFilter(short x, short y, short thresh) { float magnitude = sqrtf(s.x * s.x + s.y * s.y); if (magnitude > DEADZONE) { + // Circle to square mapping (the PSP stick outputs the full -1..1 square of values) +#if 1 + // Looks way better than the old one, below, in the axis tester. + float sx = s.x; + float sy = s.y; + float scaleFactor = sqrtf((sx * sx + sy * sy) / std::max(sx * sx, sy * sy)); + s.x = sx * scaleFactor; + s.y = sy * scaleFactor; +#else if (magnitude > 1.0f) { s.x *= 1.41421f; s.y *= 1.41421f; } - +#endif s.x = Clampf(s.x, -1.0f, 1.0f); s.y = Clampf(s.y, -1.0f, 1.0f); } else {