Beispiel #1
0
static void InitBannerFrame( void )
{
	if( !banner_local.flags.bInited )
	{
		TEXTCHAR font[256];
		InvokeDeadstart(); // register my control please... (f*****g optimizations)
		banner_local.pii = GetImageInterface();
		banner_local.pdi = GetDisplayInterface();

		banner_local.flags.bFullDraw = RequiresDrawAll();

		GetDisplaySizeEx( 0, NULL, NULL, &banner_local.w, &banner_local.h );
#ifndef __NO_OPTIONS__
		SACK_GetProfileStringEx( WIDE( "SACK/Widgets/Banner2" ), WIDE( "Default Font" ), WIDE( "arialbd.ttf" ), font, sizeof( font ), TRUE );
#else
		StrCpy( font, WIDE( "arialbd.ttf" ) );
#endif
		banner_local.font = RenderFontFile( font
													 , banner_local.w / 30, ( ( banner_local.w * 1080 ) / 1920 ) / 20
									  , 2 );
		if( !banner_local.font )
		{
#ifndef __NO_OPTIONS__
			SACK_GetProfileStringEx( WIDE( "SACK/Widgets/Banner2" ), WIDE( "Alternate Font" ), WIDE( "fonts/arialbd.ttf" ), font, sizeof( font ), TRUE );
#else
			StrCpy( font, WIDE( "fonts/arialbd.ttf" ) );
#endif
			banner_local.font = RenderFontFile( font
										  , banner_local.w / 30, ( ( banner_local.w * 1080 ) / 1920 ) / 20
														 , 2 );
		}

		banner_local.explorer_font = RenderFontFile( font
									  , banner_local.w / 60, ( ( banner_local.w * 1080 ) / 1920 ) / 40
									  , 2 );
		banner_local.flags.bInited = TRUE;
	}
}
Beispiel #2
0
void* BeginNormalProcess( void*param )
{
	engine.wait_for_startup = 0;
	sched_yield();
	LOGI( "BeginNormalProcess: %d %d %d  %d %p %p", engine.state.restarting, engine.state.closed, engine.state.opened, engine.wait_for_startup, myname, BeginNormalProcess );
	while( !engine.data_path )
      sched_yield();
	if( !engine.state.restarting && !myname )
	{
		if( findself() )
		{
			do
			{
            char buf[256];
				void (*InvokeDeadstart)(void );
				void (*MarkRootDeadstartComplete)(void );
				const char * filepath = engine.data_path;//malloc( 256 );
				//snprintf( filepath, 256, "/data/data/%s/files", engine.data_path );
				LOGI( "my path [%s][%s][%s]", filepath, mypath, myname );
				if( chdir( filepath ) )
				//if( chdir( "../files" ) )
				{
					LOGI( "path change failed to [%s]", mypath );
					if( mkdir( filepath /*"../files"*/, 0700 ) )
					{
						LOGI( "path change failed to [%s]", mypath );
					}
					chdir( filepath );
				}
				getcwd( buf, 256 );
				LOGI( "ended up in directory:%s", buf );

				{
					FILE *assets_saved = fopen( "assets.exported", "rb" );
					if( !assets_saved )
					{
						ExportAssets();
						assets_saved = fopen( "assets.exported", "wb" );
					}
               fclose( assets_saved );
				}
// do not auto load libraries
#ifndef BUILD_PORTABLE_EXECUTABLE
				LoadLibrary( mypath, "libbag.externals.so" );
				{
					void *lib;
					void (*RunExits)(void );
					lib = LoadLibrary( mypath, "libbag.so" );
					RunExits = dlsym( lib, "RunExits" );
					if( RunExits )
						atexit( RunExits );
					else
						LOGI( "Failed to get symbol RunExits:%s", dlerror() );
					InvokeDeadstart = dlsym( lib, "InvokeDeadstart" );
					if( !InvokeDeadstart )
						LOGI( "Failed to get InvokeDeadstart entry" );
					MarkRootDeadstartComplete = dlsym( lib, "MarkRootDeadstartComplete" );
					if( !MarkRootDeadstartComplete )
						LOGI( "Failed to get MarkRootDeadstartComplete entry" );
					{
						void (*f)(char*);
						f = dlsym( lib, "SACKSystemSetProgramPath" );
						f( mypath );
						f = dlsym( lib, "SACKSystemSetProgramName" );
						f( myname );
						f = dlsym( lib, "SACKSystemSetWorkingPath" );
						f( buf );
					}
				}
				LoadLibrary( mypath, "libbag.psi.so" );
#endif
				{
					void *lib;
					snprintf( buf, 256, "%s.code.so", myname );
					//LOGI( "Load library... %s", buf );
					lib = LoadLibrary( mypath, buf );
					// assume we need to init this; it's probably a portable target
					if( !InvokeDeadstart )
					{
						// this normally comes from bag; but a static/portable application may have it linked as part of its code
						InvokeDeadstart = dlsym( lib, "InvokeDeadstart" );
						{
							void (*f)(char*);
							f = dlsym( lib, "SACKSystemSetProgramPath" );
							f( mypath );
							f = dlsym( lib, "SACKSystemSetProgramName" );
							f( myname );
							f = dlsym( lib, "SACKSystemSetWorkingPath" );
							f( buf );
						}
						MarkRootDeadstartComplete = dlsym( lib, "MarkRootDeadstartComplete" );
					}

               VideoPlayer_PlayMedia = dlsym( lib, "VideoPlayer_PlayMedia" );
					SACK_Main = dlsym( lib, "SACK_Main" );
					if( !SACK_Main )
					{
						// allow normal main fail processing
						break;
					}
					//LOGI( "Invoke Deadstart..." );
					InvokeDeadstart();
					//LOGI( "Deadstart Completed..." );
					MarkRootDeadstartComplete();

					// somehow these will be loaded
					// but we don't know where, but it's pretty safe to assume the names are unique, or
					// first-come-first-serve is appropriate
					BagVidlibPureglSetNativeWindowHandle = (void (*)(NativeWindowType ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SetNativeWindowHandle" );
					if( !BagVidlibPureglSetNativeWindowHandle )
						LOGI( "Failed to get SetNativeWindowHandle:%s", dlerror() );

					BagVidlibPureglSetKeyboardMetric = (void (*)(int ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SetKeyboardMetric" );
					BagVidlibPureglFirstRender = (void (*)(void ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_DoFirstRender" );
					//if( !BagVidlibPureglFirstRender )
					//	LOGI( "Failed to get BagVidlibPureglFirstRender:%s", dlerror() );

					BagVidlibPureglRenderPass = (int (*)(void ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_DoRenderPass" );
					//if( !BagVidlibPureglRenderPass )
					//	LOGI( "Failed to get DoRenderPass:%s", dlerror() );

					BagVidlibPureglOpenCameras = (void (*)(void ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_OpenCameras" );
					if( !BagVidlibPureglOpenCameras )
						LOGI( "Failed to get OpenCameras:%s", dlerror() );

					BagVidlibPureglSendKeyEvents = (int(*)(int,int,int))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SendKeyEvents" );
					BagVidlibPureglSendTouchEvents = (void (*)(int,PINPUT_POINT ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SendTouchEvents" );
					BagVidlibPureglCloseDisplay = (void(*)(void))dlsym( RTLD_DEFAULT, "SACK_Vidlib_CloseDisplay" );
					BagVidlibPureglSurfaceLost = (void(*)(void))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SurfaceLost" );  // egl event
					BagVidlibPureglSurfaceGained = (void(*)(NativeWindowType))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SurfaceGained" );  // egl event

					BagVidlibPureglPauseDisplay = (void(*)(void))dlsym( RTLD_DEFAULT,"SACK_Vidlib_PauseDisplay" );
					BagVidlibPureglResumeDisplay = (void(*)(void))dlsym( RTLD_DEFAULT,"SACK_Vidlib_ResumeDisplay" );

					BagVidlibPureglSetTriggerKeyboard = (void(*)(void(*)(void),void(*)(void),int(*get_status_metric)(void)
																			  ,int(*get_keyboard_metric)(void)
																			  ,char*(*get_key_text)(void)
																			  ))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SetTriggerKeyboard" );
					if( BagVidlibPureglSetTriggerKeyboard )
						BagVidlibPureglSetTriggerKeyboard( show_keyboard, hide_keyboard, AndroidGetStatusMetric, AndroidGetKeyboardMetric, AndroidGetCurrentKeyText );

					BagVidlibPureglSetAnimationWake = (void(*)(void(*)(void)))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SetAnimationWake" );
					if( BagVidlibPureglSetAnimationWake )
						BagVidlibPureglSetAnimationWake( wake_animation );

					BagVidlibPureglSetSleepSuspend = (void(*)(void(*)(int)))dlsym( RTLD_DEFAULT, "SACK_Vidlib_SetSleepSuspend" );
					if( BagVidlibPureglSetSleepSuspend )
						BagVidlibPureglSetSleepSuspend( SuspendSleep );

					// shouldn't need this shortly; was more about doing things my way than the android way
					//engine.wait_for_display_init = 1;
					engine.wait_for_startup = 0;
 					// resume other threads so potentially the display is the next thing initialized.
					//while( engine.wait_for_display_init )
					sched_yield();
					//break;
				}
			}
			while( 0 );
		}
		else if( !myname )
		{
			LOGI( "Failed to open procself" );
			myname = "Reading /proc/self/maps failed";
		}
	}
	else
		engine.wait_for_startup = 0;

	if( !SACK_Main )
	{
		LOGI( "(still)Failed to get SACK_Main entry point; I am [%s]", myname );
		return 0;
	}
	LOGI( "Start Application..." );
	if( engine.app->pendingWindow && BagVidlibPureglSetNativeWindowHandle )
		BagVidlibPureglSetNativeWindowHandle( engine.app->pendingWindow );
	if( engine.resumed )
	{
		if( BagVidlibPureglResumeDisplay )
			BagVidlibPureglResumeDisplay();
      engine.state.animating = 1;
		android_app_write_cmd( engine.app, APP_CMD_WAKE);
	}
	SACK_Main( 0, NULL );
	engine.state.closed = 1;
	LOGI( "Main exited... and so should we all..." );
	return NULL;
}