nyx: Use strcat whenever possible

This commit is contained in:
CTCaer 2020-07-14 22:26:40 +03:00
parent 4eecdfa553
commit 1f67251331
6 changed files with 129 additions and 130 deletions

View file

@ -1245,18 +1245,18 @@ static void _update_status_bar(void *params)
u8 batt_level = (batt_percent >> 8) & 0xFF; u8 batt_level = (batt_percent >> 8) & 0xFF;
if (batt_level > 80) if (batt_level > 80)
s_printf(label + strlen(label), SYMBOL_BATTERY_FULL); strcat(label, SYMBOL_BATTERY_FULL);
else if (batt_level > 60) else if (batt_level > 60)
s_printf(label + strlen(label), SYMBOL_BATTERY_3); strcat(label, SYMBOL_BATTERY_3);
else if (batt_level > 40) else if (batt_level > 40)
s_printf(label + strlen(label), SYMBOL_BATTERY_2); strcat(label, SYMBOL_BATTERY_2);
else if (batt_level > 15) else if (batt_level > 15)
s_printf(label + strlen(label), SYMBOL_BATTERY_1); strcat(label, SYMBOL_BATTERY_1);
else else
s_printf(label + strlen(label), "#FF3C28 "SYMBOL_BATTERY_EMPTY"#"); strcat(label, "#FF3C28 "SYMBOL_BATTERY_EMPTY"#");
if (charge_status) if (charge_status)
s_printf(label + strlen(label), " #FFDD00 "SYMBOL_CHARGE"#"); strcat(label, " #FFDD00 "SYMBOL_CHARGE"#");
lv_label_set_text(status_bar.battery, label); lv_label_set_text(status_bar.battery, label);
lv_obj_realign(status_bar.battery); lv_obj_realign(status_bar.battery);

View file

@ -271,7 +271,7 @@ static void _create_mbox_emummc_raw()
mbr->partitions[3].type, mbr->partitions[3].start_sct, mbr->partitions[3].size_sct); mbr->partitions[3].type, mbr->partitions[3].start_sct, mbr->partitions[3].size_sct);
if (!mbr_ctx.available) if (!mbr_ctx.available)
s_printf(txt_buf + strlen(txt_buf), strcat(txt_buf,
"\n#FF8000 Do you want to partition your SD card?#\n" "\n#FF8000 Do you want to partition your SD card?#\n"
"#FF8000 (You will be asked on how to proceed)#"); "#FF8000 (You will be asked on how to proceed)#");

View file

