mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
legoomni compiles
This commit is contained in:
parent
6b177afbd6
commit
a7f7ea9e14
60
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
60
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
@ -3,15 +3,37 @@
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_stdinch
|
||||
#define SDL_bool bool
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL.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_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>
|
||||
|
||||
static std::mt19937 rng(SDL_GetPerformanceCounter());
|
||||
inline Sint32 SDL_rand(const Sint32 n)
|
||||
{
|
||||
std::uniform_int_distribution dist(0, n - 1);
|
||||
return dist(rng);
|
||||
}
|
||||
inline float SDL_randf()
|
||||
{
|
||||
static std::uniform_real_distribution dist(0.0f, 1.0f);
|
||||
return dist(rng);
|
||||
}
|
||||
|
||||
#define SDL_strtok_r SDL_strtokr
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_logh
|
||||
|
||||
@ -118,3 +140,39 @@ inline SDL_HapticID* SDL_GetHaptics(int *count)
|
||||
return haptics;
|
||||
}
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_videoh
|
||||
|
||||
#define SDL_GetDisplayForWindow SDL_GetWindowDisplayIndex
|
||||
#define SDL_SetWindowFullscreenMode SDL_SetWindowDisplayMode
|
||||
// #define SDL_GetClosestFullscreenDisplayMode SDL_GetClosestDisplayMode
|
||||
inline bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest)
|
||||
{
|
||||
SDL_DisplayMode desired{};
|
||||
desired.w = w;
|
||||
desired.h = h;
|
||||
desired.refresh_rate = static_cast<int>(refresh_rate);
|
||||
desired.format = 0;
|
||||
desired.driverdata = nullptr;
|
||||
|
||||
SDL_DisplayMode *result = SDL_GetClosestDisplayMode(displayID, &desired, closest);
|
||||
return result != nullptr;
|
||||
}
|
||||
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_mouseh
|
||||
|
||||
static void SDL_HideCursor() { SDL_ShowCursor(SDL_DISABLE); }
|
||||
static void SDL_ShowCursor() { SDL_ShowCursor(SDL_ENABLE); }
|
||||
|
||||
#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
|
||||
#define SDL_SYSTEM_CURSOR_TEXT SDL_SYSTEM_CURSOR_IBEAM
|
||||
#define SDL_SYSTEM_CURSOR_NOT_ALLOWED SDL_SYSTEM_CURSOR_NO
|
||||
#define SDL_SYSTEM_CURSOR_MOVE SDL_SYSTEM_CURSOR_SIZEALL
|
||||
#define SDL_SYSTEM_CURSOR_NESW_RESIZE SDL_SYSTEM_CURSOR_SIZENESW
|
||||
#define SDL_SYSTEM_CURSOR_NS_RESIZE SDL_SYSTEM_CURSOR_SIZENS
|
||||
#define SDL_SYSTEM_CURSOR_NWSE_RESIZE SDL_SYSTEM_CURSOR_SIZENWSE
|
||||
#define SDL_SYSTEM_CURSOR_EW_RESIZE SDL_SYSTEM_CURSOR_SIZEWE
|
||||
#define SDL_SYSTEM_CURSOR_PROGRESS SDL_SYSTEM_CURSOR_WAITARROW
|
||||
|
||||
|
||||
101
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
Normal file
101
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_audioh
|
||||
|
||||
#define SDL_DestroyAudioStream SDL_FreeAudioStream
|
||||
|
||||
#define SDL_AUDIO_F32 AUDIO_F32SYS
|
||||
|
||||
#define SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK NULL
|
||||
|
||||
typedef void SDL_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount);
|
||||
|
||||
struct ShimAudioCtx {
|
||||
SDL_AudioStream* stream;
|
||||
SDL_AudioStreamCallback* callback;
|
||||
void *userdata;
|
||||
SDL_AudioSpec obtained;
|
||||
};
|
||||
|
||||
static std::map<SDL_AudioDeviceID, ShimAudioCtx> g_audioCtxs;
|
||||
static SDL_mutex *g_audioMutex = NULL;
|
||||
|
||||
static void SDLCALL shim_audio_callback(void *userdata, Uint8 *stream, int len) {
|
||||
SDL_AudioDeviceID devid = reinterpret_cast<uintptr_t>(userdata);
|
||||
|
||||
SDL_LockMutex(g_audioMutex);
|
||||
const auto it = g_audioCtxs.find(devid);
|
||||
if (it == g_audioCtxs.end()) {
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
SDL_memset(stream, 0, len);
|
||||
return;
|
||||
}
|
||||
|
||||
ShimAudioCtx &ctx = it->second;
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
|
||||
// How many sample frames the device is asking for
|
||||
const int frame_size = (SDL_AUDIO_BITSIZE(ctx.obtained.format) / 8) * ctx.obtained.channels;
|
||||
const int needed_frames = len / frame_size;
|
||||
|
||||
int total = (SDL_AudioStreamAvailable(ctx.stream) / frame_size) + needed_frames;
|
||||
// SDL3 callback pushes more into the stream
|
||||
ctx.callback(ctx.userdata, ctx.stream, needed_frames, total);
|
||||
|
||||
int got = SDL_AudioStreamGet(ctx.stream, stream, len);
|
||||
if (got < len) {
|
||||
SDL_memset(stream + got, 0, len - got);
|
||||
}
|
||||
}
|
||||
|
||||
#define SDL_ResumeAudioDevice(device) SDL_PauseAudioDevice(device, 0)
|
||||
#define SDL_PutAudioStreamData SDL_AudioStreamPut
|
||||
|
||||
inline SDL_AudioDeviceID SDL_GetAudioStreamDevice(SDL_AudioStream* stream)
|
||||
{
|
||||
SDL_LockMutex(g_audioMutex);
|
||||
const auto it = g_audioCtxs.find(reinterpret_cast<uintptr_t>(stream));
|
||||
if (it == g_audioCtxs.end()) {
|
||||
return 0;
|
||||
}
|
||||
return it->first;
|
||||
}
|
||||
|
||||
inline SDL_AudioStream * SDL_OpenAudioDeviceStream(const char* devid, const SDL_AudioSpec* desired, SDL_AudioStreamCallback callback, void* userdata)
|
||||
{
|
||||
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_AudioStream* stream = SDL_NewAudioStream(
|
||||
desired->format, desired->channels, desired->freq,
|
||||
obtained->format, obtained->channels, obtained->freq
|
||||
);
|
||||
if (!stream) {
|
||||
SDL_CloseAudioDevice(device);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
{
|
||||
SDL_LockMutex(g_audioMutex);
|
||||
ShimAudioCtx ctx;
|
||||
ctx.stream = stream;
|
||||
ctx.callback = callback;
|
||||
ctx.userdata = userdata;
|
||||
ctx.obtained = *obtained;
|
||||
g_audioCtxs[device] = ctx;
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
}
|
||||
|
||||
SDL_LockAudioDevice(device);
|
||||
desired2.userdata = reinterpret_cast<void*>(static_cast<uintptr_t>(device));
|
||||
SDL_UnlockAudioDevice(device);
|
||||
|
||||
return stream;
|
||||
}
|
||||
67
3rdparty/sdl3-shim/SDL3/SDL_events.h
vendored
67
3rdparty/sdl3-shim/SDL3/SDL_events.h
vendored
@ -1,18 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL_events.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_eventsh
|
||||
|
||||
#define SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED
|
||||
|
||||
#define SDL_EVENT_MOUSE_BUTTON_DOWN SDL_MOUSEBUTTONDOWN
|
||||
#define SDL_EVENT_MOUSE_BUTTON_UP SDL_MOUSEBUTTONUP
|
||||
#define SDL_EVENT_MOUSE_MOTION SDL_MOUSEMOTION
|
||||
|
||||
#define SDL_EVENT_FINGER_MOTION SDL_FINGERMOTION
|
||||
#define SDL_EVENT_FINGER_DOWN SDL_FINGERDOWN
|
||||
#define SDL_EVENT_FINGER_UP SDL_FINGERUP
|
||||
// #define SDL_EVENT_MOUSE_BUTTON_DOWN SDL_MOUSEBUTTONDOWN
|
||||
// #define SDL_EVENT_MOUSE_BUTTON_UP SDL_MOUSEBUTTONUP
|
||||
// #define SDL_EVENT_MOUSE_MOTION SDL_MOUSEMOTION
|
||||
//
|
||||
// #define SDL_EVENT_FINGER_MOTION SDL_FINGERMOTION
|
||||
// #define SDL_EVENT_FINGER_DOWN SDL_FINGERDOWN
|
||||
// #define SDL_EVENT_FINGER_UP SDL_FINGERUP
|
||||
#define SDL_EVENT_FINGER_CANCELED 0
|
||||
|
||||
#define SDL_EVENT_QUIT SDL_QUIT
|
||||
|
||||
#define SDL_EVENT_WINDOW_CLOSE_REQUESTED SDL_WINDOWEVENT_CLOSE
|
||||
|
||||
#define SDL_EVENT_WINDOW_FOCUS_GAINED SDL_WINDOWEVENT_FOCUS_GAINED
|
||||
#define SDL_EVENT_WINDOW_FOCUS_LOST SDL_WINDOWEVENT_FOCUS_LOST
|
||||
|
||||
|
||||
#define SDL_EVENT_GAMEPAD_AXIS_MOTION SDL_CONTROLLERAXISMOTION
|
||||
#define SDL_EVENT_GAMEPAD_BUTTON_DOWN SDL_CONTROLLERBUTTONDOWN
|
||||
#define SDL_EVENT_GAMEPAD_BUTTON_UP SDL_CONTROLLERBUTTONUP
|
||||
#define SDL_EVENT_GAMEPAD_ADDED SDL_CONTROLLERDEVICEADDED
|
||||
// #define SDL_EVENT_GAMEPAD_REMAPPED SDL_CONTROLLERDEVICEREMAPPED
|
||||
#define SDL_EVENT_GAMEPAD_REMOVED SDL_CONTROLLERDEVICEREMOVED
|
||||
// #define SDL_EVENT_GAMEPAD_SENSOR_UPDATE SDL_CONTROLLERSENSORUPDATE
|
||||
// #define SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED SDL_CONTROLLERSTEAMHANDLEUPDATED
|
||||
// #define SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN SDL_CONTROLLERTOUCHPADDOWN
|
||||
// #define SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION SDL_CONTROLLERTOUCHPADMOTION
|
||||
// #define SDL_EVENT_GAMEPAD_TOUCHPAD_UP SDL_CONTROLLERTOUCHPADUP
|
||||
// #define SDL_EVENT_DROP_BEGIN SDL_DROPBEGIN
|
||||
// #define SDL_EVENT_DROP_COMPLETE SDL_DROPCOMPLETE
|
||||
// #define SDL_EVENT_DROP_FILE SDL_DROPFILE
|
||||
// #define SDL_EVENT_DROP_TEXT SDL_DROPTEXT
|
||||
#define SDL_EVENT_FINGER_DOWN SDL_FINGERDOWN
|
||||
#define SDL_EVENT_FINGER_MOTION SDL_FINGERMOTION
|
||||
#define SDL_EVENT_FINGER_UP SDL_FINGERUP
|
||||
// #define SDL_EVENT_FIRST SDL_FIRSTEVENT
|
||||
// #define SDL_EVENT_JOYSTICK_AXIS_MOTION SDL_JOYAXISMOTION
|
||||
// #define SDL_EVENT_JOYSTICK_BALL_MOTION SDL_JOYBALLMOTION
|
||||
// #define SDL_EVENT_JOYSTICK_BATTERY_UPDATED SDL_JOYBATTERYUPDATED
|
||||
// #define SDL_EVENT_JOYSTICK_BUTTON_DOWN SDL_JOYBUTTONDOWN
|
||||
// #define SDL_EVENT_JOYSTICK_BUTTON_UP SDL_JOYBUTTONUP
|
||||
// #define SDL_EVENT_JOYSTICK_ADDED SDL_JOYDEVICEADDED
|
||||
// #define SDL_EVENT_JOYSTICK_REMOVED SDL_JOYDEVICEREMOVED
|
||||
// #define SDL_EVENT_JOYSTICK_HAT_MOTION SDL_JOYHATMOTION
|
||||
#define SDL_EVENT_KEY_DOWN SDL_KEYDOWN
|
||||
// #define SDL_EVENT_KEYMAP_CHANGED SDL_KEYMAPCHANGED
|
||||
#define SDL_EVENT_KEY_UP SDL_KEYUP
|
||||
// #define SDL_EVENT_LAST SDL_LASTEVENT
|
||||
// #define SDL_EVENT_LOCALE_CHANGED SDL_LOCALECHANGED
|
||||
#define SDL_EVENT_MOUSE_BUTTON_DOWN SDL_MOUSEBUTTONDOWN
|
||||
#define SDL_EVENT_MOUSE_BUTTON_UP SDL_MOUSEBUTTONUP
|
||||
#define SDL_EVENT_MOUSE_MOTION SDL_MOUSEMOTION
|
||||
// #define SDL_EVENT_MOUSE_WHEEL SDL_MOUSEWHEEL
|
||||
// #define SDL_EVENT_POLL_SENTINEL SDL_POLLSENTINEL
|
||||
|
||||
|
||||
|
||||
#define fingerID fingerId
|
||||
#define touchID touchId
|
||||
#define gaxis caxis
|
||||
#define gbutton cbutton
|
||||
|
||||
50
3rdparty/sdl3-shim/SDL3/SDL_filesystem.h
vendored
Normal file
50
3rdparty/sdl3-shim/SDL3/SDL_filesystem.h
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_iostream.h"
|
||||
|
||||
// TODO: properly implement (
|
||||
|
||||
typedef Uint32 SDL_GlobFlags;
|
||||
|
||||
typedef enum SDL_PathType
|
||||
{
|
||||
SDL_PATHTYPE_NONE,
|
||||
SDL_PATHTYPE_FILE,
|
||||
SDL_PATHTYPE_DIRECTORY,
|
||||
SDL_PATHTYPE_OTHER
|
||||
} SDL_PathType;
|
||||
|
||||
typedef Sint64 SDL_Time;
|
||||
|
||||
typedef struct SDL_PathInfo
|
||||
{
|
||||
SDL_PathType type;
|
||||
Uint64 size;
|
||||
SDL_Time create_time;
|
||||
SDL_Time modify_time;
|
||||
SDL_Time access_time;
|
||||
} 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)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
|
||||
inline bool SDL_RemovePath(const char *path)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
inline bool SDL_RenamePath(const char *oldpath, const char *newpath)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
inline bool SDL_GetPathInfo(const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
104
3rdparty/sdl3-shim/SDL3/SDL_gamepad.h
vendored
104
3rdparty/sdl3-shim/SDL3/SDL_gamepad.h
vendored
@ -5,3 +5,107 @@
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_gamecontrollerh
|
||||
|
||||
#define SDL_Gamepad SDL_GameController
|
||||
|
||||
#define SDL_INIT_GAMEPAD SDL_INIT_GAMECONTROLLER
|
||||
|
||||
// #define SDL_CloseGamepad SDL_GameControllerClose
|
||||
|
||||
//
|
||||
// #define SDL_GamepadAxis SDL_GameControllerAxis
|
||||
// #define SDL_GamepadBindingType SDL_GameControllerBindType
|
||||
// #define SDL_GamepadButton SDL_GameControllerButton
|
||||
// #define SDL_GamepadType SDL_GameControllerType
|
||||
|
||||
// #define SDL_AddGamepadMapping SDL_GameControllerAddMapping
|
||||
// #define SDL_AddGamepadMappingsFromFile SDL_GameControllerAddMappingsFromFile
|
||||
// #define SDL_AddGamepadMappingsFromIO SDL_GameControllerAddMappingsFromRW
|
||||
#define SDL_CloseGamepad SDL_GameControllerClose
|
||||
// #define SDL_GetGamepadFromID SDL_GameControllerFromInstanceID
|
||||
// #define SDL_GetGamepadFromPlayerIndex SDL_GameControllerFromPlayerIndex
|
||||
// #define SDL_GetGamepadAppleSFSymbolsNameForAxis SDL_GameControllerGetAppleSFSymbolsNameForAxis
|
||||
// #define SDL_GetGamepadAppleSFSymbolsNameForButton SDL_GameControllerGetAppleSFSymbolsNameForButton
|
||||
// #define SDL_GamepadConnected SDL_GameControllerGetAttached
|
||||
#define SDL_GetGamepadAxis SDL_GameControllerGetAxis
|
||||
// #define SDL_GetGamepadAxisFromString SDL_GameControllerGetAxisFromString
|
||||
// #define SDL_GetGamepadButton SDL_GameControllerGetButton
|
||||
// #define SDL_GetGamepadButtonFromString SDL_GameControllerGetButtonFromString
|
||||
// #define SDL_GetGamepadFirmwareVersion SDL_GameControllerGetFirmwareVersion
|
||||
#define SDL_GetGamepadJoystick SDL_GameControllerGetJoystick
|
||||
// #define SDL_GetNumGamepadTouchpadFingers SDL_GameControllerGetNumTouchpadFingers
|
||||
// #define SDL_GetNumGamepadTouchpads SDL_GameControllerGetNumTouchpads
|
||||
// #define SDL_GetGamepadPlayerIndex SDL_GameControllerGetPlayerIndex
|
||||
// #define SDL_GetGamepadProduct SDL_GameControllerGetProduct
|
||||
// #define SDL_GetGamepadProductVersion SDL_GameControllerGetProductVersion
|
||||
// #define SDL_GetGamepadSensorData SDL_GameControllerGetSensorData, returns bool
|
||||
// #define SDL_GetGamepadSensorDataRate SDL_GameControllerGetSensorDataRate
|
||||
// #define SDL_GetGamepadSerial SDL_GameControllerGetSerial
|
||||
// #define SDL_GetGamepadSteamHandle SDL_GameControllerGetSteamHandle
|
||||
// #define SDL_GetGamepadStringForAxis SDL_GameControllerGetStringForAxis
|
||||
// #define SDL_GetGamepadStringForButton SDL_GameControllerGetStringForButton
|
||||
// #define SDL_GetGamepadTouchpadFinger SDL_GameControllerGetTouchpadFinger, returns bool
|
||||
// #define SDL_GetGamepadType SDL_GameControllerGetType
|
||||
// #define SDL_GetGamepadVendor SDL_GameControllerGetVendor
|
||||
// #define SDL_GamepadHasAxis SDL_GameControllerHasAxis
|
||||
// #define SDL_GamepadHasButton SDL_GameControllerHasButton
|
||||
// #define SDL_GamepadHasSensor SDL_GameControllerHasSensor
|
||||
// #define SDL_GamepadSensorEnabled SDL_GameControllerIsSensorEnabled
|
||||
// #define SDL_GetGamepadMapping SDL_GameControllerMapping
|
||||
// #define SDL_GetGamepadMappingForGUID SDL_GameControllerMappingForGUID
|
||||
// #define SDL_GetGamepadName SDL_GameControllerName
|
||||
#define SDL_OpenGamepad SDL_GameControllerOpen
|
||||
// #define SDL_GetGamepadPath SDL_GameControllerPath
|
||||
#define SDL_RumbleGamepad(...) (SDL_GameControllerRumble(__VA_ARGS__) == 0)
|
||||
// #define SDL_RumbleGamepadTriggers SDL_GameControllerRumbleTriggers, returns bool
|
||||
// #define SDL_SendGamepadEffect SDL_GameControllerSendEffect, returns bool
|
||||
// #define SDL_SetGamepadLED SDL_GameControllerSetLED, returns bool
|
||||
// #define SDL_SetGamepadPlayerIndex SDL_GameControllerSetPlayerIndex, returns bool
|
||||
// #define SDL_SetGamepadSensorEnabled SDL_GameControllerSetSensorEnabled, returns bool
|
||||
// #define SDL_UpdateGamepads SDL_GameControllerUpdate
|
||||
// #define SDL_IsGamepad SDL_IsGameController
|
||||
|
||||
// #define SDL_GAMEPAD_AXIS_INVALID SDL_CONTROLLER_AXIS_INVALID
|
||||
#define SDL_GAMEPAD_AXIS_LEFTX SDL_CONTROLLER_AXIS_LEFTX
|
||||
#define SDL_GAMEPAD_AXIS_LEFTY SDL_CONTROLLER_AXIS_LEFTY
|
||||
// #define SDL_GAMEPAD_AXIS_COUNT SDL_CONTROLLER_AXIS_MAX
|
||||
#define SDL_GAMEPAD_AXIS_RIGHTX SDL_CONTROLLER_AXIS_RIGHTX
|
||||
#define SDL_GAMEPAD_AXIS_RIGHTY SDL_CONTROLLER_AXIS_RIGHTY
|
||||
#define SDL_GAMEPAD_AXIS_LEFT_TRIGGER SDL_CONTROLLER_AXIS_TRIGGERLEFT
|
||||
#define SDL_GAMEPAD_AXIS_RIGHT_TRIGGER SDL_CONTROLLER_AXIS_TRIGGERRIGHT
|
||||
// #define SDL_GAMEPAD_BINDTYPE_AXIS SDL_CONTROLLER_BINDTYPE_AXIS
|
||||
// #define SDL_GAMEPAD_BINDTYPE_BUTTON SDL_CONTROLLER_BINDTYPE_BUTTON
|
||||
// #define SDL_GAMEPAD_BINDTYPE_HAT SDL_CONTROLLER_BINDTYPE_HAT
|
||||
#define SDL_GAMEPAD_BINDTYPE_NONE SDL_CONTROLLER_BINDTYPE_NONE
|
||||
#define SDL_GAMEPAD_BUTTON_SOUTH SDL_CONTROLLER_BUTTON_A
|
||||
#define SDL_GAMEPAD_BUTTON_EAST SDL_CONTROLLER_BUTTON_B
|
||||
// #define SDL_GAMEPAD_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK
|
||||
#define SDL_GAMEPAD_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN
|
||||
#define SDL_GAMEPAD_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT
|
||||
#define SDL_GAMEPAD_BUTTON_DPAD_RIGHT SDL_CONTROLLER_BUTTON_DPAD_RIGHT
|
||||
#define SDL_GAMEPAD_BUTTON_DPAD_UP SDL_CONTROLLER_BUTTON_DPAD_UP
|
||||
// #define SDL_GAMEPAD_BUTTON_GUIDE SDL_CONTROLLER_BUTTON_GUIDE
|
||||
// #define SDL_GAMEPAD_BUTTON_INVALID SDL_CONTROLLER_BUTTON_INVALID
|
||||
// #define SDL_GAMEPAD_BUTTON_LEFT_SHOULDER SDL_CONTROLLER_BUTTON_LEFTSHOULDER
|
||||
// #define SDL_GAMEPAD_BUTTON_LEFT_STICK SDL_CONTROLLER_BUTTON_LEFTSTICK
|
||||
// #define SDL_GAMEPAD_BUTTON_COUNT SDL_CONTROLLER_BUTTON_MAX
|
||||
// #define SDL_GAMEPAD_BUTTON_MISC1 SDL_CONTROLLER_BUTTON_MISC1
|
||||
// #define SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 SDL_CONTROLLER_BUTTON_PADDLE1
|
||||
// #define SDL_GAMEPAD_BUTTON_LEFT_PADDLE1 SDL_CONTROLLER_BUTTON_PADDLE2
|
||||
// #define SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2 SDL_CONTROLLER_BUTTON_PADDLE3
|
||||
// #define SDL_GAMEPAD_BUTTON_LEFT_PADDLE2 SDL_CONTROLLER_BUTTON_PADDLE4
|
||||
// #define SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
|
||||
// #define SDL_GAMEPAD_BUTTON_RIGHT_STICK SDL_CONTROLLER_BUTTON_RIGHTSTICK
|
||||
#define SDL_GAMEPAD_BUTTON_START SDL_CONTROLLER_BUTTON_START
|
||||
// #define SDL_GAMEPAD_BUTTON_TOUCHPAD SDL_CONTROLLER_BUTTON_TOUCHPAD
|
||||
// #define SDL_GAMEPAD_BUTTON_WEST SDL_CONTROLLER_BUTTON_X
|
||||
// #define SDL_GAMEPAD_BUTTON_NORTH SDL_CONTROLLER_BUTTON_Y
|
||||
// #define SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
|
||||
// #define SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
|
||||
// #define SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
|
||||
// #define SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
|
||||
// #define SDL_GAMEPAD_TYPE_PS3 SDL_CONTROLLER_TYPE_PS3
|
||||
// #define SDL_GAMEPAD_TYPE_PS4 SDL_CONTROLLER_TYPE_PS4
|
||||
// #define SDL_GAMEPAD_TYPE_PS5 SDL_CONTROLLER_TYPE_PS5
|
||||
// #define SDL_GAMEPAD_TYPE_STANDARD SDL_CONTROLLER_TYPE_UNKNOWN
|
||||
// #define SDL_GAMEPAD_TYPE_VIRTUAL SDL_CONTROLLER_TYPE_VIRTUAL
|
||||
// #define SDL_GAMEPAD_TYPE_XBOX360 SDL_CONTROLLER_TYPE_XBOX360
|
||||
// #define SDL_GAMEPAD_TYPE_XBOXONE SDL_CONTROLLER_TYPE_XBOXONE
|
||||
|
||||
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 <SDL2/SDL_rwops.h>
|
||||
#include <SDL_rwops.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_rwopsh
|
||||
|
||||
|
||||
60
3rdparty/sdl3-shim/SDL3/SDL_keycode.h
vendored
Normal file
60
3rdparty/sdl3-shim/SDL3/SDL_keycode.h
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL_keycode.h>
|
||||
|
||||
#define SDLK_MEDIA_FAST_FORWARD SDLK_AUDIOFASTFORWARD
|
||||
#define SDL_KMOD_ALT KMOD_ALT
|
||||
#define SDL_KMOD_CAPS KMOD_CAPS
|
||||
#define SDL_KMOD_CTRL KMOD_CTRL
|
||||
#define SDL_KMOD_GUI KMOD_GUI
|
||||
#define SDL_KMOD_LALT KMOD_LALT
|
||||
#define SDL_KMOD_LCTRL KMOD_LCTRL
|
||||
#define SDL_KMOD_LGUI KMOD_LGUI
|
||||
#define SDL_KMOD_LSHIFT KMOD_LSHIFT
|
||||
#define SDL_KMOD_MODE KMOD_MODE
|
||||
#define SDL_KMOD_NONE KMOD_NONE
|
||||
#define SDL_KMOD_NUM KMOD_NUM
|
||||
#define SDL_KMOD_RALT KMOD_RALT
|
||||
#define SDL_KMOD_RCTRL KMOD_RCTRL
|
||||
#define SDL_KMOD_RGUI KMOD_RGUI
|
||||
#define SDL_KMOD_RSHIFT KMOD_RSHIFT
|
||||
#define SDL_KMOD_SCROLL KMOD_SCROLL
|
||||
#define SDL_KMOD_SHIFT KMOD_SHIFT
|
||||
#define SDLK_MEDIA_FAST_FORWARD SDLK_AUDIOFASTFORWARD
|
||||
#define SDLK_MUTE SDLK_AUDIOMUTE
|
||||
#define SDLK_MEDIA_NEXT_TRACK SDLK_AUDIONEXT
|
||||
#define SDLK_MEDIA_PLAY SDLK_AUDIOPLAY
|
||||
#define SDLK_MEDIA_PREVIOUS_TRACK SDLK_AUDIOPREV
|
||||
#define SDLK_MEDIA_REWIND SDLK_AUDIOREWIND
|
||||
#define SDLK_MEDIA_STOP SDLK_AUDIOSTOP
|
||||
#define SDLK_GRAVE SDLK_BACKQUOTE
|
||||
#define SDLK_MEDIA_EJECT SDLK_EJECT
|
||||
#define SDLK_MEDIA_SELECT SDLK_MEDIASELECT
|
||||
#define SDLK_APOSTROPHE SDLK_QUOTE
|
||||
#define SDLK_DBLAPOSTROPHE SDLK_QUOTEDBL
|
||||
#define SDLK_A SDLK_a
|
||||
#define SDLK_B SDLK_b
|
||||
#define SDLK_C SDLK_c
|
||||
#define SDLK_D SDLK_d
|
||||
#define SDLK_E SDLK_e
|
||||
#define SDLK_F SDLK_f
|
||||
#define SDLK_G SDLK_g
|
||||
#define SDLK_H SDLK_h
|
||||
#define SDLK_I SDLK_i
|
||||
#define SDLK_J SDLK_j
|
||||
#define SDLK_K SDLK_k
|
||||
#define SDLK_L SDLK_l
|
||||
#define SDLK_M SDLK_m
|
||||
#define SDLK_N SDLK_n
|
||||
#define SDLK_O SDLK_o
|
||||
#define SDLK_P SDLK_p
|
||||
#define SDLK_Q SDLK_q
|
||||
#define SDLK_R SDLK_r
|
||||
#define SDLK_S SDLK_s
|
||||
#define SDLK_T SDLK_t
|
||||
#define SDLK_U SDLK_u
|
||||
#define SDLK_V SDLK_v
|
||||
#define SDLK_W SDLK_w
|
||||
#define SDLK_X SDLK_x
|
||||
#define SDLK_Y SDLK_y
|
||||
#define SDLK_Z SDLK_z
|
||||
3
3rdparty/sdl3-shim/SDL3/SDL_mutex.h
vendored
3
3rdparty/sdl3-shim/SDL3/SDL_mutex.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <SDL_mutex.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_mutexh
|
||||
|
||||
@ -9,3 +9,4 @@
|
||||
#define SDL_Semaphore SDL_sem
|
||||
|
||||
#define SDL_WaitSemaphore SDL_SemWait
|
||||
#define SDL_SignalSemaphore SDL_SemPost
|
||||
|
||||
2
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
2
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_pixels.h>
|
||||
#include <SDL_pixels.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_pixelsh
|
||||
#define bits_per_pixel BitsPerPixel
|
||||
|
||||
4
3rdparty/sdl3-shim/SDL3/SDL_surface.h
vendored
4
3rdparty/sdl3-shim/SDL3/SDL_surface.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_surface.h>
|
||||
#include <SDL_surface.h>
|
||||
#include "SDL_pixels.h"
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_surfaceh
|
||||
@ -32,3 +32,5 @@ inline SDL_Surface* SDL_ConvertSurface(SDL_Surface* surface, SDL_PixelFormat for
|
||||
#define SDL_BlitSurfaceScaled(surface, rect, destSurface, destRect, scaleMode) (SDL_BlitScaled(surface, rect, destSurface, destRect) == 0)
|
||||
#define SDL_SetSurfaceColorKey SDL_SetColorKey
|
||||
|
||||
#define SDL_LoadBMP_IO (SDL_Surface*)SDL_LoadBMP_RW
|
||||
#define SDL_LoadBMP(file) (SDL_Surface*)SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) //yoinked the existing SDL_LoadBMP macro so it could be cast
|
||||
|
||||
57
3rdparty/sdl3-shim/SDL3/SDL_timer.h
vendored
57
3rdparty/sdl3-shim/SDL3/SDL_timer.h
vendored
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_timer.h>
|
||||
#include <SDL_timer.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_timerh
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_timerh | SDL_GetTicksNS()
|
||||
@ -9,3 +9,58 @@
|
||||
|
||||
// time is in miliseconds not nanoseconds
|
||||
#define SDL_NS_TO_MS(MS) (MS)
|
||||
|
||||
|
||||
typedef Uint32 SDL3_TimerCallback (void *userdata, SDL_TimerID timerID, Uint32 interval);
|
||||
|
||||
struct SDL2TimerShimData {
|
||||
SDL3_TimerCallback *callback2;
|
||||
void *userdata2;
|
||||
SDL_TimerID id;
|
||||
};
|
||||
|
||||
static std::map<SDL_TimerID, void*> g_timers;
|
||||
static SDL_mutex *g_timerMutex = NULL;
|
||||
|
||||
inline Uint32 shim_timer_callback (Uint32 interval, void *param)
|
||||
{
|
||||
const auto shim = static_cast<SDL2TimerShimData*>(param);
|
||||
const Uint32 next = shim->callback2(shim->userdata2, shim->id, interval);
|
||||
|
||||
if (next == 0) {
|
||||
SDL_LockMutex(g_timerMutex);
|
||||
g_timers.erase(shim->id);
|
||||
SDL_free(shim);
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
inline SDL_TimerID SDL_AddTimer(Uint32 interval, SDL3_TimerCallback callback3, void* userdata)
|
||||
{
|
||||
const auto shim = static_cast<SDL2TimerShimData*>(SDL_malloc(sizeof(SDL2TimerShimData)));
|
||||
shim->callback2 = callback3;
|
||||
shim->userdata2 = userdata;
|
||||
|
||||
const SDL_TimerID id = ::SDL_AddTimer(interval, shim_timer_callback, shim);
|
||||
shim->id = id;
|
||||
|
||||
SDL_LockMutex(g_timerMutex);
|
||||
g_timers[id] = shim;
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
inline SDL_bool SDL_RemoveTimer(SDL_TimerID id)
|
||||
{
|
||||
SDL_LockMutex(g_timerMutex);
|
||||
if (const auto it = g_timers.find(id); it != g_timers.end()) {
|
||||
SDL_free(it->second);
|
||||
g_timers.erase(it);
|
||||
}
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
|
||||
return ::SDL_RemoveTimer(id);
|
||||
}
|
||||
|
||||
@ -879,20 +879,39 @@ MxResult IsleApp::SetupWindow()
|
||||
m_cursorBusyBitmap = &busy_cursor;
|
||||
m_cursorNoBitmap = &no_cursor;
|
||||
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, g_targetWidth);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, g_targetHeight);
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, m_fullScreen);
|
||||
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, WINDOW_TITLE);
|
||||
#endif
|
||||
#if defined(MINIWIN) && !defined(__3DS__) && !defined(WINDOWS_STORE)
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true);
|
||||
#endif
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
#endif
|
||||
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
window = SDL_CreateWindowWithProperties(props);
|
||||
SDL_SetPointerProperty(SDL_GetWindowProperties(window), ISLE_PROP_WINDOW_CREATE_VIDEO_PARAM, &m_videoParam);
|
||||
#else
|
||||
Uint32 flags = 0;
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
if (m_fullScreen) flags |= SDL_WINDOW_FULLSCREEN;
|
||||
window = SDL_CreateWindow(
|
||||
WINDOW_TITLE,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
g_targetWidth,
|
||||
g_targetHeight,
|
||||
flags
|
||||
);
|
||||
|
||||
SDL_SetWindowData(window, ISLE_PROP_WINDOW_CREATE_VIDEO_PARAM, &m_videoParam);
|
||||
#endif
|
||||
if (m_exclusiveFullScreen && m_fullScreen) {
|
||||
SDL_DisplayMode closestMode;
|
||||
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
|
||||
@ -914,9 +933,9 @@ MxResult IsleApp::SetupWindow()
|
||||
m_windowHandle =
|
||||
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
#endif
|
||||
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
SDL_DestroyProperties(props);
|
||||
|
||||
#endif
|
||||
if (!m_windowHandle) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
@ -782,14 +782,26 @@ void LegoInputManager::UpdateLastInputMethod(SDL_Event* p_event)
|
||||
switch (p_event->type) {
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
m_lastInputMethod = SDL_KeyboardID_v{p_event->key.which};
|
||||
#else
|
||||
m_lastInputMethod = SDL_KeyboardID_v{0};
|
||||
#endif
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
m_lastInputMethod = SDL_MouseID_v{p_event->button.which};
|
||||
#else
|
||||
m_lastInputMethod = SDL_MouseID_v{0};
|
||||
#endif
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
m_lastInputMethod = SDL_MouseID_v{p_event->motion.which};
|
||||
#else
|
||||
m_lastInputMethod = SDL_MouseID_v{0};
|
||||
#endif
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
|
||||
@ -71,11 +71,18 @@ BOOL MxDirect3D::Create(
|
||||
}
|
||||
|
||||
if (m_pDirect3d->QueryInterface(IID_IDirect3DMiniwin, (void**) &miniwind3d) == DD_OK) {
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
MxVideoParam* videoParam = (MxVideoParam*) SDL_GetPointerProperty(
|
||||
SDL_GetWindowProperties(reinterpret_cast<SDL_Window*>(hWnd)),
|
||||
ISLE_PROP_WINDOW_CREATE_VIDEO_PARAM,
|
||||
nullptr
|
||||
);
|
||||
#else
|
||||
MxVideoParam* videoParam = (MxVideoParam*) SDL_GetWindowData(
|
||||
reinterpret_cast<SDL_Window*>(hWnd),
|
||||
ISLE_PROP_WINDOW_CREATE_VIDEO_PARAM
|
||||
);
|
||||
#endif
|
||||
#ifndef MXDIRECTX_FOR_CONFIG
|
||||
assert(videoParam);
|
||||
#endif
|
||||
|
||||
@ -228,11 +228,18 @@ BOOL MxDeviceEnumerate::EnumDirectDrawCallback(LPGUID p_guid, LPSTR p_driverDesc
|
||||
|
||||
result = lpDD->QueryInterface(IID_IDirect3DMiniwin, (void**) &miniwind3d);
|
||||
if (result == DD_OK) {
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
MxVideoParam* videoParam = (MxVideoParam*) SDL_GetPointerProperty(
|
||||
SDL_GetWindowProperties(reinterpret_cast<SDL_Window*>(m_hWnd)),
|
||||
ISLE_PROP_WINDOW_CREATE_VIDEO_PARAM,
|
||||
nullptr
|
||||
);
|
||||
#else
|
||||
MxVideoParam* videoParam = (MxVideoParam*) SDL_GetWindowData(
|
||||
reinterpret_cast<SDL_Window*>(m_hWnd),
|
||||
ISLE_PROP_WINDOW_CREATE_VIDEO_PARAM
|
||||
);
|
||||
#endif
|
||||
#ifndef MXDIRECTX_FOR_CONFIG
|
||||
assert(videoParam);
|
||||
#endif
|
||||
|
||||
@ -34,6 +34,7 @@ MxResult MxThread::Start(MxS32 p_stackSize, MxS32 p_flag)
|
||||
}
|
||||
|
||||
{
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
const SDL_PropertiesID props = SDL_CreateProperties();
|
||||
SDL_SetPointerProperty(props, SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER, (void*) MxThread::ThreadProc);
|
||||
SDL_SetPointerProperty(props, SDL_PROP_THREAD_CREATE_USERDATA_POINTER, this);
|
||||
@ -44,6 +45,11 @@ MxResult MxThread::Start(MxS32 p_stackSize, MxS32 p_flag)
|
||||
}
|
||||
|
||||
SDL_DestroyProperties(props);
|
||||
#else
|
||||
if (!((m_thread = SDL_CreateThread(&MxThread::ThreadProc, "MxThread", this)))) {
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user