diff --git a/docs/intro.dox b/docs/intro.dox index 36ec0ef5..e973bc2a 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -119,6 +119,13 @@ The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle` extension. This extension is not used if this hint is `GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value. +@anchor GLFW_MOUSE_BUTTON_LIMIT +__GLFW_MOUSE_BUTTON_LIMIT__ specifies whether to limit reported mouse buttons to +only the named buttons, for compatibility with earlier versions of GLFW that +could only report buttons from the named set, as users might have assumed +@ref GLFW_MOUSE_BUTTON_LAST to be the last possible mouse button, and not the +last named mouse button. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. + @subsubsection init_hints_osx macOS specific init hints @@ -160,6 +167,7 @@ Initialization hint | Default value | Supported v @ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` or `GLFW_PLATFORM_NULL` @ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL` +@ref GLFW_MOUSE_BUTTON_LIMIT | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index be0958cf..2767f0ec 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1297,6 +1297,11 @@ extern "C" { * Platform selection [init hint](@ref GLFW_PLATFORM). */ #define GLFW_PLATFORM 0x00050003 +/*! @brief Mouse button limit init hint. + * + * Mouse button limit [init hint](@ref GLFW_PLATFORM). + */ +#define GLFW_MOUSE_BUTTON_LIMIT 0x00050004 /*! @brief macOS specific init hint. * * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint). diff --git a/src/init.c b/src/init.c index 2b903146..753af782 100644 --- a/src/init.c +++ b/src/init.c @@ -53,6 +53,7 @@ static _GLFWinitconfig _glfwInitHints = .angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE, .platformID = GLFW_ANY_PLATFORM, .vulkanLoader = NULL, + .mouseButtonLimit = GLFW_TRUE, .ns = { .menubar = GLFW_TRUE, @@ -474,6 +475,9 @@ GLFWAPI void glfwInitHint(int hint, int value) case GLFW_PLATFORM: _glfwInitHints.platformID = value; return; + case GLFW_MOUSE_BUTTON_LIMIT: + _glfwInitHints.mouseButtonLimit = value; + return; case GLFW_COCOA_CHDIR_RESOURCES: _glfwInitHints.ns.chdir = value; return; diff --git a/src/input.c b/src/input.c index cbb6854a..dcb1d5e6 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) + if (button < 0 || (_glfw.hints.init.mouseButtonLimit && button > GLFW_MOUSE_BUTTON_LAST)) return; if (!window->lockKeyMods) diff --git a/src/internal.h b/src/internal.h index 1ab3dea8..1458e01e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -365,6 +365,7 @@ struct _GLFWinitconfig GLFWbool hatButtons; int angleType; int platformID; + GLFWbool mouseButtonLimit; PFN_vkGetInstanceProcAddr vulkanLoader; struct { GLFWbool menubar;