Updated SDL3_shim and removed main from isleapp.cpp for now as a test

This commit is contained in:
Lyelye150 2025-10-20 20:52:42 -04:00
parent f555ef9256
commit db0216ea0d
15 changed files with 269 additions and 242 deletions

View File

@ -67,11 +67,19 @@ if(ISLE_DEBUG)
${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
)
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 PUBLIC SDL3::Headers)
target_link_libraries(imgui PRIVATE SDL3::SDL3)
set_property(TARGET imgui PROPERTY CXX_CLANG_TIDY "")
endif()

18
3rdparty/sdl3-shim/CMakeLists.txt vendored Normal file
View 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)

View File

@ -19,6 +19,7 @@
#include "SDL_pixels.h"
#include "SDL_surface.h"
#include "SDL_timer.h"
#include "SDL_version.h"
#include <random>
@ -42,14 +43,14 @@ inline float SDL_randf()
// https://wiki.libsdl.org/SDL3/README-migration#sdl_videoh
typedef Uint32 SDL_DisplayID;
typedef int SDL_DisplayID;
inline SDL_DisplayID SDL_GetPrimaryDisplay()
{
return 0;
return 1;
}
// Modified from 83bb0f9105922fd49282f0b931f7873a71877ac8 SDL_video.c#L1331
inline SDL_DisplayMode** SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count)
inline SDL_DisplayMode** SDL_GetFullscreenDisplayModes(int displayID, int* count)
{
int i;
if (count) *count = 0;
@ -76,11 +77,21 @@ inline SDL_DisplayMode** SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID,
return result;
}
inline SDL_DisplayMode* SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
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_DisplayMode* mode = nullptr;
SDL_GetCurrentDisplayMode(displayID, mode);
return mode;
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 )
@ -96,10 +107,19 @@ inline SDL_DisplayMode* SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
#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
typedef int SDL_KeyboardID;
#define SDL_GetKeyboardState (const bool*)SDL_GetKeyboardState
typedef int SDL_HapticID;
@ -167,17 +187,6 @@ inline bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w,
typedef Uint32 SDL_MouseID;
inline SDL_MouseID * SDL_GetMice(int *count)
{
if (count) {
*count = 1;
}
const auto mice = static_cast<SDL_MouseID *>(SDL_malloc((*count + 1) * sizeof(SDL_MouseID)));
mice[0] = { 0 };
mice[1] = { 0 };
return mice;
}
static void SDL_HideCursor() { SDL_ShowCursor(SDL_DISABLE); }
static void SDL_ShowCursor() { SDL_ShowCursor(SDL_ENABLE); }

View File

@ -2,13 +2,12 @@
#include "SDL.h"
#include <cstring>
#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
@ -16,40 +15,31 @@
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_AudioDeviceID, ShimAudioCtx> g_audioCtxs;
static SDL_mutex *g_audioMutex = NULL;
static std::map<SDL_AudioStream*, ShimAudioCtx*> g_audioCtxs;
static SDL_mutex *g_audioMutex = SDL_CreateMutex();
static void SDLCALL shim_audio_callback(void *userdata, Uint8 *stream, int len) {
SDL_AudioDeviceID devid = reinterpret_cast<uintptr_t>(userdata);
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;
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;
}
int available = SDL_AudioStreamAvailable(audio_stream);
ShimAudioCtx &ctx = it->second;
SDL_UnlockMutex(g_audioMutex);
int additional_amount = len - available;
if (additional_amount < 0)
additional_amount = 0;
// 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;
ctx->callback(ctx->userdata, audio_stream, additional_amount, len);
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);
int retrieved = SDL_AudioStreamGet(audio_stream, data_stream, len);
if (retrieved < len) {
memset(data_stream + retrieved, ctx->obtained.silence, len - retrieved);
}
}
@ -59,43 +49,64 @@ static void SDLCALL shim_audio_callback(void *userdata, Uint8 *stream, int len)
inline SDL_AudioDeviceID SDL_GetAudioStreamDevice(SDL_AudioStream* stream)
{
SDL_LockMutex(g_audioMutex);
const auto it = g_audioCtxs.find(reinterpret_cast<uintptr_t>(stream));
const auto it = g_audioCtxs.find(stream);
if (it == g_audioCtxs.end()) {
return 0;
}
return it->first;
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 = reinterpret_cast<void*>(static_cast<uintptr_t>(0));
SDL_AudioDeviceID device = SDL_OpenAudioDevice(devid, 0, &desired2, &obtained, 0);
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);
return nullptr;
delete ctx;
return NULL;
}
{
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);
}
ctx->device = device;
ctx->stream = stream;
ctx->obtained = obtained;
SDL_LockAudioDevice(device);
desired2.userdata = reinterpret_cast<void*>(static_cast<uintptr_t>(device));
SDL_UnlockAudioDevice(device);
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;
}

View File

@ -1,11 +1,16 @@
#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_SIZE_CHANGED
#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
@ -18,12 +23,6 @@
#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
@ -68,3 +67,60 @@
#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);
}

View File

