Allow INI combo switch only in main or system page.

This commit is contained in:
sorgelig
2020-07-13 03:03:08 +08:00
parent 0b629ae55c
commit 7e45aa5d23
3 changed files with 36 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;
}

2
menu.h
View File

@@ -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