diff --git a/deps/mingw/xinput.h b/deps/mingw/xinput.h index d3ca726ce..4480cc44f 100644 --- a/deps/mingw/xinput.h +++ b/deps/mingw/xinput.h @@ -182,8 +182,8 @@ typedef struct _XINPUT_STATE { */ typedef struct _XINPUT_VIBRATION { - WORD wLeftMotorSpeed; - WORD wRightMotorSpeed; + WORD wLeftMotorIntensity; + WORD wRightMotorIntensity; } XINPUT_VIBRATION, *PXINPUT_VIBRATION; /* diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index cd120b46d..092336c09 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5363,8 +5363,8 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); * error. * * @param[in] jid The [joystick](@ref joysticks) to vibrate. - * @param[in] slowMotorSpeed The low frequency rumble intensity. - * @param[in] fastMotorSpeed The high frequency rumble intensity. + * @param[in] slowMotorIntensity The low frequency rumble intensity. + * @param[in] fastMotorIntensity The high frequency rumble intensity. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is * connected, or the joystick does not support the rumble effect. * @@ -5373,13 +5373,16 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); * * @thread_safety This function must only be called from the main thread. * + * @note @win32 This function is only implemented for XInput devices. + * @note @macos This function is not implemented. + * * @sa @ref gamepad * @sa @ref glfwUpdateGamepadMappings * @sa @ref glfwJoystickIsGamepad * * @ingroup input */ -GLFWAPI int glfwSetJoystickRumble(int jid, float slowMotorSpeed, float fastMotorSpeed); +GLFWAPI int glfwSetJoystickRumble(int jid, float slowMotorIntensity, float fastMotorIntensity); /*! @brief Sets the clipboard to the specified string. * diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index c351b4eb8..687733dc9 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -485,7 +485,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) } } -int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, float fastMotorSpeed) +int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorIntensity, float fastMotorIntensity) { return GLFW_FALSE; } diff --git a/src/input.c b/src/input.c index e18e0740b..6a125d6ad 100644 --- a/src/input.c +++ b/src/input.c @@ -1312,7 +1312,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) return GLFW_TRUE; } -GLFWAPI int glfwSetJoystickRumble(int jid, float slowMotorSpeed, float fastMotorSpeed) +GLFWAPI int glfwSetJoystickRumble(int jid, float slowMotorIntensity, float fastMotorIntensity) { _GLFWjoystick* js; @@ -1331,13 +1331,13 @@ GLFWAPI int glfwSetJoystickRumble(int jid, float slowMotorSpeed, float fastMotor if (!js->present) return GLFW_FALSE; - slowMotorSpeed = slowMotorSpeed < 0.0f ? 0.0f : slowMotorSpeed; - slowMotorSpeed = slowMotorSpeed > 1.0f ? 1.0f : slowMotorSpeed; + slowMotorIntensity = slowMotorIntensity < 0.0f ? 0.0f : slowMotorIntensity; + slowMotorIntensity = slowMotorIntensity > 1.0f ? 1.0f : slowMotorIntensity; - fastMotorSpeed = fastMotorSpeed < 0.0f ? 0.0f : fastMotorSpeed; - fastMotorSpeed = fastMotorSpeed > 1.0f ? 1.0f : fastMotorSpeed; + fastMotorIntensity = fastMotorIntensity < 0.0f ? 0.0f : fastMotorIntensity; + fastMotorIntensity = fastMotorIntensity > 1.0f ? 1.0f : fastMotorIntensity; - return _glfwPlatformSetJoystickRumble(js, slowMotorSpeed, fastMotorSpeed); + return _glfwPlatformSetJoystickRumble(js, slowMotorIntensity, fastMotorIntensity); } GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) diff --git a/src/internal.h b/src/internal.h index e451d9c3f..4ffbf6c12 100644 --- a/src/internal.h +++ b/src/internal.h @@ -628,7 +628,7 @@ const char* _glfwPlatformGetClipboardString(void); int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode); void _glfwPlatformUpdateGamepadGUID(char* guid); -int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, float fastMotorSpeed); +int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorIntensity, float fastMotorIntensity); uint64_t _glfwPlatformGetTimerValue(void); uint64_t _glfwPlatformGetTimerFrequency(void); diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 4640f53b5..9fe1f4067 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -478,7 +478,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) } -int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, float fastMotorSpeed) +int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorIntensity, float fastMotorIntensity) { _GLFWjoystickLinux *linjs = &js->linjs; @@ -487,8 +487,8 @@ int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, floa js->linjs.rumble->u.rumble = (struct ff_rumble_effect) { - .strong_magnitude = 65535 * slowMotorSpeed, - .weak_magnitude = 65535 * fastMotorSpeed + .strong_magnitude = 65535 * slowMotorIntensity, + .weak_magnitude = 65535 * fastMotorIntensity }; struct input_event play = diff --git a/src/null_joystick.c b/src/null_joystick.c index 27c3a3238..150e36ab0 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -42,7 +42,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) { } -int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, float fastMotorSpeed) +int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorIntensity, float fastMotorIntensity) { return GLFW_FALSE; } diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 4c0b0b5c5..dd8b2a680 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -753,7 +753,7 @@ void _glfwPlatformUpdateGamepadGUID(char* guid) } } -int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, float fastMotorSpeed) +int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorIntensity, float fastMotorIntensity) { if (js->win32.device) return GLFW_FALSE; @@ -761,8 +761,8 @@ int _glfwPlatformSetJoystickRumble(_GLFWjoystick* js, float slowMotorSpeed, floa XINPUT_VIBRATION effect; ZeroMemory(&effect, sizeof(XINPUT_VIBRATION)); - effect.wLeftMotorSpeed = (WORD)(65535.0f * slowMotorSpeed); - effect.wRightMotorSpeed = (WORD)(65535.0f * fastMotorSpeed); + effect.wLeftMotorIntensity = (WORD)(65535.0f * slowMotorIntensity); + effect.wRightMotorIntensity = (WORD)(65535.0f * fastMotorIntensity); return (int) (XInputSetState(js->win32.index, &effect) == ERROR_SUCCESS); } \ No newline at end of file