diff --git a/README.md b/README.md index 0134bb22..982fa4f2 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ information on what to include when reporting a bug. - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan surface extension (#1793) - Added `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - - Added `GLFW_MOUSE_BUTTON_LIMIT` input mode for disabling the limit of + - Added `GLFW_DISABLE_MOUSE_BUTTON_LIMIT` input mode that disables the limit of reported mouse buttons to only those with associated mouse button tokens (#2423) - Added `GLFW_NATIVE_INCLUDE_NONE` for disabling inclusion of native headers (#1348) - Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958) diff --git a/docs/input.dox b/docs/input.dox index 1790e46e..a8c144de 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -494,20 +494,19 @@ a mouse button callback. glfwSetMouseButtonCallback(window, mouse_button_callback); @endcode -@anchor GLFW_MOUSE_BUTTON_LIMIT +@anchor GLFW_DISABLE_MOUSE_BUTTON_LIMIT To handle all mouse buttons, instead of only ones with associated -[button tokens](@ref buttons), set the @ref GLFW_MOUSE_BUTTON_LIMIT -input mode to `GLFW_FALSE`. +[button tokens](@ref buttons), set the @ref GLFW_DISABLE_MOUSE_BUTTON_LIMIT +input mode. @code -glfwSetInputMode(window, GLFW_MOUSE_BUTTON_LIMIT, GLFW_FALSE); +glfwSetInputMode(window, GLFW_DISABLE_MOUSE_BUTTON_LIMIT, GLFW_TRUE); @endcode -This input mode specifies whether to limit reported mouse buttons to only those -that have an associated button token, for compatibility with earlier versions of -GLFW that would only report buttons with an associated button token: users may -have assumed that reported buttons always are in the range of -@ref GLFW_MOUSE_BUTTON_1 to @ref GLFW_MOUSE_BUTTON_LAST. +When this input mode is enabled, GLFW doesn't limit the reported mouse buttons +to only those that have an associated button token, for compatibility with +earlier versions of GLFW, which never reported any buttons over +@ref GLFW_MOUSE_BUTTON_LAST, on which users could have relied on. The callback function receives the [mouse button](@ref buttons), button action and [modifier bits](@ref mods). @@ -521,8 +520,8 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) @endcode The mouse button is an integer that can be one of the -[mouse button tokens](@ref buttons) or, if @ref GLFW_MOUSE_BUTTON_LIMIT is -set to `GLFW_FALSE`, any other value. +[mouse button tokens](@ref buttons) or, if the +@ref GLFW_DISABLE_MOUSE_BUTTON_LIMIT input mode is set, any other value. The action is one of `GLFW_PRESS` or `GLFW_RELEASE`. diff --git a/docs/news.dox b/docs/news.dox index a32346d8..7ce57724 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -108,8 +108,8 @@ applications. GLFW now allows disabling the limit of reported mouse buttons to only those with associated [button tokens](@ref buttons). This allows using mouse buttons with values over 8. For compatibility with older versions, the -@ref GLFW_MOUSE_BUTTON_LIMIT input mode needs to be set to `GLFW_FALSE` to make -use of this. +@ref GLFW_DISABLE_MOUSE_BUTTON_LIMIT input mode needs to be set to make use of +this. @subsection caveats Caveats for version 3.4 diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 431b9510..4a92b1b0 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1139,12 +1139,12 @@ extern "C" { #define GLFW_OPENGL_CORE_PROFILE 0x00032001 #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 -#define GLFW_CURSOR 0x00033001 -#define GLFW_STICKY_KEYS 0x00033002 -#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 -#define GLFW_LOCK_KEY_MODS 0x00033004 -#define GLFW_RAW_MOUSE_MOTION 0x00033005 -#define GLFW_MOUSE_BUTTON_LIMIT 0x00033006 +#define GLFW_CURSOR 0x00033001 +#define GLFW_STICKY_KEYS 0x00033002 +#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 +#define GLFW_LOCK_KEY_MODS 0x00033004 +#define GLFW_RAW_MOUSE_MOTION 0x00033005 +#define GLFW_DISABLE_MOUSE_BUTTON_LIMIT 0x00033006 #define GLFW_CURSOR_NORMAL 0x00034001 #define GLFW_CURSOR_HIDDEN 0x00034002 @@ -5202,7 +5202,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * * The reported `button` value can be higher than `GLFW_MOUSE_BUTTON_LAST` if * the button does not have an associated [button token](@ref buttons) and the - * @ref GLFW_MOUSE_BUTTON_LIMIT init hint is set to `GLFW_FALSE`. + * @ref GLFW_MOUSE_BUTTON_LIMIT input mode is set. * * @param[in] window The window whose callback to set. * @param[in] callback The new callback, or `NULL` to remove the currently set diff --git a/src/input.c b/src/input.c index 72a35e65..1f7cfceb 100644 --- a/src/input.c +++ b/src/input.c @@ -351,7 +351,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods) assert(action == GLFW_PRESS || action == GLFW_RELEASE); assert(mods == (mods & GLFW_MOD_MASK)); - if (button < 0 || (window->mouseButtonLimit && button > GLFW_MOUSE_BUTTON_LAST)) + if (button < 0 || (!window->disableMouseButtonLimit && button > GLFW_MOUSE_BUTTON_LAST)) return; if (!window->lockKeyMods) @@ -578,8 +578,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode) return window->lockKeyMods; case GLFW_RAW_MOUSE_MOTION: return window->rawMouseMotion; - case GLFW_MOUSE_BUTTON_LIMIT: - return window->mouseButtonLimit; + case GLFW_DISABLE_MOUSE_BUTTON_LIMIT: + return window->disableMouseButtonLimit; } _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); @@ -688,9 +688,9 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) return; } - case GLFW_MOUSE_BUTTON_LIMIT: + case GLFW_DISABLE_MOUSE_BUTTON_LIMIT: { - window->mouseButtonLimit = value ? GLFW_TRUE : GLFW_FALSE; + window->disableMouseButtonLimit = value ? GLFW_TRUE : GLFW_FALSE; return; } } diff --git a/src/internal.h b/src/internal.h index 0cc6217c..048346b1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -539,7 +539,7 @@ struct _GLFWwindow GLFWbool stickyKeys; GLFWbool stickyMouseButtons; GLFWbool lockKeyMods; - GLFWbool mouseButtonLimit; + GLFWbool disableMouseButtonLimit; int cursorMode; char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; char keys[GLFW_KEY_LAST + 1]; diff --git a/src/window.c b/src/window.c index 313eaa64..51903e63 100644 --- a/src/window.c +++ b/src/window.c @@ -233,7 +233,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->focusOnShow = wndconfig.focusOnShow; window->mousePassthrough = wndconfig.mousePassthrough; window->cursorMode = GLFW_CURSOR_NORMAL; - window->mouseButtonLimit = GLFW_TRUE; window->doublebuffer = fbconfig.doublebuffer; diff --git a/tests/events.c b/tests/events.c index 1e06e774..b2298de3 100644 --- a/tests/events.c +++ b/tests/events.c @@ -630,7 +630,7 @@ int main(int argc, char** argv) glfwTerminate(); exit(EXIT_FAILURE); } - glfwSetInputMode(slots[i].window, GLFW_MOUSE_BUTTON_LIMIT, GLFW_FALSE); + glfwSetInputMode(slots[i].window, GLFW_DISABLE_MOUSE_BUTTON_LIMIT, GLFW_TRUE); glfwSetWindowUserPointer(slots[i].window, slots + i); diff --git a/tests/window.c b/tests/window.c index 76e44658..8154a7af 100644 --- a/tests/window.c +++ b/tests/window.c @@ -77,7 +77,7 @@ int main(int argc, char** argv) glfwTerminate(); exit(EXIT_FAILURE); } - glfwSetInputMode(window, GLFW_MOUSE_BUTTON_LIMIT, GLFW_TRUE); + glfwSetInputMode(window, GLFW_DISABLE_MOUSE_BUTTON_LIMIT, GLFW_FALSE); glfwMakeContextCurrent(window); gladLoadGL(glfwGetProcAddress);