mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-15 03:51:14 +00:00
Merge 1abee1eee3 into 3f974f7317
This commit is contained in:
commit
a3e365338d
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@ -46,6 +46,7 @@ jobs:
|
||||
- { name: 'iOS', os: 'macos-15', generator: 'Xcode', dx5: false, config: false, brew: true, werror: true, clang-tidy: false, cmake-args: '-DCMAKE_SYSTEM_NAME=iOS', ios: true }
|
||||
- { name: 'Emscripten', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' }
|
||||
- { name: 'Nintendo 3DS', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, n3ds: true, werror: true, clang-tidy: false, container: 'devkitpro/devkitarm:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake' }
|
||||
- { name: 'Nintendo Wii U', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, wiiu: true, werror: false, clang-tidy: false, container: 'devkitpro/devkitppc:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/WiiU.cmake -DCMAKE_PREFIX_PATH=/opt/devkitpro/devkitPPC/powerpc-eabi/lib/libstdc++.a', sdl2: true }
|
||||
- { name: 'Xbox One', os: 'windows-latest', generator: 'Visual Studio 17 2022', dx5: false, config: false, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0', xbox-one: true}
|
||||
- { name: 'Android', os: 'ubuntu-latest', generator: 'Ninja', dx5: false, config: false, android: true, werror: true, clang-tidy: false,}
|
||||
steps:
|
||||
@ -66,6 +67,7 @@ jobs:
|
||||
${{ matrix.msys-env }}-ninja
|
||||
${{ matrix.msys-env }}-clang-tools-extra
|
||||
${{ (matrix.config && format('{0}-qt6-base', matrix.msys-env)) || '' }}
|
||||
|
||||
- name: Install Qt
|
||||
if: ${{ !!matrix.msvc && matrix.config }}
|
||||
uses: jurplel/install-qt-action@v4
|
||||
@ -103,12 +105,6 @@ jobs:
|
||||
uses: maxim-lobanov/setup-xcode@v1.6.0
|
||||
with:
|
||||
xcode-version: latest-stable
|
||||
|
||||
- name: Install iOS components
|
||||
if: ${{ matrix.ios }}
|
||||
run: |
|
||||
xcrun simctl list > /dev/null
|
||||
xcodebuild -downloadPlatform iOS
|
||||
|
||||
- name: Setup Emscripten
|
||||
uses: mymindstorm/setup-emsdk@master
|
||||
@ -166,18 +162,20 @@ jobs:
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DISLE_USE_DX5=${{ !!matrix.dx5 }} \
|
||||
-DISLE_BUILD_CONFIG=${{ !!matrix.config }} \
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=${{ matrix.wiiu && 'OFF' || 'ON' }} \
|
||||
-DISLE_EXTENSIONS=${{ matrix.wiiu && 'OFF' || 'ON' }} \
|
||||
-DISLE_BUILD_ASSETS=${{ !!matrix.build-assets }} \
|
||||
-DENABLE_CLANG_TIDY=${{ !!matrix.clang-tidy }} \
|
||||
-DISLE_WERROR=${{ !!matrix.werror }} \
|
||||
-DISLE_DEBUG=${{ matrix.debug || 'OFF' }} \
|
||||
-Werror=dev
|
||||
${{ matrix.sdl2 && '-DUSE_SDL2=ON' || '-Werror=dev' }}
|
||||
|
||||
- name: Build (CMake)
|
||||
if: ${{ !matrix.android }}
|
||||
run: cmake --build build --verbose --config Release
|
||||
|
||||
- name: Package (CPack)
|
||||
if: ${{ !matrix.n3ds && !matrix.android }}
|
||||
if: ${{ !matrix.n3ds && !matrix.android && !matrix.wiiu }}
|
||||
run: |
|
||||
cd build
|
||||
success=0
|
||||
@ -226,6 +224,15 @@ jobs:
|
||||
mv *.3dsx dist/
|
||||
mv *.cia dist/
|
||||
|
||||
- name: Package (Wii U)
|
||||
if: ${{ matrix.wiiu }}
|
||||
run: |
|
||||
mkdir -p build/dist
|
||||
mv build/*.rpx packaging/wiiu/Legacy/
|
||||
mv packaging/wiiu/Legacy/ build/dist/
|
||||
cd build/dist
|
||||
mv Legacy isle-U
|
||||
|
||||
- name: Package (Android)
|
||||
if: ${{ matrix.android }}
|
||||
run: |
|
||||
@ -242,6 +249,7 @@ jobs:
|
||||
name: '${{ matrix.name }}'
|
||||
path: |
|
||||
build/dist/isle-*
|
||||
build/dist/isle-U-*
|
||||
build/dist/*.AppImage
|
||||
build/dist/*.3dsx
|
||||
build/dist/*.cia
|
||||
|
||||
59
3rdparty/CMakeLists.txt
vendored
59
3rdparty/CMakeLists.txt
vendored
@ -48,31 +48,42 @@ add_library(libsmacker STATIC
|
||||
)
|
||||
target_include_directories(libsmacker PUBLIC ${libsmacker_SOURCE_DIR})
|
||||
|
||||
if(DOWNLOAD_DEPENDENCIES)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
imgui
|
||||
GIT_REPOSITORY "https://github.com/ocornut/imgui"
|
||||
GIT_TAG f5befd2d29e66809cd1110a152e375a7f1981f06
|
||||
)
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
else()
|
||||
set(imgui_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
|
||||
endif()
|
||||
if(ISLE_DEBUG)
|
||||
if(DOWNLOAD_DEPENDENCIES)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
imgui
|
||||
GIT_REPOSITORY "https://github.com/ocornut/imgui"
|
||||
GIT_TAG f5befd2d29e66809cd1110a152e375a7f1981f06
|
||||
)
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
else()
|
||||
set(imgui_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
|
||||
endif()
|
||||
|
||||
add_library(imgui STATIC
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_demo.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
||||
)
|
||||
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
|
||||
target_link_libraries(imgui PUBLIC SDL3::Headers)
|
||||
target_link_libraries(imgui PRIVATE SDL3::SDL3)
|
||||
set_property(TARGET imgui PROPERTY CXX_CLANG_TIDY "")
|
||||
add_library(imgui STATIC
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_tables.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_widgets.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_demo.cpp
|
||||
)
|
||||
if(USE_SDL2)
|
||||
target_sources(imgui PRIVATE
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer2.cpp
|
||||
)
|
||||
else()
|
||||
target_sources(imgui PRIVATE
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
|
||||
target_link_libraries(imgui PRIVATE SDL3::SDL3)
|
||||
set_property(TARGET imgui PROPERTY CXX_CLANG_TIDY "")
|
||||
endif()
|
||||
|
||||
if(DOWNLOAD_DEPENDENCIES)
|
||||
include(FetchContent)
|
||||
|
||||
55
3rdparty/atomic-dummy/atomic.c
vendored
Normal file
55
3rdparty/atomic-dummy/atomic.c
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
// this is the only way to stop miniaudio atomics error when building isle.rpx and lego1.rpx
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint64_t __atomic_load_8(const uint64_t* p, int memorder) {
|
||||
(void)memorder;
|
||||
return *p;
|
||||
}
|
||||
|
||||
void __atomic_store_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
*p = v;
|
||||
}
|
||||
|
||||
uint64_t __atomic_exchange_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
uint64_t old = *p;
|
||||
*p = v;
|
||||
return old;
|
||||
}
|
||||
|
||||
uint64_t __atomic_fetch_add_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
uint64_t old = *p;
|
||||
*p += v;
|
||||
return old;
|
||||
}
|
||||
|
||||
uint64_t __atomic_fetch_sub_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
uint64_t old = *p;
|
||||
*p -= v;
|
||||
return old;
|
||||
}
|
||||
|
||||
uint64_t __atomic_fetch_and_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
uint64_t old = *p;
|
||||
*p &= v;
|
||||
return old;
|
||||
}
|
||||
|
||||
uint64_t __atomic_fetch_or_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
uint64_t old = *p;
|
||||
*p |= v;
|
||||
return old;
|
||||
}
|
||||
|
||||
uint64_t __atomic_fetch_xor_8(uint64_t* p, uint64_t v, int memorder) {
|
||||
(void)memorder;
|
||||
uint64_t old = *p;
|
||||
*p ^= v;
|
||||
return old;
|
||||
}
|
||||
18
3rdparty/sdl3-shim/CMakeLists.txt
vendored
Normal file
18
3rdparty/sdl3-shim/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
file(GLOB SDL2_HEADERS "${SDL2_INCLUDE_DIR}/*.h")
|
||||
foreach(header IN LISTS SDL2_HEADERS)
|
||||
get_filename_component(fname ${header} NAME)
|
||||
configure_file(${header} ${CMAKE_CURRENT_BINARY_DIR}/SDL3/${fname} COPYONLY)
|
||||
endforeach()
|
||||
|
||||
add_library(SDL3_shim STATIC
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(SDL3_shim PUBLIC SDL2::SDL2)
|
||||
target_include_directories(SDL3_shim PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
add_library(SDL3::SDL3 ALIAS SDL3_shim)
|
||||
add_library(SDL3::Headers ALIAS SDL3_shim)
|
||||
209
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
Normal file
209
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
#pragma once
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_stdinch
|
||||
#define SDL_bool bool
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_keyboard.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <SDL2/SDL_mouse.h>
|
||||
#include <SDL2/SDL_version.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_main.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_timer.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
|
||||
|
||||
#define SDL_LogTrace SDL_LogVerbose
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_videoh
|
||||
|
||||
typedef int SDL_DisplayID;
|
||||
inline SDL_DisplayID SDL_GetPrimaryDisplay()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Modified from 83bb0f9105922fd49282f0b931f7873a71877ac8 SDL_video.c#L1331
|
||||
inline SDL_DisplayMode** SDL_GetFullscreenDisplayModes(int displayID, int* count)
|
||||
{
|
||||
int i;
|
||||
if (count) *count = 0;
|
||||
|
||||
const int num_modes = SDL_GetNumDisplayModes(displayID);
|
||||
SDL_DisplayMode** result = static_cast<SDL_DisplayMode**>(SDL_malloc(sizeof(SDL_DisplayMode*) * (num_modes + 1)));
|
||||
SDL_DisplayMode* modes = static_cast<SDL_DisplayMode*>(SDL_malloc(sizeof(SDL_DisplayMode) * num_modes));
|
||||
if (!result || !modes) {
|
||||
SDL_free(result);
|
||||
SDL_free(modes);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < num_modes; i++) {
|
||||
if (SDL_GetDisplayMode(displayID, i, &modes[i]) == 0) {
|
||||
result[i] = &modes[i];
|
||||
}
|
||||
}
|
||||
result[i] = NULL;
|
||||
|
||||
if (count) {
|
||||
*count = num_modes;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline SDL_DisplayMode g_displayMode;
|
||||
inline SDL_mutex* g_displayMutex = SDL_CreateMutex();
|
||||
|
||||
// This does not handle the differences between the SDL_DisplayMode struct
|
||||
// https://wiki.libsdl.org/SDL3/SDL_DisplayMode
|
||||
// https://wiki.libsdl.org/SDL2/SDL_DisplayMode
|
||||
inline SDL_DisplayMode* SDL_GetCurrentDisplayMode(int displayID)
|
||||
{
|
||||
SDL_LockMutex(g_displayMutex);
|
||||
if (SDL_GetCurrentDisplayMode(displayID, &g_displayMode) == 0) {
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
return &g_displayMode;
|
||||
}
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define SDL_GetWindowSize(...) (SDL_GetWindowSize(__VA_ARGS__), true )
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_videoh
|
||||
|
||||
#define SDL_GL_DestroyContext SDL_GL_DeleteContext
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_renderh
|
||||
|
||||
// hardcode -1 as all uses are NULL or -1 (hacks out failure)
|
||||
#define SDL_CreateRenderer(window, name) SDL_CreateRenderer(window, -1, 0)
|
||||
|
||||
#define SDL_RenderTexture(...) (SDL_RenderCopyF(__VA_ARGS__) == 0)
|
||||
|
||||
#define SDL_CreateWindowAndRenderer(title, width, height, flags, window, renderer) (SDL_CreateWindowAndRenderer(width, height, flags, window, renderer) == 0)
|
||||
|
||||
#define SDL_SetRenderScale(...) (SDL_RenderSetScale(__VA_ARGS__) == 0)
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_keyboardh
|
||||
|
||||
typedef int SDL_KeyboardID;
|
||||
|
||||
#define SDL_GetKeyFromScancode(scancode, modstate, event) SDL_GetKeyFromScancode(scancode)
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_haptich
|
||||
// SDL_MouseID/SDL_KeyboardID are new
|
||||
|
||||
#define SDL_GetKeyboardState (const bool*)SDL_GetKeyboardState
|
||||
typedef int SDL_HapticID;
|
||||
|
||||
|
||||
#define SDL_CloseHaptic SDL_HapticClose
|
||||
#define SDL_OpenHaptic SDL_HapticOpen
|
||||
#define SDL_OpenHapticFromJoystick SDL_HapticOpenFromJoystick
|
||||
#define SDL_OpenHapticFromMouse SDL_HapticOpenFromMouse
|
||||
#define SDL_InitHapticRumble(...) (SDL_HapticRumbleInit(__VA_ARGS__) == 0)
|
||||
#define SDL_PlayHapticRumble(...) (SDL_HapticRumblePlay(__VA_ARGS__) == 0)
|
||||
|
||||
#define SDL_GetHapticID SDL_HapticIndex
|
||||
|
||||
// Modified from cc9937201e421ec55b12ad3f07ff2268f15096e8 SDL_haptic.c#L150
|
||||
inline SDL_HapticID* SDL_GetHaptics(int *count)
|
||||
{
|
||||
const int num_haptics = SDL_NumHaptics();
|
||||
if (count) *count = 0;
|
||||
|
||||
SDL_HapticID* haptics = static_cast<SDL_HapticID*>(SDL_malloc((num_haptics + 1) * sizeof(*haptics)));
|
||||
if (haptics) {
|
||||
if (count) {
|
||||
*count = num_haptics;
|
||||
}
|
||||
int haptic_index = 0;
|
||||
for (int device_index = 0; device_index < num_haptics; ++device_index) {
|
||||
SDL_Haptic* haptic = SDL_HapticOpen(device_index);
|
||||
if (haptic) {
|
||||
haptics[haptic_index] = SDL_GetHapticID(haptic);
|
||||
SDL_HapticClose(haptic);
|
||||
++haptic_index;
|
||||
}
|
||||
}
|
||||
haptics[haptic_index] = 0;
|
||||
} else { if (count) *count = 0; }
|
||||
|
||||
return haptics;
|
||||
}
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_videoh
|
||||
|
||||
#define SDL_CreateWindow(title, w, h, flags) SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags)
|
||||
#define SDL_SetWindowFullscreen(...) (SDL_SetWindowFullscreen(__VA_ARGS__) == 0)
|
||||
|
||||
#define SDL_GL_MakeCurrent(...) (SDL_GL_MakeCurrent(__VA_ARGS__) == 0)
|
||||
|
||||
#define SDL_GetDisplayForWindow SDL_GetWindowDisplayIndex
|
||||
#define SDL_SetWindowFullscreenMode(...) (SDL_SetWindowDisplayMode(__VA_ARGS__) == 0)
|
||||
// #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
|
||||
|
||||
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
|
||||
#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
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_inith
|
||||
|
||||
#define SDL_Init(...) (SDL_Init(__VA_ARGS__) == 0)
|
||||
112
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
Normal file
112
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_audioh
|
||||
|
||||
#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_AudioDeviceID device;
|
||||
SDL_AudioStream* stream;
|
||||
SDL_AudioStreamCallback* callback;
|
||||
void *userdata;
|
||||
SDL_AudioSpec obtained;
|
||||
};
|
||||
|
||||
static std::map<SDL_AudioStream*, ShimAudioCtx*> g_audioCtxs;
|
||||
static SDL_mutex *g_audioMutex = SDL_CreateMutex();
|
||||
|
||||
static void shim_audio_callback(void *userdata, Uint8 *data_stream, int len) {
|
||||
const auto ctx = static_cast<ShimAudioCtx*>(userdata);
|
||||
SDL_AudioStream* audio_stream = ctx->stream;
|
||||
|
||||
int available = SDL_AudioStreamAvailable(audio_stream);
|
||||
|
||||
int additional_amount = len - available;
|
||||
if (additional_amount < 0)
|
||||
additional_amount = 0;
|
||||
|
||||
ctx->callback(ctx->userdata, audio_stream, additional_amount, len);
|
||||
|
||||
int retrieved = SDL_AudioStreamGet(audio_stream, data_stream, len);
|
||||
if (retrieved < len) {
|
||||
memset(data_stream + retrieved, ctx->obtained.silence, len - retrieved);
|
||||
}
|
||||
}
|
||||
|
||||
#define SDL_ResumeAudioDevice(device) SDL_PauseAudioDevice(device, 0)
|
||||
#define SDL_PutAudioStreamData(...) (SDL_AudioStreamPut(__VA_ARGS__) == 0)
|
||||
|
||||
inline SDL_AudioDeviceID SDL_GetAudioStreamDevice(SDL_AudioStream* stream)
|
||||
{
|
||||
SDL_LockMutex(g_audioMutex);
|
||||
const auto it = g_audioCtxs.find(stream);
|
||||
if (it == g_audioCtxs.end()) {
|
||||
return 0;
|
||||
}
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
return it->second->device;
|
||||
}
|
||||
|
||||
inline SDL_AudioStream * SDL_OpenAudioDeviceStream(const char* devid, const SDL_AudioSpec* desired, SDL_AudioStreamCallback callback, void* userdata)
|
||||
{
|
||||
SDL_AudioSpec obtained{};
|
||||
SDL_AudioSpec desired2 = *desired;
|
||||
|
||||
auto ctx = new ShimAudioCtx();
|
||||
ctx->callback = callback;
|
||||
ctx->userdata = userdata;
|
||||
ctx->stream = nullptr;
|
||||
|
||||
desired2.callback = shim_audio_callback;
|
||||
desired2.userdata = ctx;
|
||||
const SDL_AudioDeviceID device = SDL_OpenAudioDevice(devid, 0, &desired2, &obtained, 0);
|
||||
if (device <= 0) {
|
||||
delete ctx;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AudioStream* stream = SDL_NewAudioStream(
|
||||
desired->format, desired->channels, desired->freq,
|
||||
obtained.format, obtained.channels, obtained.freq
|
||||
);
|
||||
if (!stream) {
|
||||
SDL_CloseAudioDevice(device);
|
||||
delete ctx;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->device = device;
|
||||
ctx->stream = stream;
|
||||
ctx->obtained = obtained;
|
||||
|
||||
SDL_LockMutex(g_audioMutex);
|
||||
g_audioCtxs[stream] = ctx;
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline SDL_bool SDL_DestroyAudioStream(SDL_AudioStream* stream)
|
||||
{
|
||||
SDL_LockMutex(g_audioMutex);
|
||||
if (const auto it = g_audioCtxs.find(stream); it != g_audioCtxs.end()) {
|
||||
SDL_CloseAudioDevice(it->second->device);
|
||||
delete it->second;
|
||||
g_audioCtxs.erase(it);
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
}
|
||||
SDL_UnlockMutex(g_audioMutex);
|
||||
|
||||
SDL_FreeAudioStream(stream);
|
||||
return true;
|
||||
}
|
||||
126
3rdparty/sdl3-shim/SDL3/SDL_events.h
vendored
Normal file
126
3rdparty/sdl3-shim/SDL3/SDL_events.h
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_eventsh
|
||||
|
||||
#define SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED (SDL_WINDOWEVENT + 2 + SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
#define SDL_EVENT_WINDOW_CLOSE_REQUESTED (SDL_WINDOWEVENT + 2 + SDL_WINDOWEVENT_CLOSE)
|
||||
#define SDL_EVENT_WINDOW_FOCUS_GAINED (SDL_WINDOWEVENT + 2 + SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||
#define SDL_EVENT_WINDOW_FOCUS_LOST (SDL_WINDOWEVENT + 2 + SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
|
||||
// #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_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
|
||||
|
||||
inline SDL_Window* SDL_GetWindowFromEvent(const SDL_Event* event)
|
||||
{
|
||||
Uint32 windowID = 0;
|
||||
|
||||
if (event->type >= SDL_USEREVENT && event->type <= SDL_LASTEVENT) {
|
||||
windowID = event->user.windowID;
|
||||
}
|
||||
else {
|
||||
switch (event->type) {
|
||||
case SDL_WINDOWEVENT:
|
||||
windowID = event->window.windowID;
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
case SDL_KEYMAPCHANGED:
|
||||
windowID = event->key.windowID;
|
||||
break;
|
||||
|
||||
case SDL_TEXTEDITING:
|
||||
windowID = event->edit.windowID;
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
windowID = event->text.windowID;
|
||||
break;
|
||||
case SDL_TEXTEDITING_EXT:
|
||||
windowID = event->editExt.windowID;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
windowID = event->motion.windowID;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
windowID = event->button.windowID;
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
windowID = event->wheel.windowID;
|
||||
break;
|
||||
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP:
|
||||
case SDL_FINGERMOTION:
|
||||
windowID = event->tfinger.windowID;
|
||||
break;
|
||||
|
||||
case SDL_DROPFILE:
|
||||
case SDL_DROPTEXT:
|
||||
case SDL_DROPBEGIN:
|
||||
case SDL_DROPCOMPLETE:
|
||||
windowID = event->drop.windowID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SDL_GetWindowFromID(windowID);
|
||||
}
|
||||
101
3rdparty/sdl3-shim/SDL3/SDL_filesystem.h
vendored
Normal file
101
3rdparty/sdl3-shim/SDL3/SDL_filesystem.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_iostream.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
|
||||
typedef Uint32 SDL_GlobFlags;
|
||||
|
||||
typedef enum SDL_PathType
|
||||
{
|
||||
SDL_PATHTYPE_NONE,
|
||||
SDL_PATHTYPE_FILE,
|
||||
SDL_PATHTYPE_DIRECTORY,
|
||||
SDL_PATHTYPE_OTHER
|
||||
} SDL_PathType;
|
||||
|
||||
typedef struct SDL_PathInfo
|
||||
{
|
||||
SDL_PathType type;
|
||||
Uint64 size;
|
||||
} 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)
|
||||
{
|
||||
if (!path || !count) return NULL;
|
||||
*count = 0;
|
||||
|
||||
std::vector<std::string> entries;
|
||||
try {
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(path)) {
|
||||
entries.push_back(std::filesystem::relative(entry.path(), path).string());
|
||||
}
|
||||
} catch (...) {
|
||||
return NULL;
|
||||
}
|
||||
if (entries.empty()) return NULL;
|
||||
|
||||
char** result = static_cast<char**>(SDL_malloc(sizeof(char*) * entries.size()));
|
||||
if (!result) return NULL;
|
||||
|
||||
for (size_t i = 0; i < entries.size(); ++i) {
|
||||
result[i] = SDL_strdup(entries[i].c_str());
|
||||
if (!result[i]) {
|
||||
for (size_t j = 0; j < i; ++j) {
|
||||
SDL_free(result[j]);
|
||||
}
|
||||
SDL_free(result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*count = static_cast<int>(entries.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool SDL_RemovePath(const char *path)
|
||||
{
|
||||
if (!path) return SDL_InvalidParamError("path");
|
||||
if (std::filesystem::remove(path)) return true;
|
||||
return false;
|
||||
}
|
||||
inline bool SDL_RenamePath(const char *oldpath, const char *newpath)
|
||||
{
|
||||
if (!oldpath) return SDL_InvalidParamError("oldpath");
|
||||
if (!newpath) return SDL_InvalidParamError("newpath");
|
||||
|
||||
std::filesystem::rename(oldpath, newpath);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool SDL_GetPathInfo(const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
if (!path) return SDL_InvalidParamError("path");
|
||||
|
||||
SDL_PathInfo dummy;
|
||||
if (!info) info = &dummy;
|
||||
|
||||
SDL_zerop(info);
|
||||
switch (const auto status = std::filesystem::status(path);status.type()) {
|
||||
case std::filesystem::file_type::regular:
|
||||
info->type = SDL_PATHTYPE_FILE;
|
||||
info->size = std::filesystem::file_size(path);
|
||||
break;
|
||||
case std::filesystem::file_type::directory:
|
||||
info->type = SDL_PATHTYPE_DIRECTORY;
|
||||
info->size = 0;
|
||||
break;
|
||||
case std::filesystem::file_type::not_found:
|
||||
info->type = SDL_PATHTYPE_NONE;
|
||||
info->size = 0;
|
||||
return false;
|
||||
default:
|
||||
info->type = SDL_PATHTYPE_OTHER;
|
||||
info->size = 0;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
111
3rdparty/sdl3-shim/SDL3/SDL_gamepad.h
vendored
Normal file
111
3rdparty/sdl3-shim/SDL3/SDL_gamepad.h
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_gamecontroller.h>
|
||||
|
||||
// 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
|
||||
49
3rdparty/sdl3-shim/SDL3/SDL_iostream.h
vendored
Normal file
49
3rdparty/sdl3-shim/SDL3/SDL_iostream.h
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_rwops.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_rwopsh
|
||||
|
||||
#define SDL_IOStream SDL_RWops
|
||||
|
||||
typedef int SDL_IOWhence;
|
||||
|
||||
#define SDL_IO_SEEK_SET RW_SEEK_SET
|
||||
#define SDL_IO_SEEK_CUR RW_SEEK_CUR
|
||||
#define SDL_IO_SEEK_END RW_SEEK_END
|
||||
|
||||
// #define SDL_IOFromConstMem SDL_RWFromConstMem
|
||||
#define SDL_IOFromFile SDL_RWFromFile
|
||||
#define SDL_IOFromMem SDL_RWFromMem
|
||||
#define SDL_CloseIO SDL_RWclose
|
||||
#define SDL_ReadIO(ctx, ptr, size) SDL_RWread(ctx, ptr, 1, size)
|
||||
#define SDL_SeekIO SDL_RWseek
|
||||
#define SDL_GetIOSize SDL_RWsize
|
||||
#define SDL_TellIO SDL_RWtell
|
||||
#define SDL_WriteIO(ctx, ptr, size) SDL_RWwrite(ctx, ptr, 1, size)
|
||||
// #define SDL_ReadU16BE SDL_ReadBE16
|
||||
// #define SDL_ReadU32BE SDL_ReadBE32
|
||||
// #define SDL_ReadU64BE SDL_ReadBE64
|
||||
// #define SDL_ReadU16LE SDL_ReadLE16
|
||||
// #define SDL_ReadU32LE SDL_ReadLE32
|
||||
// #define SDL_ReadU64LE SDL_ReadLE64
|
||||
// #define SDL_WriteU16BE SDL_WriteBE16
|
||||
// #define SDL_WriteU32BE SDL_WriteBE32
|
||||
// #define SDL_WriteU64BE SDL_WriteBE64
|
||||
// #define SDL_WriteU16LE SDL_WriteLE16
|
||||
// #define SDL_WriteU32LE SDL_WriteLE32
|
||||
// #define SDL_WriteU64LE SDL_WriteLE64
|
||||
|
||||
// FIXME: If Write/Read fail SDL_GetIOStatus is not aware.
|
||||
typedef enum SDL_IOStatus
|
||||
{
|
||||
SDL_IO_STATUS_READY,
|
||||
SDL_IO_STATUS_ERROR,
|
||||
} SDL_IOStatus;
|
||||
inline SDL_IOStatus SDL_GetIOStatus(SDL_RWops *context)
|
||||
{
|
||||
if (!context) {
|
||||
return SDL_IO_STATUS_ERROR;
|
||||
}
|
||||
return SDL_IO_STATUS_READY;
|
||||
}
|
||||
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 <SDL2/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
|
||||
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);
|
||||
12
3rdparty/sdl3-shim/SDL3/SDL_mutex.h
vendored
Normal file
12
3rdparty/sdl3-shim/SDL3/SDL_mutex.h
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_mutexh
|
||||
|
||||
#define SDL_Mutex SDL_mutex
|
||||
|
||||
#define SDL_Semaphore SDL_sem
|
||||
|
||||
#define SDL_WaitSemaphore SDL_SemWait
|
||||
#define SDL_SignalSemaphore SDL_SemPost
|
||||
47
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
Normal file
47
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_pixels.h>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_pixelsh
|
||||
#define bits_per_pixel BitsPerPixel
|
||||
|
||||
typedef SDL_PixelFormat SDL2_PixelFormat;
|
||||
#define SDL_PixelFormatDetails SDL2_PixelFormat
|
||||
#define SDL_PixelFormat SDL_PixelFormatEnum
|
||||
|
||||
#define SDL_GetRGBA(pixel, format, palette, r,g,b,a) SDL_GetRGBA(pixel, format, r,g,b,a)
|
||||
#define SDL_MapRGBA(format, palette, r,g,b,a) SDL_MapRGBA(format, r,g,b,a)
|
||||
#define SDL_GetRGB(pixel, format, palette, r,g,b) SDL_GetRGB(pixel, format, r,g,b)
|
||||
#define SDL_MapRGB(format, palette, r,g,b) SDL_MapRGB(format, r,g,b)
|
||||
|
||||
template<typename T>
|
||||
SDL_PixelFormatDetails* SDL_GetPixelFormatDetails(T format) {
|
||||
if constexpr (std::is_same_v<T, SDL_PixelFormat>) {
|
||||
return SDL_AllocFormat(format);
|
||||
} else {
|
||||
return SDL_AllocFormat(format->format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool operator!=(SDL_PixelFormatDetails* lhs, SDL_PixelFormatEnum rhs)
|
||||
{
|
||||
return lhs->format != rhs;
|
||||
}
|
||||
|
||||
#define SDL_CreatePalette SDL_AllocPalette
|
||||
#define SDL_DestroyPalette SDL_FreePalette
|
||||
|
||||
// #define SDL_GetPixelFormatForMasks (SDL_PixelFormat)SDL_MasksToPixelFormatEnum
|
||||
inline SDL_PixelFormatEnum SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
// SDL2 checks if Rmask == 0; SDL3 just returns INDEX8 if Rmask doesn't match
|
||||
// https://github.com/libsdl-org/SDL/blob/66d87bf0e1e29377b398d3c567e1ab3590760d8c/src/video/SDL_pixels.c#L310C5-L321C13
|
||||
// https://github.com/libsdl-org/SDL/blob/3669920fddcc418c5f9aca97e77a3f380308d9c0/src/video/SDL_pixels.c#L411-L418C16
|
||||
if (bpp == 8 && Rmask != 0xE0) {
|
||||
return SDL_PIXELFORMAT_INDEX8;
|
||||
}
|
||||
return static_cast<SDL_PixelFormatEnum>(SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask));
|
||||
}
|
||||
|
||||
#define SDL_GetSurfacePalette(surface) (nullptr)
|
||||
38
3rdparty/sdl3-shim/SDL3/SDL_surface.h
vendored
Normal file
38
3rdparty/sdl3-shim/SDL3/SDL_surface.h
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL_surface.h>
|
||||
#include "SDL_pixels.h"
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_surfaceh
|
||||
|
||||
#define SDL_FillSurfaceRect(...) (SDL_FillRect(__VA_ARGS__) == 0)
|
||||
|
||||
#define SDL_DestroySurface SDL_FreeSurface
|
||||
|
||||
#define SDL_LockSurface(...) (SDL_LockSurface(__VA_ARGS__) == 0)
|
||||
|
||||
template<typename T>
|
||||
SDL_Surface* SDL_CreateSurface( int width, int height, T format) {
|
||||
if constexpr (std::is_same_v<T, SDL_PixelFormat>) {
|
||||
return SDL_CreateRGBSurfaceWithFormat(0 , width, height, SDL_BITSPERPIXEL(format) ,format);
|
||||
} else {
|
||||
return SDL_CreateRGBSurfaceWithFormat(0 , width, height, SDL_BITSPERPIXEL(format->format) ,format->format);
|
||||
}
|
||||
}
|
||||
|
||||
inline SDL_Surface* SDL_ConvertSurface(SDL_Surface* surface, SDL_PixelFormat format)
|
||||
{
|
||||
return SDL_ConvertSurfaceFormat(surface, format, 0);
|
||||
};
|
||||
inline SDL_Surface* SDL_ConvertSurface(SDL_Surface* surface, const SDL_PixelFormatDetails* formatDetails)
|
||||
{
|
||||
return SDL_ConvertSurface(surface, formatDetails, 0);
|
||||
}
|
||||
|
||||
#define SDL_SCALEMODE_LINEAR SDL_ScaleModeLinear
|
||||
#define SDL_SCALEMODE_NEAREST SDL_ScaleModeNearest
|
||||
|
||||
#define SDL_BlitSurfaceScaled(surface, rect, destSurface, destRect, scaleMode) (SDL_BlitScaled(surface, rect, destSurface, destRect) == 0)
|
||||
#define SDL_SetSurfaceColorKey(...) (SDL_SetColorKey(__VA_ARGS__) == 0)
|
||||
|
||||
#define SDL_LoadBMP_IO SDL_LoadBMP_RW
|
||||
73
3rdparty/sdl3-shim/SDL3/SDL_timer.h
vendored
Normal file
73
3rdparty/sdl3-shim/SDL3/SDL_timer.h
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_timer.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <map>
|
||||
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_timerh
|
||||
// https://wiki.libsdl.org/SDL3/README-migration#sdl_timerh | SDL_GetTicksNS()
|
||||
|
||||
#define SDL_GetTicksNS SDL_GetTicks
|
||||
|
||||
// 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* callback;
|
||||
void* userdata;
|
||||
SDL_TimerID id;
|
||||
};
|
||||
|
||||
inline std::map<SDL_TimerID, SDL2TimerShimData*> g_timers;
|
||||
inline SDL_mutex* g_timerMutex = SDL_CreateMutex();
|
||||
|
||||
inline Uint32 shim_timer_callback(Uint32 interval, void* param)
|
||||
{
|
||||
auto* shim = static_cast<SDL2TimerShimData*>(param);
|
||||
const Uint32 next = shim->callback(shim->userdata, 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* callback, void* userdata)
|
||||
{
|
||||
auto* shim = static_cast<SDL2TimerShimData*>(SDL_malloc(sizeof(SDL2TimerShimData)));
|
||||
shim->callback = callback;
|
||||
shim->userdata = userdata;
|
||||
|
||||
const SDL_TimerID id = ::SDL_AddTimer(interval, shim_timer_callback, shim);
|
||||
if (id == 0) {
|
||||
SDL_free(shim);
|
||||
return 0;
|
||||
}
|
||||
shim->id = id;
|
||||
|
||||
SDL_LockMutex(g_timerMutex);
|
||||
g_timers[id] = shim;
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
|
||||
return 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()) {
|
||||
SDL_free(it->second);
|
||||
g_timers.erase(it);
|
||||
}
|
||||
SDL_UnlockMutex(g_timerMutex);
|
||||
|
||||
return ::SDL_RemoveTimer(id);
|
||||
}
|
||||
#define SDL_RemoveTimer SDL_RemoveTimer2
|
||||
30
3rdparty/sdl3-shim/main.cpp
vendored
Normal file
30
3rdparty/sdl3-shim/main.cpp
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include "SDL3/SDL_events.h"
|
||||
#include "SDL3/SDL_main.h"
|
||||
|
||||
static void TranslateSDLEvents(SDL_Event* e)
|
||||
{
|
||||
// Extend to SDL_DISPLAYEVENT & fully replace the event object passed to AppEvent
|
||||
// if wanting to drop the ifs on key, mouse and keyboard events.
|
||||
if (e->type == SDL_WINDOWEVENT) {
|
||||
e->type = SDL_WINDOWEVENT + 2 + e->window.event;
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
TranslateSDLEvents(&e);
|
||||
SDL_AppEvent(appstate, &e);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_AppQuit(appstate, static_cast<SDL_AppResult>(NULL));
|
||||
return 0;
|
||||
}
|
||||
100
CMakeLists.txt
100
CMakeLists.txt
@ -2,6 +2,19 @@ cmake_minimum_required(VERSION 3.25...4.0 FATAL_ERROR)
|
||||
|
||||
project(isle LANGUAGES CXX C VERSION 0.1)
|
||||
|
||||
if(WIIU)
|
||||
add_library(libstdc_WiiU STATIC IMPORTED)
|
||||
set_target_properties(libstdc_WiiU PROPERTIES
|
||||
IMPORTED_LOCATION /opt/devkitpro/devkitPPC/powerpc-eabi/lib/libstdc++.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES /opt/devkitpro/devkitPPC/powerpc-eabi/include/c++/15.1.0
|
||||
)
|
||||
|
||||
include_directories(BEFORE
|
||||
/opt/devkitpro/devkitPPC/powerpc-eabi/include/c++/15.1.0/powerpc-eabi
|
||||
/opt/devkitpro/devkitPPC/powerpc-eabi/include/c++/15.1.0
|
||||
)
|
||||
endif()
|
||||
|
||||
if (IOS)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
|
||||
@ -55,6 +68,7 @@ cmake_dependent_option(ISLE_COMPILE_SHADERS "Compile shaders" ON "SDL_SHADERCROS
|
||||
option(CMAKE_POSITION_INDEPENDENT_CODE "Build with -fPIC" ON)
|
||||
option(ENABLE_CLANG_TIDY "Enable clang-tidy")
|
||||
option(DOWNLOAD_DEPENDENCIES "Download dependencies" ON)
|
||||
option(USE_SDL2 "Use SDL2 instead of SDL3 via a shim" OFF)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" CACHE PATH "Directory where to put executables and dll")
|
||||
set(ISLE_EMSCRIPTEN_HOST "" CACHE STRING "Host URL for Emscripten streaming (e.g., https://test.com)")
|
||||
cmake_dependent_option(BUILD_SHARED_LIBS "Build lego1 as a shared library" ON "NOT EMSCRIPTEN" OFF)
|
||||
@ -66,6 +80,7 @@ message(STATUS "Internal miniwin: ${ISLE_MINIWIN}")
|
||||
message(STATUS "Isle extensions: ${ISLE_EXTENSIONS}")
|
||||
message(STATUS "Isle debugging: ${ISLE_DEBUG}")
|
||||
message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}")
|
||||
message(STATUS "Use SDL2: ${USE_SDL2}")
|
||||
|
||||
add_library(Isle::iniparser INTERFACE IMPORTED)
|
||||
|
||||
@ -74,26 +89,53 @@ if (DOWNLOAD_DEPENDENCIES)
|
||||
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
||||
include(FetchContent)
|
||||
|
||||
if(ANDROID)
|
||||
# Built by Gradle
|
||||
find_package(SDL3 REQUIRED CONFIG COMPONENTS Shared)
|
||||
else()
|
||||
if (WINDOWS_STORE)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/Helloyunho/SDL3-uwp.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
if(NOT USE_SDL2)
|
||||
if(ANDROID)
|
||||
# Built by Gradle
|
||||
find_package(SDL3 REQUIRED CONFIG COMPONENTS Shared)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
if (WINDOWS_STORE)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/Helloyunho/SDL3-uwp.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
else()
|
||||
if(WIIU)
|
||||
FetchContent_Declare(
|
||||
SDL2
|
||||
GIT_REPOSITORY "https://github.com/devkitPro/SDL.git"
|
||||
GIT_TAG 3e4393af9e7e36a3f669a52505281555de538923
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
# set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
# set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(SDL2)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL2
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
GIT_TAG SDL2
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
# set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
# set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(SDL2)
|
||||
endif()
|
||||
|
||||
set(SDL2_INCLUDE_DIR ${SDL2_SOURCE_DIR}/include)
|
||||
add_subdirectory(3rdparty/sdl3-shim SYSTEM)
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
@ -112,7 +154,12 @@ else()
|
||||
# find_package looks for already-installed system packages.
|
||||
# Configure with `-DCMAKE_PREFIX_PATH="/path/to/package1;/path/to/package2"`
|
||||
# to add search paths.
|
||||
find_package(SDL3 CONFIG REQUIRED)
|
||||
if(NOT USE_SDL2)
|
||||
find_package(SDL3 CONFIG REQUIRED)
|
||||
else()
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
add_subdirectory(3rdparty/sdl3-shim SYSTEM)
|
||||
endif()
|
||||
|
||||
find_package(iniparser REQUIRED CONFIG COMPONENTS shared)
|
||||
target_link_libraries(Isle::iniparser INTERFACE iniparser-shared)
|
||||
@ -176,7 +223,9 @@ target_include_directories(Vec::Vec INTERFACE "${CMAKE_SOURCE_DIR}/3rdparty/vec"
|
||||
add_library(lego1
|
||||
LEGO1/main.cpp
|
||||
)
|
||||
if(NOT WIIU)
|
||||
target_precompile_headers(lego1 PRIVATE "LEGO1/lego1_pch.h")
|
||||
endif()
|
||||
set_property(TARGET lego1 PROPERTY DEFINE_SYMBOL "LEGO1_DLL")
|
||||
target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/util>")
|
||||
target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/extensions/include>")
|
||||
@ -598,6 +647,11 @@ if (ISLE_BUILD_APP)
|
||||
ISLE/android/config.cpp
|
||||
)
|
||||
endif()
|
||||
if (WIIU)
|
||||
target_sources(isle PRIVATE
|
||||
ISLE/wiiu/config.cpp
|
||||
)
|
||||
endif()
|
||||
if(Python3_FOUND)
|
||||
if(NOT DEFINED PYTHON_PIL_AVAILABLE)
|
||||
execute_process(
|
||||
@ -881,6 +935,14 @@ if(WINDOWS_STORE)
|
||||
PATTERN "*/*.msix"
|
||||
PATTERN "*/*.msixbundle")
|
||||
endif()
|
||||
if(WIIU)
|
||||
wut_create_rpx(isle)
|
||||
|
||||
install(FILES "$<TARGET_FILE_DIR:isle>/isle.rpx" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
if(WIIU_WUHB)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
if(MSVC OR IOS)
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
if(IOS)
|
||||
|
||||
@ -77,6 +77,10 @@
|
||||
#include "android/config.h"
|
||||
#endif
|
||||
|
||||
#ifdef __WIIU__
|
||||
#include "wiiu/config.h"
|
||||
#endif
|
||||
|
||||
DECOMP_SIZE_ASSERT(IsleApp, 0x8c)
|
||||
|
||||
// GLOBAL: ISLE 0x410030
|
||||
@ -290,6 +294,13 @@ void IsleApp::SetupVideoFlags(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WUT__
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
||||
{
|
||||
*appstate = NULL;
|
||||
@ -480,10 +491,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 +510,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 +531,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);
|
||||
@ -879,20 +898,34 @@ 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);
|
||||
#if defined(MINIWIN) && !defined(__3DS__) && !defined(WINDOWS_STORE)
|
||||
#endif
|
||||
#if defined(MINIWIN) && !defined(__3DS__) && !defined(WINDOWS_STORE) && !defined(__WIIU__)
|
||||
#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, 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 +947,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;
|
||||
}
|
||||
@ -1109,6 +1142,9 @@ bool IsleApp::LoadConfig()
|
||||
#ifdef ANDROID
|
||||
Android_SetupDefaultConfigOverrides(dict);
|
||||
#endif
|
||||
#ifdef __WIIU__
|
||||
WIIU_SetupDefaultConfigOverrides(dict);
|
||||
#endif
|
||||
|
||||
iniparser_dump_ini(dict, iniFP);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "New config written at '%s'", iniConfig.GetData());
|
||||
|
||||
@ -12,8 +12,19 @@
|
||||
#include "mxticklemanager.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
#include <backends/imgui_impl_sdl3.h>
|
||||
#include <backends/imgui_impl_sdlrenderer3.h>
|
||||
#else
|
||||
#include <backends/imgui_impl_sdl2.h>
|
||||
#include <backends/imgui_impl_sdlrenderer2.h>
|
||||
#define ImGui_ImplSDL3_InitForSDLRenderer ImGui_ImplSDL2_InitForSDLRenderer
|
||||
#define ImGui_ImplSDLRenderer3_Init ImGui_ImplSDLRenderer2_Init
|
||||
#define ImGui_ImplSDL3_ProcessEvent ImGui_ImplSDL2_ProcessEvent
|
||||
#define ImGui_ImplSDLRenderer3_NewFrame ImGui_ImplSDLRenderer2_NewFrame
|
||||
#define ImGui_ImplSDL3_NewFrame ImGui_ImplSDL2_NewFrame
|
||||
#define ImGui_ImplSDLRenderer3_RenderDrawData ImGui_ImplSDLRenderer2_RenderDrawData
|
||||
#endif
|
||||
#include <imgui.h>
|
||||
|
||||
#ifdef ISLE_VALGRIND
|
||||
@ -221,7 +232,11 @@ bool IsleDebug_Event(SDL_Event* event)
|
||||
return false;
|
||||
}
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
if (event->key.scancode == SCANCODE_KEY_PAUSE) {
|
||||
#else
|
||||
if (event->key.keysym.scancode == SCANCODE_KEY_PAUSE) {
|
||||
#endif
|
||||
if (!g_debugPaused) {
|
||||
IsleDebug_SetPaused(true);
|
||||
}
|
||||
@ -230,7 +245,11 @@ bool IsleDebug_Event(SDL_Event* event)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
if (event->key.scancode == SCANCODE_KEY_RESUME) {
|
||||
#else
|
||||
if (event->key.keysym.scancode == SCANCODE_KEY_RESUME) {
|
||||
#endif
|
||||
g_debugDoStep = false;
|
||||
if (g_debugPaused) {
|
||||
IsleDebug_SetPaused(false);
|
||||
|
||||
14
ISLE/wiiu/config.cpp
Normal file
14
ISLE/wiiu/config.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <iniparser.h>
|
||||
|
||||
// copy of 3ds config
|
||||
|
||||
void WIIU_SetupDefaultConfigOverrides(dictionary* p_dictionary)
|
||||
{
|
||||
SDL_Log("Overriding default config for Wii U");
|
||||
|
||||
iniparser_set(p_dictionary, "isle:diskpath", "sdmc:/wiiu/apps/isle-U/content/LEGO");
|
||||
iniparser_set(p_dictionary, "isle:cdpath", "sdmc:/wiiu/apps/isle-U/content/LEGO");
|
||||
}
|
||||
8
ISLE/wiiu/config.h
Normal file
8
ISLE/wiiu/config.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef WIIU_CONFIG_H
|
||||
#define WIIU_CONFIG_H
|
||||
|
||||
#include "dictionary.h"
|
||||
|
||||
void WIIU_SetupDefaultConfigOverrides(dictionary* p_dictionary);
|
||||
|
||||
#endif // WIIU_CONFIG_H
|
||||
3
LEGO1/exports.def
Normal file
3
LEGO1/exports.def
Normal file
@ -0,0 +1,3 @@
|
||||
:NAME lego1
|
||||
|
||||
:TEXT
|
||||
@ -8,6 +8,7 @@
|
||||
#include "mxpresenter.h"
|
||||
#include "mxqueue.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_haptic.h>
|
||||
#include <SDL3/SDL_joystick.h>
|
||||
#include <SDL3/SDL_keyboard.h>
|
||||
|
||||
@ -30,7 +30,11 @@ MxU32 LegoState::Playlist::Next()
|
||||
break;
|
||||
|
||||
case e_random:
|
||||
#ifdef __WIIU__
|
||||
m_nextIndex = SDL_tanf(m_length);
|
||||
#else
|
||||
m_nextIndex = SDL_rand(m_length);
|
||||
#endif
|
||||
objectId = m_objectIds[m_nextIndex];
|
||||
break;
|
||||
|
||||
|
||||
@ -32,8 +32,11 @@
|
||||
#include "scripts.h"
|
||||
|
||||
#include <SDL3/SDL_events.h>
|
||||
#ifndef __WIIU__
|
||||
#include <SDL3/SDL_process.h>
|
||||
#endif
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <vec.h>
|
||||
@ -322,8 +325,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);
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "roi/legoroi.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoInputManager, 0x338)
|
||||
DECOMP_SIZE_ASSERT(LegoNotifyList, 0x18)
|
||||
@ -783,14 +784,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{1};
|
||||
#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{1};
|
||||
#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{1};
|
||||
#endif
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
|
||||
25
LEGO1/mainUclass.h
Normal file
25
LEGO1/mainUclass.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
class Lego1App {
|
||||
public:
|
||||
Lego1App() {}
|
||||
|
||||
~Lego1App() {}
|
||||
|
||||
void Run()
|
||||
{
|
||||
SDL_Log("Lego1App::Run called");
|
||||
|
||||
bool running = true;
|
||||
SDL_Event e;
|
||||
|
||||
while (running) {
|
||||
while (SDL_PollEvent(&e)) {
|
||||
if (e.type == SDL_QUIT) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -72,11 +72,16 @@ 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
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "omni/include/mxvideoparam.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
#include <assert.h>
|
||||
#include <miniwin/miniwind3d.h>
|
||||
#include <stdio.h> // for vsprintf
|
||||
@ -228,11 +229,16 @@ 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
|
||||
|
||||
@ -114,7 +114,11 @@ void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_flags)
|
||||
MxS16 value = atoi(&m_unk0x9c.GetData()[strlen("RANDOM_")]);
|
||||
|
||||
srand(Timer()->GetTime());
|
||||
#ifdef __WIIU__
|
||||
MxS32 random = SDL_tanf(value);
|
||||
#else
|
||||
MxS32 random = SDL_rand(value);
|
||||
#endif
|
||||
string = SDL_itoa((MxS16) random, buffer, 10);
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,9 @@
|
||||
#include "mxmain.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#ifndef __WIIU__
|
||||
#include <SDL3/SDL_platform_defines.h>
|
||||
#endif
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "decomp.h"
|
||||
|
||||
#include <SDL3/SDL_timer.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxThread, 0x1c)
|
||||
|
||||
@ -34,6 +35,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 +46,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;
|
||||
|
||||
0
android-project/gradlew.bat
vendored
Normal file → Executable file
0
android-project/gradlew.bat
vendored
Normal file → Executable file
@ -28,7 +28,9 @@ target_compile_definitions(miniwin PRIVATE
|
||||
)
|
||||
|
||||
list(APPEND GRAPHICS_BACKENDS USE_SOFTWARE_RENDER)
|
||||
list(APPEND GRAPHICS_BACKENDS USE_SDL_GPU)
|
||||
if(NOT USE_SDL2)
|
||||
list(APPEND GRAPHICS_BACKENDS USE_SDL_GPU)
|
||||
endif()
|
||||
|
||||
if(NOT WINDOWS_STORE)
|
||||
find_package(OpenGL)
|
||||
@ -116,11 +118,16 @@ endif()
|
||||
|
||||
target_compile_definitions(miniwin PUBLIC MINIWIN)
|
||||
|
||||
target_include_directories(miniwin PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/internal
|
||||
)
|
||||
|
||||
if(USE_SDL_GPU IN_LIST GRAPHICS_BACKENDS)
|
||||
target_include_directories(miniwin
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/internal
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/generated
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(miniwin PUBLIC miniwin-headers)
|
||||
|
||||
target_link_libraries(miniwin PRIVATE SDL3::SDL3)
|
||||
@ -129,7 +136,7 @@ target_compile_definitions(miniwin PUBLIC ${GRAPHICS_BACKENDS})
|
||||
|
||||
|
||||
# Shader stuff
|
||||
|
||||
if(USE_SDL_GPU IN_LIST GRAPHICS_BACKENDS)
|
||||
set(shader_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/src")
|
||||
set(shader_gen_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/generated")
|
||||
set(py_gencshadersource "${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/gencshadersource.py")
|
||||
@ -213,7 +220,7 @@ endforeach()
|
||||
|
||||
set(index_cpp "${shader_gen_dir}/ShaderIndex.cpp")
|
||||
set(index_h "${shader_gen_dir}/ShaderIndex.h")
|
||||
|
||||
endif()
|
||||
if(ISLE_COMPILE_SHADERS)
|
||||
add_custom_command(OUTPUT "${index_h}" "${index_cpp}"
|
||||
COMMAND Python3::Interpreter "${py_gencshadersource}" "index"
|
||||
|
||||
8
miniwin/src/d3drm/backends/gx2/actual.h
Normal file
8
miniwin/src/d3drm/backends/gx2/actual.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <gx2/mem.h>
|
||||
#include <gx2r/buffer.h>
|
||||
|
||||
inline uint32_t GX2RGetGpuAddr(const GX2RBuffer* buffer)
|
||||
{
|
||||
return (uint32_t) buffer->buffer;
|
||||
}
|
||||
109
miniwin/src/d3drm/backends/gx2/renderer.cpp
Normal file
109
miniwin/src/d3drm/backends/gx2/renderer.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/thread.h>
|
||||
#include <coreinit/time.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <gfd.h>
|
||||
#include <gx2/draw.h>
|
||||
#include <gx2/mem.h>
|
||||
#include <whb/gfx.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <whb/proc.h>
|
||||
#include <whb/sdcard.h>
|
||||
|
||||
struct IsleGX2Backend {
|
||||
GX2RBuffer positionBuffer;
|
||||
GX2RBuffer colourBuffer;
|
||||
WHBGfxShaderGroup shaderGroup;
|
||||
bool rendering = false;
|
||||
|
||||
void Init(const char* shaderPath)
|
||||
{
|
||||
WHBLogUdpInit();
|
||||
WHBProcInit();
|
||||
WHBGfxInit();
|
||||
WHBMountSdCard();
|
||||
char path[256];
|
||||
sprintf(path, "%s/%s", WHBGetSdCardMountPath(), shaderPath);
|
||||
FILE* f = fopen(path, "rb");
|
||||
if (!f) {
|
||||
return;
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
size_t fsize = ftell(f);
|
||||
rewind(f);
|
||||
char* data = (char*) malloc(fsize);
|
||||
fread(data, 1, fsize, f);
|
||||
WHBGfxLoadGFDShaderGroup(&shaderGroup, 0, data);
|
||||
free(data);
|
||||
WHBGfxInitShaderAttribute(&shaderGroup, "aPosition", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32);
|
||||
WHBGfxInitShaderAttribute(&shaderGroup, "aColour", 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32);
|
||||
WHBGfxInitFetchShader(&shaderGroup);
|
||||
}
|
||||
|
||||
void StartFrame()
|
||||
{
|
||||
if (rendering) {
|
||||
return;
|
||||
}
|
||||
WHBGfxBeginRender();
|
||||
WHBGfxBeginRenderTV();
|
||||
rendering = true;
|
||||
}
|
||||
|
||||
void EndFrame()
|
||||
{
|
||||
if (!rendering) {
|
||||
return;
|
||||
}
|
||||
WHBGfxFinishRenderTV();
|
||||
WHBGfxBeginRenderDRC();
|
||||
WHBGfxFinishRenderDRC();
|
||||
WHBGfxFinishRender();
|
||||
rendering = false;
|
||||
}
|
||||
|
||||
void Clear(float r, float g, float b)
|
||||
{
|
||||
StartFrame();
|
||||
WHBGfxClearColor(r, g, b, 1.0f);
|
||||
}
|
||||
|
||||
void Flip() { EndFrame(); }
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
WHBUnmountSdCard();
|
||||
WHBGfxShutdown();
|
||||
WHBProcShutdown();
|
||||
WHBLogUdpDeinit();
|
||||
}
|
||||
};
|
||||
|
||||
static IsleGX2Backend g_backend;
|
||||
|
||||
extern "C" void IsleBackendInit(const char* shaderPath)
|
||||
{
|
||||
g_backend.Init(shaderPath);
|
||||
}
|
||||
extern "C" void IsleBackendStartFrame()
|
||||
{
|
||||
g_backend.StartFrame();
|
||||
}
|
||||
extern "C" void IsleBackendEndFrame()
|
||||
{
|
||||
g_backend.EndFrame();
|
||||
}
|
||||
extern "C" void IsleBackendClear(float r, float g, float b)
|
||||
{
|
||||
g_backend.Clear(r, g, b);
|
||||
}
|
||||
extern "C" void IsleBackendFlip()
|
||||
{
|
||||
g_backend.Flip();
|
||||
}
|
||||
extern "C" void IsleBackendShutdown()
|
||||
{
|
||||
g_backend.Shutdown();
|
||||
}
|
||||
6
miniwin/src/d3drm/backends/gx2/renderer.ps
Normal file
6
miniwin/src/d3drm/backends/gx2/renderer.ps
Normal file
@ -0,0 +1,6 @@
|
||||
#version 450
|
||||
layout(location = 0) in vec4 vColour;
|
||||
layout(location = 0) out vec4 outColour;
|
||||
void main() {
|
||||
outColour = vColour;
|
||||
}
|
||||
8
miniwin/src/d3drm/backends/gx2/renderer.vs
Normal file
8
miniwin/src/d3drm/backends/gx2/renderer.vs
Normal file
@ -0,0 +1,8 @@
|
||||
#version 450
|
||||
layout(location = 0) in vec4 aPosition;
|
||||
layout(location = 1) in vec4 aColour;
|
||||
layout(location = 0) out vec4 vColour;
|
||||
void main() {
|
||||
gl_Position = aPosition;
|
||||
vColour = aColour;
|
||||
}
|
||||
@ -152,7 +152,7 @@ HRESULT DirectDrawImpl::EnumDisplayModes(
|
||||
#ifdef MINIWIN_PIXELFORMAT
|
||||
format = MINIWIN_PIXELFORMAT;
|
||||
#else
|
||||
format = modes[i]->format;
|
||||
format = static_cast<SDL_PixelFormat>(modes[i]->format);
|
||||
#endif
|
||||
|
||||
const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(format);
|
||||
@ -245,7 +245,7 @@ HRESULT DirectDrawImpl::GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc)
|
||||
#ifdef MINIWIN_PIXELFORMAT
|
||||
format = MINIWIN_PIXELFORMAT;
|
||||
#else
|
||||
format = mode->format;
|
||||
format = static_cast<SDL_PixelFormat>(mode->format);
|
||||
#endif
|
||||
|
||||
const SDL_PixelFormatDetails* details = SDL_GetPixelFormatDetails(format);
|
||||
|
||||
30
miniwin/src/internal/d3drmrenderer_gx2.h
Normal file
30
miniwin/src/internal/d3drmrenderer_gx2.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3drmrenderer.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <wut.h>
|
||||
|
||||
DEFINE_GUID(GX2_GUID, 0xA12B56F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x53);
|
||||
|
||||
class GX2Renderer : public Direct3DRMRenderer {
|
||||
public:
|
||||
GX2Renderer(DWORD width, DWORD height);
|
||||
~GX2Renderer() override;
|
||||
};
|
||||
|
||||
inline static void GX2Renderer_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||
{
|
||||
D3DDEVICEDESC halDesc = {};
|
||||
halDesc.dcmColorModel = D3DCOLOR_RGB;
|
||||
halDesc.dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
||||
halDesc.dwDeviceZBufferBitDepth = DDBD_24;
|
||||
halDesc.dwDeviceRenderBitDepth = DDBD_32;
|
||||
halDesc.dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
||||
halDesc.dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
||||
halDesc.dpcTriCaps.dwTextureFilterCaps = D3DPTFILTERCAPS_LINEAR;
|
||||
|
||||
D3DDEVICEDESC helDesc = {};
|
||||
|
||||
EnumDevice(cb, ctx, "GX2", &halDesc, &helDesc, GX2_GUID);
|
||||
}
|
||||
7
miniwin/src/internal/d3drmrenderer_gx2stub.cpp
Normal file
7
miniwin/src/internal/d3drmrenderer_gx2stub.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "d3drmrenderer_gx2.h"
|
||||
|
||||
GX2Renderer::GX2Renderer(DWORD width, DWORD height) : Direct3DRMRenderer(width, height)
|
||||
{
|
||||
}
|
||||
|
||||
GX2Renderer::~GX2Renderer() = default;
|
||||
BIN
packaging/wiiu/Legacy/content/renderer.gsh
Normal file
BIN
packaging/wiiu/Legacy/content/renderer.gsh
Normal file
Binary file not shown.
BIN
packaging/wiiu/Legacy/icon.png
Normal file
BIN
packaging/wiiu/Legacy/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
12
packaging/wiiu/Legacy/meta.xml
Normal file
12
packaging/wiiu/Legacy/meta.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<app>
|
||||
<name>Isle-U</name>
|
||||
<short_description>LEGO Island for the Wii U</short_description>
|
||||
<long_description>
|
||||
LEGO Island for the Wii U
|
||||
</long_description>
|
||||
<coder>Lyelye</coder>
|
||||
<version>1.0.0</version>
|
||||
<release_date>2025-09-16</release_date>
|
||||
<category>application</category>
|
||||
</app>
|
||||
Loading…
Reference in New Issue
Block a user