@ -32,6 +32,16 @@ static bool operator!=(SDL_PixelFormatDetails* lhs, SDL_PixelFormatEnum rhs)
#define SDL_CreatePalette SDL_AllocPalette
#define SDL_DestroyPalette SDL_FreePalette
#define SDL_GetPixelFormatForMasks (SDL_PixelFormat)SDL_MasksToPixelFormatEnum
// #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)

View File

@ -3,7 +3,6 @@
#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()
@ -13,22 +12,21 @@
// time is in miliseconds not nanoseconds
#define SDL_NS_TO_MS(MS) (MS)
typedef Uint32 SDL3_TimerCallback (void *userdata, SDL_TimerID timerID, Uint32 interval);
typedef Uint32 SDL3_TimerCallback(void* userdata, SDL_TimerID timerID, Uint32 interval);
struct SDL2TimerShimData {
SDL3_TimerCallback *callback2;
void *userdata2;
SDL3_TimerCallback* callback;
void* userdata;
SDL_TimerID id;
};
static std::map<SDL_TimerID, void*> g_timers;
static SDL_mutex *g_timerMutex = NULL;
inline std::map<SDL_TimerID, SDL2TimerShimData*> g_timers;
inline SDL_mutex* g_timerMutex = SDL_CreateMutex();
inline Uint32 shim_timer_callback (Uint32 interval, void *param)
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);
auto* shim = static_cast<SDL2TimerShimData*>(param);
const Uint32 next = shim->callback(shim->userdata, shim->id, interval);
if (next == 0) {
SDL_LockMutex(g_timerMutex);
@ -40,13 +38,17 @@ inline Uint32 shim_timer_callback (Uint32 interval, void *param)
return next;
}
inline SDL_TimerID SDL_AddTimer(Uint32 interval, SDL3_TimerCallback callback3, void* userdata)
inline SDL_TimerID SDL_AddTimer(Uint32 interval, SDL3_TimerCallback* callback, void* userdata)
{
const auto shim = static_cast<SDL2TimerShimData*>(SDL_malloc(sizeof(SDL2TimerShimData)));
shim->callback2 = callback3;
shim->userdata2 = 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);
@ -67,5 +69,4 @@ inline SDL_bool SDL_RemoveTimer2(SDL_TimerID id)
return ::SDL_RemoveTimer(id);
}
#define SDL_RemoveTimer SDL_RemoveTimer2

View File

@ -2,6 +2,15 @@
#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) {
@ -11,6 +20,7 @@ int main(int argc, char *argv[]) {
SDL_Event e;
while (!SDL_AppIterate(appstate)) {
while (SDL_PollEvent(&e)) {
TranslateSDLEvents(&e);
SDL_AppEvent(appstate, &e);
}
}

View File

@ -83,12 +83,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" CACHE PATH "Directory w
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)
if(USE_SDL2)
add_compile_definitions(SDL_MAJOR_VERSION=2)
else()
add_compile_definitions(SDL_MAJOR_VERSION=3)
endif()
message(STATUS "Isle app: ${ISLE_BUILD_APP}")
message(STATUS "Config app: ${ISLE_BUILD_CONFIG}")
message(STATUS "Internal DirectX5 SDK: ${ISLE_USE_DX5}")
@ -106,27 +100,42 @@ if (DOWNLOAD_DEPENDENCIES)
include(FetchContent)
if(NOT USE_SDL2)
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(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)
endif()
else()
# wut/devkitPPC has a prebuilt SDL2
if(NOT WIIU)
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)
set(SDL2_INCLUDE_DIR ${SDL2_SOURCE_DIR}/include)
endif()
add_subdirectory(3rdparty/sdl3-shim SYSTEM)
endif()
FetchContent_Declare(
@ -145,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)

View File

