diff --git a/gx/frontend/main.c b/gx/frontend/main.c index 84126118c3..e6619de2ad 100644 --- a/gx/frontend/main.c +++ b/gx/frontend/main.c @@ -162,6 +162,7 @@ static void menu_loop(void) static const struct retro_keybind _quit_binds[] = { { 0, 0, (enum retro_key)0, (GX_CLASSIC_HOME), 0 }, { 0, 0, (enum retro_key)0, (GX_WIIMOTE_HOME), 0 }, + { 0, 0, (enum retro_key)0, (GX_QUIT_KEY), 0 }, }; const struct retro_keybind *quit_binds[] = { @@ -174,6 +175,9 @@ static void menu_loop(void) input_state |= input_wii.input_state(NULL, quit_binds, false, RETRO_DEVICE_JOYPAD, 0, 1) ? (GX_WIIMOTE_HOME) : 0; + input_state |= input_wii.input_state(NULL, quit_binds, false, + RETRO_DEVICE_JOYPAD, 0, 2) ? (GX_QUIT_KEY) : 0; + uint64_t trigger_state = input_state & ~old_input_state; rgui_action_t action = RGUI_ACTION_NOOP; @@ -214,21 +218,28 @@ static void menu_loop(void) old_input_state = input_state; - bool quit_key_pressed = ((trigger_state & GX_WIIMOTE_HOME) || (trigger_state & GX_CLASSIC_HOME)) ? true : false; + bool goto_menu_key_pressed = ((trigger_state & GX_WIIMOTE_HOME) || (trigger_state & GX_CLASSIC_HOME)) ? true : false; + bool quit_key_pressed = (trigger_state & GX_QUIT_KEY) ? true : false; if(IS_TIMER_EXPIRED(gx)) { // if we want to force goto the emulation loop, skip this if(g_console.mode_switch != MODE_EMULATION) { - if(quit_key_pressed) + if(goto_menu_key_pressed) { - g_console.menu_enable = (quit_key_pressed && g_console.emulator_initialized) ? false : true; + g_console.menu_enable = (goto_menu_key_pressed && g_console.emulator_initialized) ? false : true; g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION; } } } + if(quit_key_pressed) + { + g_console.menu_enable = false; + g_console.mode_switch = MODE_EXIT; + } + // set a timer delay so that we don't instantly switch back to the menu when // press and holding QUIT in the emulation loop (lasts for 30 frame ticks) if(g_console.mode_switch == MODE_EMULATION) diff --git a/gx/gx_input.c b/gx/gx_input.c index e08d86ac2e..24a75eaa57 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -258,6 +258,9 @@ static void wii_input_post_init(void) static void wii_input_poll(void *data) { (void)data; + bool quit_gc = false; + bool quit_classic = false; + bool quit_wiimote = false; PAD_ScanPads(); #ifdef HW_RVL @@ -283,6 +286,9 @@ static void wii_input_poll(void *data) state |= (PAD_TriggerL(port) > 127) ? GX_GC_L_TRIGGER : 0; state |= (PAD_TriggerR(port) > 127) ? GX_GC_R_TRIGGER : 0; + if((down & PAD_BUTTON_A) && (PAD_TriggerL(port) > 127) && (PAD_TriggerR(port) > 127) && (down & PAD_TRIGGER_Z) && (down & PAD_BUTTON_START) && (down & PAD_BUTTON_A)) + quit_gc = true; + s8 x = PAD_StickX(port); s8 y = PAD_StickY(port); @@ -320,6 +326,9 @@ static void wii_input_poll(void *data) state |= (down & WPAD_BUTTON_MINUS) ? GX_WIIMOTE_MINUS : 0; state |= (down & WPAD_BUTTON_HOME) ? GX_WIIMOTE_HOME : 0; + if((down & WPAD_BUTTON_HOME) && (down & WPAD_BUTTON_B)) + quit_wiimote = true; + expansion_t exp; WPAD_Expansion(port, &exp); switch (exp.type) @@ -366,6 +375,9 @@ static void wii_input_poll(void *data) state |= (down & WPAD_CLASSIC_BUTTON_ZL) ? GX_CLASSIC_ZL_TRIGGER : 0; state |= (down & WPAD_CLASSIC_BUTTON_ZR) ? GX_CLASSIC_ZR_TRIGGER : 0; + if((down & WPAD_CLASSIC_BUTTON_HOME) && (down & WPAD_CLASSIC_BUTTON_ZL) && (down & WPAD_CLASSIC_BUTTON_ZR)) + quit_classic = true; + s8 x = wii_stick_x(exp.classic.ljs); s8 y = wii_stick_y(exp.classic.ljs); @@ -407,6 +419,9 @@ static void wii_input_poll(void *data) state |= GX_WIIMOTE_HOME; } + if (quit_gc || quit_wiimote || quit_classic) + state |= GX_QUIT_KEY; + pad_state[port] = state; } @@ -428,10 +443,11 @@ static bool wii_key_pressed(void *data, int key) case RARCH_QUIT_KEY: if(IS_TIMER_EXPIRED(gx)) { - uint64_t quit_pressed_classic = pad_state[0] & GX_CLASSIC_HOME; - uint64_t quit_pressed_wiimote = pad_state[0] & GX_WIIMOTE_HOME; + uint64_t goto_menu_pressed_classic = pad_state[0] & GX_CLASSIC_HOME; + uint64_t goto_menu_pressed_wiimote = pad_state[0] & GX_WIIMOTE_HOME; + uint64_t quit_rarch = pad_state[0] & GX_QUIT_KEY; bool retval = false; - g_console.menu_enable = ((quit_pressed_classic || quit_pressed_wiimote) && IS_TIMER_EXPIRED(gx)); + g_console.menu_enable = ((goto_menu_pressed_classic || goto_menu_pressed_wiimote || quit_rarch) && IS_TIMER_EXPIRED(gx)); if(g_console.menu_enable) { @@ -440,6 +456,9 @@ static bool wii_key_pressed(void *data, int key) retval = g_console.menu_enable; } + if(quit_rarch) + g_console.mode_switch = MODE_EXIT; + retval = g_console.menu_enable; return retval; } diff --git a/gx/gx_input.h b/gx/gx_input.h index 2b35da0c10..41a3ef41a1 100644 --- a/gx/gx_input.h +++ b/gx/gx_input.h @@ -82,6 +82,7 @@ enum GX_NUNCHUK_LEFT = 1ULL << 58, GX_NUNCHUK_RIGHT = 1ULL << 59, #endif + GX_QUIT_KEY = 1ULL << 60, }; enum wii_device_id