Fix SDL2main on PSP (#5076)

- Fix SDL2main on PSP
  SDL2main was not working for PSP, because it wasn't being activated and
  it wasn't unsetting the main. Besides that a debug screen being started
  was causing issues with joystick input and the sceKernelExitGame calli
  is no longer needed with the current PSPDEV SDK.
- Clean up imports in PSP main
- Set PSP GPU and user modes in main
- Fix exit callback in PSP main
This commit is contained in:
Wouter Wijsman 2021-12-07 16:43:50 +01:00 committed by GitHub
parent 2d673e5b56
commit da5dbb4763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View File

@ -83,6 +83,15 @@
*/
#define SDL_MAIN_NEEDED
#elif defined(__PSP__)
/* On PSP SDL provides a main function that sets the module info,
activates the GPU and starts the thread required to be able to exit
the software.
If you provide this yourself, you may define SDL_MAIN_HANDLED
*/
#define SDL_MAIN_AVAILABLE
#endif
#endif /* SDL_MAIN_HANDLED */

View File

@ -7,11 +7,12 @@
#include "SDL_main.h"
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspthreadman.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef main
#undef main
#endif
/* If application's main() is redefined as SDL_main, and libSDLmain is
linked, then this file will create the standard exit callback,
@ -23,11 +24,12 @@
PSP_MAIN_THREAD_STACK_SIZE, etc.
*/
PSP_MODULE_INFO("SDL App", 0, 1, 1);
PSP_MODULE_INFO("SDL App", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU | THREAD_ATTR_USER);
int sdl_psp_exit_callback(int arg1, int arg2, void *common)
{
exit(0);
sceKernelExitGame();
return 0;
}
@ -53,12 +55,8 @@ int sdl_psp_setup_callbacks(void)
int main(int argc, char *argv[])
{
pspDebugScreenInit();
sdl_psp_setup_callbacks();
/* Register sceKernelExitGame() to be called when we exit */
atexit(sceKernelExitGame);
SDL_SetMainReady();
(void)SDL_main(argc, argv);