Rename mouse BUTTON(DOWN|UP) event to BUTTON_(DOWN|UP)

This commit is contained in:
Anonymous Maarten 2023-01-30 04:06:08 +01:00 committed by Sam Lantinga
parent 413376cdb3
commit 758c0dd6d8
23 changed files with 45 additions and 45 deletions

View file

@ -2180,11 +2180,11 @@ expression e;
@@ @@
@@ @@
- SDL_MOUSEBUTTONDOWN - SDL_MOUSEBUTTONDOWN
+ SDL_EVENT_MOUSE_BUTTONDOWN + SDL_EVENT_MOUSE_BUTTON_DOWN
@@ @@
@@ @@
- SDL_MOUSEBUTTONUP - SDL_MOUSEBUTTONUP
+ SDL_EVENT_MOUSE_BUTTONUP + SDL_EVENT_MOUSE_BUTTON_UP
@@ @@
@@ @@
- SDL_MOUSEWHEEL - SDL_MOUSEWHEEL

View file

@ -170,8 +170,8 @@ The following symbols have been renamed:
* SDL_KEYUP => SDL_EVENT_KEY_UP * SDL_KEYUP => SDL_EVENT_KEY_UP
* SDL_LASTEVENT => SDL_EVENT_LAST * SDL_LASTEVENT => SDL_EVENT_LAST
* SDL_LOCALECHANGED => SDL_EVENT_LOCALECHANGED * SDL_LOCALECHANGED => SDL_EVENT_LOCALECHANGED
* SDL_MOUSEBUTTONDOWN => SDL_EVENT_MOUSE_BUTTONDOWN * SDL_MOUSEBUTTONDOWN => SDL_EVENT_MOUSE_BUTTON_DOWN
* SDL_MOUSEBUTTONUP => SDL_EVENT_MOUSE_BUTTONUP * SDL_MOUSEBUTTONUP => SDL_EVENT_MOUSE_BUTTON_UP
* SDL_MOUSEMOTION => SDL_EVENT_MOUSE_MOTION * SDL_MOUSEMOTION => SDL_EVENT_MOUSE_MOTION
* SDL_MOUSEWHEEL => SDL_EVENT_MOUSE_WHEEL * SDL_MOUSEWHEEL => SDL_EVENT_MOUSE_WHEEL
* SDL_POLLSENTINEL => SDL_EVENT_POLL_SENTINEL * SDL_POLLSENTINEL => SDL_EVENT_POLL_SENTINEL

View file

