diff --git a/src/init.c b/src/init.c index 9e670d42..4f424c4a 100644 --- a/src/init.c +++ b/src/init.c @@ -119,6 +119,30 @@ char* _glfw_strdup(const char* source) return result; } +float _glfw_fminf(float a, float b) +{ + if (a != a) + return b; + else if (b != b) + return a; + else if (a < b) + return a; + else + return b; +} + +float _glfw_fmaxf(float a, float b) +{ + if (a != a) + return b; + else if (b != b) + return a; + else if (a > b) + return a; + else + return b; +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// diff --git a/src/input.c b/src/input.c index b0bb3de4..460e9f31 100644 --- a/src/input.c +++ b/src/input.c @@ -1242,7 +1242,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) if (e->type == _GLFW_JOYSTICK_AXIS) { const float value = js->axes[e->index] * e->axisScale + e->axisOffset; - state->axes[i] = fminf(fmaxf(value, -1.f), 1.f); + state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f); } else if (e->type == _GLFW_JOYSTICK_HATBIT) { diff --git a/src/internal.h b/src/internal.h index 7be2b267..30c7551a 100644 --- a/src/internal.h +++ b/src/internal.h @@ -766,4 +766,6 @@ void _glfwTerminateVulkan(void); const char* _glfwGetVulkanResultString(VkResult result); char* _glfw_strdup(const char* source); +float _glfw_fminf(float a, float b); +float _glfw_fmaxf(float a, float b);