33
33
#include <coreinit/dynload.h>
34
34
#include <coreinit/ios.h>
35
35
#include <coreinit/foreground.h>
36
+ #include <coreinit/memory.h>
36
37
#include <coreinit/time.h>
37
38
#include <coreinit/title.h>
38
39
#include <proc_ui/procui.h>
40
+ #include <proc_ui/memory.h>
39
41
#include <padscore/wpad.h>
40
42
#include <padscore/kpad.h>
41
43
#include <sysapp/launch.h>
@@ -228,6 +230,25 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content)
228
230
return 0 ;
229
231
}
230
232
233
+ static bool check_proc () {
234
+ switch (ProcUIProcessMessages (true)) {
235
+ case PROCUI_STATUS_EXITING : {
236
+ return false;
237
+ }
238
+ case PROCUI_STATUS_RELEASE_FOREGROUND : {
239
+ ProcUIDrawDoneRelease ();
240
+ break ;
241
+ }
242
+ case PROCUI_STATUS_IN_FOREGROUND : {
243
+ break ;
244
+ }
245
+ case PROCUI_STATUS_IN_BACKGROUND :
246
+ default :
247
+ break ;
248
+ }
249
+ return true;
250
+ }
251
+
231
252
static void frontend_wiiu_exec (const char * path , bool should_load_content )
232
253
{
233
254
/* goal: make one big buffer with all the argv's, seperated by NUL. we can
@@ -317,6 +338,13 @@ static void frontend_wiiu_exec(const char *path, bool should_load_content)
317
338
318
339
in_exec = true;
319
340
341
+ if (!should_load_content ) {
342
+ SYSLaunchMenu ();
343
+ }
344
+ while (check_proc ()) {
345
+
346
+ }
347
+
320
348
cleanup :
321
349
free (argv_buf );
322
350
argv_buf = NULL ;
@@ -451,7 +479,7 @@ int main(int argc, char **argv)
451
479
static void main_setup (void )
452
480
{
453
481
memoryInitialize ();
454
- init_os_exceptions ();
482
+ // init_os_exceptions();
455
483
init_logging ();
456
484
init_filesystems ();
457
485
init_pad_libraries ();
@@ -464,35 +492,16 @@ static void main_teardown(void)
464
492
deinit_pad_libraries ();
465
493
deinit_filesystems ();
466
494
deinit_logging ();
467
- deinit_os_exceptions ();
495
+ // deinit_os_exceptions();
468
496
memoryRelease ();
469
497
}
470
498
471
- // https://github.com/devkitPro/wut/blob/7d9fa9e416bffbcd747f1a8e5701fd6342f9bc3d/libraries/libwhb/src/proc.c
472
-
473
- #define HBL_TITLE_ID (0x0005000013374842)
474
- #define MII_MAKER_JPN_TITLE_ID (0x000500101004A000)
475
- #define MII_MAKER_USA_TITLE_ID (0x000500101004A100)
476
- #define MII_MAKER_EUR_TITLE_ID (0x000500101004A200)
477
-
478
- static bool in_hbl = false;
479
499
static bool in_aroma = false;
500
+ static void * procui_mem1Storage = NULL ;
501
+ static void * procui_bucketStorage = NULL ;
480
502
481
503
static void proc_setup (void )
482
504
{
483
- uint64_t titleID = OSGetTitleID ();
484
-
485
- // Homebrew Launcher does not like the standard ProcUI application loop, sad!
486
- if (titleID == HBL_TITLE_ID ||
487
- titleID == MII_MAKER_JPN_TITLE_ID ||
488
- titleID == MII_MAKER_USA_TITLE_ID ||
489
- titleID == MII_MAKER_EUR_TITLE_ID )
490
- {
491
- // Important: OSEnableHomeButtonMenu must come before ProcUIInitEx.
492
- OSEnableHomeButtonMenu (FALSE);
493
- in_hbl = TRUE;
494
- }
495
-
496
505
/* Detect Aroma explicitly (it's possible to run under H&S while using Tiramisu) */
497
506
OSDynLoad_Module rpxModule ;
498
507
if (OSDynLoad_Acquire ("homebrew_rpx_loader" , & rpxModule ) == OS_DYNLOAD_OK )
@@ -502,33 +511,33 @@ static void proc_setup(void)
502
511
}
503
512
504
513
ProcUIInit (& proc_save_callback );
514
+
515
+ uint32_t addr = 0 ;
516
+ uint32_t size = 0 ;
517
+ if (OSGetMemBound (OS_MEM1 , & addr , & size ) == 0 ) {
518
+ procui_mem1Storage = malloc (size );
519
+ if (procui_mem1Storage ) {
520
+ ProcUISetMEM1Storage (procui_mem1Storage , size );
521
+ }
522
+ }
523
+ if (OSGetForegroundBucketFreeArea (& addr , & size )) {
524
+ procui_bucketStorage = malloc (size );
525
+ if (procui_bucketStorage ) {
526
+ ProcUISetBucketStorage (procui_bucketStorage , size );
527
+ }
528
+ }
505
529
}
506
530
507
531
static void proc_exit (void )
508
532
{
509
- /* If we're doing a normal exit while running under HBL, we must SYSRelaunchTitle.
510
- * If we're in an exec (i.e. launching mocha homebrew wrapper) we must *not* do that. yay! */
511
- if (in_hbl && !in_exec )
512
- SYSRelaunchTitle (0 , NULL );
513
-
514
- /* Similar deal for Aroma, but exit to menu. */
515
- if (!in_hbl && !in_exec )
516
- SYSLaunchMenu ();
517
-
518
- /* Now just tell the OS that we really are ok to exit */
519
- if (!ProcUIInShutdown ())
520
- {
521
- for (;;)
522
- {
523
- ProcUIStatus status ;
524
- status = ProcUIProcessMessages (TRUE);
525
- if (status == PROCUI_STATUS_EXITING )
526
- break ;
527
- else if (status == PROCUI_STATUS_RELEASE_FOREGROUND )
528
- ProcUIDrawDoneRelease ();
529
- }
533
+ if (procui_mem1Storage ) {
534
+ free (procui_mem1Storage );
535
+ procui_mem1Storage = NULL ;
536
+ }
537
+ if (procui_bucketStorage ) {
538
+ free (procui_bucketStorage );
539
+ procui_bucketStorage = NULL ;
530
540
}
531
-
532
541
ProcUIShutdown ();
533
542
}
534
543
@@ -600,7 +609,10 @@ static void main_loop(void)
600
609
OSTime start_time ;
601
610
int status ;
602
611
603
- for (;;)
612
+ bool home_menu_allowed = true;
613
+ OSEnableHomeButtonMenu (TRUE);
614
+
615
+ while (check_proc ())
604
616
{
605
617
if (video_driver_get_ptr ())
606
618
{
@@ -612,8 +624,22 @@ static void main_loop(void)
612
624
613
625
status = runloop_iterate ();
614
626
615
- if (status == -1 )
627
+ // TODO: make this less ugly...
628
+ if ((runloop_get_flags () & RUNLOOP_FLAG_CORE_RUNNING )) {
629
+ if (home_menu_allowed ) {
630
+ OSEnableHomeButtonMenu (FALSE);
631
+ home_menu_allowed = false;
632
+ }
633
+ } else {
634
+ if (!home_menu_allowed ) {
635
+ OSEnableHomeButtonMenu (TRUE);
636
+ home_menu_allowed = true;
637
+ }
638
+ }
639
+
640
+ if (status == -1 ) {
616
641
break ;
642
+ }
617
643
}
618
644
}
619
645
#endif
0 commit comments