Compare commits
5 Commits
dev
...
335ea03b05
| Author | SHA1 | Date | |
|---|---|---|---|
| 335ea03b05 | |||
| b0523ada6c | |||
| 9a2307a8ee | |||
| e71fb13bfc | |||
| 5bcd3987a2 |
@@ -122,9 +122,8 @@ static const char* config_dirs_to_delete[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Switch directories to delete
|
// Switch directories to delete
|
||||||
// NOTE: .packages is intentionally excluded - UltraHand package cache, preserve during updates
|
// NOTE: .overlays and .packages excluded - preserve UltraHand .offload hide state during updates
|
||||||
static const char* switch_dirs_to_delete[] = {
|
static const char* switch_dirs_to_delete[] = {
|
||||||
"sd:/switch/.overlays",
|
|
||||||
"sd:/switch/90DNS_tester",
|
"sd:/switch/90DNS_tester",
|
||||||
"sd:/switch/aio-switch-updater",
|
"sd:/switch/aio-switch-updater",
|
||||||
"sd:/switch/amsPLUS-downloader",
|
"sd:/switch/amsPLUS-downloader",
|
||||||
|
|||||||
163
source/install.c
163
source/install.c
@@ -275,6 +275,167 @@ int folder_copy_with_progress_v2(const char *src, const char *dst, const char *d
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy one directory (e.g. .overlays or .packages) with .offload awareness: if the same
|
||||||
|
// name exists in dst_offload, copy pack's version into dst_offload (update in place);
|
||||||
|
// otherwise copy to dst_parent. Used only for update mode to preserve UltraHand hide state.
|
||||||
|
static int copy_dir_offload_aware(const char *src_parent, const char *dst_parent, const char *dst_offload,
|
||||||
|
const char *display_name, int *copied, int total, u32 start_x, u32 start_y, int *last_percent)
|
||||||
|
{
|
||||||
|
DIR dir;
|
||||||
|
FILINFO fno;
|
||||||
|
int res;
|
||||||
|
char src_full[256];
|
||||||
|
char dst_main[256];
|
||||||
|
char dst_off[256];
|
||||||
|
|
||||||
|
res = f_opendir(&dir, src_parent);
|
||||||
|
if (res != FR_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
res = f_readdir(&dir, &fno);
|
||||||
|
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||||
|
if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0')))
|
||||||
|
continue;
|
||||||
|
if (strcmp(fno.fname, ".offload") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
install_combine_path(src_full, sizeof(src_full), src_parent, fno.fname);
|
||||||
|
install_combine_path(dst_off, sizeof(dst_off), dst_offload, fno.fname);
|
||||||
|
|
||||||
|
if (install_path_exists(dst_off)) {
|
||||||
|
res = (fno.fattrib & AM_DIR) ? folder_copy(src_full, dst_offload) : file_copy(src_full, dst_off);
|
||||||
|
} else {
|
||||||
|
install_combine_path(dst_main, sizeof(dst_main), dst_parent, fno.fname);
|
||||||
|
res = (fno.fattrib & AM_DIR) ? folder_copy(src_full, dst_parent) : file_copy(src_full, dst_main);
|
||||||
|
}
|
||||||
|
(*copied)++;
|
||||||
|
if (total > 0) {
|
||||||
|
int percent = (*copied * 100) / total;
|
||||||
|
if (percent != *last_percent || *copied % 20 == 0) {
|
||||||
|
gfx_con_setpos(start_x, start_y);
|
||||||
|
install_set_color(COLOR_CYAN);
|
||||||
|
gfx_printf(" Kopiere: %s [%3d%%] (%d/%d)", display_name, percent, *copied, total);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
*last_percent = percent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res != FR_OK) {
|
||||||
|
f_closedir(&dir);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f_closedir(&dir);
|
||||||
|
return FR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy switch/ folder for update mode only: preserve SD's .overlays/.offload and
|
||||||
|
// .packages/.offload; for items that exist there, update in place instead of main area.
|
||||||
|
int folder_copy_switch_update_offload_aware(const char *src_switch, const char *dst_base, const char *display_name) {
|
||||||
|
char dst_switch[256];
|
||||||
|
char src_overlays[256], src_packages[256];
|
||||||
|
char dst_overlays[256], dst_offload_ovl[256], dst_packages[256], dst_offload_pkg[256];
|
||||||
|
DIR dir;
|
||||||
|
FILINFO fno;
|
||||||
|
int res;
|
||||||
|
int copied = 0;
|
||||||
|
int total;
|
||||||
|
int last_percent = -1;
|
||||||
|
u32 start_x, start_y;
|
||||||
|
|
||||||
|
install_combine_path(dst_switch, sizeof(dst_switch), dst_base, "switch");
|
||||||
|
|
||||||
|
if (!install_path_exists(src_switch)) {
|
||||||
|
install_set_color(COLOR_ORANGE);
|
||||||
|
gfx_printf(" Ueberspringe: %s (nicht gefunden)\n", display_name);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
return FR_NO_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
total = install_count_directory_items(src_switch);
|
||||||
|
if (total == 0) {
|
||||||
|
f_mkdir(dst_switch);
|
||||||
|
return FR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx_con_getpos(&start_x, &start_y);
|
||||||
|
install_set_color(COLOR_CYAN);
|
||||||
|
gfx_printf(" Kopiere: %s [ 0%%] (0/%d)", display_name, total);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
|
||||||
|
res = f_mkdir(dst_switch);
|
||||||
|
if (res != FR_OK && res != FR_EXIST) return res;
|
||||||
|
|
||||||
|
res = f_opendir(&dir, src_switch);
|
||||||
|
if (res != FR_OK) return res;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
res = f_readdir(&dir, &fno);
|
||||||
|
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||||
|
if (fno.fname[0] == '.' && (fno.fname[1] == '\0' || (fno.fname[1] == '.' && fno.fname[2] == '\0')))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(fno.fname, ".overlays") == 0) {
|
||||||
|
install_combine_path(src_overlays, sizeof(src_overlays), src_switch, ".overlays");
|
||||||
|
install_combine_path(dst_overlays, sizeof(dst_overlays), dst_switch, ".overlays");
|
||||||
|
install_combine_path(dst_offload_ovl, sizeof(dst_offload_ovl), dst_overlays, ".offload");
|
||||||
|
if (!install_path_exists(src_overlays)) { f_closedir(&dir); continue; }
|
||||||
|
f_mkdir(dst_overlays);
|
||||||
|
f_mkdir(dst_offload_ovl);
|
||||||
|
res = copy_dir_offload_aware(src_overlays, dst_overlays, dst_offload_ovl, display_name,
|
||||||
|
&copied, total, start_x, start_y, &last_percent);
|
||||||
|
} else if (strcmp(fno.fname, ".packages") == 0) {
|
||||||
|
install_combine_path(src_packages, sizeof(src_packages), src_switch, ".packages");
|
||||||
|
install_combine_path(dst_packages, sizeof(dst_packages), dst_switch, ".packages");
|
||||||
|
install_combine_path(dst_offload_pkg, sizeof(dst_offload_pkg), dst_packages, ".offload");
|
||||||
|
if (!install_path_exists(src_packages)) { f_closedir(&dir); continue; }
|
||||||
|
f_mkdir(dst_packages);
|
||||||
|
f_mkdir(dst_offload_pkg);
|
||||||
|
{ /* package.ini into main area */
|
||||||
|
char src_ini[256], dst_ini[256];
|
||||||
|
s_printf(src_ini, "%s/package.ini", src_packages);
|
||||||
|
s_printf(dst_ini, "%s/package.ini", dst_packages);
|
||||||
|
if (install_path_exists(src_ini)) {
|
||||||
|
res = file_copy(src_ini, dst_ini);
|
||||||
|
if (res == FR_OK) copied++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res = copy_dir_offload_aware(src_packages, dst_packages, dst_offload_pkg, display_name,
|
||||||
|
&copied, total, start_x, start_y, &last_percent);
|
||||||
|
} else {
|
||||||
|
char src_full[256], dst_full[256];
|
||||||
|
install_combine_path(src_full, sizeof(src_full), src_switch, fno.fname);
|
||||||
|
install_combine_path(dst_full, sizeof(dst_full), dst_switch, fno.fname);
|
||||||
|
if (fno.fattrib & AM_DIR)
|
||||||
|
res = folder_copy(src_full, dst_switch);
|
||||||
|
else
|
||||||
|
res = file_copy(src_full, dst_full);
|
||||||
|
copied++;
|
||||||
|
}
|
||||||
|
if (res != FR_OK) break;
|
||||||
|
if (total > 0 && (copied % 20 == 0 || copied == total)) {
|
||||||
|
int percent = (copied * 100) / total;
|
||||||
|
gfx_con_setpos(start_x, start_y);
|
||||||
|
install_set_color(COLOR_CYAN);
|
||||||
|
gfx_printf(" Kopiere: %s [%3d%%] (%d/%d)", display_name, percent, copied, total);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f_closedir(&dir);
|
||||||
|
|
||||||
|
gfx_con_setpos(start_x, start_y);
|
||||||
|
if (res == FR_OK) {
|
||||||
|
install_set_color(COLOR_GREEN);
|
||||||
|
gfx_printf(" Kopiere: %s [100%%] (%d/%d) - Fertig!\n", display_name, copied, total);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
} else {
|
||||||
|
install_set_color(COLOR_RED);
|
||||||
|
gfx_printf(" Kopiere: %s - Fehlgeschlagen!\n", display_name);
|
||||||
|
install_set_color(COLOR_WHITE);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// Recursive folder delete with progress tracking (shared implementation)
|
// Recursive folder delete with progress tracking (shared implementation)
|
||||||
int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent) {
|
int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent) {
|
||||||
DIR dir;
|
DIR dir;
|
||||||
@@ -603,7 +764,7 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode) {
|
|||||||
install_set_color(COLOR_YELLOW);
|
install_set_color(COLOR_YELLOW);
|
||||||
gfx_printf("Schritt 2: Dateien kopieren...\n");
|
gfx_printf("Schritt 2: Dateien kopieren...\n");
|
||||||
install_set_color(COLOR_WHITE);
|
install_set_color(COLOR_WHITE);
|
||||||
res = update_mode_install(pack_variant);
|
res = update_mode_install(pack_variant, true);
|
||||||
if (res != FR_OK) return res;
|
if (res != FR_OK) return res;
|
||||||
|
|
||||||
install_check_and_clear_screen_if_needed();
|
install_check_and_clear_screen_if_needed();
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ int perform_installation(omninx_variant_t pack_variant, install_mode_t mode);
|
|||||||
|
|
||||||
// Update mode operations (install_update.c)
|
// Update mode operations (install_update.c)
|
||||||
int update_mode_cleanup(omninx_variant_t variant);
|
int update_mode_cleanup(omninx_variant_t variant);
|
||||||
int update_mode_install(omninx_variant_t variant);
|
/* offload_aware_switch: true = update (preserve .offload), false = clean (normal copy) */
|
||||||
|
int update_mode_install(omninx_variant_t variant, bool offload_aware_switch);
|
||||||
int cleanup_staging_directory(omninx_variant_t pack_variant);
|
int cleanup_staging_directory(omninx_variant_t pack_variant);
|
||||||
// Remove other OmniNX staging directories (Standard/Light/OC) that exist, except the one just installed
|
// Remove other OmniNX staging directories (Standard/Light/OC) that exist, except the one just installed
|
||||||
int cleanup_other_staging_directories(omninx_variant_t installed_variant);
|
int cleanup_other_staging_directories(omninx_variant_t installed_variant);
|
||||||
@@ -40,3 +41,5 @@ int delete_path_lists_grouped(const char *folder_display_name, ...);
|
|||||||
int folder_delete_single_with_progress(const char *path, const char *display_name);
|
int folder_delete_single_with_progress(const char *path, const char *display_name);
|
||||||
int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent);
|
int folder_delete_progress_recursive(const char *path, int *deleted, int total, u32 start_x, u32 start_y, const char *display_name, int *last_percent);
|
||||||
int folder_copy_with_progress_v2(const char *src, const char *dst, const char *display_name);
|
int folder_copy_with_progress_v2(const char *src, const char *dst, const char *display_name);
|
||||||
|
// Update-only: copy switch/ preserving .overlays/.offload and .packages/.offload (UltraHand hide state)
|
||||||
|
int folder_copy_switch_update_offload_aware(const char *src_switch, const char *dst_base, const char *display_name);
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ int clean_mode_restore(void) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean mode: Install files (reuse update mode install)
|
// Clean mode: Install files (reuse update copy logic, but normal switch copy – no .offload preservation)
|
||||||
int clean_mode_install(omninx_variant_t variant) {
|
int clean_mode_install(omninx_variant_t variant) {
|
||||||
return update_mode_install(variant);
|
return update_mode_install(variant, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove other staging directories (OmniNX Standard/Light/OC) that exist on SD
|
// Remove other staging directories (OmniNX Standard/Light/OC) that exist on SD
|
||||||
|
|||||||
@@ -73,8 +73,9 @@ int update_mode_cleanup(omninx_variant_t variant) {
|
|||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update mode: Copy files from staging
|
// Update/Clean mode: Copy files from staging.
|
||||||
int update_mode_install(omninx_variant_t variant) {
|
// offload_aware_switch: true = update (preserve .overlays/.offload, .packages/.offload); false = clean (normal copy).
|
||||||
|
int update_mode_install(omninx_variant_t variant, bool offload_aware_switch) {
|
||||||
int res;
|
int res;
|
||||||
const char* staging = get_staging_path(variant);
|
const char* staging = get_staging_path(variant);
|
||||||
char src_path[256];
|
char src_path[256];
|
||||||
@@ -103,7 +104,10 @@ int update_mode_install(omninx_variant_t variant) {
|
|||||||
if (res != FR_OK && res != FR_NO_FILE) return res;
|
if (res != FR_OK && res != FR_NO_FILE) return res;
|
||||||
|
|
||||||
s_printf(src_path, "%s/switch", staging);
|
s_printf(src_path, "%s/switch", staging);
|
||||||
res = folder_copy_with_progress_v2(src_path, "sd:/", "switch/");
|
if (offload_aware_switch)
|
||||||
|
res = folder_copy_switch_update_offload_aware(src_path, "sd:/", "switch/");
|
||||||
|
else
|
||||||
|
res = folder_copy_with_progress_v2(src_path, "sd:/", "switch/");
|
||||||
if (res != FR_OK && res != FR_NO_FILE) return res;
|
if (res != FR_OK && res != FR_NO_FILE) return res;
|
||||||
|
|
||||||
s_printf(src_path, "%s/warmboot_mariko", staging);
|
s_printf(src_path, "%s/warmboot_mariko", staging);
|
||||||
|
|||||||
114
source/main.c
114
source/main.c
@@ -35,6 +35,7 @@
|
|||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "install.h"
|
#include "install.h"
|
||||||
|
#include "screenshot.h"
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
#define PAYLOAD_PATH "sd:/bootloader/update.bin"
|
#define PAYLOAD_PATH "sd:/bootloader/update.bin"
|
||||||
@@ -264,11 +265,15 @@ void ipl_main(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check joycon A button
|
// Check joycon A button; Capture = screenshot
|
||||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
if (jc && jc->a) {
|
if (jc) {
|
||||||
button_pressed = true;
|
if (jc->cap)
|
||||||
break;
|
take_screenshot();
|
||||||
|
if (jc->a) {
|
||||||
|
button_pressed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msleep(50); // Small delay to avoid busy-waiting
|
msleep(50); // Small delay to avoid busy-waiting
|
||||||
@@ -345,6 +350,9 @@ void ipl_main(void) {
|
|||||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
u8 btn = btn_read();
|
u8 btn = btn_read();
|
||||||
|
|
||||||
|
if (jc && jc->cap)
|
||||||
|
take_screenshot();
|
||||||
|
|
||||||
// D-pad or Vol+ / Vol- for selection (Vol+ = up, Vol- = down)
|
// D-pad or Vol+ / Vol- for selection (Vol+ = up, Vol- = down)
|
||||||
bool cur_up = false, cur_down = false;
|
bool cur_up = false, cur_down = false;
|
||||||
if (jc) {
|
if (jc) {
|
||||||
@@ -402,9 +410,13 @@ void ipl_main(void) {
|
|||||||
bool user_cancelled = false;
|
bool user_cancelled = false;
|
||||||
while (batt_pct < BATT_LOW_THRESHOLD && !bq24193_charger_connected() && !user_cancelled) {
|
while (batt_pct < BATT_LOW_THRESHOLD && !bq24193_charger_connected() && !user_cancelled) {
|
||||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
if (jc && jc->plus && jc->minus) {
|
if (jc) {
|
||||||
user_cancelled = true;
|
if (jc->cap)
|
||||||
break;
|
take_screenshot();
|
||||||
|
if (jc->plus && jc->minus) {
|
||||||
|
user_cancelled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (max17050_get_property(MAX17050_RepSOC, &batt_raw) == 0) {
|
if (max17050_get_property(MAX17050_RepSOC, &batt_raw) == 0) {
|
||||||
batt_pct = batt_raw >> 8;
|
batt_pct = batt_raw >> 8;
|
||||||
@@ -428,6 +440,67 @@ void ipl_main(void) {
|
|||||||
gfx_con_setpos(0, 0);
|
gfx_con_setpos(0, 0);
|
||||||
print_header();
|
print_header();
|
||||||
|
|
||||||
|
// UHS class check: recommend U2 / V30 / A2 for emuMMC (speed and reliability)
|
||||||
|
#define UHS_U2_MIN 2
|
||||||
|
#define UHS_V30_MIN 30
|
||||||
|
#define UHS_A2_MIN 2
|
||||||
|
bool uhs_ok = (sd_storage.ssr.uhs_grade >= UHS_U2_MIN &&
|
||||||
|
sd_storage.ssr.video_class >= UHS_V30_MIN &&
|
||||||
|
sd_storage.ssr.app_class >= UHS_A2_MIN);
|
||||||
|
if (!uhs_ok) {
|
||||||
|
jc_init_hw();
|
||||||
|
gfx_clear_grey(0x1B);
|
||||||
|
gfx_con_setpos(0, 0);
|
||||||
|
set_color(COLOR_RED);
|
||||||
|
gfx_printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
|
||||||
|
gfx_printf("!! WARNUNG - SD-KARTEN-KLASSE !!\n");
|
||||||
|
gfx_printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n");
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
gfx_printf("Diese SD-Karte erfuellt NICHT die empfohlenen\n");
|
||||||
|
gfx_printf("Mindestanforderungen (U2 | V30 | A2).\n\n");
|
||||||
|
set_color(COLOR_YELLOW);
|
||||||
|
gfx_printf("Aktuelle Werte: UHS%d | V%d | A%d\n\n",
|
||||||
|
(u32)sd_storage.ssr.uhs_grade,
|
||||||
|
(u32)sd_storage.ssr.video_class,
|
||||||
|
(u32)sd_storage.ssr.app_class);
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
gfx_printf("Moegliche Folgen bei schwachen Karten:\n");
|
||||||
|
gfx_printf(" - Langsamere emuMMC / Spiel-Ladezeiten\n");
|
||||||
|
gfx_printf(" - Hoheres Risiko von Korruption oder Abstuerzen\n");
|
||||||
|
gfx_printf(" - Instabilitaet beim Schreiben groesserer Daten\n\n");
|
||||||
|
set_color(COLOR_CYAN);
|
||||||
|
gfx_printf("Empfohlen: U2 | V30 | A2 oder besser.\n");
|
||||||
|
gfx_printf("Empfohlene Karten: Samsung EVO Plus, EVO Select und PRO Plus.\n\n");
|
||||||
|
set_color(COLOR_GREEN);
|
||||||
|
gfx_printf("Druecke A (oder Power), um trotzdem fortzufahren.\n");
|
||||||
|
set_color(COLOR_WHITE);
|
||||||
|
while (btn_read() & BTN_POWER) { msleep(50); }
|
||||||
|
bool acknowledged = false;
|
||||||
|
while (!acknowledged) {
|
||||||
|
u8 btn_state = btn_read();
|
||||||
|
if (btn_state & BTN_POWER) acknowledged = true;
|
||||||
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
|
if (jc) {
|
||||||
|
if (jc->cap)
|
||||||
|
take_screenshot();
|
||||||
|
if (jc->a) acknowledged = true;
|
||||||
|
}
|
||||||
|
msleep(50);
|
||||||
|
}
|
||||||
|
// Wait for A and Power to be released so the same press doesn't start the install
|
||||||
|
while (btn_read() & BTN_POWER) { msleep(50); }
|
||||||
|
bool released = false;
|
||||||
|
while (!released) {
|
||||||
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
|
released = (!jc || !jc->a) && !(btn_read() & BTN_POWER);
|
||||||
|
if (!released) msleep(50);
|
||||||
|
}
|
||||||
|
msleep(300); // Short delay so the next screen is visible before accepting input
|
||||||
|
gfx_clear_grey(0x1B);
|
||||||
|
gfx_con_setpos(0, 0);
|
||||||
|
print_header();
|
||||||
|
}
|
||||||
|
|
||||||
// Show information
|
// Show information
|
||||||
set_color(COLOR_CYAN);
|
set_color(COLOR_CYAN);
|
||||||
gfx_printf("Installationsmodus: %s\n", mode == INSTALL_MODE_UPDATE ? "Update" : "Saubere Installation");
|
gfx_printf("Installationsmodus: %s\n", mode == INSTALL_MODE_UPDATE ? "Update" : "Saubere Installation");
|
||||||
@@ -473,9 +546,11 @@ void ipl_main(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check joycon buttons
|
// Check joycon buttons; Capture = screenshot
|
||||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
if (jc) {
|
if (jc) {
|
||||||
|
if (jc->cap)
|
||||||
|
take_screenshot();
|
||||||
if (jc->a) {
|
if (jc->a) {
|
||||||
button_pressed = true;
|
button_pressed = true;
|
||||||
break;
|
break;
|
||||||
@@ -521,6 +596,7 @@ void ipl_main(void) {
|
|||||||
|
|
||||||
// Wait 3 seconds before clearing screen to allow errors to be visible
|
// Wait 3 seconds before clearing screen to allow errors to be visible
|
||||||
msleep(3000);
|
msleep(3000);
|
||||||
|
// take_screenshot(); // Take a screenshot of the installation summary
|
||||||
|
|
||||||
// Clear screen for final summary to ensure it's visible
|
// Clear screen for final summary to ensure it's visible
|
||||||
gfx_clear_grey(0x1B);
|
gfx_clear_grey(0x1B);
|
||||||
@@ -573,11 +649,15 @@ void ipl_main(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check joycon A button
|
// Check joycon A button; Capture = screenshot
|
||||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
if (jc && jc->a) {
|
if (jc) {
|
||||||
button_pressed = true;
|
if (jc->cap)
|
||||||
break;
|
take_screenshot();
|
||||||
|
if (jc->a) {
|
||||||
|
button_pressed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msleep(50); // Small delay to avoid busy-waiting
|
msleep(50); // Small delay to avoid busy-waiting
|
||||||
@@ -615,9 +695,13 @@ void ipl_main(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jc_gamepad_rpt_t *jc = joycon_poll();
|
jc_gamepad_rpt_t *jc = joycon_poll();
|
||||||
if (jc && jc->a) {
|
if (jc) {
|
||||||
button_pressed = true;
|
if (jc->cap)
|
||||||
break;
|
take_screenshot();
|
||||||
|
if (jc->a) {
|
||||||
|
button_pressed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msleep(50);
|
msleep(50);
|
||||||
|
|||||||
@@ -184,6 +184,11 @@ static void _sd_deinit()
|
|||||||
void sd_unmount() { _sd_deinit(); }
|
void sd_unmount() { _sd_deinit(); }
|
||||||
void sd_end() { _sd_deinit(); }
|
void sd_end() { _sd_deinit(); }
|
||||||
|
|
||||||
|
bool sd_get_card_mounted(void)
|
||||||
|
{
|
||||||
|
return sd_mounted;
|
||||||
|
}
|
||||||
|
|
||||||
void *sd_file_read(const char *path, u32 *fsize)
|
void *sd_file_read(const char *path, u32 *fsize)
|
||||||
{
|
{
|
||||||
FIL fp;
|
FIL fp;
|
||||||
|
|||||||
111
source/screenshot.c
Normal file
111
source/screenshot.c
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Screenshot support for OmniNX Installer Payload
|
||||||
|
* Based on TegraExplorer (AllgemeinerProblemLoeser) TakeScreenshot implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "screenshot.h"
|
||||||
|
#include "gfx.h"
|
||||||
|
#include "nx_sd.h"
|
||||||
|
#include <libs/fatfs/ff.h>
|
||||||
|
#include <mem/heap.h>
|
||||||
|
#include <display/di.h>
|
||||||
|
#include <utils/util.h>
|
||||||
|
#include <utils/sprintf.h>
|
||||||
|
#include <rtc/max77620-rtc.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* BMP file header (54 bytes), matching TegraExplorer tools.h */
|
||||||
|
typedef struct __attribute__((packed)) _bmp_hdr_t
|
||||||
|
{
|
||||||
|
u16 magic;
|
||||||
|
u32 size;
|
||||||
|
u32 rsvd;
|
||||||
|
u32 data_off;
|
||||||
|
u32 hdr_size;
|
||||||
|
u32 width;
|
||||||
|
u32 height;
|
||||||
|
u16 planes;
|
||||||
|
u16 pxl_bits;
|
||||||
|
u32 comp;
|
||||||
|
u32 img_size;
|
||||||
|
u32 res_h;
|
||||||
|
u32 res_v;
|
||||||
|
u64 rsvd2;
|
||||||
|
} bmp_hdr_t;
|
||||||
|
|
||||||
|
#define BMP_HEADER_SIZE 0x36
|
||||||
|
#define FB_SIZE 0x384000 /* 1280 * 720 * 4 */
|
||||||
|
#define SCREEN_W 1280
|
||||||
|
#define SCREEN_H 720
|
||||||
|
|
||||||
|
void take_screenshot(void)
|
||||||
|
{
|
||||||
|
static u32 last_timer = 0;
|
||||||
|
|
||||||
|
if (!sd_get_card_mounted())
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* 3-second cooldown (same as TegraExplorer) */
|
||||||
|
u32 now = get_tmr_s();
|
||||||
|
if (last_timer != 0 && now < last_timer + 3)
|
||||||
|
return;
|
||||||
|
last_timer = now;
|
||||||
|
|
||||||
|
const char basepath[] = "sd:/switch/screenshot";
|
||||||
|
char name[48];
|
||||||
|
char path[80];
|
||||||
|
rtc_time_t rtc;
|
||||||
|
|
||||||
|
max77620_rtc_get_time(&rtc);
|
||||||
|
s_printf(name, "omninx_installer_%04d%02d%02d_%02d%02d%02d.bmp",
|
||||||
|
(u32)rtc.year, (u32)rtc.month, (u32)rtc.day,
|
||||||
|
(u32)rtc.hour, (u32)rtc.min, (u32)rtc.sec);
|
||||||
|
s_printf(path, "%s/%s", basepath, name);
|
||||||
|
|
||||||
|
f_mkdir("sd:/switch");
|
||||||
|
f_mkdir(basepath);
|
||||||
|
|
||||||
|
const u32 file_size = BMP_HEADER_SIZE + FB_SIZE;
|
||||||
|
u8 *bitmap = (u8 *)malloc(file_size);
|
||||||
|
u32 *fb_copy = (u32 *)malloc(FB_SIZE);
|
||||||
|
if (!bitmap || !fb_copy) {
|
||||||
|
if (bitmap) free(bitmap);
|
||||||
|
if (fb_copy) free(fb_copy);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy framebuffer with same coordinate flip as TegraExplorer (BGR layout) */
|
||||||
|
u32 *fb_ptr = gfx_ctxt.fb;
|
||||||
|
for (int x = SCREEN_W - 1; x >= 0; x--) {
|
||||||
|
for (int y = SCREEN_H - 1; y >= 0; y--)
|
||||||
|
fb_copy[y * SCREEN_W + x] = *fb_ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(bitmap + BMP_HEADER_SIZE, fb_copy, FB_SIZE);
|
||||||
|
|
||||||
|
bmp_hdr_t *bmp = (bmp_hdr_t *)bitmap;
|
||||||
|
bmp->magic = 0x4D42;
|
||||||
|
bmp->size = file_size;
|
||||||
|
bmp->rsvd = 0;
|
||||||
|
bmp->data_off = BMP_HEADER_SIZE;
|
||||||
|
bmp->hdr_size = 40;
|
||||||
|
bmp->width = SCREEN_W;
|
||||||
|
bmp->height = SCREEN_H;
|
||||||
|
bmp->planes = 1;
|
||||||
|
bmp->pxl_bits = 32;
|
||||||
|
bmp->comp = 0;
|
||||||
|
bmp->img_size = FB_SIZE;
|
||||||
|
bmp->res_h = 2834;
|
||||||
|
bmp->res_v = 2834;
|
||||||
|
bmp->rsvd2 = 0;
|
||||||
|
|
||||||
|
sd_save_to_file(bitmap, file_size, path);
|
||||||
|
|
||||||
|
free(bitmap);
|
||||||
|
free(fb_copy);
|
||||||
|
|
||||||
|
/* Brief backlight flash (same as TegraExplorer) */
|
||||||
|
display_backlight_brightness(255, 1000);
|
||||||
|
msleep(100);
|
||||||
|
display_backlight_brightness(100, 1000);
|
||||||
|
}
|
||||||
13
source/screenshot.h
Normal file
13
source/screenshot.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Screenshot support for OmniNX Installer Payload
|
||||||
|
* Based on TegraExplorer (AllgemeinerProblemLoeser) TakeScreenshot implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/types.h>
|
||||||
|
|
||||||
|
/* Take a screenshot of the current framebuffer and save as BMP to SD.
|
||||||
|
* Triggered by Capture button (jc->cap). Uses 3-second cooldown.
|
||||||
|
* Saves to sd:/switch/screenshot/omninx_installer_YYYYMMDD_HHMMSS.bmp */
|
||||||
|
void take_screenshot(void);
|
||||||
Reference in New Issue
Block a user