From 7e45aa5d2356191873fabd4a632bbf8ea1822e12 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 13 Jul 2020 03:03:08 +0800 Subject: [PATCH] Allow INI combo switch only in main or system page. --- input.cpp | 11 +++++++---- menu.cpp | 28 +++++++++++++++++++++++++++- menu.h | 2 ++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/input.cpp b/input.cpp index 04fccd7..0016d4a 100644 --- a/input.cpp +++ b/input.cpp @@ -1534,10 +1534,13 @@ static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int struct input_event ev; ev.type = EV_KEY; ev.value = press; + + int cfg_switch = menu_allow_cfg_switch() && (osdbtn & JOY_BTN2) && press; + switch (mask) { case JOY_RIGHT: - if (press && (osdbtn & JOY_BTN2)) + if (cfg_switch) { user_io_set_ini(0); osdbtn = 0; @@ -1547,7 +1550,7 @@ static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int break; case JOY_LEFT: - if (press && (osdbtn & JOY_BTN2)) + if (cfg_switch) { user_io_set_ini(1); osdbtn = 0; @@ -1557,7 +1560,7 @@ static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int break; case JOY_UP: - if (press && (osdbtn & JOY_BTN2)) + if (cfg_switch) { user_io_set_ini(2); osdbtn = 0; @@ -1567,7 +1570,7 @@ static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int break; case JOY_DOWN: - if (press && (osdbtn & JOY_BTN2)) + if (cfg_switch) { user_io_set_ini(3); osdbtn = 0; diff --git a/menu.cpp b/menu.cpp index 73229e9..f3225c6 100644 --- a/menu.cpp +++ b/menu.cpp @@ -843,6 +843,7 @@ static int wm_y = 0; static int wm_ok = 0; static int wm_side = 0; static uint16_t wm_pos[4] = {}; +static int page = 0; void HandleUI(void) { @@ -881,7 +882,6 @@ void HandleUI(void) static int flash_state = 0; static uint32_t dip_submenu; static int need_reset = 0; - static int page = 0; static int flat = 0; static int menusub_parent = 0; static char title[32] = {}; @@ -5862,3 +5862,29 @@ int menu_lightgun_cb(uint16_t type, uint16_t code, int value) } return 0; } + +int menu_allow_cfg_switch() +{ + if (user_io_osd_is_visible()) + { + switch (menustate) + { + case MENU_ST_MAIN2: + case MENU_ARCHIE_MAIN2: + case MENU_MAIN2: + case MENU_8BIT_SYSTEM2: + case MENU_SYSTEM2: + return 1; + + case MENU_FILE_SELECT2: + if (is_menu() && (fs_Options & SCANO_CORES)) return 1; + break; + + case MENU_8BIT_MAIN2: + if (!page) return 1; + break; + } + } + + return 0; +} diff --git a/menu.h b/menu.h index 4bb25f4..4ceb494 100644 --- a/menu.h +++ b/menu.h @@ -19,4 +19,6 @@ void substrcpy(char *d, char *s, char idx); void open_joystick_setup(); int menu_lightgun_cb(uint16_t type, uint16_t code, int value); +int menu_allow_cfg_switch(); + #endif