Win32: Fix underflow in deadzone logic

Fixes #910.
This commit is contained in:
Camilla Löwy 2016-12-19 05:38:33 +01:00
parent e649708cb2
commit 0f488ac286
2 changed files with 10 additions and 6 deletions

View File

@ -118,6 +118,7 @@ information on what to include when reporting a bug.
- Bugfix: `glfwGetInstanceProcAddress` returned `NULL` for
`vkGetInstanceProcAddr` when `_GLFW_VULKAN_STATIC` was enabled
- [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861)
- [Win32] Bugfix: Deadzone logic could underflow with some controllers (#910)
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
- [Cocoa] Added support for Vulkan window surface creation via MoltenVK (#870)
- [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852)
@ -260,6 +261,7 @@ skills.
- Arthur Tombs
- Ioannis Tsakpinis
- Samuli Tuomola
- Matthew Turner
- urraka
- Elias Vanderstuyft
- Jari Vetoniemi

View File

@ -603,9 +603,10 @@ static GLFWbool pollJoystickState(_GLFWjoystickWin32* js, int mode)
if (mode == _GLFW_PRESENCE_ONLY)
return GLFW_TRUE;
if (sqrt((double) (xis.Gamepad.sThumbLX * xis.Gamepad.sThumbLX +
xis.Gamepad.sThumbLY * xis.Gamepad.sThumbLY)) >
(double) XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)
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)
{
js->axes[0] = (xis.Gamepad.sThumbLX + 0.5f) / 32767.f;
js->axes[1] = (xis.Gamepad.sThumbLY + 0.5f) / 32767.f;
@ -616,9 +617,10 @@ static GLFWbool pollJoystickState(_GLFWjoystickWin32* js, int mode)
js->axes[1] = 0.f;
}
if (sqrt((double) (xis.Gamepad.sThumbRX * xis.Gamepad.sThumbRX +
xis.Gamepad.sThumbRY * xis.Gamepad.sThumbRY)) >
(double) XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
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)
{
js->axes[2] = (xis.Gamepad.sThumbRX + 0.5f) / 32767.f;
js->axes[3] = (xis.Gamepad.sThumbRY + 0.5f) / 32767.f;