Replace GLFW_MOUSE_BUTTON_LIMIT with GLFW_DISABLE_MOUSE_BUTTON_LIMIT

Normally I'd be against such a double negative, but it seems more
intuitive in this case - enabling new handling makes more sense than
disabling old handling.
This commit is contained in:
Grzesiek11 2024-02-11 20:29:58 +01:00
parent 571dfb80ba
commit e23231de5d
No known key found for this signature in database
GPG Key ID: 4A5445FB68CDB5C4
9 changed files with 28 additions and 30 deletions

View File

@ -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)

View File

@ -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`.

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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];

View File

@ -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;

View File

@ -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);

View File

@ -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);