From 4394cb25b28cfb560476f6ac3726b2c2f63a7d27 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Fri, 8 May 2020 22:01:34 -0400 Subject: [PATCH] windows bug on full extension of stick --- joystick.d | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/joystick.d b/joystick.d index cbf50ef..15865f6 100644 --- a/joystick.d +++ b/joystick.d @@ -415,6 +415,14 @@ struct JoystickUpdate { } static short normalizeAxis(short value) { + /+ + auto v = normalizeAxisHack(value); + import std.stdio; + writeln(value, " :: ", v); + return v; + } + static short normalizeAxisHack(short value) { + +/ if(value > -1600 && value < 1600) return 0; // the deadzone gives too much useless junk return cast(short) (value >>> 11); @@ -523,6 +531,9 @@ struct JoystickUpdate { (what.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) ? cast(short)-cast(int)digitalFallbackValue : what.Gamepad.sThumbLY; + if(got == short.min) + got++; // to avoid overflow on the axis inversion below + return normalizeAxis(cast(short)-cast(int)got); case PS1AnalogAxes.horizontalRightStick: return normalizeAxis(what.Gamepad.sThumbRX);