@ -133,8 +133,8 @@ typedef enum
/* Mouse events */ /* Mouse events */
SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */ SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
SDL_EVENT_MOUSE_BUTTONDOWN, /**< Mouse button pressed */ SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */
SDL_EVENT_MOUSE_BUTTONUP, /**< Mouse button released */ SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */
SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */ SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */
/* Joystick events */ /* Joystick events */
@ -307,7 +307,7 @@ typedef struct SDL_MouseMotionEvent
*/ */
typedef struct SDL_MouseButtonEvent typedef struct SDL_MouseButtonEvent
{ {
Uint32 type; /**< ::SDL_EVENT_MOUSE_BUTTONDOWN or ::SDL_EVENT_MOUSE_BUTTONUP */ Uint32 type; /**< ::SDL_EVENT_MOUSE_BUTTON_DOWN or ::SDL_EVENT_MOUSE_BUTTON_UP */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_WindowID windowID;/**< The window with mouse focus, if any */ SDL_WindowID windowID;/**< The window with mouse focus, if any */
SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ SDL_MouseID which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */

View file

@ -98,8 +98,8 @@
#define SDL_KEYUP SDL_EVENT_KEY_UP #define SDL_KEYUP SDL_EVENT_KEY_UP
#define SDL_LASTEVENT SDL_EVENT_LAST #define SDL_LASTEVENT SDL_EVENT_LAST
#define SDL_LOCALECHANGED SDL_EVENT_LOCALE_CHANGED #define SDL_LOCALECHANGED SDL_EVENT_LOCALE_CHANGED
#define SDL_MOUSEBUTTONDOWN SDL_EVENT_MOUSE_BUTTONDOWN #define SDL_MOUSEBUTTONDOWN SDL_EVENT_MOUSE_BUTTON_DOWN
#define SDL_MOUSEBUTTONUP SDL_EVENT_MOUSE_BUTTONUP #define SDL_MOUSEBUTTONUP SDL_EVENT_MOUSE_BUTTON_UP
#define SDL_MOUSEMOTION SDL_EVENT_MOUSE_MOTION #define SDL_MOUSEMOTION SDL_EVENT_MOUSE_MOTION
#define SDL_MOUSEWHEEL SDL_EVENT_MOUSE_WHEEL #define SDL_MOUSEWHEEL SDL_EVENT_MOUSE_WHEEL
#define SDL_POLLSENTINEL SDL_EVENT_POLL_SENTINEL #define SDL_POLLSENTINEL SDL_EVENT_POLL_SENTINEL
@ -479,8 +479,8 @@
#define SDL_KEYUP SDL_KEYUP_renamed_SDL_EVENT_KEY_UP #define SDL_KEYUP SDL_KEYUP_renamed_SDL_EVENT_KEY_UP
#define SDL_LASTEVENT SDL_LASTEVENT_renamed_SDL_EVENT_LAST #define SDL_LASTEVENT SDL_LASTEVENT_renamed_SDL_EVENT_LAST
#define SDL_LOCALECHANGED SDL_LOCALECHANGED_renamed_SDL_EVENT_LOCALECHANGED #define SDL_LOCALECHANGED SDL_LOCALECHANGED_renamed_SDL_EVENT_LOCALECHANGED
#define SDL_MOUSEBUTTONDOWN SDL_MOUSEBUTTONDOWN_renamed_SDL_EVENT_MOUSE_BUTTONDOWN #define SDL_MOUSEBUTTONDOWN SDL_MOUSEBUTTONDOWN_renamed_SDL_EVENT_MOUSE_BUTTON_DOWN
#define SDL_MOUSEBUTTONUP SDL_MOUSEBUTTONUP_renamed_SDL_EVENT_MOUSE_BUTTONUP #define SDL_MOUSEBUTTONUP SDL_MOUSEBUTTONUP_renamed_SDL_EVENT_MOUSE_BUTTON_UP
#define SDL_MOUSEMOTION SDL_MOUSEMOTION_renamed_SDL_EVENT_MOUSE_MOTION #define SDL_MOUSEMOTION SDL_MOUSEMOTION_renamed_SDL_EVENT_MOUSE_MOTION
#define SDL_MOUSEWHEEL SDL_MOUSEWHEEL_renamed_SDL_EVENT_MOUSE_WHEEL #define SDL_MOUSEWHEEL SDL_MOUSEWHEEL_renamed_SDL_EVENT_MOUSE_WHEEL
#define SDL_POLLSENTINEL SDL_POLLSENTINEL_renamed_SDL_EVENT_POLL_SENTINEL #define SDL_POLLSENTINEL SDL_POLLSENTINEL_renamed_SDL_EVENT_POLL_SENTINEL

View file

@ -296,10 +296,10 @@ static void SDL_LogEvent(const SDL_Event *event)
(uint)event->button.which, (uint)event->button.button, \ (uint)event->button.which, (uint)event->button.button, \
event->button.state == SDL_PRESSED ? "pressed" : "released", \ event->button.state == SDL_PRESSED ? "pressed" : "released", \
(uint)event->button.clicks, event->button.x, event->button.y) (uint)event->button.clicks, event->button.x, event->button.y)
SDL_EVENT_CASE(SDL_EVENT_MOUSE_BUTTONDOWN) SDL_EVENT_CASE(SDL_EVENT_MOUSE_BUTTON_DOWN)
PRINT_MBUTTON_EVENT(event); PRINT_MBUTTON_EVENT(event);
break; break;
SDL_EVENT_CASE(SDL_EVENT_MOUSE_BUTTONUP) SDL_EVENT_CASE(SDL_EVENT_MOUSE_BUTTON_UP)
PRINT_MBUTTON_EVENT(event); PRINT_MBUTTON_EVENT(event);
break; break;
#undef PRINT_MBUTTON_EVENT #undef PRINT_MBUTTON_EVENT

View file

