Skip to content

Commit 1d50e6a

Browse files
committed
use system() rather than popen() in FunKey menu
Signed-off-by: Vincent-FK <[email protected]>
1 parent ce1ea99 commit 1d50e6a

File tree

2 files changed

+15
-63
lines changed

2 files changed

+15
-63
lines changed

menu/main.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,7 @@ uint32 S9xReadJoypad (int which1)
407407
FILE *fp;
408408
sprintf(shell_cmd, "%s %d \" DISPLAY MODE: %s\"",
409409
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_name[aspect_ratio]);
410-
fp = popen(shell_cmd, "r");
411-
if (fp == NULL) {
412-
printf("Failed to run command %s\n", shell_cmd);
413-
} else {
414-
pclose(fp);
415-
}
410+
system(shell_cmd);
416411

417412
// Save config file
418413
configfile_save(cfg_file_rom);

menu/menu.cpp

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ void run_menu_loop()
643643
int start_scroll=0;
644644
uint8_t screen_refresh = 1;
645645
char shell_cmd[100];
646-
FILE *fp;
647646
uint8_t menu_confirmation = 0;
648647
stop_menu_loop = 0;
649648
char fname[MAXPATHLEN];
@@ -664,10 +663,7 @@ void run_menu_loop()
664663
RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof(u16));
665664

666665
/* Stop Ampli */
667-
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
668-
if (fp != NULL) {
669-
pclose(fp);
670-
}
666+
system(SHELL_CMD_TURN_AMPLI_OFF);
671667

672668
/// -------- Main loop ---------
673669
while (!stop_menu_loop)
@@ -742,12 +738,7 @@ void run_menu_loop()
742738

743739
/// ----- Shell cmd ----
744740
sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
745-
fp = popen(shell_cmd, "r");
746-
if (fp == NULL) {
747-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
748-
} else {
749-
pclose(fp);
750-
}
741+
system(shell_cmd);
751742

752743
/// ------ Refresh screen ------
753744
screen_refresh = 1;
@@ -760,13 +751,9 @@ void run_menu_loop()
760751

761752
/// ----- Shell cmd ----
762753
sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
763-
fp = popen(shell_cmd, "r");
764-
if (fp == NULL) {
765-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
766-
} else {
767-
pclose(fp);
768-
}
769-
/// ------ Refresh screen ------
754+
system(shell_cmd);
755+
756+
/// ------ Refresh screen ------
770757
screen_refresh = 1;
771758
}
772759
else if(idx_menus[menuItem] == MENU_TYPE_SAVE){
@@ -818,12 +805,8 @@ void run_menu_loop()
818805

819806
/// ----- Shell cmd ----
820807
sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
821-
fp = popen(shell_cmd, "r");
822-
if (fp == NULL) {
823-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
824-
} else {
825-
pclose(fp);
826-
}
808+
system(shell_cmd);
809+
827810
/// ------ Refresh screen ------
828811
screen_refresh = 1;
829812
}
@@ -835,12 +818,8 @@ void run_menu_loop()
835818

836819
/// ----- Shell cmd ----
837820
sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
838-
fp = popen(shell_cmd, "r");
839-
if (fp == NULL) {
840-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
841-
} else {
842-
pclose(fp);
843-
}
821+
system(shell_cmd);
822+
844823
/// ------ Refresh screen ------
845824
screen_refresh = 1;
846825
}
@@ -898,13 +877,7 @@ void run_menu_loop()
898877
/// ----- Hud Msg -----
899878
sprintf(shell_cmd, "%s %d \" SAVED IN SLOT %d\"",
900879
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, savestate_slot+1);
901-
fp = popen(shell_cmd, "r");
902-
if (fp == NULL) {
903-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
904-
} else {
905-
pclose(fp);
906-
}
907-
880+
system(shell_cmd);
908881
stop_menu_loop = 1;
909882
}
910883
else{
@@ -937,13 +910,7 @@ void run_menu_loop()
937910
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
938911
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, savestate_slot+1);
939912
}
940-
fp = popen(shell_cmd, "r");
941-
if (fp == NULL) {
942-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
943-
} else {
944-
pclose(fp);
945-
}
946-
913+
system(shell_cmd);
947914
stop_menu_loop = 1;
948915
}
949916
else{
@@ -1042,10 +1009,7 @@ void run_menu_loop()
10421009
}
10431010

10441011
/* Start Ampli */
1045-
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
1046-
if (fp != NULL) {
1047-
pclose(fp);
1048-
}
1012+
system(SHELL_CMD_TURN_AMPLI_ON);
10491013
}
10501014

10511015

@@ -1068,13 +1032,9 @@ int launch_resume_menu_loop()
10681032
uint8_t screen_refresh = 1;
10691033
uint8_t menu_confirmation = 0;
10701034
int option_idx=RESUME_YES;
1071-
FILE *fp;
10721035

10731036
/* Stop Ampli */
1074-
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
1075-
if (fp != NULL) {
1076-
pclose(fp);
1077-
}
1037+
system(SHELL_CMD_TURN_AMPLI_OFF);
10781038

10791039
/* Save prev key repeat params and set new Key repeat */
10801040
SDL_GetKeyRepeat(&backup_key_repeat_delay, &backup_key_repeat_interval);
@@ -1239,10 +1199,7 @@ int launch_resume_menu_loop()
12391199
}
12401200

12411201
/* Start Ampli */
1242-
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
1243-
if (fp != NULL) {
1244-
pclose(fp);
1245-
}
1202+
system(SHELL_CMD_TURN_AMPLI_ON);
12461203

12471204
return option_idx;
12481205
}

0 commit comments

Comments
 (0)