From 463ef7eb71268f57790fdb67f26d328b45d3346e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 31 Jan 2019 01:54:06 +0100 Subject: [PATCH] Cocoa: Fix handling of analog joystick buttons The reported state was not clamped to [0,1], i.e. GLFW_RELEASE and GLFW_PRESS. Fixes #1385. --- README.md | 1 + src/cocoa_joystick.m | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b361ae3f..5ea88f98 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,7 @@ information on what to include when reporting a bug. (#1334,#1346) - [Cocoa] Bugfix: Caps Lock did not generate any key events (#1368,#1373) - [Cocoa] Bugfix: Some buttons for some joysticks were ignored (#1385) +- [Cocoa] Bugfix: Analog joystick buttons were not translated correctly (#1385) - [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts - [WGL] Added support for `WGL_ARB_create_context_no_error` - [GLX] Added support for `GLX_ARB_create_context_no_error` diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index 2d1522e6..2ce977d0 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -426,7 +426,8 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) _GLFWjoyelementNS* button = (_GLFWjoyelementNS*) CFArrayGetValueAtIndex(js->ns.buttons, i); const char value = getElementValue(js, button) - button->minimum; - _glfwInputJoystickButton(js, (int) i, value); + const int state = (value > 0) ? GLFW_PRESS : GLFW_RELEASE; + _glfwInputJoystickButton(js, (int) i, state); } for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)