@ -287,7 +287,7 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
if (!pkg1_id) if (!pkg1_id)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Unknown pkg1 version for reading#\n#FFDD00 TSEC firmware!#"); strcat(txt_buf, "#FFDD00 Unknown pkg1 version for reading#\n#FFDD00 TSEC firmware!#");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
goto out; goto out;
@ -382,38 +382,38 @@ static lv_res_t _create_mbox_cal0(lv_obj_t *btn)
switch (display_id) switch (display_id)
{ {
case PANEL_JDI_LAM062M109A: case PANEL_JDI_LAM062M109A:
s_printf(txt_buf + strlen(txt_buf), "JDI LAM062M109A"); strcat(txt_buf, "JDI LAM062M109A");
break; break;
case PANEL_JDI_LPM062M326A: case PANEL_JDI_LPM062M326A:
s_printf(txt_buf + strlen(txt_buf), "JDI LPM062M326A"); strcat(txt_buf, "JDI LPM062M326A");
break; break;
case PANEL_INL_P062CCA_AZ1: case PANEL_INL_P062CCA_AZ1:
s_printf(txt_buf + strlen(txt_buf), "InnoLux P062CCA-AZ1"); strcat(txt_buf, "InnoLux P062CCA-AZ1");
break; break;
case PANEL_AUO_A062TAN01: case PANEL_AUO_A062TAN01:
s_printf(txt_buf + strlen(txt_buf), "AUO A062TAN01"); strcat(txt_buf, "AUO A062TAN01");
break; break;
case PANEL_INL_P062CCA_AZ2: case PANEL_INL_P062CCA_AZ2:
s_printf(txt_buf + strlen(txt_buf), "InnoLux P062CCA-AZ2"); strcat(txt_buf, "InnoLux P062CCA-AZ2");
break; break;
case PANEL_AUO_A062TAN02: case PANEL_AUO_A062TAN02:
s_printf(txt_buf + strlen(txt_buf), "AUO A062TAN02"); strcat(txt_buf, "AUO A062TAN02");
break; break;
default: default:
switch (cal0->lcd_vendor & 0xFF) switch (cal0->lcd_vendor & 0xFF)
{ {
case 0: case 0:
case PANEL_JDI_XXX062M: case PANEL_JDI_XXX062M:
s_printf(txt_buf + strlen(txt_buf), "JDI "); strcat(txt_buf, "JDI ");
break; break;
case (PANEL_INL_P062CCA_AZ1 & 0xFF): case (PANEL_INL_P062CCA_AZ1 & 0xFF):
s_printf(txt_buf + strlen(txt_buf), "InnoLux "); strcat(txt_buf, "InnoLux ");
break; break;
case (PANEL_AUO_A062TAN01 & 0xFF): case (PANEL_AUO_A062TAN01 & 0xFF):
s_printf(txt_buf + strlen(txt_buf), "AUO "); strcat(txt_buf, "AUO ");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), "Unknown"); strcat(txt_buf, "Unknown");
break; break;
} }
@ -576,32 +576,32 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
switch (ram_vendor.dev0_ch0) switch (ram_vendor.dev0_ch0)
{ {
case 1: case 1:
s_printf(txt_buf + strlen(txt_buf), "Samsung"); strcat(txt_buf, "Samsung");
break; break;
case 6: case 6:
s_printf(txt_buf + strlen(txt_buf), "Hynix"); strcat(txt_buf, "Hynix");
break; break;
case 255: case 255:
s_printf(txt_buf + strlen(txt_buf), "Micron"); strcat(txt_buf, "Micron");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "Unknown"); strcat(txt_buf, "Unknown");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), " (%d) #FF8000 |# ", ram_vendor.dev0_ch0); s_printf(txt_buf + strlen(txt_buf), " (%d) #FF8000 |# ", ram_vendor.dev0_ch0);
switch (ram_vendor.dev1_ch0) switch (ram_vendor.dev1_ch0)
{ {
case 1: case 1:
s_printf(txt_buf + strlen(txt_buf), "Samsung"); strcat(txt_buf, "Samsung");
break; break;
case 6: case 6:
s_printf(txt_buf + strlen(txt_buf), "Hynix"); strcat(txt_buf, "Hynix");
break; break;
case 255: case 255:
s_printf(txt_buf + strlen(txt_buf), "Micron"); strcat(txt_buf, "Micron");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "Unknown"); strcat(txt_buf, "Unknown");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), " (%d)\n#FF8000 Rev ID:# %04X #FF8000 |# %04X\n#FF8000 Density:# ", s_printf(txt_buf + strlen(txt_buf), " (%d)\n#FF8000 Rev ID:# %04X #FF8000 |# %04X\n#FF8000 Density:# ",
@ -609,32 +609,32 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
switch ((ram_density.dev0_ch0 & 0x3C) >> 2) switch ((ram_density.dev0_ch0 & 0x3C) >> 2)
{ {
case 2: case 2:
s_printf(txt_buf + strlen(txt_buf), "4x512MB"); strcat(txt_buf, "4x512MB");
break; break;
case 3: case 3:
s_printf(txt_buf + strlen(txt_buf), "4x768MB"); strcat(txt_buf, "4x768MB");
break; break;
case 4: case 4:
s_printf(txt_buf + strlen(txt_buf), "4x1GB"); strcat(txt_buf, "4x1GB");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "4xUnk"); strcat(txt_buf, "4xUnk");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), " (%d) #FF8000 |# ", (ram_density.dev0_ch0 & 0x3C) >> 2); s_printf(txt_buf + strlen(txt_buf), " (%d) #FF8000 |# ", (ram_density.dev0_ch0 & 0x3C) >> 2);
switch ((ram_density.dev1_ch0 & 0x3C) >> 2) switch ((ram_density.dev1_ch0 & 0x3C) >> 2)
{ {
case 2: case 2:
s_printf(txt_buf + strlen(txt_buf), "4x512MB"); strcat(txt_buf, "4x512MB");
break; break;
case 3: case 3:
s_printf(txt_buf + strlen(txt_buf), "4x768MB"); strcat(txt_buf, "4x768MB");
break; break;
case 4: case 4:
s_printf(txt_buf + strlen(txt_buf), "4x1GB"); strcat(txt_buf, "4x1GB");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "2xUnk"); strcat(txt_buf, "2xUnk");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), " (%d)\n\n", (ram_density.dev1_ch0 & 0x3C) >> 2); s_printf(txt_buf + strlen(txt_buf), " (%d)\n\n", (ram_density.dev1_ch0 & 0x3C) >> 2);
@ -642,42 +642,42 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
// Display info. // Display info.
u32 display_id = ((nyx_str->info.disp_id >> 8) & 0xFF00) | (nyx_str->info.disp_id & 0xFF); u32 display_id = ((nyx_str->info.disp_id >> 8) & 0xFF00) | (nyx_str->info.disp_id & 0xFF);
s_printf(txt_buf + strlen(txt_buf), "#00DDFF Display Panel:#\n#FF8000 Model:# "); strcat(txt_buf, "#00DDFF Display Panel:#\n#FF8000 Model:# ");
switch (display_id) switch (display_id)
{ {
case PANEL_JDI_LAM062M109A: case PANEL_JDI_LAM062M109A:
s_printf(txt_buf + strlen(txt_buf), "JDI LAM062M109A"); strcat(txt_buf, "JDI LAM062M109A");
break; break;
case PANEL_JDI_LPM062M326A: case PANEL_JDI_LPM062M326A:
s_printf(txt_buf + strlen(txt_buf), "JDI LPM062M326A"); strcat(txt_buf, "JDI LPM062M326A");
break; break;
case PANEL_INL_P062CCA_AZ1: case PANEL_INL_P062CCA_AZ1:
s_printf(txt_buf + strlen(txt_buf), "InnoLux P062CCA-AZ1"); strcat(txt_buf, "InnoLux P062CCA-AZ1");
break; break;
case PANEL_AUO_A062TAN01: case PANEL_AUO_A062TAN01:
s_printf(txt_buf + strlen(txt_buf), "AUO A062TAN01"); strcat(txt_buf, "AUO A062TAN01");
break; break;
case PANEL_INL_P062CCA_AZ2: case PANEL_INL_P062CCA_AZ2:
s_printf(txt_buf + strlen(txt_buf), "InnoLux P062CCA-AZ2"); strcat(txt_buf, "InnoLux P062CCA-AZ2");
break; break;
case PANEL_AUO_A062TAN02: case PANEL_AUO_A062TAN02:
s_printf(txt_buf + strlen(txt_buf), "AUO A062TAN02"); strcat(txt_buf, "AUO A062TAN02");
break; break;
default: default:
switch (display_id & 0xFF) switch (display_id & 0xFF)
{ {
case PANEL_JDI_XXX062M: case PANEL_JDI_XXX062M:
s_printf(txt_buf + strlen(txt_buf), "JDI "); strcat(txt_buf, "JDI ");
break; break;
case (PANEL_INL_P062CCA_AZ1 & 0xFF): case (PANEL_INL_P062CCA_AZ1 & 0xFF):
s_printf(txt_buf + strlen(txt_buf), "InnoLux "); strcat(txt_buf, "InnoLux ");
break; break;
case (PANEL_AUO_A062TAN01 & 0xFF): case (PANEL_AUO_A062TAN01 & 0xFF):
s_printf(txt_buf + strlen(txt_buf), "AUO "); strcat(txt_buf, "AUO ");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), "Unknown"); strcat(txt_buf, "Unknown");
break; break;
} }
@ -688,30 +688,30 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
if (!touch_get_fw_info(&touch_fw)) if (!touch_get_fw_info(&touch_fw))
{ {
s_printf(txt_buf + strlen(txt_buf), "\n\n#00DDFF Touch Panel:#\n#FF8000 Model:# "); strcat(txt_buf, "\n\n#00DDFF Touch Panel:#\n#FF8000 Model:# ");
switch (touch_fw.fw_id) switch (touch_fw.fw_id)
{ {
case 0x100100: case 0x100100:
s_printf(txt_buf + strlen(txt_buf), "NTD 4CD 1601"); strcat(txt_buf, "NTD 4CD 1601");
break; break;
case 0x00120100: case 0x00120100:
case 0x32000001: case 0x32000001:
s_printf(txt_buf + strlen(txt_buf), "NTD 4CD 1801"); strcat(txt_buf, "NTD 4CD 1801");
break; break;
case 0x001A0300: case 0x001A0300:
case 0x32000102: case 0x32000102:
s_printf(txt_buf + strlen(txt_buf), "NTD 4CD 2602"); strcat(txt_buf, "NTD 4CD 2602");
break; break;
case 0x00290100: case 0x00290100:
case 0x32000302: case 0x32000302:
s_printf(txt_buf + strlen(txt_buf), "NTD 4CD 3801"); strcat(txt_buf, "NTD 4CD 3801");
break; break;
case 0x31051820: case 0x31051820:
case 0x32000402: case 0x32000402:
s_printf(txt_buf + strlen(txt_buf), "NTD 4CD XXXX"); strcat(txt_buf, "NTD 4CD XXXX");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "Unknown"); strcat(txt_buf, "Unknown");
} }
s_printf(txt_buf + strlen(txt_buf), "\n#FF8000 ID:# %X\n#FF8000 FTB ver:# %04X\n#FF8000 FW rev:# %04X", s_printf(txt_buf + strlen(txt_buf), "\n#FF8000 ID:# %X\n#FF8000 FTB ver:# %04X\n#FF8000 FW rev:# %04X",
@ -720,9 +720,9 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
// Check if patched unit. // Check if patched unit.
if (!fuse_check_patched_rcm()) if (!fuse_check_patched_rcm())
s_printf(txt_buf + strlen(txt_buf), "\n\n#96FF00 Your unit is exploitable#\n#96FF00 to the RCM bug!#"); strcat(txt_buf, "\n\n#96FF00 Your unit is exploitable#\n#96FF00 to the RCM bug!#");
else else
s_printf(txt_buf + strlen(txt_buf), "\n\n#FF8000 Your unit is patched#\n#FF8000 to the RCM bug!#"); strcat(txt_buf, "\n\n#FF8000 Your unit is patched#\n#FF8000 to the RCM bug!#");
lv_label_set_text(lb_desc2, txt_buf); lv_label_set_text(lb_desc2, txt_buf);
@ -756,7 +756,7 @@ static void _ipatch_process(u32 offset, u32 value)
s_printf(ipatches_txt + strlen(ipatches_txt), "SVC ##0x%02X", lo); s_printf(ipatches_txt + strlen(ipatches_txt), "SVC ##0x%02X", lo);
break; break;
} }
s_printf(ipatches_txt + strlen(ipatches_txt), "\n"); strcat(ipatches_txt, "\n");
} }
static lv_res_t _create_window_bootrom_info_status(lv_obj_t *btn) static lv_res_t _create_window_bootrom_info_status(lv_obj_t *btn)
@ -825,7 +825,7 @@ static lv_res_t _create_window_tsec_keys_status(lv_obj_t *btn)
if (!pkg1_id) if (!pkg1_id)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Unknown pkg1 version for reading#\n#FFDD00 TSEC firmware!#"); strcat(txt_buf, "#FFDD00 Unknown pkg1 version for reading#\n#FFDD00 TSEC firmware!#");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
lv_obj_set_width(lb_desc, lv_obj_get_width(desc)); lv_obj_set_width(lb_desc, lv_obj_get_width(desc));
@ -885,7 +885,7 @@ static lv_res_t _create_window_tsec_keys_status(lv_obj_t *btn)
} }
} }
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 TSEC Key:#\n"); strcat(txt_buf, "#C7EA46 TSEC Key:#\n");
if (res >= 0) if (res >= 0)
{ {
s_printf(txt_buf2, "\n%08X%08X%08X%08X\n", s_printf(txt_buf2, "\n%08X%08X%08X%08X\n",
@ -893,7 +893,7 @@ static lv_res_t _create_window_tsec_keys_status(lv_obj_t *btn)
if (pkg1_id->kb == KB_FIRMWARE_VERSION_620) if (pkg1_id->kb == KB_FIRMWARE_VERSION_620)
{ {
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 TSEC root:#\n"); strcat(txt_buf, "#C7EA46 TSEC root:#\n");
s_printf(txt_buf2 + strlen(txt_buf2), "%08X%08X%08X%08X\n", s_printf(txt_buf2 + strlen(txt_buf2), "%08X%08X%08X%08X\n",
byte_swap_32(tsec_keys[4]), byte_swap_32(tsec_keys[5]), byte_swap_32(tsec_keys[6]), byte_swap_32(tsec_keys[7])); byte_swap_32(tsec_keys[4]), byte_swap_32(tsec_keys[5]), byte_swap_32(tsec_keys[6]), byte_swap_32(tsec_keys[7]));
} }
@ -985,7 +985,7 @@ static lv_res_t _create_mbox_benchmark(bool sd_bench)
u32 timer = get_tmr_ms(); u32 timer = get_tmr_ms();
s_printf(txt_buf + strlen(txt_buf), "\n"); strcat(txt_buf, "\n");
lv_mbox_set_text(mbox, txt_buf); lv_mbox_set_text(mbox, txt_buf);
while (data_remaining) while (data_remaining)
@ -1169,7 +1169,7 @@ static lv_res_t _create_window_emmc_info_status(lv_obj_t *btn)
{ {
if (idx > 10) if (idx > 10)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Table truncated!#"); strcat(txt_buf, "#FFDD00 Table truncated!#");
break; break;
} }
@ -1509,16 +1509,16 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn)
switch (value) switch (value)
{ {
case 0: case 0:
s_printf(txt_buf + strlen(txt_buf), "Not charging\n"); strcat(txt_buf, "Not charging\n");
break; break;
case 1: case 1:
s_printf(txt_buf + strlen(txt_buf), "Pre-charging\n"); strcat(txt_buf, "Pre-charging\n");
break; break;
case 2: case 2:
s_printf(txt_buf + strlen(txt_buf), "Fast charging\n"); strcat(txt_buf, "Fast charging\n");
break; break;
case 3: case 3:
s_printf(txt_buf + strlen(txt_buf), "Charge terminated\n"); strcat(txt_buf, "Charge terminated\n");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "Unknown (%d)\n", value); s_printf(txt_buf + strlen(txt_buf), "Unknown (%d)\n", value);
@ -1529,19 +1529,19 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn)
switch (value) switch (value)
{ {
case 0: case 0:
s_printf(txt_buf + strlen(txt_buf), "Normal"); strcat(txt_buf, "Normal");
break; break;
case 2: case 2:
s_printf(txt_buf + strlen(txt_buf), "Warm"); strcat(txt_buf, "Warm");
break; break;
case 3: case 3:
s_printf(txt_buf + strlen(txt_buf), "Cool"); strcat(txt_buf, "Cool");
break; break;
case 5: case 5:
s_printf(txt_buf + strlen(txt_buf), "Cold"); strcat(txt_buf, "Cold");
break; break;
case 6: case 6:
s_printf(txt_buf + strlen(txt_buf), "Hot"); strcat(txt_buf, "Hot");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "Unknown (%d)", value); s_printf(txt_buf + strlen(txt_buf), "Unknown (%d)", value);

View file

@ -817,7 +817,7 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
// Check if pairing info was found. // Check if pairing info was found.
if (joycon_found == 2) if (joycon_found == 2)
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 Found 2 out of 2 Joy-Con pairing data!#\n"); strcat(txt_buf, "#C7EA46 Found 2 out of 2 Joy-Con pairing data!#\n");
else else
{ {
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# Found #FFDD00 %d out of 2# pairing data!\n", joycon_found); s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# Found #FFDD00 %d out of 2# pairing data!\n", joycon_found);
@ -826,25 +826,25 @@ static lv_res_t _joycon_info_dump_action(lv_obj_t * btn)
// Check if pairing was done in HOS. // Check if pairing was done in HOS.
if (is_l_hos && is_r_hos) if (is_l_hos && is_r_hos)
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 Both pairing data are HOS based!#"); strcat(txt_buf, "#C7EA46 Both pairing data are HOS based!#");
else if (!is_l_hos && is_r_hos) else if (!is_l_hos && is_r_hos)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# #FFDD00 Left# pairing data is not HOS based!"); strcat(txt_buf, "#FF8000 Warning:# #FFDD00 Left# pairing data is not HOS based!");
success = false; success = false;
} }
else if (is_l_hos && !is_r_hos) else if (is_l_hos && !is_r_hos)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# #FFDD00 Right# pairing data is not HOS based!"); strcat(txt_buf, "#FF8000 Warning:# #FFDD00 Right# pairing data is not HOS based!");
success = false; success = false;
} }
else else
{ {
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# #FFDD00 No# pairing data is HOS based!"); strcat(txt_buf, "#FF8000 Warning:# #FFDD00 No# pairing data is HOS based!");
success = false; success = false;
} }
if (!success) if (!success)
s_printf(txt_buf + strlen(txt_buf), strcat(txt_buf,
"\n\n#FFDD00 Make sure that both Joy-Con are connected,#\n" "\n\n#FFDD00 Make sure that both Joy-Con are connected,#\n"
"#FFDD00 and that you paired them in HOS!#"); "#FFDD00 and that you paired them in HOS!#");
} }

