Skip to content

Commit 90330a7

Browse files
committed
Update for latest 'main' version/renderer/keysym changes.
1 parent 7ae338f commit 90330a7

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

src/SDLmzx.h

+25-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ __M_BEGIN_DECLS
3232

3333
#if CONFIG_SDL == 3
3434
#include <SDL3/SDL.h>
35+
#include <SDL3/SDL_version.h>
3536
#else
3637
#include <SDL.h>
3738
#if defined(_WIN32) || defined(CONFIG_X11)
@@ -284,6 +285,8 @@ static inline void SDL_SetJoystickEventsEnabled(SDL_bool enabled)
284285
* SDL_keyboard.h and SDL_keycode.h
285286
*/
286287
#if !SDL_VERSION_ATLEAST(3,0,0)
288+
#define SDLK_APOSTROPHE SDLK_QUOTE
289+
#define SDLK_GRAVE SDLK_BACKQUOTE
287290
#define SDL_KMOD_CTRL KMOD_CTRL
288291
#define SDL_KMOD_ALT KMOD_ALT
289292
#define SDL_KMOD_NUM KMOD_NUM
@@ -418,7 +421,28 @@ typedef SDL_sem SDL_Semaphore;
418421
* SDL_version.h
419422
*/
420423
#if !SDL_VERSION_ATLEAST(3,0,0)
421-
typedef SDL_version SDL_Version;
424+
#define SDL_MICRO_VERSION SDL_PATCHLEVEL
425+
426+
#undef SDL_VERSIONNUM
427+
#define SDL_VERSIONNUM(x,y,z) ((x) * 1000000 + (y) * 1000 + (z))
428+
#define SDL_VERSIONNUM_MAJOR(v) ((v) / 1000000)
429+
#define SDL_VERSIONNUM_MINOR(v) (((v) / 1000) % 1000)
430+
#define SDL_VERSIONNUM_MICRO(v) ((v) % 1000)
431+
432+
#undef SDL_VERSION
433+
#define SDL_VERSION SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
434+
435+
static inline int replace_SDL_GetVersion(void)
436+
{
437+
SDL_version ver;
438+
#if SDL_VERSION_ATLEAST(2,0,0)
439+
SDL_GetVersion(&ver);
440+
#else
441+
ver = *SDL_Linked_Version();
442+
#endif
443+
return SDL_VERSIONNUM(ver.major, ver.minor, ver.patch);
444+
}
445+
#define SDL_GetVersion replace_SDL_GetVersion
422446
#endif
423447

424448
/**

src/about.c

+12-11
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,22 @@ static char **about_text(int *num_lines)
112112

113113
#ifdef CONFIG_SDL
114114
{
115-
SDL_Version compiled;
116-
SDL_Version ver;
117-
SDL_VERSION(&compiled);
118-
#if SDL_VERSION_ATLEAST(2,0,0)
119-
SDL_GetVersion(&ver);
120-
#else
121-
ver = *SDL_Linked_Version();
122-
#endif
123-
if(memcmp(&compiled, &ver, sizeof(SDL_Version)))
115+
int ver_compiled = SDL_VERSION;
116+
int ver_linked = SDL_GetVersion();
117+
118+
if(ver_compiled != ver_linked)
124119
{
125120
lines[i++] = about_line("SDL: %u.%u.%u (compiled: %u.%u.%u)",
126-
ver.major, ver.minor, ver.patch, compiled.major, compiled.minor, compiled.patch);
121+
SDL_VERSIONNUM_MAJOR(ver_linked),
122+
SDL_VERSIONNUM_MINOR(ver_linked),
123+
SDL_VERSIONNUM_MICRO(ver_linked),
124+
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
127125
}
128126
else
129-
lines[i++] = about_line("SDL: %u.%u.%u", ver.major, ver.minor, ver.patch);
127+
{
128+
lines[i++] = about_line("SDL: %u.%u.%u",
129+
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
130+
}
130131
}
131132
#endif
132133

src/event_sdl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static enum keycode convert_SDL_internal(SDL_Keycode key)
5050
case SDLK_RETURN: return IKEY_RETURN;
5151
case SDLK_ESCAPE: return IKEY_ESCAPE;
5252
case SDLK_SPACE: return IKEY_SPACE;
53-
case SDLK_QUOTE: return IKEY_QUOTE;
53+
case SDLK_APOSTROPHE: return IKEY_QUOTE;
5454
case SDLK_PLUS: return IKEY_EQUALS;
5555
case SDLK_COMMA: return IKEY_COMMA;
5656
case SDLK_MINUS: return IKEY_MINUS;
@@ -71,7 +71,7 @@ static enum keycode convert_SDL_internal(SDL_Keycode key)
7171
case SDLK_LEFTBRACKET: return IKEY_LEFTBRACKET;
7272
case SDLK_BACKSLASH: return IKEY_BACKSLASH;
7373
case SDLK_RIGHTBRACKET: return IKEY_RIGHTBRACKET;
74-
case SDLK_BACKQUOTE: return IKEY_BACKQUOTE;
74+
case SDLK_GRAVE: return IKEY_BACKQUOTE;
7575
case SDLK_a: return IKEY_a;
7676
case SDLK_b: return IKEY_b;
7777
case SDLK_c: return IKEY_c;

src/render_sdl.c

+4
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,12 @@ boolean sdlrender_set_video_mode(struct graphics_data *graphics,
834834

835835
// Note: previously attempted SDL_RENDERER_ACCELERATED first, then
836836
// SDL_RENDERER_SOFTWARE, but these flags were removed in SDL3.
837+
#if SDL_VERSION_ATLEAST(3,0,0)
838+
render_data->renderer = SDL_CreateRenderer(render_data->window, BEST_RENDERER);
839+
#else
837840
render_data->renderer =
838841
SDL_CreateRenderer(render_data->window, BEST_RENDERER, sdl_rendererflags);
842+
#endif
839843
if(!render_data->renderer)
840844
{
841845
warn("Failed to create renderer: %s\n", SDL_GetError());

0 commit comments

Comments
 (0)