Browse Source

engine: platform: psvita: added developer mode button to launcher

pull/2/head
SNMetamorph 2 years ago committed by Alibek Omarov
parent
commit
e3103249f4
  1. 6
      engine/common/launcher.c
  2. 1
      engine/platform/platform.h
  3. 9
      engine/platform/psvita/sce_sys/livearea/contents/template.xml
  4. 61
      engine/platform/psvita/sys_psvita.c

6
engine/common/launcher.c

@ -91,9 +91,13 @@ _inline int Sys_Start( void )
#if !XASH_WIN32 #if !XASH_WIN32
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
#if XASH_PSVITA
// inject -dev -console into args if required
szArgc = PSVita_GetArgv( argc, argv, &szArgv );
#else
szArgc = argc; szArgc = argc;
szArgv = argv; szArgv = argv;
#endif // XASH_PSVITA
return Sys_Start(); return Sys_Start();
} }
#else #else

1
engine/platform/platform.h

@ -60,6 +60,7 @@ void NSwitch_Shutdown( void );
void PSVita_Init( void ); void PSVita_Init( void );
void PSVita_Shutdown( void ); void PSVita_Shutdown( void );
qboolean PSVita_GetBasePath( char *buf, const size_t buflen ); qboolean PSVita_GetBasePath( char *buf, const size_t buflen );
int PSVita_GetArgv( int in_argc, char **in_argv, char ***out_argv );
void PSVita_InputUpdate( void ); void PSVita_InputUpdate( void );
#endif #endif

9
engine/platform/psvita/sce_sys/livearea/contents/template.xml

@ -8,4 +8,13 @@
<gate> <gate>
<startup-image>startup.png</startup-image> <startup-image>startup.png</startup-image>
</gate> </gate>
<frame id="frame3">
<liveitem>
<target>psla:dev</target>
<text>
<str>Developer mode</str>
</text>
</liveitem>
</frame>
</livearea> </livearea>

61
engine/platform/psvita/sys_psvita.c

@ -24,6 +24,7 @@ GNU General Public License for more details.
#include <vrtld.h> #include <vrtld.h>
#define DATA_PATH "data/xash3d" #define DATA_PATH "data/xash3d"
#define MAX_ARGV 5 // "" -log -dev X NULL
// 200MB libc heap, 512K main thread stack, 40MB for loading game DLLs // 200MB libc heap, 512K main thread stack, 40MB for loading game DLLs
// the rest goes to vitaGL // the rest goes to vitaGL
@ -75,17 +76,73 @@ const size_t __vrtld_num_exports = sizeof( aux_exports ) / sizeof( *aux_exports
/* end of export crap */ /* end of export crap */
static const char *PSVita_GetLaunchParameter( char *outbuf )
{
SceAppUtilAppEventParam param;
memset( &param, 0, sizeof( param ) );
sceAppUtilReceiveAppEvent( &param );
if( param.type == 0x05 )
{
sceAppUtilAppEventParseLiveArea( &param, outbuf );
return outbuf;
}
return NULL;
}
void Platform_ShellExecute( const char *path, const char *parms ) void Platform_ShellExecute( const char *path, const char *parms )
{ {
Con_Reportf( S_WARN "Tried to shell execute ;%s; -- not supported\n", path ); Con_Reportf( S_WARN "Tried to shell execute ;%s; -- not supported\n", path );
} }
/*
===========
PSVita_GetArgv
On the PS Vita under normal circumstances argv is empty, so we'll construct our own
based on which button the user pressed in the LiveArea launcher.
===========
*/
int PSVita_GetArgv( int in_argc, char **in_argv, char ***out_argv )
{
static const char *fake_argv[MAX_ARGV] = { "app0:/eboot.bin", NULL };
int fake_argc = 1;
char tmp[2048] = { 0 };
SceAppUtilInitParam initParam = { 0 };
SceAppUtilBootParam bootParam = { 0 };
// on the Vita under normal circumstances argv is empty, unless we're launching from Change Game
sceAppUtilInit( &initParam, &bootParam );
if( in_argc > 1 )
{
// probably coming from Change Game, in which case we just need to keep the old args
*out_argv = in_argv;
return in_argc;
}
// got empty args, which means that we're probably coming from LiveArea
// construct argv based on which button the user pressed in the LiveArea launcher
if( PSVita_GetLaunchParameter( tmp ))
{
if( !Q_strcmp( tmp, "dev" ))
{
// user hit the "Developer Mode" button, inject "-log" and "-dev" arguments
fake_argv[fake_argc++] = "-log";
fake_argv[fake_argc++] = "-dev";
fake_argv[fake_argc++] = "2";
}
}
*out_argv = (char **)fake_argv;
return fake_argc;
}
void PSVita_Init( void ) void PSVita_Init( void )
{ {
char xashdir[1024] = { 0 }; char xashdir[1024] = { 0 };
// cd to the base dir immediately for library loading to work // cd to the base dir immediately for library loading to work
if ( PSVita_GetBasePath( xashdir, sizeof( xashdir ) ) ) if( PSVita_GetBasePath( xashdir, sizeof( xashdir )))
{ {
chdir( xashdir ); chdir( xashdir );
} }
@ -97,7 +154,7 @@ void PSVita_Init( void )
scePowerSetGpuXbarClockFrequency( 166 ); scePowerSetGpuXbarClockFrequency( 166 );
sceSysmoduleLoadModule( SCE_SYSMODULE_NET ); sceSysmoduleLoadModule( SCE_SYSMODULE_NET );
if ( vrtld_init( 0 ) < 0 ) if( vrtld_init( 0 ) < 0 )
{ {
Sys_Error( "Could not init vrtld: %s\n", vrtld_dlerror( ) ); Sys_Error( "Could not init vrtld: %s\n", vrtld_dlerror( ) );
} }

Loading…
Cancel
Save