From 2148ce9dec509725835728d81e47527ba1c7282c Mon Sep 17 00:00:00 2001 From: TwinAphex51224 Date: Sat, 11 Feb 2012 16:27:13 +0100 Subject: [PATCH] (PS3) Can now return to menu from game by pressing L3 + R3 --- ps3/main.c | 16 +++------------- ps3/menu.c | 25 +++++++------------------ ps3/ps3_input.c | 27 +++++++++++++++++++++++---- ps3/ps3_video_psgl.h | 5 +++++ ps3/shared.h | 1 - 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/ps3/main.c b/ps3/main.c index 8e20ffc9d3..3fbb1de257 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -46,7 +46,6 @@ #define EMULATOR_CONTENT_DIR "SSNE10000" char special_action_msg[256]; /* message which should be overlaid on top of the screen*/ -uint32_t special_action_msg_expired; /* time at which the message no longer needs to be overlaid onscreen*/ uint64_t ingame_menu_item = 0; char contentInfoPath[MAX_PATH_LENGTH]; @@ -71,15 +70,10 @@ SYS_PROCESS_PARAM(1001, 0x100000) #undef main -uint32_t set_text_message_speed(uint32_t value) -{ - return g_frame_count + value; -} - void set_text_message(const char * message, uint32_t speed) { snprintf(special_action_msg, sizeof(special_action_msg), message); - special_action_msg_expired = set_text_message_speed(speed); + SET_TIMER_EXPIRATION(speed); } static bool file_exists(const char * filename) @@ -386,10 +380,7 @@ static void ingame_menu(void) ssnes_render_cached_frame(); - if(g_frame_count < special_action_msg_expired && blocking) - { - } - else + if(IS_TIMER_EXPIRED() && blocking == false) { if(CTRL_CIRCLE(state)) { @@ -728,7 +719,7 @@ static void ingame_menu(void) cellDbgFontPuts (x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_XMB)), font_size+0.01f, BLUE, "Return to XMB"); cellDbgFontPuts(x_position, (ypos+(ypos_increment*MENU_ITEM_RETURN_TO_XMB)), font_size, menuitem_colors[MENU_ITEM_RETURN_TO_XMB], "Return to XMB"); - if(g_frame_count < special_action_msg_expired) + if(IS_TIMER_NOT_EXPIRED()) { cellDbgFontPrintf (0.09f, 0.90f, 1.51f, BLUE, special_action_msg); cellDbgFontPrintf (0.09f, 0.90f, 1.50f, WHITE, special_action_msg); @@ -736,7 +727,6 @@ static void ingame_menu(void) } else { - special_action_msg_expired = 0; cellDbgFontPrintf (0.09f, 0.90f, 0.98f+0.01f, BLUE, comment); cellDbgFontPrintf (0.09f, 0.90f, 0.98f, LIGHTBLUE, comment); } diff --git a/ps3/menu.c b/ps3/menu.c index b326156ecc..4cd99e39be 100644 --- a/ps3/menu.c +++ b/ps3/menu.c @@ -164,10 +164,7 @@ static void browser_update(filebrowser_t * b) diff_state = old_state ^ state; button_was_pressed = old_state & diff_state; - if(g_frame_count < special_action_msg_expired) - { - } - else + if(IS_TIMER_EXPIRED()) { if (CTRL_LSTICK_DOWN(state)) { @@ -276,16 +273,11 @@ static void browser_update(filebrowser_t * b) } - if (CTRL_L3(state) && CTRL_R3(state)) - { - /* if a rom is loaded then resume it */ - if (g_console.emulator_initialized) - { - g_console.menu_enable = false; - g_console.mode_switch = MODE_EMULATION; - set_text_message("", 15); - } - } + g_console.menu_enable = !((CTRL_L3(state) && CTRL_R3(state) && g_console.emulator_initialized)); + g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION; + + if(g_console.mode_switch == MODE_EMULATION) + SET_TIMER_EXPIRATION(60); old_state = state; } @@ -1420,10 +1412,7 @@ static void select_setting(menu * menu_obj) button_was_pressed = old_state & diff_state; - if(g_frame_count < special_action_msg_expired) - { - } - else + if(IS_TIMER_EXPIRED()) { /* back to ROM menu if CIRCLE is pressed */ if (CTRL_L1(button_was_pressed) || CTRL_CIRCLE(button_was_pressed)) diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index b957807e1c..afbe40e106 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -18,9 +18,11 @@ #include "../driver.h" #include "ps3_input.h" +#include "ps3_video_psgl.h" #include #include "../libsnes.hpp" #include "../general.h" +#include "shared.h" #include @@ -89,7 +91,7 @@ static bool ps3_key_pressed(void *data, int key) switch (key) { case SSNES_FAST_FORWARD_HOLD_KEY: - return CTRL_RSTICK_UP(state[0]) && CTRL_R2(~state[0]); + return CTRL_RSTICK_DOWN(state[0]) && CTRL_R2(~state[0]); case SSNES_LOAD_STATE_KEY: return (CTRL_RSTICK_UP(state[0]) && CTRL_R2(state[0])); case SSNES_SAVE_STATE_KEY: @@ -99,10 +101,27 @@ static bool ps3_key_pressed(void *data, int key) case SSNES_STATE_SLOT_MINUS: return (CTRL_RSTICK_LEFT(state[0]) && CTRL_R2(state[0])); case SSNES_REWIND: - return CTRL_RSTICK_DOWN(state[0]) && CTRL_R2(~state[0]); + return CTRL_RSTICK_UP(state[0]) && CTRL_R2(~state[0]); case SSNES_QUIT_KEY: - g_console.ingame_menu_enable = CTRL_R3(state[0]) && !CTRL_L3(state[0]); - return CTRL_R3(state[0]); + { + uint32_t r3_pressed = CTRL_R3(state[0]); + uint32_t l3_pressed = CTRL_L3(state[0]); + bool retval = false; + g_console.menu_enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED()); + g_console.ingame_menu_enable = r3_pressed && !l3_pressed; + if(g_console.menu_enable && !g_console.ingame_menu_enable) + { + g_console.mode_switch = MODE_MENU; + SET_TIMER_EXPIRATION(60); + retval = g_console.menu_enable; + } + else + { + g_console.mode_switch = MODE_EMULATION; + retval = g_console.ingame_menu_enable; + } + return retval; + } default: return false; } diff --git a/ps3/ps3_video_psgl.h b/ps3/ps3_video_psgl.h index 64f88bd7af..15ce950cf6 100644 --- a/ps3/ps3_video_psgl.h +++ b/ps3/ps3_video_psgl.h @@ -41,6 +41,10 @@ enum LAST_ASPECT_RATIO }; +#define IS_TIMER_NOT_EXPIRED() (g_frame_count < g_console.timer_expiration_frame_count) +#define IS_TIMER_EXPIRED() (!(IS_TIMER_NOT_EXPIRED())) +#define SET_TIMER_EXPIRATION(value) g_console.timer_expiration_frame_count = g_frame_count + value; + bool ps3_setup_texture(void); const char * ps3_get_resolution_label(uint32_t resolution); int ps3_check_resolution(uint32_t resolution_id); @@ -60,5 +64,6 @@ void ps3graphics_video_init(bool get_all_resolutions); void ps3graphics_video_reinit(void); extern void *g_gl; +extern unsigned g_frame_count; #endif diff --git a/ps3/shared.h b/ps3/shared.h index 594c6c58ab..c646b91c92 100644 --- a/ps3/shared.h +++ b/ps3/shared.h @@ -57,7 +57,6 @@ enum { #define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_XMB+1 extern char special_action_msg[256]; -extern uint32_t special_action_msg_expired; extern unsigned g_frame_count; extern bool g_quitting;