View file

@ -173,16 +173,17 @@ static lv_res_t _create_mbox_hid(usb_ctxt_t *usbs)
lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true); lv_mbox_set_recolor_text(mbox, true);
char *text_buf = malloc(0x1000); char *txt_buf = malloc(0x1000);
s_printf(text_buf, "#FF8000 HID Emulation#\n\n#C7EA46 Device:# "); s_printf(txt_buf, "#FF8000 HID Emulation#\n\n#C7EA46 Device:# ");
if (usbs->type == USB_HID_GAMEPAD) if (usbs->type == USB_HID_GAMEPAD)
s_printf(text_buf + strlen(text_buf), "Gamepad"); strcat(txt_buf, "Gamepad");
else else
s_printf(text_buf + strlen(text_buf), "Touchpad"); strcat(txt_buf, "Touchpad");
lv_mbox_set_text(mbox, text_buf); lv_mbox_set_text(mbox, txt_buf);
free(txt_buf);
lv_obj_t *lbl_status = lv_label_create(mbox, NULL); lv_obj_t *lbl_status = lv_label_create(mbox, NULL);
lv_label_set_recolor(lbl_status, true); lv_label_set_recolor(lbl_status, true);
@ -217,25 +218,25 @@ static lv_res_t _create_mbox_ums(usb_ctxt_t *usbs)
lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true); lv_mbox_set_recolor_text(mbox, true);
char *text_buf = malloc(0x1000); char *txt_buf = malloc(0x1000);
s_printf(text_buf, "#FF8000 USB Mass Storage#\n\n#C7EA46 Device:# "); s_printf(txt_buf, "#FF8000 USB Mass Storage#\n\n#C7EA46 Device:# ");
if (usbs->type == MMC_SD) if (usbs->type == MMC_SD)
{ {
switch (usbs->partition) switch (usbs->partition)
{ {
case 0: case 0:
s_printf(text_buf + strlen(text_buf), "SD Card"); strcat(txt_buf, "SD Card");
break; break;
case EMMC_GPP + 1: case EMMC_GPP + 1:
s_printf(text_buf + strlen(text_buf), "emuMMC GPP"); strcat(txt_buf, "emuMMC GPP");
break; break;
case EMMC_BOOT0 + 1: case EMMC_BOOT0 + 1:
s_printf(text_buf + strlen(text_buf), "emuMMC BOOT0"); strcat(txt_buf, "emuMMC BOOT0");
break; break;
case EMMC_BOOT1 + 1: case EMMC_BOOT1 + 1:
s_printf(text_buf + strlen(text_buf), "emuMMC BOOT1"); strcat(txt_buf, "emuMMC BOOT1");
break; break;
} }
} }
@ -244,18 +245,19 @@ static lv_res_t _create_mbox_ums(usb_ctxt_t *usbs)
switch (usbs->partition) switch (usbs->partition)
{ {
case EMMC_GPP + 1: case EMMC_GPP + 1:
s_printf(text_buf + strlen(text_buf), "eMMC GPP"); strcat(txt_buf, "eMMC GPP");
break; break;
case EMMC_BOOT0 + 1: case EMMC_BOOT0 + 1:
s_printf(text_buf + strlen(text_buf), "eMMC BOOT0"); strcat(txt_buf, "eMMC BOOT0");
break; break;
case EMMC_BOOT1 + 1: case EMMC_BOOT1 + 1:
s_printf(text_buf + strlen(text_buf), "eMMC BOOT1"); strcat(txt_buf, "eMMC BOOT1");
break; break;
} }
} }
lv_mbox_set_text(mbox, text_buf); lv_mbox_set_text(mbox, txt_buf);
free(txt_buf);
lv_obj_t *lbl_status = lv_label_create(mbox, NULL); lv_obj_t *lbl_status = lv_label_create(mbox, NULL);
lv_label_set_recolor(lbl_status, true); lv_label_set_recolor(lbl_status, true);
@ -947,7 +949,7 @@ static lv_res_t _create_mbox_fix_touchscreen(lv_obj_t *btn)
lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL); lv_obj_t * mbox = lv_mbox_create(dark_bg, NULL);
lv_mbox_set_recolor_text(mbox, true); lv_mbox_set_recolor_text(mbox, true);
char *txt_buf = malloc(0x1000); char *txt_buf = malloc(0x4000);
strcpy(txt_buf, "#FF8000 Don't touch the screen!#\n\nThe tuning process will start in "); strcpy(txt_buf, "#FF8000 Don't touch the screen!#\n\nThe tuning process will start in ");
u32 text_idx = strlen(txt_buf); u32 text_idx = strlen(txt_buf);
lv_mbox_set_text(mbox, txt_buf); lv_mbox_set_text(mbox, txt_buf);
@ -994,45 +996,45 @@ static lv_res_t _create_mbox_fix_touchscreen(lv_obj_t *btn)
switch (err[0]) switch (err[0])
{ {
case ITO_FORCE_OPEN: case ITO_FORCE_OPEN:
s_printf(txt_buf + strlen(txt_buf), "Force Open"); strcat(txt_buf, "Force Open");
break; break;
case ITO_SENSE_OPEN: case ITO_SENSE_OPEN:
s_printf(txt_buf + strlen(txt_buf), "Sense Open"); strcat(txt_buf, "Sense Open");
break; break;
case ITO_FORCE_SHRT_GND: case ITO_FORCE_SHRT_GND:
s_printf(txt_buf + strlen(txt_buf), "Force Short to GND"); strcat(txt_buf, "Force Short to GND");
break; break;
case ITO_SENSE_SHRT_GND: case ITO_SENSE_SHRT_GND:
s_printf(txt_buf + strlen(txt_buf), "Sense Short to GND"); strcat(txt_buf, "Sense Short to GND");
break; break;
case ITO_FORCE_SHRT_VCM: case ITO_FORCE_SHRT_VCM:
s_printf(txt_buf + strlen(txt_buf), "Force Short to VDD"); strcat(txt_buf, "Force Short to VDD");
break; break;
case ITO_SENSE_SHRT_VCM: case ITO_SENSE_SHRT_VCM:
s_printf(txt_buf + strlen(txt_buf), "Sense Short to VDD"); strcat(txt_buf, "Sense Short to VDD");
break; break;
case ITO_FORCE_SHRT_FORCE: case ITO_FORCE_SHRT_FORCE:
s_printf(txt_buf + strlen(txt_buf), "Force Short to Force"); strcat(txt_buf, "Force Short to Force");
break; break;
case ITO_SENSE_SHRT_SENSE: case ITO_SENSE_SHRT_SENSE:
s_printf(txt_buf + strlen(txt_buf), "Sense Short to Sense"); strcat(txt_buf, "Sense Short to Sense");
break; break;
case ITO_F2E_SENSE: case ITO_F2E_SENSE:
s_printf(txt_buf + strlen(txt_buf), "Force Short to Sense"); strcat(txt_buf, "Force Short to Sense");
break; break;
case ITO_FPC_FORCE_OPEN: case ITO_FPC_FORCE_OPEN:
s_printf(txt_buf + strlen(txt_buf), "FPC Force Open"); strcat(txt_buf, "FPC Force Open");
break; break;
case ITO_FPC_SENSE_OPEN: case ITO_FPC_SENSE_OPEN:
s_printf(txt_buf + strlen(txt_buf), "FPC Sense Open"); strcat(txt_buf, "FPC Sense Open");
break; break;
default: default:
s_printf(txt_buf + strlen(txt_buf), "Unknown"); strcat(txt_buf, "Unknown");
break; break;
} }
s_printf(txt_buf + strlen(txt_buf), " (%d), Chn: %d#\n\n", err[0], err[1]); s_printf(txt_buf + strlen(txt_buf), " (%d), Chn: %d#\n\n", err[0], err[1]);
s_printf(txt_buf + strlen(txt_buf), "#FFFF00 The touchscreen calibration failed!"); strcat(txt_buf, "#FFFF00 The touchscreen calibration failed!");
lv_mbox_set_text(mbox, txt_buf); lv_mbox_set_text(mbox, txt_buf);
goto out2; goto out2;
} }
@ -1087,7 +1089,6 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
u8 kb = 0; u8 kb = 0;
char *txt_buf = (char *)malloc(0x4000); char *txt_buf = (char *)malloc(0x4000);
char *txt_buf2 = (char *)malloc(0x4000);
tsec_ctxt_t tsec_ctxt; tsec_ctxt_t tsec_ctxt;
@ -1116,8 +1117,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
// Dump package1 in its encrypted state if unknown. // Dump package1 in its encrypted state if unknown.
if (!pkg1_id) if (!pkg1_id)
{ {
s_printf(txt_buf + strlen(txt_buf), strcat(txt_buf, "#FFDD00 Unknown pkg1 version for reading#\n#FFDD00 TSEC firmware!#");
"#FFDD00 Unknown pkg1 version for reading#\n#FFDD00 TSEC firmware!#");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1125,7 +1125,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
if (sd_save_to_file(pkg1, 0x40000, path)) if (sd_save_to_file(pkg1, 0x40000, path))
goto out_free; goto out_free;
s_printf(txt_buf + strlen(txt_buf), "\nEncrypted pkg1 dumped to pkg1_enc.bin"); strcat(txt_buf, "\nEncrypted pkg1 dumped to pkg1_enc.bin");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1201,7 +1201,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &storage); emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &storage);
if (sd_save_to_file(pkg1, 0x40000, path)) if (sd_save_to_file(pkg1, 0x40000, path))
goto out_free; goto out_free;
s_printf(txt_buf + strlen(txt_buf), "pkg1 dumped to pkg1_decr.bin\n"); strcat(txt_buf, "pkg1 dumped to pkg1_decr.bin\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1209,7 +1209,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
emmcsn_path_impl(path, "/pkg1", "nxloader.bin", &storage); emmcsn_path_impl(path, "/pkg1", "nxloader.bin", &storage);
if (sd_save_to_file(loader, hdr->ldr_size, path)) if (sd_save_to_file(loader, hdr->ldr_size, path))
goto out_free; goto out_free;
s_printf(txt_buf + strlen(txt_buf), "NX Bootloader dumped to nxloader.bin\n"); strcat(txt_buf, "NX Bootloader dumped to nxloader.bin\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1217,7 +1217,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
emmcsn_path_impl(path, "/pkg1", "secmon.bin", &storage); emmcsn_path_impl(path, "/pkg1", "secmon.bin", &storage);
if (sd_save_to_file(secmon, hdr->sm_size, path)) if (sd_save_to_file(secmon, hdr->sm_size, path))
goto out_free; goto out_free;
s_printf(txt_buf + strlen(txt_buf), "Secure Monitor dumped to secmon.bin\n"); strcat(txt_buf, "Secure Monitor dumped to secmon.bin\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1225,7 +1225,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
emmcsn_path_impl(path, "/pkg1", "warmboot.bin", &storage); emmcsn_path_impl(path, "/pkg1", "warmboot.bin", &storage);
if (sd_save_to_file(warmboot, hdr->wb_size, path)) if (sd_save_to_file(warmboot, hdr->wb_size, path))
goto out_free; goto out_free;
s_printf(txt_buf + strlen(txt_buf), "Warmboot dumped to warmboot.bin\n\n"); strcat(txt_buf, "Warmboot dumped to warmboot.bin\n\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
} }
@ -1262,7 +1262,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
pkg2_hdr_t *pkg2_hdr = pkg2_decrypt(pkg2, kb); pkg2_hdr_t *pkg2_hdr = pkg2_decrypt(pkg2, kb);
if (!pkg2_hdr) if (!pkg2_hdr)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Pkg2 decryption failed!#"); strcat(txt_buf, "#FFDD00 Pkg2 decryption failed!#");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1287,7 +1287,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
emmcsn_path_impl(path, "/pkg2", "pkg2_decr.bin", &storage); emmcsn_path_impl(path, "/pkg2", "pkg2_decr.bin", &storage);
if (sd_save_to_file(pkg2, pkg2_hdr->sec_size[PKG2_SEC_KERNEL] + pkg2_hdr->sec_size[PKG2_SEC_INI1], path)) if (sd_save_to_file(pkg2, pkg2_hdr->sec_size[PKG2_SEC_KERNEL] + pkg2_hdr->sec_size[PKG2_SEC_INI1], path))
goto out; goto out;
s_printf(txt_buf + strlen(txt_buf), "pkg2 dumped to pkg2_decr.bin\n"); strcat(txt_buf, "pkg2 dumped to pkg2_decr.bin\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1295,7 +1295,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
emmcsn_path_impl(path, "/pkg2", "kernel.bin", &storage); emmcsn_path_impl(path, "/pkg2", "kernel.bin", &storage);
if (sd_save_to_file(pkg2_hdr->data, pkg2_hdr->sec_size[PKG2_SEC_KERNEL], path)) if (sd_save_to_file(pkg2_hdr->data, pkg2_hdr->sec_size[PKG2_SEC_KERNEL], path))
goto out; goto out;
s_printf(txt_buf + strlen(txt_buf), "Kernel dumped to kernel.bin\n"); strcat(txt_buf, "Kernel dumped to kernel.bin\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1311,7 +1311,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
if (!ini1_off) if (!ini1_off)
{ {
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Failed to dump INI1 and kips!#\n"); strcat(txt_buf, "#FFDD00 Failed to dump INI1 and kips!#\n");
goto out; goto out;
} }
@ -1320,7 +1320,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
if (sd_save_to_file(ini1, ini1_size, path)) if (sd_save_to_file(ini1, ini1_size, path))
goto out; goto out;
s_printf(txt_buf + strlen(txt_buf), "INI1 dumped to ini1.bin\n\n"); strcat(txt_buf, "INI1 dumped to ini1.bin\n\n");
lv_label_set_text(lb_desc, txt_buf); lv_label_set_text(lb_desc, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1367,7 +1367,6 @@ out_free:
free(loader); free(loader);
free(pkg2); free(pkg2);
free(txt_buf); free(txt_buf);
free(txt_buf2);
sdmmc_storage_end(&storage); sdmmc_storage_end(&storage);
sd_unmount(); sd_unmount();
@ -1616,7 +1615,7 @@ static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent)
"#FF3C28 bootloader.#"); "#FF3C28 bootloader.#");
if (h_cfg.rcm_patched) if (h_cfg.rcm_patched)
s_printf(txt_buf + strlen(txt_buf), " #FF8000 This is disabled because this unit is patched!#"); strcat(txt_buf, " #FF8000 This is disabled because this unit is patched!#");
lv_obj_t *label_txt4 = lv_label_create(h2, NULL); lv_obj_t *label_txt4 = lv_label_create(h2, NULL);
lv_label_set_recolor(label_txt4, true); lv_label_set_recolor(label_txt4, true);

View file

@ -1008,21 +1008,21 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
} }
if ((file_size >> 9) > size_sct) if ((file_size >> 9) > size_sct)
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# TWRP image too big!\n"); strcat(txt_buf, "#FF8000 Warning:# TWRP image too big!\n");
else else
{ {
sdmmc_storage_write(&sd_storage, offset_sct, file_size >> 9, buf); sdmmc_storage_write(&sd_storage, offset_sct, file_size >> 9, buf);
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 Success:# TWRP image flashed!\n"); strcat(txt_buf, "#C7EA46 Success:# TWRP image flashed!\n");
f_unlink(path); f_unlink(path);
} }
free(buf); free(buf);
} }
else else
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# TWRP partition not found!\n"); strcat(txt_buf, "#FF8000 Warning:# TWRP partition not found!\n");
} }
else else
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# TWRP image not found!\n"); strcat(txt_buf, "#FF8000 Warning:# TWRP image not found!\n");
lv_label_set_text(lbl_status, txt_buf); lv_label_set_text(lbl_status, txt_buf);
manual_system_maintenance(true); manual_system_maintenance(true);
@ -1060,21 +1060,21 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
} }
if ((file_size >> 9) > size_sct) if ((file_size >> 9) > size_sct)
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# DTB image too big!"); strcat(txt_buf, "#FF8000 Warning:# DTB image too big!");
else else
{ {
sdmmc_storage_write(&sd_storage, offset_sct, file_size >> 9, buf); sdmmc_storage_write(&sd_storage, offset_sct, file_size >> 9, buf);
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 Success:# DTB image flashed!"); strcat(txt_buf, "#C7EA46 Success:# DTB image flashed!");
f_unlink(path); f_unlink(path);
} }
free(buf); free(buf);
} }
else else
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# DTB partition not found!"); strcat(txt_buf, "#FF8000 Warning:# DTB partition not found!");
} }
else else
s_printf(txt_buf + strlen(txt_buf), "#FF8000 Warning:# DTB image not found!"); strcat(txt_buf, "#FF8000 Warning:# DTB image not found!");
lv_label_set_text(lbl_status, txt_buf); lv_label_set_text(lbl_status, txt_buf);
@ -1098,7 +1098,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
error: error:
if (boot_twrp) if (boot_twrp)
{ {
s_printf(txt_buf + strlen(txt_buf),"\n\nDo you want to reboot into TWRP\nto finish Android installation?"); strcat(txt_buf,"\n\nDo you want to reboot into TWRP\nto finish Android installation?");
lv_label_set_text(lbl_status, txt_buf); lv_label_set_text(lbl_status, txt_buf);
lv_mbox_add_btns(mbox, mbox_btn_map2, _action_reboot_twrp); lv_mbox_add_btns(mbox, mbox_btn_map2, _action_reboot_twrp);
} }
@ -1525,9 +1525,9 @@ static lv_res_t _create_mbox_partitioning_next(lv_obj_t *btn)
s_printf(txt_buf, "#FFDD00 Warning: This will partition your SD Card!#\n\n"); s_printf(txt_buf, "#FFDD00 Warning: This will partition your SD Card!#\n\n");
if (part_info.backup_possible) if (part_info.backup_possible)
s_printf(txt_buf + strlen(txt_buf), "#C7EA46 Your files will be backed up and restored!#"); strcat(txt_buf, "#C7EA46 Your files will be backed up and restored!#");
else else
s_printf(txt_buf + strlen(txt_buf), "#FFDD00 Your files will be wiped!#\n#FFDD00 Use USB UMS to copy them over!#"); strcat(txt_buf, "#FFDD00 Your files will be wiped!#\n#FFDD00 Use USB UMS to copy them over!#");
lv_label_set_text(lbl_status, txt_buf); lv_label_set_text(lbl_status, txt_buf);