Rename SDL_BUTTON() to SDL_BUTTON_MASK()

Fixes https://github.com/libsdl-org/SDL/issues/11056
This commit is contained in:
Sam Lantinga 2024-10-04 09:13:36 -07:00
parent d529407ce7
commit 6c64c62114
11 changed files with 40 additions and 33 deletions

View File

@ -3710,3 +3710,7 @@ identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAltern
- SDL_SetThreadPriority - SDL_SetThreadPriority
+ SDL_SetCurrentThreadPriority + SDL_SetCurrentThreadPriority
(...) (...)
@@
@@
- SDL_BUTTON
+ SDL_BUTTON_MASK

View File

@ -1174,6 +1174,7 @@ The following functions have been removed:
* SDL_GetRelativeMouseMode() - replaced with SDL_GetWindowRelativeMouseMode() * SDL_GetRelativeMouseMode() - replaced with SDL_GetWindowRelativeMouseMode()
The following symbols have been renamed: The following symbols have been renamed:
* SDL_BUTTON => SDL_BUTTON_MASK
* SDL_NUM_SYSTEM_CURSORS => SDL_SYSTEM_CURSOR_COUNT * SDL_NUM_SYSTEM_CURSORS => SDL_SYSTEM_CURSOR_COUNT
* SDL_SYSTEM_CURSOR_ARROW => SDL_SYSTEM_CURSOR_DEFAULT * SDL_SYSTEM_CURSOR_ARROW => SDL_SYSTEM_CURSOR_DEFAULT
* SDL_SYSTEM_CURSOR_HAND => SDL_SYSTEM_CURSOR_POINTER * SDL_SYSTEM_CURSOR_HAND => SDL_SYSTEM_CURSOR_POINTER

View File

