From 75e44abf09621180b6c67dc44aaf60a2309f1253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Aug 2017 02:11:32 +0200 Subject: [PATCH] Win32: Remove deadzone logic from XInput path Related to #1021. Related to #1045. --- README.md | 1 + src/win32_joystick.c | 33 ++++++--------------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 62dc98bd..7fe97897 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,7 @@ information on what to include when reporting a bug. - Bugfix: The scancode for synthetic key release events was always zero - [Win32] Added system error strings to relevant GLFW error descriptions (#733) - [Win32] Moved to `WM_INPUT` for disabled cursor mode motion input (#125) +- [Win32] Removed XInput circular deadzone from joystick axis data (#1045) - [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861) - [Win32] Bugfix: Deadzone logic could underflow with some controllers (#910) - [Win32] Bugfix: Bitness test in `FindVulkan.cmake` was VS specific (#928) diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 6db08467..c3a7c767 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -675,7 +675,6 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) int i, dpad = 0; DWORD result; XINPUT_STATE xis; - float axes[6] = { 0.f, 0.f, 0.f, 0.f, -1.f, -1.f }; const WORD buttons[10] = { XINPUT_GAMEPAD_A, @@ -702,32 +701,12 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) if (mode == _GLFW_POLL_PRESENCE) return GLFW_TRUE; - if ((float) xis.Gamepad.sThumbLX * xis.Gamepad.sThumbLX + - (float) xis.Gamepad.sThumbLY * xis.Gamepad.sThumbLY > - (float) XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE * - XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) - { - axes[0] = (xis.Gamepad.sThumbLX + 0.5f) / 32767.f; - axes[1] = (xis.Gamepad.sThumbLY + 0.5f) / 32767.f; - } - - if ((float) xis.Gamepad.sThumbRX * xis.Gamepad.sThumbRX + - (float) xis.Gamepad.sThumbRY * xis.Gamepad.sThumbRY > - (float) XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE * - XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) - { - axes[2] = (xis.Gamepad.sThumbRX + 0.5f) / 32767.f; - axes[3] = (xis.Gamepad.sThumbRY + 0.5f) / 32767.f; - } - - if (xis.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) - axes[4] = xis.Gamepad.bLeftTrigger / 127.5f - 1.f; - - if (xis.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD) - axes[5] = xis.Gamepad.bRightTrigger / 127.5f - 1.f; - - for (i = 0; i < 6; i++) - _glfwInputJoystickAxis(js, i, axes[i]); + _glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.f); + _glfwInputJoystickAxis(js, 1, (xis.Gamepad.sThumbLY + 0.5f) / 32767.f); + _glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.f); + _glfwInputJoystickAxis(js, 3, (xis.Gamepad.sThumbRY + 0.5f) / 32767.f); + _glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f); + _glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f); for (i = 0; i < 10; i++) {