@ -687,11 +687,11 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_
/* Figure out which event to perform */ /* Figure out which event to perform */
switch (state) { switch (state) {
case SDL_PRESSED: case SDL_PRESSED:
type = SDL_EVENT_MOUSE_BUTTONDOWN; type = SDL_EVENT_MOUSE_BUTTON_DOWN;
buttonstate |= SDL_BUTTON(button); buttonstate |= SDL_BUTTON(button);
break; break;
case SDL_RELEASED: case SDL_RELEASED:
type = SDL_EVENT_MOUSE_BUTTONUP; type = SDL_EVENT_MOUSE_BUTTON_UP;
buttonstate &= ~SDL_BUTTON(button); buttonstate &= ~SDL_BUTTON(button);
break; break;
default: default:

View file

@ -772,8 +772,8 @@ static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event)
} }
} }
} }
} else if (event->type == SDL_EVENT_MOUSE_BUTTONDOWN || } else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
event->type == SDL_EVENT_MOUSE_BUTTONUP) { event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
SDL_Window *window = SDL_GetWindowFromID(event->button.windowID); SDL_Window *window = SDL_GetWindowFromID(event->button.windowID);
if (window == renderer->window) { if (window == renderer->window) {
int logical_w, logical_h; int logical_w, logical_h;

View file

@ -1526,12 +1526,12 @@ static void SDLTest_PrintEvent(SDL_Event *event)
event->motion.xrel, event->motion.yrel, event->motion.xrel, event->motion.yrel,
event->motion.windowID); event->motion.windowID);
break; break;
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
SDL_Log("SDL EVENT: Mouse: button %d pressed at %g,%g with click count %d in window %" SDL_PRIu32, SDL_Log("SDL EVENT: Mouse: button %d pressed at %g,%g with click count %d in window %" SDL_PRIu32,
event->button.button, event->button.x, event->button.y, event->button.clicks, event->button.button, event->button.x, event->button.y, event->button.clicks,
event->button.windowID); event->button.windowID);
break; break;
case SDL_EVENT_MOUSE_BUTTONUP: case SDL_EVENT_MOUSE_BUTTON_UP:
SDL_Log("SDL EVENT: Mouse: button %d released at %g,%g with click count %d in window %" SDL_PRIu32, SDL_Log("SDL EVENT: Mouse: button %d released at %g,%g with click count %d in window %" SDL_PRIu32,
event->button.button, event->button.x, event->button.y, event->button.clicks, event->button.button, event->button.x, event->button.y, event->button.clicks,
event->button.windowID); event->button.windowID);

View file

@ -658,10 +658,10 @@ static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouse
emscripten_request_pointerlock(window_data->canvas_id, 0); /* try to regrab lost pointer lock. */ emscripten_request_pointerlock(window_data->canvas_id, 0); /* try to regrab lost pointer lock. */
} }
sdl_button_state = SDL_PRESSED; sdl_button_state = SDL_PRESSED;
sdl_event_type = SDL_EVENT_MOUSE_BUTTONDOWN; sdl_event_type = SDL_EVENT_MOUSE_BUTTON_DOWN;
} else { } else {
sdl_button_state = SDL_RELEASED; sdl_button_state = SDL_RELEASED;
sdl_event_type = SDL_EVENT_MOUSE_BUTTONUP; sdl_event_type = SDL_EVENT_MOUSE_BUTTON_UP;
} }
SDL_SendMouseButton(0, window_data->window, 0, sdl_button_state, sdl_button); SDL_SendMouseButton(0, window_data->window, 0, sdl_button_state, sdl_button);

View file

@ -209,7 +209,7 @@ void loop()
SDL_StartTextInput(); SDL_StartTextInput();
} }
break; break;
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
/* Left button quits the app, other buttons toggles text input */ /* Left button quits the app, other buttons toggles text input */
if (event.button.button == SDL_BUTTON_LEFT) { if (event.button.button == SDL_BUTTON_LEFT) {
done = 1; done = 1;

View file

@ -184,7 +184,7 @@ void loop()
case SDL_EVENT_TEXT_INPUT: case SDL_EVENT_TEXT_INPUT:
PrintText("INPUT", event.text.text); PrintText("INPUT", event.text.text);
break; break;
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
/* Left button quits the app, other buttons toggles text input */ /* Left button quits the app, other buttons toggles text input */
(void)fprintf(stderr, "mouse button down button: %d (LEFT=%d)\n", event.button.button, SDL_BUTTON_LEFT); (void)fprintf(stderr, "mouse button down button: %d (LEFT=%d)\n", event.button.button, SDL_BUTTON_LEFT);
(void)fflush(stderr); (void)fflush(stderr);

View file

@ -516,7 +516,7 @@ WatchJoystick(SDL_Joystick *joystick)
} }
break; break;
case SDL_EVENT_FINGER_DOWN: case SDL_EVENT_FINGER_DOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
/* Skip this step */ /* Skip this step */
SetCurrentBinding(s_iCurrentBinding + 1); SetCurrentBinding(s_iCurrentBinding + 1);
break; break;

