Updates the SDL library to the latest standard bugfix release

This commit is contained in:
JeffR 2023-07-13 15:20:29 -05:00
parent cb766f2878
commit 083d2175ea
1280 changed files with 343926 additions and 179615 deletions

View file

@ -8,15 +8,13 @@
#ifdef main
#undef main
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
return (SDL_main(argc, argv));
return SDL_main(argc, argv);
}
#else
/* Nothing to do on this platform */
int
SDL_main_stub_symbol(void)
int SDL_main_stub_symbol(void)
{
return 0;
}

View file

@ -0,0 +1,41 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
/* Include this so we define UNICODE properly */
#include "../../core/windows/SDL_windows.h"
/* Include the SDL main definition header */
#include "SDL.h"
#include "SDL_main.h"
#ifdef main
#undef main
#endif /* main */
/* This is where execution begins */
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
return SDL_GDKRunApp(SDL_main, NULL);
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -30,7 +30,6 @@
#include "../../video/haiku/SDL_bkeyboard.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -49,28 +48,27 @@ extern "C" {
#include <vector>
/* Forward declarations */
class SDL_BLooper;
class SDL_BWin;
/* Message constants */
enum ToSDL {
enum ToSDL
{
/* Intercepted by BWindow on its way to BView */
BAPP_MOUSE_MOVED,
BAPP_MOUSE_BUTTON,
BAPP_MOUSE_WHEEL,
BAPP_KEY,
BAPP_REPAINT, /* from _UPDATE_ */
BAPP_REPAINT, /* from _UPDATE_ */
/* From BWindow */
BAPP_MAXIMIZE, /* from B_ZOOM */
BAPP_MAXIMIZE, /* from B_ZOOM */
BAPP_MINIMIZE,
BAPP_RESTORE, /* TODO: IMPLEMENT! */
BAPP_RESTORE, /* TODO: IMPLEMENT! */
BAPP_SHOW,
BAPP_HIDE,
BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */
BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */
BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */
BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */
BAPP_WINDOW_CLOSE_REQUESTED,
BAPP_WINDOW_MOVED,
BAPP_WINDOW_RESIZED,
@ -78,36 +76,29 @@ enum ToSDL {
};
extern "C" SDL_BLooper *SDL_Looper;
/* Create a descendant of BApplication */
class SDL_BApp : public BApplication {
public:
SDL_BApp(const char* signature) :
BApplication(signature) {
/* Create a descendant of BLooper */
class SDL_BLooper : public BLooper
{
public:
SDL_BLooper(const char* name) : BLooper(name)
{
#if SDL_VIDEO_OPENGL
_current_context = NULL;
#endif
}
virtual ~SDL_BApp() {
virtual ~SDL_BLooper()
{
}
virtual void RefsReceived(BMessage* message) {
char filePath[512];
entry_ref entryRef;
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
BPath referencePath = BPath(&entryRef);
SDL_SendDropFile(NULL, referencePath.Path());
}
return;
}
/* Event-handling functions */
virtual void MessageReceived(BMessage* message) {
/* Event-handling functions */
virtual void MessageReceived(BMessage *message)
{
/* Sort out SDL-related messages */
switch ( message->what ) {
switch (message->what) {
case BAPP_MOUSE_MOVED:
_HandleMouseMove(message);
break;
@ -173,23 +164,24 @@ public:
break;
default:
BApplication::MessageReceived(message);
break;
BLooper::MessageReceived(message);
break;
}
}
/* Window creation/destruction methods */
int32 GetID(SDL_Window *win) {
int32 GetID(SDL_Window *win)
{
int32 i;
for(i = 0; i < _GetNumWindowSlots(); ++i) {
if( GetSDLWindow(i) == NULL ) {
for (i = 0; i < _GetNumWindowSlots(); ++i) {
if (GetSDLWindow(i) == NULL) {
_SetSDLWindow(win, i);
return i;
}
}
/* Expand the vector if all slots are full */
if( i == _GetNumWindowSlots() ) {
if (i == _GetNumWindowSlots()) {
_PushBackWindow(win);
return i;
}
@ -202,18 +194,20 @@ public:
there another way to do this? */
void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
SDL_Window *GetSDLWindow(int32 winID) {
SDL_Window *GetSDLWindow(int32 winID)
{
return _window_map[winID];
}
#if SDL_VIDEO_OPENGL
BGLView *GetCurrentContext() {
BGLView *GetCurrentContext()
{
return _current_context;
}
void SetCurrentContext(BGLView *newContext) {
if(_current_context)
void SetCurrentContext(BGLView *newContext)
{
if (_current_context)
_current_context->UnlockGL();
_current_context = newContext;
if (_current_context)
@ -221,25 +215,26 @@ public:
}
#endif
private:
private:
/* Event management */
void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) {
void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType)
{
SDL_Window *win;
int32 winID;
if(
!_GetWinID(msg, &winID)
) {
if (
!_GetWinID(msg, &winID)) {
return;
}
win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, sdlEventType, 0, 0);
}
void _HandleMouseMove(BMessage *msg) {
void _HandleMouseMove(BMessage *msg)
{
SDL_Window *win;
int32 winID;
int32 x = 0, y = 0;
if(
if (
!_GetWinID(msg, &winID) ||
msg->FindInt32("x", &x) != B_OK || /* x movement */
msg->FindInt32("y", &y) != B_OK /* y movement */
@ -266,47 +261,47 @@ private:
}
}
void _HandleMouseButton(BMessage *msg) {
void _HandleMouseButton(BMessage *msg)
{
SDL_Window *win;
int32 winID;
int32 button, state; /* left/middle/right, pressed/released */
if(
int32 button, state; /* left/middle/right, pressed/released */
if (
!_GetWinID(msg, &winID) ||
msg->FindInt32("button-id", &button) != B_OK ||
msg->FindInt32("button-state", &state) != B_OK
) {
msg->FindInt32("button-state", &state) != B_OK) {
return;
}
win = GetSDLWindow(winID);
SDL_SendMouseButton(win, 0, state, button);
}
void _HandleMouseWheel(BMessage *msg) {
void _HandleMouseWheel(BMessage *msg)
{
SDL_Window *win;
int32 winID;
int32 xTicks, yTicks;
if(
if (
!_GetWinID(msg, &winID) ||
msg->FindInt32("xticks", &xTicks) != B_OK ||
msg->FindInt32("yticks", &yTicks) != B_OK
) {
msg->FindInt32("yticks", &yTicks) != B_OK) {
return;
}
win = GetSDLWindow(winID);
SDL_SendMouseWheel(win, 0, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL);
}
void _HandleKey(BMessage *msg) {
int32 scancode, state; /* scancode, pressed/released */
if(
void _HandleKey(BMessage *msg)
{
int32 scancode, state; /* scancode, pressed/released */
if (
msg->FindInt32("key-state", &state) != B_OK ||
msg->FindInt32("key-scancode", &scancode) != B_OK
) {
msg->FindInt32("key-scancode", &scancode) != B_OK) {
return;
}
/* Make sure this isn't a repeated event (key pressed and held) */
if(state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) {
if (state == SDL_PRESSED && HAIKU_GetKeyState(scancode) == SDL_PRESSED) {
return;
}
HAIKU_SetKeyState(scancode, state);
@ -315,7 +310,7 @@ private:
if (state == SDL_PRESSED && SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
const int8 *keyUtf8;
ssize_t count;
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void**)&keyUtf8, &count) == B_OK) {
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) {
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
SDL_zeroa(text);
SDL_memcpy(text, keyUtf8, count);
@ -324,107 +319,108 @@ private:
}
}
void _HandleMouseFocus(BMessage *msg) {
void _HandleMouseFocus(BMessage *msg)
{
SDL_Window *win;
int32 winID;
bool bSetFocus; /* If false, lose focus */
if(
if (
!_GetWinID(msg, &winID) ||
msg->FindBool("focusGained", &bSetFocus) != B_OK
) {
msg->FindBool("focusGained", &bSetFocus) != B_OK) {
return;
}
win = GetSDLWindow(winID);
if(bSetFocus) {
if (bSetFocus) {
SDL_SetMouseFocus(win);
} else if(SDL_GetMouseFocus() == win) {
} else if (SDL_GetMouseFocus() == win) {
/* Only lose all focus if this window was the current focus */
SDL_SetMouseFocus(NULL);
}
}
void _HandleKeyboardFocus(BMessage *msg) {
void _HandleKeyboardFocus(BMessage *msg)
{
SDL_Window *win;
int32 winID;
bool bSetFocus; /* If false, lose focus */
if(
if (
!_GetWinID(msg, &winID) ||
msg->FindBool("focusGained", &bSetFocus) != B_OK
) {
msg->FindBool("focusGained", &bSetFocus) != B_OK) {
return;
}
win = GetSDLWindow(winID);
if(bSetFocus) {
if (bSetFocus) {
SDL_SetKeyboardFocus(win);
} else if(SDL_GetKeyboardFocus() == win) {
} else if (SDL_GetKeyboardFocus() == win) {
/* Only lose all focus if this window was the current focus */
SDL_SetKeyboardFocus(NULL);
}
}
void _HandleWindowMoved(BMessage *msg) {
void _HandleWindowMoved(BMessage *msg)
{
SDL_Window *win;
int32 winID;
int32 xPos, yPos;
/* Get the window id and new x/y position of the window */
if(
if (
!_GetWinID(msg, &winID) ||
msg->FindInt32("window-x", &xPos) != B_OK ||
msg->FindInt32("window-y", &yPos) != B_OK
) {
msg->FindInt32("window-y", &yPos) != B_OK) {
return;
}
win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos);
}
void _HandleWindowResized(BMessage *msg) {
void _HandleWindowResized(BMessage *msg)
{
SDL_Window *win;
int32 winID;
int32 w, h;
/* Get the window id ]and new x/y position of the window */
if(
if (
!_GetWinID(msg, &winID) ||
msg->FindInt32("window-w", &w) != B_OK ||
msg->FindInt32("window-h", &h) != B_OK
) {
msg->FindInt32("window-h", &h) != B_OK) {
return;
}
win = GetSDLWindow(winID);
SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h);
}
bool _GetWinID(BMessage *msg, int32 *winID) {
bool _GetWinID(BMessage *msg, int32 *winID)
{
return msg->FindInt32("window-id", winID) == B_OK;
}
/* Vector functions: Wraps vector stuff in case we need to change
implementation */
void _SetSDLWindow(SDL_Window *win, int32 winID) {
void _SetSDLWindow(SDL_Window *win, int32 winID)
{
_window_map[winID] = win;
}
int32 _GetNumWindowSlots() {
int32 _GetNumWindowSlots()
{
return _window_map.size();
}
void _PopBackWindow() {
void _PopBackWindow()
{
_window_map.pop_back();
}
void _PushBackWindow(SDL_Window *win) {
void _PushBackWindow(SDL_Window *win)
{
_window_map.push_back(win);
}
/* Members */
std::vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id */
std::vector<SDL_Window *> _window_map; /* Keeps track of SDL_Windows by index-id */
#if SDL_VIDEO_OPENGL
BGLView *_current_context;
BGLView *_current_context;
#endif
};

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -31,7 +31,7 @@
#include <storage/File.h>
#include <unistd.h>
#include "SDL_BApp.h" /* SDL_BApp class definition */
#include "SDL_BApp.h" /* SDL_BLooper class definition */
#include "SDL_BeApp.h"
#include "SDL_timer.h"
#include "SDL_error.h"
@ -44,15 +44,40 @@ extern "C" {
#include "../../thread/SDL_systhread.h"
/* Flag to tell whether or not the Be application is active or not */
/* Flag to tell whether or not the Be application and looper are active or not */
static int SDL_BeAppActive = 0;
static SDL_Thread *SDL_AppThread = NULL;
SDL_BLooper *SDL_Looper = NULL;
/* Default application signature */
const char *signature = "application/x-SDL-executable";
const char *SDL_signature = "application/x-SDL-executable";
static int
StartBeApp(void *unused)
/* Create a descendant of BApplication */
class SDL_BApp : public BApplication {
public:
SDL_BApp(const char* signature) :
BApplication(signature) {
}
virtual ~SDL_BApp() {
}
virtual void RefsReceived(BMessage* message) {
entry_ref entryRef;
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
BPath referencePath = BPath(&entryRef);
SDL_SendDropFile(NULL, referencePath.Path());
}
return;
}
};
static int StartBeApp(void *unused)
{
BApplication *App;
@ -65,48 +90,61 @@ StartBeApp(void *unused)
BAppFileInfo app_info(&f);
if (app_info.InitCheck() == B_OK) {
char sig[B_MIME_TYPE_LENGTH];
if (app_info.GetSignature(sig) == B_OK)
signature = strndup(sig, B_MIME_TYPE_LENGTH);
if (app_info.GetSignature(sig) == B_OK) {
SDL_signature = strndup(sig, B_MIME_TYPE_LENGTH);
}
}
}
}
App = new SDL_BApp(signature);
App = new SDL_BApp(SDL_signature);
App->Run();
delete App;
return (0);
return 0;
}
/* Initialize the Be Application, if it's not already started */
int
SDL_InitBeApp(void)
static int StartBeLooper()
{
/* Create the BApplication that handles appserver interaction */
if (SDL_BeAppActive <= 0) {
if (!be_app) {
SDL_AppThread = SDL_CreateThreadInternal(StartBeApp, "SDLApplication", 0, NULL);
if (SDL_AppThread == NULL) {
return SDL_SetError("Couldn't create BApplication thread");
}
/* Change working directory to that of executable */
app_info info;
if (B_OK == be_app->GetAppInfo(&info)) {
entry_ref ref = info.ref;
BEntry entry;
if (B_OK == entry.SetTo(&ref)) {
BPath path;
if (B_OK == path.SetTo(&entry)) {
if (B_OK == path.GetParent(&path)) {
chdir(path.Path());
}
}
}
}
do {
SDL_Delay(10);
} while ((be_app == NULL) || be_app->IsLaunching());
}
/* Change working directory to that of executable */
app_info info;
if (B_OK == be_app->GetAppInfo(&info)) {
entry_ref ref = info.ref;
BEntry entry;
if (B_OK == entry.SetTo(&ref)) {
BPath path;
if (B_OK == path.SetTo(&entry)) {
if (B_OK == path.GetParent(&path)) {
chdir(path.Path());
}
}
}
}
SDL_Looper = new SDL_BLooper("SDLLooper");
SDL_Looper->Run();
return (0);
}
/* Initialize the Be Application, if it's not already started */
int SDL_InitBeApp(void)
{
/* Create the BApplication that handles appserver interaction */
if (SDL_BeAppActive <= 0) {
StartBeLooper();
/* Mark the application active */
SDL_BeAppActive = 0;
@ -116,18 +154,20 @@ SDL_InitBeApp(void)
++SDL_BeAppActive;
/* The app is running, and we're ready to go */
return (0);
return 0;
}
/* Quit the Be Application, if there's nothing left to do */
void
SDL_QuitBeApp(void)
void SDL_QuitBeApp(void)
{
/* Decrement the application reference count */
--SDL_BeAppActive;
/* If the reference count reached zero, clean up the app */
if (SDL_BeAppActive == 0) {
SDL_Looper->Lock();
SDL_Looper->Quit();
SDL_Looper = NULL;
if (SDL_AppThread != NULL) {
if (be_app != NULL) { /* Not tested */
be_app->PostMessage(B_QUIT_REQUESTED);
@ -144,10 +184,10 @@ SDL_QuitBeApp(void)
#endif
/* SDL_BApp functions */
void SDL_BApp::ClearID(SDL_BWin *bwin) {
void SDL_BLooper::ClearID(SDL_BWin *bwin) {
_SetSDLWindow(NULL, bwin->GetID());
int32 i = _GetNumWindowSlots() - 1;
while(i >= 0 && GetSDLWindow(i) == NULL) {
while (i >= 0 && GetSDLWindow(i) == NULL) {
_PopBackWindow();
--i;
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -32,7 +32,7 @@ extern int SDL_InitBeApp(void);
extern void SDL_QuitBeApp(void);
/* Be Application Signature*/
extern const char *signature;
extern const char *SDL_signature;
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,61 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifdef __3DS__
#include "SDL_main.h"
#include <3ds.h>
#ifdef main
#undef main
#endif
SDL_FORCE_INLINE void N3DS_Init(void);
SDL_FORCE_INLINE void N3DS_Quit(void);
int main(int argc, char *argv[])
{
int result;
N3DS_Init();
SDL_SetMainReady();
result = SDL_main(argc, argv);
N3DS_Quit();
return result;
}
SDL_FORCE_INLINE void
N3DS_Init(void)
{
osSetSpeedupEnable(true);
romfsInit();
}
SDL_FORCE_INLINE void
N3DS_Quit(void)
{
romfsExit();
}
#endif /* __3DS__ */
/* vi: set sts=4 ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -33,20 +33,19 @@
extern void NACL_SetScreenResolution(int width, int height, Uint32 format);
int
nacl_main(int argc, char *argv[])
int nacl_main(int argc, char *argv[])
{
int status;
PSEvent* ps_event;
PP_Resource event;
PP_Resource event;
struct PP_Rect rect;
int ready = 0;
const PPB_View *ppb_view = PSInterfaceView();
/* This is started in a worker thread by ppapi_simple! */
/* Wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before starting the app */
PSEventSetFilter(PSE_INSTANCE_DIDCHANGEVIEW);
while (!ready) {
/* Process all waiting events without blocking */
@ -65,13 +64,13 @@ nacl_main(int argc, char *argv[])
PSEventRelease(ps_event);
}
}
/* Do a default httpfs mount on /,
* apps can override this by unmounting /
/* Do a default httpfs mount on /,
* apps can override this by unmounting /
* and remounting with the desired configuration
*/
nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface);
umount("/");
mount(
"", /* source */
@ -79,7 +78,7 @@ nacl_main(int argc, char *argv[])
"httpfs", /* filesystemtype */
0, /* mountflags */
""); /* data specific to the html5fs type */
/* Everything is ready, start the user main function */
SDL_SetMainReady();
status = SDL_main(argc, argv);

View file

@ -23,17 +23,17 @@ extern "C" int main(int argc, char *argv[]);
TInt E32Main()
{
/* Get the clean-up stack */
CTrapCleanup* cleanup = CTrapCleanup::New();
CTrapCleanup *cleanup = CTrapCleanup::New();
/* Arrange for multi-threaded operation */
SpawnPosixServerThread();
/* Get args and environment */
int argc = 0;
char** argv = 0;
char** envp = 0;
int argc = 0;
char **argv = 0;
char **envp = 0;
__crt0(argc,argv,envp);
__crt0(argc, argv, envp);
/* Start the application! */
@ -42,29 +42,26 @@ TInt E32Main()
/* Set process and thread priority and name */
RThread currentThread;
RThread currentThread;
RProcess thisProcess;
TParse exeName;
TParse exeName;
exeName.Set(thisProcess.FileName(), NULL, NULL);
currentThread.Rename(exeName.Name());
currentThread.SetProcessPriority(EPriorityLow);
currentThread.SetPriority(EPriorityMuchLess);
/* Increase heap size */
RHeap* newHeap = NULL;
RHeap* oldHeap = NULL;
TInt heapSize = 7500000;
int ret;
RHeap *newHeap = NULL;
RHeap *oldHeap = NULL;
TInt heapSize = 7500000;
int ret;
newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy);
if (NULL == newHeap)
{
if (newHeap == NULL) {
ret = 3;
goto cleanup;
}
else
{
} else {
oldHeap = User::SwitchHeap(newHeap);
/* Call stdlib main */
SDL_SetMainReady();

View file

@ -0,0 +1,74 @@
/*
SDL_ps2_main.c, fjtrujy@gmail.com
*/
#include "SDL_config.h"
#ifdef __PS2__
#include "SDL_main.h"
#include "SDL_error.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <kernel.h>
#include <sifrpc.h>
#include <iopcontrol.h>
#include <sbv_patches.h>
#include <ps2_filesystem_driver.h>
#ifdef main
#undef main
#endif
__attribute__((weak)) void reset_IOP()
{
SifInitRpc(0);
while (!SifIopReset(NULL, 0)) {
}
while (!SifIopSync()) {
}
}
static void prepare_IOP()
{
reset_IOP();
SifInitRpc(0);
sbv_patch_enable_lmb();
sbv_patch_disable_prefix_check();
sbv_patch_fileio();
}
static void init_drivers()
{
init_ps2_filesystem_driver();
}
static void deinit_drivers()
{
deinit_ps2_filesystem_driver();
}
int main(int argc, char *argv[])
{
int res;
char cwd[FILENAME_MAX];
prepare_IOP();
init_drivers();
getcwd(cwd, sizeof(cwd));
waitUntilDeviceIsReady(cwd);
res = SDL_main(argc, argv);
deinit_drivers();
return res;
}
#endif /* _PS2 */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -10,7 +10,7 @@
#include <pspthreadman.h>
#ifdef main
#undef main
#undef main
#endif
/* If application's main() is redefined as SDL_main, and libSDLmain is
@ -36,7 +36,7 @@ int sdl_psp_callback_thread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback",
sdl_psp_exit_callback, NULL);
sdl_psp_exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
@ -46,9 +46,10 @@ int sdl_psp_setup_callbacks(void)
{
int thid;
thid = sceKernelCreateThread("update_thread",
sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0);
if (thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}

View file

@ -5,16 +5,19 @@
/* Include the SDL main definition header */
#include "SDL_main.h"
#if defined(__IPHONEOS__) || defined(__TVOS__)
#ifndef SDL_MAIN_HANDLED
#ifdef main
#undef main
#endif
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
return SDL_UIKitRunApp(argc, argv, SDL_main);
}
#endif /* !SDL_MAIN_HANDLED */
#endif /* __IPHONEOS__ || __TVOS__ */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -16,12 +16,11 @@
#include "SDL_main.h"
#ifdef main
# undef main
#undef main
#endif /* main */
/* Pop up an out of memory message, returns to Windows */
static BOOL
OutOfMemory(void)
static BOOL OutOfMemory(void)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL);
return FALSE;
@ -29,16 +28,15 @@ OutOfMemory(void)
#if defined(_MSC_VER)
/* The VC++ compiler needs main/wmain defined */
# define console_ansi_main main
# if UNICODE
# define console_wmain wmain
# endif
#define console_ansi_main main
#if UNICODE
#define console_wmain wmain
#endif
#endif
/* Gets the arguments with GetCommandLine, converts them to argc and argv
and calls SDL_main */
static int
main_getcmdline(void)
static int main_getcmdline(void)
{
LPWSTR *argvw;
char **argv;
@ -56,21 +54,21 @@ main_getcmdline(void)
/* Parse it into argv and argc */
argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv));
if (!argv) {
if (argv == NULL) {
return OutOfMemory();
}
for (i = 0; i < argc; ++i) {
DWORD len;
char *arg = WIN_StringToUTF8W(argvw[i]);
if (!arg) {
if (arg == NULL) {
return OutOfMemory();
}
len = (DWORD)SDL_strlen(arg);
argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1);
argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (size_t)len + 1);
if (!argv[i]) {
return OutOfMemory();
}
CopyMemory(argv[i], arg, len);
SDL_memcpy(argv[i], arg, len);
SDL_free(arg);
}
argv[i] = NULL;
@ -91,17 +89,14 @@ main_getcmdline(void)
}
/* This is where execution begins [console apps, ansi] */
int
console_ansi_main(int argc, char *argv[])
int console_ansi_main(int argc, char *argv[])
{
return main_getcmdline();
}
#if UNICODE
/* This is where execution begins [console apps, unicode] */
int
console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
int console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
{
return main_getcmdline();
}
@ -109,7 +104,7 @@ console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
/* This is where execution begins [windowed apps] */
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) /* NOLINT(readability-inconsistent-declaration-parameter-name) */
{
return main_getcmdline();
}

View file

@ -1,4 +1,4 @@
// This file is public domain. Do what you like with it.
#include "winresrc.h"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,23,0,0
PRODUCTVERSION 2,23,0,0
FILEVERSION 2,28,1,0
PRODUCTVERSION 2,28,1,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 23, 0, 0\0"
VALUE "FileVersion", "2, 28, 1, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2022 Sam Lantinga\0"
VALUE "LegalCopyright", "Copyright (C) 2023 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 23, 0, 0\0"
VALUE "ProductVersion", "2, 28, 1, 0\0"
END
END
BLOCK "VarFileInfo"

View file

@ -40,7 +40,7 @@
is compiled with C++/CX enabled (via the /ZW compiler flag).
*/
#ifdef _MSC_VER
#pragma warning(disable:4447)
#pragma warning(disable : 4447)
#endif
/* Make sure the function to initialize the Windows Runtime gets linked in. */