Skip to content

Commit

Permalink
Fixed SDL1.2 legacy support
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Feb 11, 2022
1 parent c1cca93 commit 0a14363
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/build/include/mutex.h
Expand Up @@ -48,16 +48,18 @@ static FORCE_INLINE void mutex_unlock(mutex_t *mutex)
#endif
}

#if SDL_MAJOR_VERSION != 1
static FORCE_INLINE bool mutex_try(mutex_t *mutex)
{
#if SDL_MAJOR_VERSION >= 2
return SDL_AtomicTryLock(mutex);
#elif defined _WIN32
return TryEnterCriticalSection(mutex);
#elif SDL_MAJOR_VERSION == 1
return SDL_TryLockMutex(*mutex);
#else
# error No mutex try implementation provided.
#endif
}
#endif

#ifdef __cplusplus
}
Expand Down
12 changes: 12 additions & 0 deletions source/build/src/sdlayer.cpp
Expand Up @@ -1396,6 +1396,8 @@ void videoGetModes(int display)

modeschecked = 1;
}
#else
void videoGetModes(int display);
#endif

//
Expand Down Expand Up @@ -1457,7 +1459,11 @@ int32_t videoCheckMode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t fo

char const *videoGetDisplayName(int display)
{
#if SDL_MAJOR_VERSION >= 2
return SDL_GetDisplayName(display);
#else
return "Primary display";
#endif
}

static void destroy_window_resources()
Expand Down Expand Up @@ -1645,7 +1651,9 @@ void setvideomode_sdlcommonpost(int32_t x, int32_t y, int32_t c, int32_t fs, int
if (regrab)
mouseGrabInput(g_mouseLockedToWindow);

#if SDL_MAJOR_VERSION >= 2
g_displayindex = newdisplayindex;
#endif
}

#if SDL_MAJOR_VERSION >= 2
Expand Down Expand Up @@ -2571,12 +2579,14 @@ int32_t handleevents(void)
}
#endif

#if SDL_MAJOR_VERSION >= 2
if (g_mouseBits & 2 && osd->flags & OSD_CAPTURE && SDL_HasClipboardText())
{
auto text = SDL_GetClipboardText();
OSD_HandleClipboard(text);
SDL_free(text);
}
#endif

if (inputchecked && g_mouseEnabled)
{
Expand Down Expand Up @@ -2633,6 +2643,7 @@ int32_t handleevents(void)
}
#endif

#if SDL_MAJOR_VERSION >= 2
if (!frameplace && sdl_resize.x)
{
if (in3dmode())
Expand All @@ -2642,6 +2653,7 @@ int32_t handleevents(void)

sdl_resize = {};
}
#endif

#ifndef _WIN32
startwin_idle(NULL);
Expand Down

0 comments on commit 0a14363

Please sign in to comment.