@@ -97,7 +97,7 @@ int MenuMode::indexChooseLayout = 0;
9797
9898// / USB stuff
9999int usb_data_connected = 0 ;
100- int usb_mounted = 0 ;
100+ int usb_sharing = 0 ;
101101
102102
103103// / -------------- FUNCTIONS IMPLEMENTATION --------------
@@ -414,16 +414,16 @@ void MenuMode::init_menu_system_values(){
414414 }
415415
416416 // / ------- Get USB Value -------
417- // should be getters from retroFe here, instead of setting values
418- usb_data_connected = 1 ;
419- usb_mounted = 0 ;
417+ usb_data_connected = !Utils::executeRawPath (SHELL_CMD_USB_DATA_CONNECTED);
418+ usb_sharing = !Utils::executeRawPath (SHELL_CMD_USB_CHECK_IS_SHARING);
420419
421- if (usb_mounted && !usb_data_connected){
422- MENU_ERROR_PRINTF (" WARNING usb_mounted && !usb_data_connected\n " );
423- usb_mounted = 0 ;
420+ if (usb_sharing && !usb_data_connected){
421+ MENU_ERROR_PRINTF (" WARNING usb_sharing && !usb_data_connected\n " );
422+ usb_sharing = 0 ;
424423 }
425424
426- if (usb_mounted){
425+ if (usb_sharing){
426+
427427 // / Force USB menu to launch
428428 for (int cur_idx=0 ; cur_idx < nb_menu_zones; cur_idx++){
429429 if (idx_menus[cur_idx] == MENU_TYPE_USB){
@@ -433,20 +433,11 @@ void MenuMode::init_menu_system_values(){
433433 }
434434 }
435435 }
436-
437- // / ------ Save prev key repeat params and set new Key repeat -------
438- SDL_GetKeyRepeat (&backup_key_repeat_delay, &backup_key_repeat_interval);
439- if (SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL)){
440- MENU_ERROR_PRINTF (" ERROR with SDL_EnableKeyRepeat: %s\n " , SDL_GetError ());
441- }
442-
443- // / Get save slot from game
444- savestate_slot = (savestate_slot%MAX_SAVE_SLOTS); // security
445436}
446437
447438void MenuMode::menu_screen_refresh (int menuItem, int prevItem, int scroll, uint8_t menu_confirmation, uint8_t menu_action){
448439 // / --------- Vars ---------
449- int print_arrows = (scroll || usb_mounted )?0 :1 ;
440+ int print_arrows = (scroll || usb_sharing )?0 :1 ;
450441
451442 // / --------- Clear HW screen ----------
452443 SDL_Surface * virtual_hw_screen = SDL::getWindow ();
@@ -565,7 +556,7 @@ void MenuMode::menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8
565556
566557 case MENU_TYPE_USB:
567558 // / ---- Write slot -----
568- sprintf (text_tmp, " %s USB" , usb_mounted ?" EJECT" :" MOUNT" );
559+ sprintf (text_tmp, " %s USB" , usb_sharing ?" EJECT" :" MOUNT" );
569560 text_surface = TTF_RenderText_Blended (menu_title_font, text_tmp, text_color);
570561 text_pos.x = (virtual_hw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w )/2 ;
571562 text_pos.y = virtual_hw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h /2 ;
@@ -689,10 +680,20 @@ int MenuMode::launch( )
689680 char fname[MAXPATHLEN];
690681 indexChooseLayout = config->currentLayoutIdx_ ;
691682 int returnCode = MENU_RETURN_OK;
683+ int prevItem=menuItem;
692684
693- // / ------ Get init values -------
685+ // / ------ Get System values -------
694686 init_menu_system_values ();
695- int prevItem=menuItem;
687+
688+
689+ // / Save prev key repeat params and set new Key repeat
690+ SDL_GetKeyRepeat (&backup_key_repeat_delay, &backup_key_repeat_interval);
691+ if (SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL)){
692+ MENU_ERROR_PRINTF (" ERROR with SDL_EnableKeyRepeat: %s\n " , SDL_GetError ());
693+ }
694+
695+ // / Get save slot from game
696+ // savestate_slot = (savestate_slot%MAX_SAVE_SLOTS); // security
696697
697698 // / ------ Copy currently displayed screen -------
698699 SDL_Surface * virtual_hw_screen = SDL::getWindow ();
@@ -730,7 +731,7 @@ int MenuMode::launch( )
730731 case SDLK_q:
731732 case SDLK_ESCAPE:
732733 // / ------ Check if no action ------
733- if (usb_mounted ){
734+ if (usb_sharing ){
734735 break ;
735736 }
736737
@@ -741,7 +742,7 @@ int MenuMode::launch( )
741742 case SDLK_DOWN:
742743 MENU_DEBUG_PRINTF (" DOWN\n " );
743744 // / ------ Check if no action ------
744- if (usb_mounted ){
745+ if (usb_sharing ){
745746 break ;
746747 }
747748
@@ -768,7 +769,7 @@ int MenuMode::launch( )
768769 case SDLK_UP:
769770 MENU_DEBUG_PRINTF (" UP\n " );
770771 // / ------ Check if no action ------
771- if (usb_mounted ){
772+ if (usb_sharing ){
772773 break ;
773774 }
774775
@@ -947,35 +948,35 @@ int MenuMode::launch( )
947948 }
948949 }
949950 else if (idx_menus[menuItem] == MENU_TYPE_USB){
950- MENU_DEBUG_PRINTF (" USB %s\n " , usb_mounted ?" unmount" :" mount" );
951+ MENU_DEBUG_PRINTF (" USB %s\n " , usb_sharing ?" unmount" :" mount" );
951952 if (menu_confirmation){
952- MENU_DEBUG_PRINTF (" %s USB - confirmed\n " , usb_mounted ?" Unmount" :" Mount" );
953+ MENU_DEBUG_PRINTF (" %s USB - confirmed\n " , usb_sharing ?" Unmount" :" Mount" );
953954 // / ----- Refresh screen ----
954955 menu_screen_refresh (menuItem, prevItem, scroll, menu_confirmation, 1 );
955956
956957 // / ----- Shell cmd ----
957- /* fp = popen(usb_mounted ?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r");
958+ /* fp = popen(usb_sharing ?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r");
958959 if (fp == NULL) {
959960 MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
960961 }
961962 else{
962- usb_mounted = !usb_mounted ;
963+ usb_sharing = !usb_sharing ;
963964 }*/
964965
965- bool res = Utils::executeRawPath (usb_mounted ?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
966+ bool res = Utils::executeRawPath (usb_sharing ?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
966967 if (!res) {
967968 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
968969 }
969970 else {
970- usb_mounted = !usb_mounted ;
971+ usb_sharing = !usb_sharing ;
971972 }
972973
973974 // / ------ Refresh screen ------
974975 menu_confirmation = 0 ;
975976 screen_refresh = 1 ;
976977 }
977978 else {
978- MENU_DEBUG_PRINTF (" %s USB - asking confirmation\n " , usb_mounted ?" Unmount" :" Mount" );
979+ MENU_DEBUG_PRINTF (" %s USB - asking confirmation\n " , usb_sharing ?" Unmount" :" Mount" );
979980 menu_confirmation = 1 ;
980981 screen_refresh = 1 ;
981982 }
0 commit comments