@ -124,12 +124,12 @@ typedef Uint32 SDL_MouseButtonFlags;
#define SDL_BUTTON_X1 4 #define SDL_BUTTON_X1 4
#define SDL_BUTTON_X2 5 #define SDL_BUTTON_X2 5
#define SDL_BUTTON(X) (1u << ((X)-1)) #define SDL_BUTTON_MASK(X) (1u << ((X)-1))
#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) #define SDL_BUTTON_LMASK SDL_BUTTON_MASK(SDL_BUTTON_LEFT)
#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) #define SDL_BUTTON_MMASK SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE)
#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) #define SDL_BUTTON_RMASK SDL_BUTTON_MASK(SDL_BUTTON_RIGHT)
#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) #define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1)
#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) #define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2)
/* Function prototypes */ /* Function prototypes */
@ -194,7 +194,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
* Retrieve the current state of the mouse. * Retrieve the current state of the mouse.
* *
* The current button state is returned as a button bitmask, which can be * The current button state is returned as a button bitmask, which can be
* tested using the SDL_BUTTON(X) macro (where `X` is generally 1 for the * tested using the SDL_BUTTON_MASK(X) macro (where `X` is generally 1 for the
* left, 2 for middle, 3 for the right button), and `x` and `y` are set to the * left, 2 for middle, 3 for the right button), and `x` and `y` are set to the
* mouse cursor position relative to the focus window. You can pass NULL for * mouse cursor position relative to the focus window. You can pass NULL for
* either `x` or `y`. * either `x` or `y`.
@ -233,7 +233,7 @@ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetMouseState(float *x, flo
* \param y filled in with the current Y coord relative to the desktop; can be * \param y filled in with the current Y coord relative to the desktop; can be
* NULL. * NULL.
* \returns the current button state as a bitmask which can be tested using * \returns the current button state as a bitmask which can be tested using
* the SDL_BUTTON(X) macros. * the SDL_BUTTON_MASK(X) macros.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
@ -246,7 +246,7 @@ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *
* Retrieve the relative state of the mouse. * Retrieve the relative state of the mouse.
* *
* The current button state is returned as a button bitmask, which can be * The current button state is returned as a button bitmask, which can be
* tested using the `SDL_BUTTON(X)` macros (where `X` is generally 1 for the * tested using the `SDL_BUTTON_MASK(X)` macros (where `X` is generally 1 for the
* left, 2 for middle, 3 for the right button), and `x` and `y` are set to the * left, 2 for middle, 3 for the right button), and `x` and `y` are set to the
* mouse deltas since the last call to SDL_GetRelativeMouseState() or since * mouse deltas since the last call to SDL_GetRelativeMouseState() or since
* event initialization. You can pass NULL for either `x` or `y`. * event initialization. You can pass NULL for either `x` or `y`.

View File

@ -429,6 +429,7 @@
#define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_COUNT #define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_COUNT
/* ##SDL_mouse.h */ /* ##SDL_mouse.h */
#define SDL_BUTTON SDL_BUTTON_MASK
#define SDL_FreeCursor SDL_DestroyCursor #define SDL_FreeCursor SDL_DestroyCursor
#define SDL_NUM_SYSTEM_CURSORS SDL_SYSTEM_CURSOR_COUNT #define SDL_NUM_SYSTEM_CURSORS SDL_SYSTEM_CURSOR_COUNT
#define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_DEFAULT #define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_DEFAULT
@ -1067,6 +1068,7 @@
#define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_MAX_renamed_SDL_MESSAGEBOX_COLOR_COUNT #define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_MAX_renamed_SDL_MESSAGEBOX_COLOR_COUNT
/* ##SDL_mouse.h */ /* ##SDL_mouse.h */
#define SDL_BUTTON SDL_BUTTON_renamed_SDL_BUTTON_MASK
#define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor #define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor
#define SDL_NUM_SYSTEM_CURSORS SDL_NUM_SYSTEM_CURSORS_renamed_SDL_SYSTEM_CURSOR_COUNT #define SDL_NUM_SYSTEM_CURSORS SDL_NUM_SYSTEM_CURSORS_renamed_SDL_SYSTEM_CURSOR_COUNT
#define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_ARROW_renamed_SDL_SYSTEM_CURSOR_DEFAULT #define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_ARROW_renamed_SDL_SYSTEM_CURSOR_DEFAULT

View File

@ -485,7 +485,7 @@ void SDL_ResetMouse(void)
int i; int i;
for (i = 1; i <= sizeof(buttonState)*8; ++i) { for (i = 1; i <= sizeof(buttonState)*8; ++i) {
if (buttonState & SDL_BUTTON(i)) { if (buttonState & SDL_BUTTON_MASK(i)) {
SDL_SendMouseButton(0, mouse->focus, mouse->mouseID, i, false); SDL_SendMouseButton(0, mouse->focus, mouse->mouseID, i, false);
} }
} }
@ -876,13 +876,13 @@ static SDL_MouseInputSource *GetMouseInputSource(SDL_Mouse *mouse, SDL_MouseID m
} }
} }
if (!down && (!match || !(match->buttonstate & SDL_BUTTON(button)))) { if (!down && (!match || !(match->buttonstate & SDL_BUTTON_MASK(button)))) {
/* This might be a button release from a transition between mouse messages and raw input. /* This might be a button release from a transition between mouse messages and raw input.
* See if there's another mouse source that already has that button down and use that. * See if there's another mouse source that already has that button down and use that.
*/ */
for (i = 0; i < mouse->num_sources; ++i) { for (i = 0; i < mouse->num_sources; ++i) {
source = &mouse->sources[i]; source = &mouse->sources[i];
if ((source->buttonstate & SDL_BUTTON(button))) { if ((source->buttonstate & SDL_BUTTON_MASK(button))) {
match = source; match = source;
break; break;
} }
@ -966,10 +966,10 @@ static void SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL
// Figure out which event to perform // Figure out which event to perform
if (down) { if (down) {
type = SDL_EVENT_MOUSE_BUTTON_DOWN; type = SDL_EVENT_MOUSE_BUTTON_DOWN;
buttonstate |= SDL_BUTTON(button); buttonstate |= SDL_BUTTON_MASK(button);
} else { } else {
type = SDL_EVENT_MOUSE_BUTTON_UP; type = SDL_EVENT_MOUSE_BUTTON_UP;
buttonstate &= ~SDL_BUTTON(button); buttonstate &= ~SDL_BUTTON_MASK(button);
} }
// We do this after calculating buttonstate so button presses gain focus // We do this after calculating buttonstate so button presses gain focus

View File

@ -1018,12 +1018,12 @@ static void SDLTest_PrintButtonMask(char *text, size_t maxlen, SDL_MouseButtonFl
int i; int i;
int count = 0; int count = 0;
for (i = 1; i <= 32; ++i) { for (i = 1; i <= 32; ++i) {
const Uint32 flag = SDL_BUTTON(i); const Uint32 flag = SDL_BUTTON_MASK(i);
if ((flags & flag) == flag) { if ((flags & flag) == flag) {
if (count > 0) { if (count > 0) {
SDL_snprintfcat(text, maxlen, " | "); SDL_snprintfcat(text, maxlen, " | ");
} }
SDL_snprintfcat(text, maxlen, "SDL_BUTTON(%d)", i); SDL_snprintfcat(text, maxlen, "SDL_BUTTON_MASK(%d)", i);
++count; ++count;
} }
} }

View File

@ -238,7 +238,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
int i; int i;
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) { for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
if (event.buttonMask & SDL_BUTTON(i)) { if (event.buttonMask & SDL_BUTTON_MASK(i)) {
Uint8 button; Uint8 button;
switch (i) { switch (i) {
@ -294,7 +294,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
int i; int i;
for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) { for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) {
if (event.buttonMask & SDL_BUTTON(i)) { if (event.buttonMask & SDL_BUTTON_MASK(i)) {
Uint8 button; Uint8 button;
switch (i) { switch (i) {

View File

@ -740,9 +740,9 @@ static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_
* long as any button is still down, the capture remains). * long as any button is still down, the capture remains).
*/ */
if (state) { // update our mask of currently-pressed buttons if (state) { // update our mask of currently-pressed buttons
input->buttons_pressed |= SDL_BUTTON(sdl_button); input->buttons_pressed |= SDL_BUTTON_MASK(sdl_button);
} else { } else {
input->buttons_pressed &= ~(SDL_BUTTON(sdl_button)); input->buttons_pressed &= ~(SDL_BUTTON_MASK(sdl_button));
} }
// Don't modify the capture flag in relative mode. // Don't modify the capture flag in relative mode.

View File

@ -220,10 +220,10 @@ static void WIN_CheckWParamMouseButton(Uint64 timestamp, bool bwParamMousePresse
} }
} }
if (data->focus_click_pending & SDL_BUTTON(button)) { if (data->focus_click_pending & SDL_BUTTON_MASK(button)) {
// Ignore the button click for activation // Ignore the button click for activation
if (!bwParamMousePressed) { if (!bwParamMousePressed) {
data->focus_click_pending &= ~SDL_BUTTON(button); data->focus_click_pending &= ~SDL_BUTTON_MASK(button);
WIN_UpdateClipCursor(data->window); WIN_UpdateClipCursor(data->window);
} }
if (WIN_ShouldIgnoreFocusClick(data)) { if (WIN_ShouldIgnoreFocusClick(data)) {
@ -231,9 +231,9 @@ static void WIN_CheckWParamMouseButton(Uint64 timestamp, bool bwParamMousePresse
} }
} }
if (bwParamMousePressed && !(mouseFlags & SDL_BUTTON(button))) { if (bwParamMousePressed && !(mouseFlags & SDL_BUTTON_MASK(button))) {
SDL_SendMouseButton(timestamp, data->window, mouseID, button, true); SDL_SendMouseButton(timestamp, data->window, mouseID, button, true);
} else if (!bwParamMousePressed && (mouseFlags & SDL_BUTTON(button))) { } else if (!bwParamMousePressed && (mouseFlags & SDL_BUTTON_MASK(button))) {
SDL_SendMouseButton(timestamp, data->window, mouseID, button, false); SDL_SendMouseButton(timestamp, data->window, mouseID, button, false);
} }
} }
@ -651,10 +651,10 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL
} }
} }
if (windowdata->focus_click_pending & SDL_BUTTON(button)) { if (windowdata->focus_click_pending & SDL_BUTTON_MASK(button)) {
// Ignore the button click for activation // Ignore the button click for activation
if (!down) { if (!down) {
windowdata->focus_click_pending &= ~SDL_BUTTON(button); windowdata->focus_click_pending &= ~SDL_BUTTON_MASK(button);
WIN_UpdateClipCursor(window); WIN_UpdateClipCursor(window);
} }
if (WIN_ShouldIgnoreFocusClick(windowdata)) { if (WIN_ShouldIgnoreFocusClick(windowdata)) {

View File

@ -17,11 +17,11 @@
static int mouseStateCheck(Uint32 state) static int mouseStateCheck(Uint32 state)
{ {
return (state == 0) || return (state == 0) ||
(state == SDL_BUTTON(SDL_BUTTON_LEFT)) || (state == SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) ||
(state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) || (state == SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE)) ||
(state == SDL_BUTTON(SDL_BUTTON_RIGHT)) || (state == SDL_BUTTON_MASK(SDL_BUTTON_RIGHT)) ||
(state == SDL_BUTTON(SDL_BUTTON_X1)) || (state == SDL_BUTTON_MASK(SDL_BUTTON_X1)) ||
(state == SDL_BUTTON(SDL_BUTTON_X2)); (state == SDL_BUTTON_MASK(SDL_BUTTON_X2));
} }
/** /**

View File

@ -286,9 +286,9 @@ static void HandleMouseButton(SDL_MouseButtonEvent *event)
} }
if (event->which == mouse_state->instance_id) { if (event->which == mouse_state->instance_id) {
if (event->down) { if (event->down) {
mouse_state->button_state |= SDL_BUTTON(event->button); mouse_state->button_state |= SDL_BUTTON_MASK(event->button);
} else { } else {
mouse_state->button_state &= ~SDL_BUTTON(event->button); mouse_state->button_state &= ~SDL_BUTTON_MASK(event->button);
} }
} }
} }