diff --git a/bootloader/utils/btn.c b/bootloader/utils/btn.c index d21d633..5a1d024 100644 --- a/bootloader/utils/btn.c +++ b/bootloader/utils/btn.c @@ -34,6 +34,16 @@ u8 btn_read() return res; } +u8 btn_read_vol() +{ + u8 res = 0; + if (!gpio_read(GPIO_PORT_X, GPIO_PIN_7)) + res |= BTN_VOL_DOWN; + if (!gpio_read(GPIO_PORT_X, GPIO_PIN_6)) + res |= BTN_VOL_UP; + return res; +} + u8 btn_wait() { u8 res = 0, btn = btn_read(); diff --git a/bootloader/utils/btn.h b/bootloader/utils/btn.h index d6cad0c..4f6b4d2 100644 --- a/bootloader/utils/btn.h +++ b/bootloader/utils/btn.h @@ -26,6 +26,7 @@ #define BTN_SINGLE (1 << 7) u8 btn_read(); +u8 btn_read_vol(); u8 btn_wait(); u8 btn_wait_timeout(u32 time_ms, u8 mask); diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 0ce64d7..b2ac307 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -143,7 +143,6 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 FIL fp; FIL hashFp; u8 sparseShouldVerify = 4; - u32 btn = 0; u32 prevPct = 200; u32 sdFileSector = 0; int res = 0; @@ -301,8 +300,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 sparseShouldVerify++; // Check for cancellation combo. - btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); - if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) + if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN)) { s_printf(gui->txt_buf, "#FFDD00 Verification was cancelled!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); @@ -352,7 +350,6 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t u32 currPartIdx = 0; u32 numSplitParts = 0; u32 maxSplitParts = 0; - u32 btn = 0; bool isSmallSdCard = false; bool partialDumpInProgress = false; int res = 0; @@ -662,8 +659,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t } // Check for cancellation combo. - btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); - if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) + if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN)) { s_printf(gui->txt_buf, "\n#FFDD00 The backup was cancelled!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 7a2d633..634b60f 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -217,8 +217,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto } // Check for cancellation combo. - u32 btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); - if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) + if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN)) { s_printf(gui->txt_buf, "#FFDD00 The emuMMC was cancelled!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); @@ -482,7 +481,6 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%"); manual_system_maintenance(true); - s_printf(gui->txt_buf, "#96FF00 Base folder:#\n%s\n#96FF00 Partition offset:# #FF8000 0x%08X#", gui->base_path, sd_part_off); lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf); @@ -503,8 +501,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part while (totalSectors > 0) { // Check for cancellation combo. - u32 btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); - if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) + if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN)) { s_printf(gui->txt_buf, "#FFDD00 The emuMMC was cancelled!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); diff --git a/nyx/nyx_gui/input/touch.c b/nyx/nyx_gui/input/touch.c index cfa6e2f..09bd0b5 100644 --- a/nyx/nyx_gui/input/touch.c +++ b/nyx/nyx_gui/input/touch.c @@ -364,8 +364,8 @@ int touch_power_on() // Wait for the touchscreen module to get ready. touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20); - u32 btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); - if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) + // Check for forced boot time calibration. + if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN)) { u8 err[2]; if (touch_panel_ito_test(err)) diff --git a/nyx/nyx_gui/utils/btn.c b/nyx/nyx_gui/utils/btn.c index 63a983a..7ac35ef 100644 --- a/nyx/nyx_gui/utils/btn.c +++ b/nyx/nyx_gui/utils/btn.c @@ -34,6 +34,16 @@ u8 btn_read() return res; } +u8 btn_read_vol() +{ + u8 res = 0; + if (!gpio_read(GPIO_PORT_X, GPIO_PIN_7)) + res |= BTN_VOL_DOWN; + if (!gpio_read(GPIO_PORT_X, GPIO_PIN_6)) + res |= BTN_VOL_UP; + return res; +} + u8 btn_wait() { u8 res = 0, btn = btn_read(); diff --git a/nyx/nyx_gui/utils/btn.h b/nyx/nyx_gui/utils/btn.h index 8394a52..c0f0e08 100644 --- a/nyx/nyx_gui/utils/btn.h +++ b/nyx/nyx_gui/utils/btn.h @@ -25,6 +25,7 @@ #define BTN_VOL_UP (1 << 2) u8 btn_read(); +u8 btn_read_vol(); u8 btn_wait(); u8 btn_wait_timeout(u32 time_ms, u8 mask);