diff --git a/src/SDLmzx.h b/src/SDLmzx.h index d97d9538e..6c2e322ce 100644 --- a/src/SDLmzx.h +++ b/src/SDLmzx.h @@ -32,6 +32,7 @@ __M_BEGIN_DECLS #if CONFIG_SDL == 3 #include +#include #else #include #if defined(_WIN32) || defined(CONFIG_X11) @@ -284,6 +285,8 @@ static inline void SDL_SetJoystickEventsEnabled(SDL_bool enabled) * SDL_keyboard.h and SDL_keycode.h */ #if !SDL_VERSION_ATLEAST(3,0,0) +#define SDLK_APOSTROPHE SDLK_QUOTE +#define SDLK_GRAVE SDLK_BACKQUOTE #define SDL_KMOD_CTRL KMOD_CTRL #define SDL_KMOD_ALT KMOD_ALT #define SDL_KMOD_NUM KMOD_NUM @@ -418,7 +421,28 @@ typedef SDL_sem SDL_Semaphore; * SDL_version.h */ #if !SDL_VERSION_ATLEAST(3,0,0) -typedef SDL_version SDL_Version; +#define SDL_MICRO_VERSION SDL_PATCHLEVEL + +#undef SDL_VERSIONNUM +#define SDL_VERSIONNUM(x,y,z) ((x) * 1000000 + (y) * 1000 + (z)) +#define SDL_VERSIONNUM_MAJOR(v) ((v) / 1000000) +#define SDL_VERSIONNUM_MINOR(v) (((v) / 1000) % 1000) +#define SDL_VERSIONNUM_MICRO(v) ((v) % 1000) + +#undef SDL_VERSION +#define SDL_VERSION SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +static inline int replace_SDL_GetVersion(void) +{ + SDL_version ver; +#if SDL_VERSION_ATLEAST(2,0,0) + SDK_GetVersion(&ver); +#else + ver = *SDL_Linked_Version(); +#endif + return SDL_VERSIONNUM(ver.major, ver.minor, ver.patch); +} +#define SDL_GetVersion replace_SDL_GetVersion #endif /** diff --git a/src/about.c b/src/about.c index 0f904b1e7..9861a950c 100644 --- a/src/about.c +++ b/src/about.c @@ -112,21 +112,22 @@ static char **about_text(int *num_lines) #ifdef CONFIG_SDL { - SDL_Version compiled; - SDL_Version ver; - SDL_VERSION(&compiled); -#if SDL_VERSION_ATLEAST(2,0,0) - SDL_GetVersion(&ver); -#else - ver = *SDL_Linked_Version(); -#endif - if(memcmp(&compiled, &ver, sizeof(SDL_Version))) + int ver_compiled = SDL_VERSION; + int ver_linked = SDL_GetVersion(); + + if(ver_compiled != ver_linked) { lines[i++] = about_line("SDL: %u.%u.%u (compiled: %u.%u.%u)", - ver.major, ver.minor, ver.patch, compiled.major, compiled.minor, compiled.patch); + SDL_VERSIONNUM_MAJOR(ver_linked), + SDL_VERSIONNUM_MINOR(ver_linked), + SDL_VERSIONNUM_MICRO(ver_linked), + SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION); } else - lines[i++] = about_line("SDL: %u.%u.%u", ver.major, ver.minor, ver.patch); + { + lines[i++] = about_line("SDL: %u.%u.%u", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION); + } } #endif diff --git a/src/event_sdl.c b/src/event_sdl.c index 5dbe3f35a..317c3bd4e 100644 --- a/src/event_sdl.c +++ b/src/event_sdl.c @@ -50,7 +50,7 @@ static enum keycode convert_SDL_internal(SDL_Keycode key) case SDLK_RETURN: return IKEY_RETURN; case SDLK_ESCAPE: return IKEY_ESCAPE; case SDLK_SPACE: return IKEY_SPACE; - case SDLK_QUOTE: return IKEY_QUOTE; + case SDLK_APOSTROPHE: return IKEY_QUOTE; case SDLK_PLUS: return IKEY_EQUALS; case SDLK_COMMA: return IKEY_COMMA; case SDLK_MINUS: return IKEY_MINUS; @@ -71,7 +71,7 @@ static enum keycode convert_SDL_internal(SDL_Keycode key) case SDLK_LEFTBRACKET: return IKEY_LEFTBRACKET; case SDLK_BACKSLASH: return IKEY_BACKSLASH; case SDLK_RIGHTBRACKET: return IKEY_RIGHTBRACKET; - case SDLK_BACKQUOTE: return IKEY_BACKQUOTE; + case SDLK_GRAVE: return IKEY_BACKQUOTE; case SDLK_a: return IKEY_a; case SDLK_b: return IKEY_b; case SDLK_c: return IKEY_c; diff --git a/src/render_sdl.c b/src/render_sdl.c index 2902b435d..e403eccc9 100644 --- a/src/render_sdl.c +++ b/src/render_sdl.c @@ -834,8 +834,12 @@ boolean sdlrender_set_video_mode(struct graphics_data *graphics, // Note: previously attempted SDL_RENDERER_ACCELERATED first, then // SDL_RENDERER_SOFTWARE, but these flags were removed in SDL3. +#if SDL_VERSION_ATLEAST(3,0,0) + render_data->renderer = SDL_CreateRenderer(render_data->window, BEST_RENDERER); +#else render_data->renderer = SDL_CreateRenderer(render_data->window, BEST_RENDERER, sdl_rendererflags); +#endif if(!render_data->renderer) { warn("Failed to create renderer: %s\n", SDL_GetError());