Browse Source

[rcore] fix warnings in SDL3 compatibility layer

pull/4459/head
evertonse 1 week ago
parent
commit
505d5fcf1b
2 changed files with 13 additions and 13 deletions
  1. +13
    -12
      src/platforms/rcore_desktop_sdl.c
  2. +0
    -1
      src/raylib.h

+ 13
- 12
src/platforms/rcore_desktop_sdl.c View File

@ -272,7 +272,7 @@ const char* SDL_GameControllerNameForIndex(int joystickIndex)
{
// NOTE: SDL3 uses the IDs itself (SDL_JoystickID) instead of SDL2 joystick_index
const char* name = NULL;
int i, numJoysticks;
int numJoysticks = 0;
SDL_JoystickID *joysticks = SDL_GetJoysticks(&numJoysticks);
if (joysticks) {
if (joystickIndex < numJoysticks) {
@ -294,19 +294,20 @@ int SDL_GetNumVideoDisplays(void)
return monitorCount;
}
// SLD3 Migration:
// To emulate SDL2 this function should return `SDL_DISABLE` or `SDL_ENABLE`
// representing the *processing state* of the event before this function makes any changes to it.
Uint8 SDL_EventState(Uint32 type, int state) {
Uint8 stateBefore = SDL_EventEnabled(type);
switch (state)
{
case SDL_DISABLE:
SDL_SetEventEnabled(type, false);
break;
case SDL_ENABLE:
SDL_SetEventEnabled(type, true);
break;
default:
TRACELOG(LOG_WARNING, "Event sate: unknow type");
break;
case SDL_DISABLE: SDL_SetEventEnabled(type, false); break;
case SDL_ENABLE: SDL_SetEventEnabled(type, true); break;
default: TRACELOG(LOG_WARNING, "Event sate: unknow type");
}
return stateBefore;
}
void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode* mode)
@ -336,7 +337,7 @@ SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth
// not reliable across platforms, approximately replaced by multiplying
// SDL_GetWindowDisplayScale() times 160 on iPhone and Android, and 96 on other platforms.
int SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi) {
SDL_GetWindowDisplayScale(platform.window) * 96;
k">return SDL_GetWindowDisplayScale(platform.window) * 96;
}
SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
@ -356,7 +357,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int hei
int SDL_NumJoysticks(void)
{
int i, numJoysticks;
int numJoysticks;
SDL_JoystickID *joysticks = SDL_GetJoysticks(&numJoysticks);
SDL_free(joysticks);
return numJoysticks;

+ 0
- 1
src/raylib.h View File

@ -1012,7 +1012,6 @@ RLAPI const char *GetMonitorName(int monitor); // Get the hum
RLAPI void SetClipboardText(const char *text); // Set clipboard text content
RLAPI const char *GetClipboardText(void); // Get clipboard text content
RLAPI Image GetClipboardImage(void); // Get clipboard image
void SetClipboardImage(Image *image)
RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling
RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling

Loading…
Cancel
Save