From 67e0f34b93f3ce807a04572a7db916c7680b1e70 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Tue, 27 Apr 2021 23:07:29 +0200 Subject: [PATCH] use system() rather than popen() in FunKey menu Signed-off-by: Vincent-FK --- RetroFE/Source/Menu/MenuMode.cpp | 49 ++++++-------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/RetroFE/Source/Menu/MenuMode.cpp b/RetroFE/Source/Menu/MenuMode.cpp index 2625a36..88a0029 100755 --- a/RetroFE/Source/Menu/MenuMode.cpp +++ b/RetroFE/Source/Menu/MenuMode.cpp @@ -717,7 +717,6 @@ int MenuMode::launch( ) int start_scroll=0; uint8_t screen_refresh = 1; char shell_cmd[100]; - FILE *fp; uint8_t menu_confirmation = 0; stop_menu_loop = 0; char fname[MAXPATHLEN]; @@ -845,12 +844,7 @@ int MenuMode::launch( ) /// ----- Shell cmd ---- sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage); - fp = popen(shell_cmd, "r"); - if (fp == NULL) { - MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); - } else { - pclose(fp); - } + system(shell_cmd); /// ------ Refresh screen ------ screen_refresh = 1; @@ -863,12 +857,8 @@ int MenuMode::launch( ) /// ----- Shell cmd ---- sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage); - fp = popen(shell_cmd, "r"); - if (fp == NULL) { - MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); - } else { - pclose(fp); - } + system(shell_cmd); + /// ------ Refresh screen ------ screen_refresh = 1; } @@ -910,12 +900,8 @@ int MenuMode::launch( ) /// ----- Shell cmd ---- sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage); - fp = popen(shell_cmd, "r"); - if (fp == NULL) { - MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); - } else { - pclose(fp); - } + system(shell_cmd); + /// ------ Refresh screen ------ screen_refresh = 1; } @@ -927,12 +913,8 @@ int MenuMode::launch( ) /// ----- Shell cmd ---- sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage); - fp = popen(shell_cmd, "r"); - if (fp == NULL) { - MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); - } else { - pclose(fp); - } + system(shell_cmd); + /// ------ Refresh screen ------ screen_refresh = 1; } @@ -1005,14 +987,7 @@ int MenuMode::launch( ) menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1); /// ----- Shell cmd ---- - /*fp = popen(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r"); - if (fp == NULL) { - MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); - } - else{ - usb_sharing = !usb_sharing; - pclose(fp); - }*/ + /*system(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);*/ bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT); if (!res) { @@ -1099,13 +1074,7 @@ int MenuMode::launch( ) /// ----- Shell cmd ---- sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN); - fp = popen(shell_cmd, "r"); - if (fp == NULL) { - MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); - } else { - pclose(fp); - } - + system(shell_cmd); return MENU_RETURN_EXIT; } else{