From 152a35882ede8d6155f1d918258faa8335d0b3b8 Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Thu, 23 May 2024 11:10:14 -0400 Subject: [PATCH] add reboot option to menu --- channel/channelapp/source/m_main.c | 16 ++++++++++------ channel/channelapp/source/main.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/channel/channelapp/source/m_main.c b/channel/channelapp/source/m_main.c index 93c888a..c264aa0 100644 --- a/channel/channelapp/source/m_main.c +++ b/channel/channelapp/source/m_main.c @@ -84,10 +84,11 @@ void m_main_theme_reinit(void) { for (i = 0; i < v_m_main->widget_count; ++i) widget_free(&v_m_main->widgets[i]); - if (bootmii_ios) + // Chances are BootMii will be installed - otherwise, this will be enough room anyways for a 'Reboot' option. + // if (bootmii_ios) yadd = 16; - else - yadd = 32; + // else + // yadd = 32; x = (view_width - theme_gfx[THEME_BUTTON]->w) / 2; y = 80; @@ -106,16 +107,19 @@ void m_main_theme_reinit(void) { widget_button (&v_m_main->widgets[3], x, y, 0, BTN_NORMAL, _("Exit to System Menu")); y += theme_gfx[THEME_BUTTON]->h + yadd; - widget_button (&v_m_main->widgets[4], x, y, 0, BTN_NORMAL, _("Shutdown")); + widget_button (&v_m_main->widgets[4], x, y, 0, BTN_NORMAL, _("Reboot")); + y += theme_gfx[THEME_BUTTON]->h + yadd; - widget_label (&v_m_main->widgets[5], view_width / 3 * 2 - 16, 32, 0, + widget_button (&v_m_main->widgets[5], x, y, 0, BTN_NORMAL, _("Shutdown")); + + widget_label (&v_m_main->widgets[6], view_width / 3 * 2 - 16, 32, 0, CHANNEL_VERSION_STR, view_width / 3 - 32, FA_RIGHT, FA_ASCENDER, FONT_LABEL); sprintf(buffer, "IOS%d v%d.%d", IOS_GetVersion(), IOS_GetRevisionMajor(), IOS_GetRevisionMinor()); - widget_label (&v_m_main->widgets[6], view_width / 3 * 2 - 16, + widget_label (&v_m_main->widgets[7], view_width / 3 * 2 - 16, 32 + font_get_y_spacing(FONT_LABEL), 0, buffer, view_width / 3 - 32, FA_RIGHT, FA_ASCENDER, FONT_LABEL); diff --git a/channel/channelapp/source/main.c b/channel/channelapp/source/main.c index 889cc2d..63f6dab 100644 --- a/channel/channelapp/source/main.c +++ b/channel/channelapp/source/main.c @@ -291,6 +291,7 @@ void main_real(void) { bool reloced; bool ahb_access; bool launch_bootmii; + bool restart; u64 frame; bool exit_about; @@ -333,6 +334,7 @@ void main_real(void) { reloced = false; ahb_access = false; launch_bootmii = false; + restart = false; frame = 0; exit_about = false; @@ -434,6 +436,7 @@ void main_real(void) { if (bd & PADS_DOWN) view_set_focus_next (v_current); + // what to do when a button is pressed if (bd & PADS_A) { switch (v_m_main->focus) { case 0: @@ -452,16 +455,24 @@ void main_real(void) { continue; + // "Launch BootMii" case 2: launch_bootmii = true; should_exit = true; break; + // "Exit to System Menu" case 3: should_exit = true; continue; + // "Reboot" case 4: + restart = true; + should_exit = true; + + // "Shutdown" + case 5: should_exit = true; shutdown = true; break; @@ -807,6 +818,11 @@ void main_real(void) { loader_exec (ep); } + if (restart) { + gprintf ("rebooting console\n"); + STM_RebootSystem(); + } + if (shutdown) { gprintf ("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0);