Renamed SDL events for clarity

Fixes https://github.com/libsdl-org/SDL/issues/6877
This commit is contained in:
Sam Lantinga
2023-01-23 17:54:09 -08:00
parent 74697bc351
commit 7b50bae524
101 changed files with 1375 additions and 862 deletions

View File

@@ -173,10 +173,10 @@ void loop()
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
if (event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_KEY_DOWN) {
switch (event.key.keysym.sym) {
case SDLK_BACKSPACE:
SDLTest_TextWindowAddText(textwin, "\b");
@@ -189,18 +189,18 @@ void loop()
}
}
break;
case SDL_TEXTEDITING:
case SDL_EVENT_TEXT_EDITING:
PrintText("EDIT", event.edit.text);
break;
case SDL_TEXTEDITING_EXT:
case SDL_EVENT_TEXTEDITING_EXT:
PrintText("EDIT_EXT", event.editExt.text);
SDL_free(event.editExt.text);
break;
case SDL_TEXTINPUT:
case SDL_EVENT_TEXT_INPUT:
PrintText("INPUT", event.text.text);
SDLTest_TextWindowAddText(textwin, "%s", event.text.text);
break;
case SDL_FINGERDOWN:
case SDL_EVENT_FINGER_DOWN:
if (SDL_TextInputActive()) {
SDL_Log("Stopping text input\n");
SDL_StopTextInput();
@@ -209,7 +209,7 @@ void loop()
SDL_StartTextInput();
}
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
/* Left button quits the app, other buttons toggles text input */
if (event.button.button == SDL_BUTTON_LEFT) {
done = 1;
@@ -223,7 +223,7 @@ void loop()
}
}
break;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = 1;
break;
default:

View File

