mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
ISLE compiles & starts
SDL_filesystem is just stubs so it cannot read any game data
This commit is contained in:
parent
68a4ee445d
commit
d8a584268e
13
3rdparty/CMakeLists.txt
vendored
13
3rdparty/CMakeLists.txt
vendored
@ -118,13 +118,16 @@ if(USE_SDL2)
|
||||
endforeach()
|
||||
|
||||
|
||||
add_library(SDL3_shim INTERFACE)
|
||||
target_link_libraries(SDL3_shim INTERFACE SDL2::SDL2)
|
||||
target_include_directories(SDL3_shim INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/sdl3-shim")
|
||||
target_include_directories(SDL3_shim INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/sdl3-shim/")
|
||||
add_library(SDL3_shim STATIC
|
||||
sdl3-shim/main.cpp
|
||||
)
|
||||
target_link_libraries(SDL3_shim PRIVATE SDL2::SDL2)
|
||||
target_include_directories(SDL3_shim PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/sdl3-shim"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sdl3-shim"
|
||||
)
|
||||
|
||||
add_library(SDL3::SDL3 ALIAS SDL3_shim)
|
||||
|
||||
add_library(SDL3::Headers ALIAS SDL3_shim)
|
||||
|
||||
endif()
|
||||
|
||||
16
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
16
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
@ -3,21 +3,22 @@
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_stdinch
|
||||
#define SDL_bool bool
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_keyboard.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <SDL2/SDL_mouse.h>
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_filesystem.h"
|
||||
#include "SDL_gamepad.h"
|
||||
#include "SDL_iostream.h"
|
||||
#include "SDL_keycode.h"
|
||||
#include "SDL_keyboard.h"
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_pixels.h"
|
||||
// #include "SDL_properties.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
|
||||
#include <random>
|
||||
|
||||
@ -98,7 +99,6 @@ inline SDL_DisplayMode* SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_haptich
|
||||
// SDL_MouseID/SDL_KeyboardID are new
|
||||
|
||||
typedef int SDL_MouseID;
|
||||
typedef int SDL_KeyboardID;
|
||||
#define SDL_GetKeyboardState (const bool*)SDL_GetKeyboardState
|
||||
typedef int SDL_HapticID;
|
||||
@ -165,9 +165,13 @@ inline bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w,
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_mouseh
|
||||
|
||||
typedef Uint32 SDL_MouseID;
|
||||
|
||||
static void SDL_HideCursor() { SDL_ShowCursor(SDL_DISABLE); }
|
||||
static void SDL_ShowCursor() { SDL_ShowCursor(SDL_ENABLE); }
|
||||
|
||||
typedef Uint32 SDL_MouseButtonFlags;
|
||||
|
||||
#define SDL_SYSTEM_CURSOR_COUNT SDL_NUM_SYSTEM_CURSORS
|
||||
#define SDL_SYSTEM_CURSOR_DEFAULT SDL_SYSTEM_CURSOR_ARROW
|
||||
#define SDL_SYSTEM_CURSOR_POINTER SDL_SYSTEM_CURSOR_HAND
|
||||
|
||||
8
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
8
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
@ -68,14 +68,14 @@ inline SDL_AudioDeviceID SDL_GetAudioStreamDevice(SDL_AudioStream* stream)
|
||||
|
||||
inline SDL_AudioStream * SDL_OpenAudioDeviceStream(const char* devid, const SDL_AudioSpec* desired, SDL_AudioStreamCallback callback, void* userdata)
|
||||
{
|
||||
SDL_AudioSpec* obtained{};
|
||||
SDL_AudioSpec obtained{};
|
||||
SDL_AudioSpec desired2 = *desired;
|
||||
desired2.callback = shim_audio_callback;
|
||||
desired2.userdata = reinterpret_cast<void*>(static_cast<uintptr_t>(0));
|
||||
SDL_AudioDeviceID device = SDL_OpenAudioDevice(devid, 0, &desired2, obtained, 0);
|
||||
SDL_AudioDeviceID device = SDL_OpenAudioDevice(devid, 0, &desired2, &obtained, 0);
|
||||
SDL_AudioStream* stream = SDL_NewAudioStream(
|
||||
desired->format, desired->channels, desired->freq,
|
||||
obtained->format, obtained->channels, obtained->freq
|
||||
obtained.format, obtained.channels, obtained.freq
|
||||
);
|
||||
if (!stream) {
|
||||
SDL_CloseAudioDevice(device);
|
||||
@ -88,7 +88,7 @@ inline SDL_AudioStream * SDL_OpenAudioDeviceStream(const char* devid, const SDL_
|
||||
ctx.stream = stream;
|
||||
ctx.callback = callback;
|
||||
ctx.userdata = userdata;
|
||||
ctx.obtained = *obtained;
|
||||
ctx.obtained = obtained;
|
||||
g_audioCtxs[device] = ctx;
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
}
|
||||
|
||||
3
3rdparty/sdl3-shim/SDL3/SDL_events.h
vendored
3
3rdparty/sdl3-shim/SDL3/SDL_events.h
vendored
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_events.h>
|
||||
#include "SDL.h"
|
||||
#include <SDL2/SDL_events.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_eventsh
|
||||
|
||||
|
||||
4
3rdparty/sdl3-shim/SDL3/SDL_filesystem.h
vendored
4
3rdparty/sdl3-shim/SDL3/SDL_filesystem.h
vendored
@ -28,11 +28,11 @@ typedef struct SDL_PathInfo
|
||||
|
||||
// https://github.com/libsdl-org/SDL/blob/main/src/filesystem/
|
||||
|
||||
inline char ** SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count)
|
||||
inline char** SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count)
|
||||
{
|
||||
// since the one use of this doesnt use pattern or flags this should be a pretty simple stub
|
||||
SDL_Unsupported();
|
||||
return static_cast<char**>(SDL_malloc(0));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline bool SDL_RemovePath(const char *path)
|
||||
|
||||
2
3rdparty/sdl3-shim/SDL3/SDL_gamepad.h
vendored
2
3rdparty/sdl3-shim/SDL3/SDL_gamepad.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_gamecontroller.h>
|
||||
#include <SDL2/SDL_gamecontroller.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_gamecontrollerh
|
||||
|
||||
|
||||
2
3rdparty/sdl3-shim/SDL3/SDL_iostream.h
vendored
2
3rdparty/sdl3-shim/SDL3/SDL_iostream.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_rwops.h>
|
||||
#include <SDL2/SDL_rwops.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_rwopsh
|
||||
|
||||
|
||||
2
3rdparty/sdl3-shim/SDL3/SDL_keycode.h
vendored
2
3rdparty/sdl3-shim/SDL3/SDL_keycode.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_keycode.h>
|
||||
#include <SDL2/SDL_keycode.h>
|
||||
|
||||
#define SDLK_MEDIA_FAST_FORWARD SDLK_AUDIOFASTFORWARD
|
||||
#define SDL_KMOD_ALT KMOD_ALT
|
||||
|
||||
13
3rdparty/sdl3-shim/SDL3/SDL_main.h
vendored
Normal file
13
3rdparty/sdl3-shim/SDL3/SDL_main.h
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum SDL_AppResult
|
||||
{
|
||||
SDL_APP_CONTINUE,
|
||||
SDL_APP_SUCCESS,
|
||||
SDL_APP_FAILURE
|
||||
} SDL_AppResult;
|
||||
|
||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]);
|
||||
SDL_AppResult SDL_AppIterate(void *appstate);
|
||||
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event);
|
||||
void SDL_AppQuit(void *appstate, SDL_AppResult result);
|
||||
2
3rdparty/sdl3-shim/SDL3/SDL_mutex.h
vendored
2
3rdparty/sdl3-shim/SDL3/SDL_mutex.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_mutex.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_mutexh
|
||||
|
||||
|
||||
4
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
4
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_pixels.h>
|
||||
#include <SDL2/SDL_pixels.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_pixelsh
|
||||
#define bits_per_pixel BitsPerPixel
|
||||
@ -26,7 +26,7 @@ SDL_PixelFormatDetails* SDL_GetPixelFormatDetails(T format) {
|
||||
|
||||
static bool operator!=(SDL_PixelFormatDetails* lhs, SDL_PixelFormatEnum rhs)
|
||||
{
|
||||
return lhs->format == rhs;
|
||||
return lhs->format != rhs;
|
||||
}
|
||||
|
||||
#define SDL_CreatePalette SDL_AllocPalette
|
||||
|
||||
7
3rdparty/sdl3-shim/SDL3/SDL_surface.h
vendored
7
3rdparty/sdl3-shim/SDL3/SDL_surface.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_surface.h>
|
||||
#include <SDL2/SDL_surface.h>
|
||||
#include "SDL_pixels.h"
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_surfaceh
|
||||
@ -22,10 +22,7 @@ SDL_Surface* SDL_CreateSurface( int width, int height, T format) {
|
||||
|
||||
inline SDL_Surface* SDL_ConvertSurface(SDL_Surface* surface, SDL_PixelFormat format)
|
||||
{
|
||||
SDL_PixelFormatDetails* formatDetails = SDL_AllocFormat(format);
|
||||
SDL_Surface* result = SDL_ConvertSurface(surface, formatDetails, 0);
|
||||
SDL_free(formatDetails);
|
||||
return result;
|
||||
return SDL_ConvertSurfaceFormat(surface, format, 0);
|
||||
};
|
||||
inline SDL_Surface* SDL_ConvertSurface(SDL_Surface* surface, const SDL_PixelFormatDetails* formatDetails)
|
||||
{
|
||||
|
||||
8
3rdparty/sdl3-shim/SDL3/SDL_timer.h
vendored
8
3rdparty/sdl3-shim/SDL3/SDL_timer.h
vendored
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_timer.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_timer.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_timerh
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_timerh | SDL_GetTicksNS()
|
||||
@ -53,7 +55,7 @@ inline SDL_TimerID SDL_AddTimer(Uint32 interval, SDL3_TimerCallback callback3, v
|
||||
return id;
|
||||
}
|
||||
|
||||
inline SDL_bool SDL_RemoveTimer(SDL_TimerID id)
|
||||
inline SDL_bool SDL_RemoveTimer2(SDL_TimerID id)
|
||||
{
|
||||
SDL_LockMutex(g_timerMutex);
|
||||
if (const auto it = g_timers.find(id); it != g_timers.end()) {
|
||||
@ -64,3 +66,5 @@ inline SDL_bool SDL_RemoveTimer(SDL_TimerID id)
|
||||
|
||||
return ::SDL_RemoveTimer(id);
|
||||
}
|
||||
|
||||
#define SDL_RemoveTimer SDL_RemoveTimer2
|
||||
|
||||
20
3rdparty/sdl3-shim/main.cpp
vendored
Normal file
20
3rdparty/sdl3-shim/main.cpp
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include "SDL3/SDL_events.h"
|
||||
#include "SDL3/SDL_main.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
void *appstate = NULL;
|
||||
if (SDL_AppInit(&appstate, argc, argv) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_Event e;
|
||||
while (!SDL_AppIterate(appstate)) {
|
||||
while (SDL_PollEvent(&e)) {
|
||||
SDL_AppEvent(appstate, &e);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_AppQuit(appstate, static_cast<SDL_AppResult>(NULL));
|
||||
return 0;
|
||||
}
|
||||
@ -480,10 +480,16 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
|
||||
if (event->key.repeat) {
|
||||
break;
|
||||
}
|
||||
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
SDL_Keycode keyCode = event->key.key;
|
||||
|
||||
if ((event->key.mod & SDL_KMOD_LALT) && keyCode == SDLK_RETURN) {
|
||||
#else
|
||||
SDL_Keycode keyCode = event->key.keysym.sym;
|
||||
|
||||
if ((event->key.keysym.mod & SDL_KMOD_LALT) && keyCode == SDLK_RETURN) {
|
||||
#endif
|
||||
|
||||
SDL_SetWindowFullscreen(window, !(SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN));
|
||||
}
|
||||
else {
|
||||
@ -493,6 +499,7 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
case SDL_EVENT_KEYBOARD_ADDED:
|
||||
if (InputManager()) {
|
||||
InputManager()->AddKeyboard(event->kdevice.which);
|
||||
@ -513,6 +520,7 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
|
||||
InputManager()->RemoveMouse(event->mdevice.which);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
if (InputManager()) {
|
||||
InputManager()->AddJoystick(event->jdevice.which);
|
||||
|
||||
@ -322,8 +322,10 @@ void InvokeAction(Extra::ActionType p_actionId, const MxAtomId& p_pAtom, MxS32 p
|
||||
|
||||
break;
|
||||
case Extra::ActionType::e_run: {
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
const char* args[] = {"/lego/sources/main/main.exe", "/script", p_pAtom.GetInternal(), NULL};
|
||||
SDL_Process* process = SDL_CreateProcess(args, false);
|
||||
#endif
|
||||
} break;
|
||||
case Extra::ActionType::e_enable:
|
||||
assert(p_streamId != DS_NOT_A_STREAM);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user