View file

@ -38,12 +38,12 @@ loop()
if (e.key.keysym.sym == SDLK_ESCAPE) { if (e.key.keysym.sym == SDLK_ESCAPE) {
please_quit = SDL_TRUE; please_quit = SDL_TRUE;
} }
} else if (e.type == SDL_EVENT_MOUSE_BUTTONDOWN) { } else if (e.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
if (e.button.button == 1) { if (e.button.button == 1) {
SDL_PauseAudioDevice(devid_out); SDL_PauseAudioDevice(devid_out);
SDL_PlayAudioDevice(devid_in); SDL_PlayAudioDevice(devid_in);
} }
} else if (e.type == SDL_EVENT_MOUSE_BUTTONUP) { } else if (e.type == SDL_EVENT_MOUSE_BUTTON_UP) {
if (e.button.button == 1) { if (e.button.button == 1) {
SDL_PauseAudioDevice(devid_in); SDL_PauseAudioDevice(devid_in);
SDL_PlayAudioDevice(devid_out); SDL_PlayAudioDevice(devid_out);

View file

@ -154,7 +154,7 @@ void loop()
/* Check for events */ /* Check for events */
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done); SDLTest_CommonEvent(state, &event, &done);
if (event.type == SDL_EVENT_MOUSE_BUTTONDOWN) { if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
if (event.button.button == SDL_BUTTON_LEFT) { if (event.button.button == SDL_BUTTON_LEFT) {
if (num_cursors == 0) { if (num_cursors == 0) {
continue; continue;

View file

@ -627,13 +627,13 @@ void loop(void *arg)
SDL_Log("Gamepad %" SDL_PRIu32 " battery state changed to %s\n", event.jbattery.which, power_level_strings[event.jbattery.level + 1]); SDL_Log("Gamepad %" SDL_PRIu32 " battery state changed to %s\n", event.jbattery.which, power_level_strings[event.jbattery.level + 1]);
break; break;
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
if (virtual_joystick) { if (virtual_joystick) {
VirtualGamepadMouseDown(event.button.x, event.button.y); VirtualGamepadMouseDown(event.button.x, event.button.y);
} }
break; break;
case SDL_EVENT_MOUSE_BUTTONUP: case SDL_EVENT_MOUSE_BUTTON_UP:
if (virtual_joystick) { if (virtual_joystick) {
VirtualGamepadMouseUp(event.button.x, event.button.y); VirtualGamepadMouseUp(event.button.x, event.button.y);
} }

View file

@ -104,11 +104,11 @@ int main(int argc, char **argv)
nothing_to_do = 0; nothing_to_do = 0;
switch (e.type) { switch (e.type) {
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
SDL_Log("button down!\n"); SDL_Log("button down!\n");
break; break;
case SDL_EVENT_MOUSE_BUTTONUP: case SDL_EVENT_MOUSE_BUTTON_UP:
SDL_Log("button up!\n"); SDL_Log("button up!\n");
break; break;

View file

@ -217,11 +217,11 @@ void loop()
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done); SDLTest_CommonEvent(state, &event, &done);
switch (event.type) { switch (event.type) {
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
mouse_begin_x = event.button.x; mouse_begin_x = event.button.x;
mouse_begin_y = event.button.y; mouse_begin_y = event.button.y;
break; break;
case SDL_EVENT_MOUSE_BUTTONUP: case SDL_EVENT_MOUSE_BUTTON_UP:
if (event.button.button == 3) { if (event.button.button == 3) {
add_line(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y); add_line(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
} }

View file

@ -198,7 +198,7 @@ void loop(void *arg)
} }
SDL_FALLTHROUGH; SDL_FALLTHROUGH;
case SDL_EVENT_FINGER_DOWN: case SDL_EVENT_FINGER_DOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
case SDL_EVENT_QUIT: case SDL_EVENT_QUIT:
done = SDL_TRUE; done = SDL_TRUE;
break; break;

View file

@ -136,7 +136,7 @@ void loop(void *arg)
active->y2 = event.motion.y; active->y2 = event.motion.y;
break; break;
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
if (active == NULL) { if (active == NULL) {
active = SDL_calloc(1, sizeof(*active)); active = SDL_calloc(1, sizeof(*active));
active->x1 = active->x2 = event.button.x; active->x1 = active->x2 = event.button.x;
@ -170,7 +170,7 @@ void loop(void *arg)
} }
break; break;
case SDL_EVENT_MOUSE_BUTTONUP: case SDL_EVENT_MOUSE_BUTTON_UP:
if (active == NULL) { if (active == NULL) {
break; break;
} }

View file

@ -167,7 +167,7 @@ quit(int rc)
/* If rc is 0, just let main return normally rather than calling exit. /* If rc is 0, just let main return normally rather than calling exit.
* This allows testing of platforms where SDL_main is required and does meaningful cleanup. * This allows testing of platforms where SDL_main is required and does meaningful cleanup.
*/ */
SDL_free(RawMooseData); SDL_free(RawMooseData);
for (i = 0; i < MOOSEFRAMES_COUNT; i++) { for (i = 0; i < MOOSEFRAMES_COUNT; i++) {
@ -221,7 +221,7 @@ void loop()
Uint64 now; Uint64 now;
int i; int i;
SDL_Event event; SDL_Event event;
SDL_Renderer *renderer = state->renderers[0]; /* only 1 window */ SDL_Renderer *renderer = state->renderers[0]; /* only 1 window */
/* Check for events */ /* Check for events */
@ -236,7 +236,7 @@ void loop()
displayrect.w = (float)window_w; displayrect.w = (float)window_w;
displayrect.h = (float)window_h; displayrect.h = (float)window_h;
break; break;
case SDL_EVENT_MOUSE_BUTTONDOWN: case SDL_EVENT_MOUSE_BUTTON_DOWN:
displayrect.x = event.button.x - window_w / 2; displayrect.x = event.button.x - window_w / 2;
displayrect.y = event.button.y - window_h / 2; displayrect.y = event.button.y - window_h / 2;
break; break;
@ -302,12 +302,12 @@ int main(int argc, char **argv)
if (state == NULL) { if (state == NULL) {
return 1; return 1;
} }
SDL_zeroa(MooseYUVSurfaces); SDL_zeroa(MooseYUVSurfaces);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;
consumed = SDLTest_CommonArg(state, i); consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) { if (consumed == 0) {
consumed = -1; consumed = -1;
@ -383,7 +383,7 @@ int main(int argc, char **argv)
static const char *options[] = { static const char *options[] = {
"[--fps <frames per second>]", "[--fps <frames per second>]",
"[--nodelay]", "[--nodelay]",
"[--yuvformat <fmt>] (one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)", "[--yuvformat <fmt>] (one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)",
"[--scale <scale factor>] (initial scale of the overlay)", "[--scale <scale factor>] (initial scale of the overlay)",
"[--nostreaming] path that use SDL_CreateTextureFromSurface() not STREAMING texture", "[--nostreaming] path that use SDL_CreateTextureFromSurface() not STREAMING texture",
NULL NULL

View file

@ -106,7 +106,7 @@ int main(int argc, char **argv)
case SDL_EVENT_SENSOR_UPDATE: case SDL_EVENT_SENSOR_UPDATE:
HandleSensorEvent(&event.sensor); HandleSensorEvent(&event.sensor);
break; break;
case SDL_EVENT_MOUSE_BUTTONUP: case SDL_EVENT_MOUSE_BUTTON_UP:
case SDL_EVENT_KEY_UP: case SDL_EVENT_KEY_UP:
case SDL_EVENT_QUIT: case SDL_EVENT_QUIT:
done = SDL_TRUE; done = SDL_TRUE;

View file

@ -204,7 +204,7 @@ void loop()
SDL_SetCursor(cursor); SDL_SetCursor(cursor);
} }
} }
if (event.type == SDL_EVENT_MOUSE_BUTTONUP) { if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) {
SDL_Window *window = SDL_GetMouseFocus(); SDL_Window *window = SDL_GetMouseFocus();
if (highlighted_mode != -1 && window != NULL) { if (highlighted_mode != -1 && window != NULL) {
const int display_index = SDL_GetWindowDisplayIndex(window); const int display_index = SDL_GetWindowDisplayIndex(window);

View file

@ -411,7 +411,7 @@ int main(int argc, char **argv)
++current; ++current;
} }
} }
if (event.type == SDL_EVENT_MOUSE_BUTTONDOWN) { if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
if (event.button.x < (original->w / 2)) { if (event.button.x < (original->w / 2)) {
--current; --current;
} else { } else {