@ -300,131 +300,6 @@ void IsleApp::SetupVideoFlags(
m_videoParam.Flags().Set16Bit(1);
}
}
// i will figure out how to get this working :/
// still black screen i checked if i had the right assets for isle-U/content/LEGO/
// and i do the .si files are still there :/
#ifdef __WUT__
static void DrawColorScreen(float r, float g, float b)
{
WHBGfxBeginRender();
WHBGfxBeginRenderTV();
WHBGfxClearColor(r, g, b, 1.0f);
WHBGfxFinishRenderTV();
WHBGfxBeginRenderDRC();
WHBGfxClearColor(r, g, b, 1.0f);
WHBGfxFinishRenderDRC();
WHBGfxFinishRender();
}
static void ShowWiiUError(const char16_t* msg)
{
WHBProcInit();
WHBGfxInit();
FSInit();
VPADInit();
FSClient* fsClient = (FSClient*)MEMAllocFromDefaultHeap(sizeof(FSClient));
FSAddClient(fsClient, FS_ERROR_FLAG_NONE);
nn::erreula::CreateArg createArg;
createArg.region = nn::erreula::RegionType::Europe;
createArg.language = nn::erreula::LangType::English;
createArg.workMemory = MEMAllocFromDefaultHeap(nn::erreula::GetWorkMemorySize());
createArg.fsClient = fsClient;
nn::erreula::Create(createArg);
nn::erreula::AppearArg appearArg;
appearArg.errorArg.errorType = nn::erreula::ErrorType::Message1Button;
appearArg.errorArg.renderTarget = nn::erreula::RenderTarget::Both;
appearArg.errorArg.controllerType = nn::erreula::ControllerType::DrcGamepad;
appearArg.errorArg.errorMessage = msg;
appearArg.errorArg.button1Label = u"OK";
appearArg.errorArg.errorTitle = u"Isle Error";
nn::erreula::AppearErrorViewer(appearArg);
while (WHBProcIsRunning()) {
VPADStatus vpadStatus;
VPADRead(VPAD_CHAN_0, &vpadStatus, 1, nullptr);
VPADGetTPCalibratedPoint(VPAD_CHAN_0, &vpadStatus.tpNormal, &vpadStatus.tpNormal);
nn::erreula::ControllerInfo controllerInfo;
controllerInfo.vpad = &vpadStatus;
for (int i = 0; i < 4; i++) controllerInfo.kpad[i] = nullptr;
nn::erreula::Calc(controllerInfo);
if (nn::erreula::IsDecideSelectButtonError()) {
nn::erreula::DisappearErrorViewer();
break;
}
WHBGfxBeginRender();
WHBGfxBeginRenderTV();
WHBGfxClearColor(0, 0, 0, 1);
nn::erreula::DrawTV();
WHBGfxFinishRenderTV();
WHBGfxBeginRenderDRC();
WHBGfxClearColor(0, 0, 0, 1);
nn::erreula::DrawDRC();
WHBGfxFinishRenderDRC();
WHBGfxFinishRender();
}
nn::erreula::Destroy();
MEMFreeToDefaultHeap(createArg.workMemory);
FSDelClient(fsClient, FS_ERROR_FLAG_NONE);
MEMFreeToDefaultHeap(fsClient);
FSShutdown();
VPADShutdown();
WHBGfxShutdown();
WHBProcShutdown();
}
int main(int argc, char** argv)
{
void* appstate = NULL;
WHBProcInit();
WHBGfxInit();
DrawColorScreen(1.0f, 0.0f, 0.0f);
SDL_AppResult initResult = SDL_AppInit(&appstate, argc, argv);
if (initResult != 0) {
ShowWiiUError(u"SDL_AppInit failed");
return -1;
}
DrawColorScreen(0.0f, 1.0f, 0.0f);
SDL_AppResult iterateResult = SDL_AppIterate(&appstate);
if (iterateResult != 0) {
ShowWiiUError(u"SDL_AppIterate failed");
return -1;
}
DrawColorScreen(1.0f, 1.0f, 0.0f);
SDL_Event event;
SDL_AppResult eventResult = SDL_AppEvent(appstate, &event);
if (eventResult != 0) {
ShowWiiUError(u"SDL_AppEvent failed");
return -1;
}
DrawColorScreen(0.0f, 0.0f, 1.0f);
IsleApp app;
SDL_AppResult argResult = app.ParseArguments(argc, argv);
if (argResult == SDL_APP_FAILURE) {
return -1;
} else if (argResult == SDL_APP_SUCCESS) {
return 0;
}
DrawColorScreen(1.0f, 0.0f, 1.0f);
return 0;
}
#endif
SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
{
*appstate = NULL;

View File

@ -11,9 +11,20 @@
#include "misc.h"
#include "mxticklemanager.h"
#if SDL_MAJOR_VERSION >= 3
#include <SDL3/SDL.h>
#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

View File

@ -34,6 +34,7 @@
#include <SDL3/SDL_events.h>
#ifdef __WIIU__
#include <SDL3/SDL.h>
#include <SDL3/SDL_version.h>
#else
#include <SDL3/SDL_process.h>
#endif

View File

@ -12,6 +12,7 @@
#include "roi/legoroi.h"
#include <SDL3/SDL_log.h>
#include <SDL3/SDL_version.h>
#ifdef __WIIU__
template <class... Ts>
@ -793,7 +794,7 @@ void LegoInputManager::UpdateLastInputMethod(SDL_Event* p_event)
#if SDL_MAJOR_VERSION >= 3
m_lastInputMethod = SDL_KeyboardID_v{p_event->key.which};
#else
m_lastInputMethod = SDL_KeyboardID_v{0};
m_lastInputMethod = SDL_KeyboardID_v{1};
#endif
break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
@ -801,14 +802,14 @@ void LegoInputManager::UpdateLastInputMethod(SDL_Event* p_event)
#if SDL_MAJOR_VERSION >= 3
m_lastInputMethod = SDL_MouseID_v{p_event->button.which};
#else
m_lastInputMethod = SDL_MouseID_v{0};
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{0};
m_lastInputMethod = SDL_MouseID_v{1};
#endif
break;
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:

View File

@ -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

View File

@ -3,6 +3,7 @@
#include "decomp.h"
#include <SDL3/SDL_timer.h>
#include <SDL3/SDL_version.h>
DECOMP_SIZE_ASSERT(MxThread, 0x1c)