@@ -174,17 +174,17 @@ void loop()
while (!done && SDL_WaitEvent(&event)) {
SDL_Log("Got event type: %" SDL_PRIu32 "\n", event.type);
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
break;
case SDL_TEXTEDITING:
case SDL_EVENT_TEXT_EDITING:
PrintText("EDIT", event.text.text);
break;
case SDL_TEXTINPUT:
case SDL_EVENT_TEXT_INPUT:
PrintText("INPUT", event.text.text);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
/* 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)fflush(stderr);
@@ -200,7 +200,7 @@ void loop()
}
}
break;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = 1;
break;
default:
@@ -227,7 +227,7 @@ static int SDLCALL ping_thread(void *ptr)
for (cnt = 0; cnt < 10; ++cnt) {
(void)fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10);
(void)fflush(stderr);
sdlevent.type = SDL_KEYDOWN;
sdlevent.type = SDL_EVENT_KEY_DOWN;
sdlevent.key.keysym.sym = SDLK_1;
SDL_PushEvent(&sdlevent);
SDL_Delay(1000 + rand() % 1000);

View File

@@ -438,12 +438,12 @@ WatchJoystick(SDL_Joystick *joystick)
while (SDL_PollEvent(&event) > 0) {
switch (event.type) {
case SDL_JOYDEVICEREMOVED:
case SDL_EVENT_JOYSTICK_REMOVED:
if (event.jaxis.which == nJoystickID) {
done = SDL_TRUE;
}
break;
case SDL_JOYAXISMOTION:
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
if (event.jaxis.which == nJoystickID) {
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 gamepad needed 96 */
AxisState *pAxisState = &s_arrAxisState[event.jaxis.axis];
@@ -484,7 +484,7 @@ WatchJoystick(SDL_Joystick *joystick)
}
}
break;
case SDL_JOYHATMOTION:
case SDL_EVENT_JOYSTICK_HAT_MOTION:
if (event.jhat.which == nJoystickID) {
if (event.jhat.value != SDL_HAT_CENTERED) {
SDL_GameControllerExtendedBind binding;
@@ -501,7 +501,7 @@ WatchJoystick(SDL_Joystick *joystick)
}
}
break;
case SDL_JOYBUTTONUP:
case SDL_EVENT_JOYSTICK_BUTTON_UP:
if (event.jbutton.which == nJoystickID) {
SDL_GameControllerExtendedBind binding;
@@ -515,12 +515,12 @@ WatchJoystick(SDL_Joystick *joystick)
ConfigureBinding(&binding);
}
break;
case SDL_FINGERDOWN:
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_FINGER_DOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
/* Skip this step */
SetCurrentBinding(s_iCurrentBinding + 1);
break;
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
if (event.key.keysym.sym == SDLK_BACKSPACE || event.key.keysym.sym == SDLK_AC_BACK) {
SetCurrentBinding(s_iCurrentBinding - 1);
break;
@@ -534,7 +534,7 @@ WatchJoystick(SDL_Joystick *joystick)
break;
}
SDL_FALLTHROUGH;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
default:
@@ -763,12 +763,12 @@ int main(int argc, char *argv[])
while (SDL_PollEvent(&event) > 0) {
switch (event.type) {
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
if ((event.key.keysym.sym != SDLK_ESCAPE)) {
break;
}
SDL_FALLTHROUGH;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
default:

View File

@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
open_audio();
SDL_FlushEvents(SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED);
SDL_FlushEvents(SDL_EVENT_AUDIO_DEVICE_ADDED, SDL_EVENT_AUDIO_DEVICE_REMOVED);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
@@ -157,11 +157,11 @@ int main(int argc, char *argv[])
SDL_Event event;
while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT) {
if (event.type == SDL_EVENT_QUIT) {
done = 1;
}
if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) ||
(event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
if ((event.type == SDL_EVENT_AUDIO_DEVICE_ADDED && !event.adevice.iscapture) ||
(event.type == SDL_EVENT_AUDIO_DEVICE_REMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
reopen_audio();
}
}

View File

@@ -25,7 +25,7 @@ Code
{
switch (event.type)
{
case SDL_QUIT:
case SDL_EVENT_QUIT:
return 1;
default:
break;

View File

@@ -495,7 +495,7 @@ static int SDLCALL FIFO_Writer(void *_data)
int i;
SDL_Event event;
event.type = SDL_USEREVENT;
event.type = SDL_EVENT_USER;
event.user.windowID = 0;
event.user.code = 0;
event.user.data1 = data;

View File

@@ -32,18 +32,18 @@ loop()
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
if (e.type == SDL_EVENT_QUIT) {
please_quit = SDL_TRUE;
} else if (e.type == SDL_KEYDOWN) {
} else if (e.type == SDL_EVENT_KEY_DOWN) {
if (e.key.keysym.sym == SDLK_ESCAPE) {
please_quit = SDL_TRUE;
}
} else if (e.type == SDL_MOUSEBUTTONDOWN) {
} else if (e.type == SDL_EVENT_MOUSE_BUTTONDOWN) {
if (e.button.button == 1) {
SDL_PauseAudioDevice(devid_out);
SDL_PlayAudioDevice(devid_in);
}
} else if (e.type == SDL_MOUSEBUTTONUP) {
} else if (e.type == SDL_EVENT_MOUSE_BUTTONUP) {
if (e.button.button == 1) {
SDL_PauseAudioDevice(devid_in);
SDL_PlayAudioDevice(devid_out);

View File

@@ -84,13 +84,13 @@ iteration()
SDL_Event e;
SDL_AudioDeviceID dev;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
if (e.type == SDL_EVENT_QUIT) {
done = 1;
} else if (e.type == SDL_KEYUP) {
} else if (e.type == SDL_EVENT_KEY_UP) {
if (e.key.keysym.sym == SDLK_ESCAPE) {
done = 1;
}
} else if (e.type == SDL_AUDIODEVICEADDED) {
} else if (e.type == SDL_EVENT_AUDIO_DEVICE_ADDED) {
int index = e.adevice.which;
int iscapture = e.adevice.iscapture;
const char *name = SDL_GetAudioDeviceName(index, iscapture);
@@ -113,7 +113,7 @@ iteration()
SDL_PlayAudioDevice(dev);
}
}
} else if (e.type == SDL_AUDIODEVICEREMOVED) {
} else if (e.type == SDL_EVENT_AUDIO_DEVICE_REMOVED) {
dev = (SDL_AudioDeviceID)e.adevice.which;
SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int)dev);
SDL_CloseAudioDevice(dev);

View File

@@ -49,7 +49,7 @@ int events_pushPumpAndPollUserevent(void *arg)
int result;
/* Create user event */
event1.type = SDL_USEREVENT;
event1.type = SDL_EVENT_USER;
event1.user.code = SDLTest_RandomSint32();
event1.user.data1 = (void *)&g_userdataValue1;
event1.user.data2 = (void *)&g_userdataValue2;
@@ -80,7 +80,7 @@ int events_addDelEventWatch(void *arg)
SDL_Event event;
/* Create user event */
event.type = SDL_USEREVENT;
event.type = SDL_EVENT_USER;
event.user.code = SDLTest_RandomSint32();
event.user.data1 = (void *)&g_userdataValue1;
event.user.data2 = (void *)&g_userdataValue2;
@@ -129,7 +129,7 @@ int events_addDelEventWatchWithUserdata(void *arg)
SDL_Event event;
/* Create user event */
event.type = SDL_USEREVENT;
event.type = SDL_EVENT_USER;
event.user.code = SDLTest_RandomSint32();
event.user.data1 = (void *)&g_userdataValue1;
event.user.data2 = (void *)&g_userdataValue2;

View File

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

View File

@@ -63,7 +63,7 @@ void loop()
while (SDL_PollEvent(&e)) {
/* Re-create when window has been resized */
if (e.type == SDL_WINDOWEVENT_SIZE_CHANGED) {
if (e.type == SDL_EVENT_WINDOW_SIZE_CHANGED) {
SDL_DestroyRenderer(renderer);
@@ -74,7 +74,7 @@ void loop()
SDL_RenderClear(renderer);
}
if (e.type == SDL_QUIT) {
if (e.type == SDL_EVENT_QUIT) {
done = 1;
#ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop();
@@ -82,7 +82,7 @@ void loop()
return;
}
if ((e.type == SDL_KEYDOWN) && (e.key.keysym.sym == SDLK_ESCAPE)) {
if ((e.type == SDL_EVENT_KEY_DOWN) && (e.key.keysym.sym == SDLK_ESCAPE)) {
done = 1;
#ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop();

View File

@@ -67,19 +67,19 @@ int main(int argc, char *argv[])
SDL_RenderPresent(renderer);
}
SDL_SetEventEnabled(SDL_DROPFILE, SDL_TRUE);
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_TRUE);
/* Main render loop */
done = 0;
while (!done) {
/* Check for events */
while (SDL_PollEvent(&event)) {
if (event.type == SDL_DROPBEGIN) {
if (event.type == SDL_EVENT_DROP_BEGIN) {
SDL_Log("Drop beginning on window %u", (unsigned int)event.drop.windowID);
} else if (event.type == SDL_DROPCOMPLETE) {
} else if (event.type == SDL_EVENT_DROP_COMPLETE) {
SDL_Log("Drop complete on window %u", (unsigned int)event.drop.windowID);
} else if ((event.type == SDL_DROPFILE) || (event.type == SDL_DROPTEXT)) {
const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text";
} else if ((event.type == SDL_EVENT_DROP_FILE) || (event.type == SDL_EVENT_DROP_TEXT)) {
const char *typestr = (event.type == SDL_EVENT_DROP_FILE) ? "File" : "Text";
char *dropped_filedir = event.drop.file;
SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int)event.drop.windowID, dropped_filedir);
/* Normally you'd have to do this, but this is freed in SDLTest_CommonEvent() */

View File

@@ -560,26 +560,26 @@ void loop(void *arg)
SDL_PumpEvents();
/* Process all currently pending events */
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1) {
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) == 1) {
switch (event.type) {
case SDL_GAMEPADADDED:
case SDL_EVENT_GAMEPAD_ADDED:
SDL_Log("Gamepad device %" SDL_PRIu32 " added.\n", event.cdevice.which);
AddGamepad(event.cdevice.which, SDL_TRUE);
break;
case SDL_GAMEPADREMOVED:
case SDL_EVENT_GAMEPAD_REMOVED:
SDL_Log("Gamepad device %" SDL_PRIu32 " removed.\n", event.cdevice.which);
DelGamepad(event.cdevice.which);
break;
case SDL_GAMEPADTOUCHPADDOWN:
case SDL_GAMEPADTOUCHPADMOTION:
case SDL_GAMEPADTOUCHPADUP:
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
SDL_Log("Gamepad %" SDL_PRIu32 " touchpad %" SDL_PRIs32 " finger %" SDL_PRIs32 " %s %.2f, %.2f, %.2f\n",
event.ctouchpad.which,
event.ctouchpad.touchpad,
event.ctouchpad.finger,
(event.type == SDL_GAMEPADTOUCHPADDOWN ? "pressed at" : (event.type == SDL_GAMEPADTOUCHPADUP ? "released at" : "moved to")),
(event.type == SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN ? "pressed at" : (event.type == SDL_EVENT_GAMEPAD_TOUCHPAD_UP ? "released at" : "moved to")),
event.ctouchpad.x,
event.ctouchpad.y,
event.ctouchpad.pressure);
@@ -587,7 +587,7 @@ void loop(void *arg)
#define VERBOSE_SENSORS
#ifdef VERBOSE_SENSORS
case SDL_GAMEPADSENSORUPDATE:
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE:
SDL_Log("Gamepad %" SDL_PRIu32 " sensor %s: %.2f, %.2f, %.2f (%" SDL_PRIu64 ")\n",
event.csensor.which,
GetSensorName((SDL_SensorType)event.csensor.sensor),
@@ -600,7 +600,7 @@ void loop(void *arg)
#define VERBOSE_AXES
#ifdef VERBOSE_AXES
case SDL_GAMEPADAXISMOTION:
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
if (event.caxis.value <= (-SDL_JOYSTICK_AXIS_MAX / 2) || event.caxis.value >= (SDL_JOYSTICK_AXIS_MAX / 2)) {
SetGamepad(event.caxis.which);
}
@@ -608,44 +608,44 @@ void loop(void *arg)
break;
#endif /* VERBOSE_AXES */
case SDL_GAMEPADBUTTONDOWN:
case SDL_GAMEPADBUTTONUP:
if (event.type == SDL_GAMEPADBUTTONDOWN) {
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
case SDL_EVENT_GAMEPAD_BUTTON_UP:
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
SetGamepad(event.cbutton.which);
}
SDL_Log("Gamepad %" SDL_PRIu32 " button %s %s\n", event.cbutton.which, SDL_GetGamepadStringForButton((SDL_GamepadButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released");
/* Cycle PS5 trigger effects when the microphone button is pressed */
if (event.type == SDL_GAMEPADBUTTONDOWN &&
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN &&
event.cbutton.button == SDL_GAMEPAD_BUTTON_MISC1 &&
SDL_GetGamepadType(gamepad) == SDL_GAMEPAD_TYPE_PS5) {
CyclePS5TriggerEffect();
}
break;
case SDL_JOYBATTERYUPDATED:
case SDL_EVENT_JOYSTICK_BATTERY_UPDATED:
SDL_Log("Gamepad %" SDL_PRIu32 " battery state changed to %s\n", event.jbattery.which, power_level_strings[event.jbattery.level + 1]);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
if (virtual_joystick) {
VirtualGamepadMouseDown(event.button.x, event.button.y);
}
break;
case SDL_MOUSEBUTTONUP:
case SDL_EVENT_MOUSE_BUTTONUP:
if (virtual_joystick) {
VirtualGamepadMouseUp(event.button.x, event.button.y);
}
break;
case SDL_MOUSEMOTION:
case SDL_EVENT_MOUSE_MOTION:
if (virtual_joystick) {
VirtualGamepadMouseMotion(event.motion.x, event.motion.y);
}
break;
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
if (event.key.keysym.sym >= SDLK_0 && event.key.keysym.sym <= SDLK_9) {
if (gamepad) {
int player_index = (event.key.keysym.sym - SDLK_0);
@@ -666,7 +666,7 @@ void loop(void *arg)
break;
}
SDL_FALLTHROUGH;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
default:

View File

@@ -70,7 +70,7 @@ void loop()
/* Check for events */
while (SDL_PollEvent(&event)) {
if (event.type == SDL_MOUSEMOTION) {
if (event.type == SDL_EVENT_MOUSE_MOTION) {
if (event.motion.state) {
float xrel, yrel;
int window_w, window_h;

View File

@@ -387,7 +387,7 @@ int main(int argc, char *argv[])
++frames;
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
if (event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_KEY_DOWN) {
if (event.key.keysym.sym == SDLK_o) {
swap_interval--;
update_swap_interval = SDL_TRUE;

View File

@@ -283,7 +283,7 @@ int main(int argc, char *argv[])
/* Check for events */
++frames;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT_RESIZED) {
if (event.type == SDL_EVENT_WINDOW_RESIZED) {
for (i = 0; i < state->num_windows; ++i) {
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);

View File

@@ -567,7 +567,7 @@ loop_threaded()
/* Wait for events */
while (SDL_WaitEvent(&event) && !done) {
if (event.type == SDL_WINDOWEVENT_CLOSE) {
if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) {
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if (window) {
for (i = 0; i < state->num_windows; ++i) {

View File

@@ -331,7 +331,7 @@ void loop()
++frames;
while (SDL_PollEvent(&event) && !done) {
switch (event.type) {
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
{
const int sym = event.key.keysym.sym;
@@ -355,7 +355,7 @@ void loop()
break;
}
case SDL_WINDOWEVENT_RESIZED:
case SDL_EVENT_WINDOW_RESIZED:
for (i = 0; i < state->num_windows; ++i) {
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
int w, h;

View File

@@ -104,19 +104,19 @@ int main(int argc, char **argv)
nothing_to_do = 0;
switch (e.type) {
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
SDL_Log("button down!\n");
break;
case SDL_MOUSEBUTTONUP:
case SDL_EVENT_MOUSE_BUTTONUP:
SDL_Log("button up!\n");
break;
case SDL_WINDOWEVENT_MOVED:
case SDL_EVENT_WINDOW_MOVED:
SDL_Log("Window event moved to (%d, %d)!\n", (int)e.window.data1, (int)e.window.data2);
break;
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
if (e.key.keysym.sym == SDLK_ESCAPE) {
done = 1;
} else if (e.key.keysym.sym == SDLK_x) {
@@ -130,7 +130,7 @@ int main(int argc, char **argv)
}
break;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = 1;
break;
}

View File

@@ -63,10 +63,10 @@ int main(int argc, char *argv[])
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
case SDL_EVENT_QUIT:
keepGoing = SDL_FALSE;
break;
case SDL_JOYDEVICEADDED:
case SDL_EVENT_JOYSTICK_ADDED:
if (joystick != NULL) {
SDL_Log("Only one joystick supported by this test\n");
} else {
@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
}
}
break;
case SDL_JOYDEVICEREMOVED:
case SDL_EVENT_JOYSTICK_REMOVED:
if (instance == event.jdevice.which) {
SDL_Log("Joy Removed: %" SDL_PRIs32 "\n", event.jdevice.which);
instance = 0;
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
SDL_Log("Unknown joystick diconnected\n");
}
break;
case SDL_JOYAXISMOTION:
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
/*
// SDL_Log("Axis Move: %d\n", event.jaxis.axis);
*/
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
SDL_HapticRumblePlay(haptic, 0.25, 250);
}
break;
case SDL_JOYBUTTONDOWN:
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
SDL_Log("Button Press: %d\n", event.jbutton.button);
if (enable_haptic && haptic) {
SDL_HapticRumblePlay(haptic, 0.25, 250);
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
keepGoing = SDL_FALSE;
}
break;
case SDL_JOYBUTTONUP:
case SDL_EVENT_JOYSTICK_BUTTON_UP:
SDL_Log("Button Release: %d\n", event.jbutton.button);
break;
}

View File

@@ -716,7 +716,7 @@ int main(int argc, char *argv[])
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
switch (event.type) {
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
switch (event.key.keysym.sym) {
case SDLK_RETURN:
text[0] = 0x00;
@@ -764,7 +764,7 @@ int main(int argc, char *argv[])
SDL_GetKeyName(event.key.keysym.sym));
break;
case SDL_TEXTINPUT:
case SDL_EVENT_TEXT_INPUT:
if (event.text.text[0] == '\0' || event.text.text[0] == '\n' || markedRect.w < 0) {
break;
}
@@ -783,7 +783,7 @@ int main(int argc, char *argv[])
Redraw();
break;
case SDL_TEXTEDITING:
case SDL_EVENT_TEXT_EDITING:
SDL_Log("text editing \"%s\", selected range (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n",
event.edit.text, event.edit.start, event.edit.length);

View File

@@ -217,11 +217,11 @@ void loop()
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
mouse_begin_x = event.button.x;
mouse_begin_y = event.button.y;
break;
case SDL_MOUSEBUTTONUP:
case SDL_EVENT_MOUSE_BUTTONUP:
if (event.button.button == 3) {
add_line(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
}
@@ -229,7 +229,7 @@ void loop()
add_rect(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
}
break;
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
switch (event.key.keysym.sym) {
case 'l':
if (event.key.keysym.mod & SDL_KMOD_SHIFT) {

View File

@@ -111,7 +111,7 @@ void loop(void *arg)
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_JOYDEVICEADDED:
case SDL_EVENT_JOYSTICK_ADDED:
SDL_Log("Joystick device %" SDL_PRIu32 " added.\n", event.jdevice.which);
if (joystick == NULL) {
joystick = SDL_OpenJoystick(event.jdevice.which);
@@ -123,7 +123,7 @@ void loop(void *arg)
}
break;
case SDL_JOYDEVICEREMOVED:
case SDL_EVENT_JOYSTICK_REMOVED:
SDL_Log("Joystick device %" SDL_PRIu32 " removed.\n", event.jdevice.which);
if (event.jdevice.which == SDL_GetJoystickInstanceID(joystick)) {
SDL_JoystickID *joysticks;
@@ -146,12 +146,12 @@ void loop(void *arg)
}
break;
case SDL_JOYAXISMOTION:
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
SDL_Log("Joystick %" SDL_PRIu32 " axis %d value: %d\n",
event.jaxis.which,
event.jaxis.axis, event.jaxis.value);
break;
case SDL_JOYHATMOTION:
case SDL_EVENT_JOYSTICK_HAT_MOTION:
SDL_Log("Joystick %" SDL_PRIu32 " hat %d value:",
event.jhat.which, event.jhat.hat);
if (event.jhat.value == SDL_HAT_CENTERED) {
@@ -171,7 +171,7 @@ void loop(void *arg)
}
SDL_Log("\n");
break;
case SDL_JOYBUTTONDOWN:
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
SDL_Log("Joystick %" SDL_PRIu32 " button %d down\n",
event.jbutton.which, event.jbutton.button);
/* First button triggers a 0.5 second full strength rumble */
@@ -179,11 +179,11 @@ void loop(void *arg)
SDL_RumbleJoystick(joystick, 0xFFFF, 0xFFFF, 500);
}
break;
case SDL_JOYBUTTONUP:
case SDL_EVENT_JOYSTICK_BUTTON_UP:
SDL_Log("Joystick %" SDL_PRIu32 " button %d up\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
/* Press the L key to lag for 3 seconds, to see what happens
when SDL doesn't service the event loop quickly. */
if (event.key.keysym.sym == SDLK_l) {
@@ -197,9 +197,9 @@ void loop(void *arg)
break;
}
SDL_FALLTHROUGH;
case SDL_FINGERDOWN:
case SDL_MOUSEBUTTONDOWN:
case SDL_QUIT:
case SDL_EVENT_FINGER_DOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
default:

View File

@@ -47,10 +47,10 @@ int main(int argc, char **argv)
while (keep_going) {
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
if (e.type == SDL_EVENT_QUIT) {
keep_going = SDL_FALSE;
} else if (e.type == SDL_LOCALECHANGED) {
SDL_Log("Saw SDL_LOCALECHANGED event!");
} else if (e.type == SDL_EVENT_LOCALE_CHANGED) {
SDL_Log("Saw SDL_EVENT_LOCALE_CHANGED event!");
log_locales();
}
}

View File

@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
}
while (SDL_WaitEvent(&event)) {
if (event.type == SDL_QUIT || event.type == SDL_KEYUP) {
if (event.type == SDL_EVENT_QUIT || event.type == SDL_EVENT_KEY_UP) {
break;
}
}

View File

@@ -110,7 +110,7 @@ void loop(void *arg)
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_MOUSEWHEEL:
case SDL_EVENT_MOUSE_WHEEL:
if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) {
event.wheel.x *= -1;
event.wheel.y *= -1;
@@ -127,7 +127,7 @@ void loop(void *arg)
}
break;
case SDL_MOUSEMOTION:
case SDL_EVENT_MOUSE_MOTION:
if (active == NULL) {
break;
}
@@ -136,7 +136,7 @@ void loop(void *arg)
active->y2 = event.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
if (active == NULL) {
active = SDL_calloc(1, sizeof(*active));
active->x1 = active->x2 = event.button.x;
@@ -170,7 +170,7 @@ void loop(void *arg)
}
break;
case SDL_MOUSEBUTTONUP:
case SDL_EVENT_MOUSE_BUTTONUP:
if (active == NULL) {
break;
}
@@ -199,8 +199,8 @@ void loop(void *arg)
}
break;
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
switch (event.key.keysym.sym) {
case SDLK_LSHIFT:
isRect = (event.key.state == SDL_PRESSED);
@@ -211,7 +211,7 @@ void loop(void *arg)
}
break;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;

View File

@@ -180,11 +180,11 @@ int main(int argc, char *argv[])
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_WINDOWEVENT_EXPOSED:
case SDL_EVENT_WINDOW_EXPOSED:
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear(renderer);
break;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = 1;
break;
default:

View File

@@ -75,7 +75,7 @@ void loop()
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
}

View File

@@ -229,24 +229,24 @@ void loop()
SDLTest_CommonEvent(state, &event, &done);
switch (event.type) {
case SDL_WINDOWEVENT_RESIZED:
case SDL_EVENT_WINDOW_RESIZED:
SDL_SetRenderViewport(renderer, NULL);
window_w = event.window.data1;
window_h = event.window.data2;
displayrect.w = (float)window_w;
displayrect.h = (float)window_h;
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_EVENT_MOUSE_BUTTONDOWN:
displayrect.x = event.button.x - window_w / 2;
displayrect.y = event.button.y - window_h / 2;
break;
case SDL_MOUSEMOTION:
case SDL_EVENT_MOUSE_MOTION:
if (event.motion.state) {
displayrect.x = event.motion.x - window_w / 2;
displayrect.y = event.motion.y - window_h / 2;
}
break;
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
if (event.key.keysym.sym == SDLK_SPACE) {
paused = !paused;
break;
@@ -494,7 +494,7 @@ int main(int argc, char **argv)
displayrect.h = (float)window_h;
/* Ignore key up events, they don't even get filtered */
SDL_SetEventEnabled(SDL_KEYUP, SDL_FALSE);
SDL_SetEventEnabled(SDL_EVENT_KEY_UP, SDL_FALSE);
/* Main render loop */
frames = 0;

View File

@@ -44,7 +44,7 @@ loop()
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
switch (event.type) {
case SDL_MOUSEMOTION:
case SDL_EVENT_MOUSE_MOTION:
{
mouseX += event.motion.xrel;
mouseY += event.motion.yrel;

View File

@@ -101,14 +101,14 @@ int main(int argc, char **argv)
SDL_PumpEvents();
/* Process all currently pending events */
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) == 1) {
while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) == 1) {
switch (event.type) {
case SDL_SENSORUPDATE:
case SDL_EVENT_SENSOR_UPDATE:
HandleSensorEvent(&event.sensor);
break;
case SDL_MOUSEBUTTONUP:
case SDL_KEYUP:
case SDL_QUIT:
case SDL_EVENT_MOUSE_BUTTONUP:
case SDL_EVENT_KEY_UP:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
default:

View File

@@ -493,10 +493,10 @@ int main(int argc, char **argv)
{
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
if (event.type == SDL_EVENT_QUIT) {
done = 1;
}
if (event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_KEY_DOWN) {
if (event.key.keysym.sym == SDLK_SPACE) {
current_shader = (current_shader + 1) % NUM_SHADERS;
}

View File

@@ -168,14 +168,14 @@ int main(int argc, char **argv)
SDL_SetWindowShape(window, pictures[current_picture].surface, &pictures[current_picture].mode);
while (should_exit == 0) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_KEY_DOWN) {
button_down = 1;
if (event.key.keysym.sym == SDLK_ESCAPE) {
should_exit = 1;
break;
}
}
if (button_down && event.type == SDL_KEYUP) {
if (button_down && event.type == SDL_EVENT_KEY_UP) {
button_down = 0;
current_picture += 1;
if (current_picture >= num_pictures) {
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
SDL_SetWindowSize(window, texture_dimensions.w, texture_dimensions.h);
SDL_SetWindowShape(window, pictures[current_picture].surface, &pictures[current_picture].mode);
}
if (event.type == SDL_QUIT) {
if (event.type == SDL_EVENT_QUIT) {
should_exit = 1;
break;
}

View File

@@ -83,7 +83,7 @@ void loop()
/* Check for events */
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT || event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_QUIT || event.type == SDL_EVENT_KEY_DOWN) {
done = 1;
}
}

View File

@@ -100,12 +100,12 @@ void loop()
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
case SDL_EVENT_KEY_DOWN:
if (event.key.keysym.sym == SDLK_ESCAPE) {
done = SDL_TRUE;
}
break;
case SDL_QUIT:
case SDL_EVENT_QUIT:
done = SDL_TRUE;
break;
}

View File

@@ -1125,7 +1125,7 @@ int main(int argc, char **argv)
/* Need to destroy the swapchain before the window created
* by SDL.
*/
if (event.type == SDL_WINDOWEVENT_CLOSE) {
if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) {
destroySwapchainAndSwapchainSpecificStuff(SDL_TRUE);
}
SDLTest_CommonEvent(state, &event, &done);

View File

@@ -151,7 +151,7 @@ void loop()
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
if (event.type == SDL_WINDOWEVENT_RESIZED) {
if (event.type == SDL_EVENT_WINDOW_RESIZED) {
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if (window) {
SDL_Log("Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32 "\n",
@@ -160,7 +160,7 @@ void loop()
event.window.data2);
}
}
if (event.type == SDL_WINDOWEVENT_MOVED) {
if (event.type == SDL_EVENT_WINDOW_MOVED) {
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if (window) {
SDL_Log("Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (display %s)\n",
@@ -170,18 +170,18 @@ void loop()
SDL_GetDisplayName(SDL_GetWindowDisplayIndex(window)));
}
}
if (event.type == SDL_WINDOWEVENT_FOCUS_LOST) {
if (event.type == SDL_EVENT_WINDOW_FOCUS_LOST) {
relative_mode = SDL_GetRelativeMouseMode();
if (relative_mode) {
SDL_SetRelativeMouseMode(SDL_FALSE);
}
}
if (event.type == SDL_WINDOWEVENT_FOCUS_GAINED) {
if (event.type == SDL_EVENT_WINDOW_FOCUS_GAINED) {
if (relative_mode) {
SDL_SetRelativeMouseMode(SDL_TRUE);
}
}
if (event.type == SDL_KEYUP) {
if (event.type == SDL_EVENT_KEY_UP) {
SDL_bool updateCursor = SDL_FALSE;
if (event.key.keysym.sym == SDLK_LEFT) {
@@ -204,7 +204,7 @@ void loop()
SDL_SetCursor(cursor);
}
}
if (event.type == SDL_MOUSEBUTTONUP) {
if (event.type == SDL_EVENT_MOUSE_BUTTONUP) {
SDL_Window *window = SDL_GetMouseFocus();
if (highlighted_mode != -1 && window != NULL) {
const int display_index = SDL_GetWindowDisplayIndex(window);
@@ -271,8 +271,8 @@ int main(int argc, char *argv[])
return 1;
}
SDL_SetEventEnabled(SDL_DROPFILE, SDL_TRUE);
SDL_SetEventEnabled(SDL_DROPTEXT, SDL_TRUE);
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_TRUE);
SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, SDL_TRUE);
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];

View File

@@ -399,10 +399,10 @@ int main(int argc, char **argv)
while (!done) {
SDL_Event event;
while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT) {
if (event.type == SDL_EVENT_QUIT) {
done = 1;
}
if (event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_KEY_DOWN) {
if (event.key.keysym.sym == SDLK_ESCAPE) {
done = 1;
} else if (event.key.keysym.sym == SDLK_LEFT) {
@@ -411,7 +411,7 @@ int main(int argc, char **argv)
++current;
}
}
if (event.type == SDL_MOUSEBUTTONDOWN) {
if (event.type == SDL_EVENT_MOUSE_BUTTONDOWN) {
if (event.button.x < (original->w / 2)) {
--current;
} else {