diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index 7b32c3d..170c58c 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -31,6 +31,7 @@ const key_names_s key_names[] = { sed 's/^#define \([^ \t]\+\)[ \t]*\([^\ \t]\+\)/ { \"\1\",\t\2 },/' /usr/include/linux/input.h */ { "KEY_RESERVED", SDLK_UNKNOWN }, + { "KEY_FIRST", SDLK_FIRST }, { "Escape", SDLK_ESCAPE }, { "1", SDLK_1 }, { "2", SDLK_2 }, @@ -236,7 +237,7 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required) bool found = false; - if (scanCode != SDLK_UNKNOWN) + if (scanCode != SDLK_UNKNOWN || !strcmp(token.c_str(),"SDLK_FIRST") ) { Logger::write(Logger::ZONE_INFO, "Input", "Binding key " + configKey + ", Key Value: " + std::to_string(scanCode)); keyHandlers_.push_back(std::pair(new KeyboardHandler(scanCode), key)); diff --git a/RetroFE/Source/Menu/MenuMode.cpp b/RetroFE/Source/Menu/MenuMode.cpp index 968bdcf..8e77bd8 100644 --- a/RetroFE/Source/Menu/MenuMode.cpp +++ b/RetroFE/Source/Menu/MenuMode.cpp @@ -515,13 +515,22 @@ void MenuMode::menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8 case MENU_TYPE_EXIT: case MENU_TYPE_POWERDOWN: - if(menu_confirmation){ - sprintf(text_tmp, "Are you sure ?"); + if(menu_action){ + sprintf(text_tmp, "Shutting down..."); text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color); text_pos.x = (virtual_hw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2; text_pos.y = virtual_hw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2 + 2*padding_y_from_center_menu_zone; SDL_BlitSurface(text_surface, NULL, virtual_hw_screen, &text_pos); } + else{ + if(menu_confirmation){ + sprintf(text_tmp, "Are you sure ?"); + text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color); + text_pos.x = (virtual_hw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2; + text_pos.y = virtual_hw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2 + 2*padding_y_from_center_menu_zone; + SDL_BlitSurface(text_surface, NULL, virtual_hw_screen, &text_pos); + } + } break; default: break; @@ -597,6 +606,7 @@ void MenuMode::launch( ) break; case SDLK_q: + case SDLK_FIRST: case SDLK_ESCAPE: stop_menu_loop = 1; break; @@ -809,6 +819,10 @@ void MenuMode::launch( ) else if(idx_menus[menuItem] == MENU_TYPE_POWERDOWN){ if(menu_confirmation){ MENU_DEBUG_PRINTF("Powerdown - confirmed\n"); + + /// ------ Refresh Screen ------- + menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1); + /// ----- Shell cmd ---- sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN); fp = popen(shell_cmd, "r"); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 947ff7e..f54928b 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -441,8 +441,6 @@ void RetroFE::run( ) } float preloadTime = 0; - int current_sdl_ticks = 0; - int process_time = 0; // Force refresh variables #ifdef PERIOD_FORCE_REFRESH @@ -1137,6 +1135,14 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page ) SDL_Event e; while ( SDL_PollEvent( &e ) ) { + if ( e.type == SDL_QUIT ) + { + printf("How dare you interrupt me!\n"); + attract_.reset( ); + state = RETROFE_QUIT_REQUEST; + return state; + } + input_.update(e); /*if ( e.type == SDL_KEYDOWN && !e.key.repeat ) {