diff --git a/Makefile.common b/Makefile.common index f41786b8b2d3..13357bd26be2 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1087,15 +1087,39 @@ endif ifeq ($(HAVE_LAKKA), 1) DEFINES += -DHAVE_LAKKA + ifeq ($(HAVE_RETROFLAG), 1) + DEFINES += -DHAVE_RETROFLAG + ifeq ($(HAVE_RETROFLAG_RPI5), 1) + DEFINES += -DHAVE_RETROFLAG_RPI5 + endif + else + ifeq ($(HAVE_RETROFLAG_RPI5), 1) + DEFINES += -DHAVE_RETROFLAG + DEFINES += -DHAVE_RETROFLAG_RPI5 + endif + endif ifneq ($(HAVE_LAKKA_PROJECT),) DEFINES += -DHAVE_LAKKA_PROJECT=\"${HAVE_LAKKA_PROJECT}\" else - $(error You asked for Lakka, but you did not specify a target device name in HAVE_LAKKA_PROJECT) + $(error You asked for Lakka, but you did not specify a target device name in HAVE_LAKKA_PROJECT.) endif ifneq ($(HAVE_LAKKA_SERVER),) DEFINES += -DHAVE_LAKKA_SERVER=\"${HAVE_LAKKA_SERVER}\" else - $(error You asked for Lakka, but you did not specify update server in HAVE_LAKKA_SERVER) + $(error You asked for Lakka, but you did not specify update server in HAVE_LAKKA_SERVER.) + endif +else + ifeq ($(HAVE_RETROFLAG), 1) + $(error You enabled Retroflag specific codepaths with HAVE_RETROFLAG, but not Lakka! Add HAVE_LAKKA=1 to continue.) + endif + ifeq ($(HAVE_RETROFLAG_RPI5), 1) + $(error You enabled Retroflag specific codepaths with HAVE_RETROFLAG_RPI5, but not Lakka! Add HAVE_LAKKA=1 to continue.) + endif + ifneq ($(HAVE_LAKKA_PROJECT),) + $(error You set Lakka project with HAVE_LAKKA_PROJECT, but did not enable Lakka! Add HAVE_LAKKA=1 to continue.) + endif + ifneq ($(HAVE_LAKKA_SERVER),) + $(error You set Lakka update server with HAVE_LAKKA_SERVER, but did not enable Lakka! Add HAVE_LAKKA=1 to continue.) endif endif diff --git a/configuration.c b/configuration.c index 7ff06177d323..22decb24f6cb 100644 --- a/configuration.c +++ b/configuration.c @@ -3066,6 +3066,10 @@ void config_set_defaults(void *data) settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH)); configuration_set_bool(settings, settings->bools.localap_enable, false); load_timezone(settings->arrays.timezone, TIMEZONE_LENGTH); +#ifdef HAVE_RETROFLAG + configuration_set_bool(settings, + settings->bools.safeshutdown_enable, filestream_exists(LAKKA_SAFESHUTDOWN_PATH)); +#endif #endif #if __APPLE__ @@ -4430,6 +4434,10 @@ static bool config_load_file(global_t *global, settings->bools.samba_enable, filestream_exists(LAKKA_SAMBA_PATH)); configuration_set_bool(settings, settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH)); +#ifdef HAVE_RETROFLAG + configuration_set_bool(settings, + settings->bools.safeshutdown_enable, filestream_exists(LAKKA_SAFESHUTDOWN_PATH)); +#endif #endif if ( !retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL) @@ -5692,6 +5700,14 @@ bool config_save_file(const char *path) RETRO_VFS_FILE_ACCESS_HINT_NONE)); else filestream_delete(LAKKA_BLUETOOTH_PATH); +#ifdef HAVE_RETROFLAG + if (settings->bools.safeshutdown_enable) + filestream_close(filestream_open(LAKKA_SAFESHUTDOWN_PATH, + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); + else + filestream_delete(LAKKA_SAFESHUTDOWN_PATH); +#endif #endif for (i = 0; i < MAX_USERS; i++) diff --git a/configuration.h b/configuration.h index 85c6045f6049..591c4a64bfd7 100644 --- a/configuration.h +++ b/configuration.h @@ -1095,15 +1095,20 @@ typedef struct settings bool savestates_in_content_dir; bool screenshots_in_content_dir; bool systemfiles_in_content_dir; - bool ssh_enable; #ifdef HAVE_LAKKA_SWITCH bool switch_oc; bool switch_cec; bool bluetooth_ertm_disable; #endif +#ifdef HAVE_LAKKA + bool ssh_enable; bool samba_enable; bool bluetooth_enable; +#ifdef HAVE_RETROFLAG + bool safeshutdown_enable; +#endif bool localap_enable; +#endif bool video_window_show_decorations; bool video_window_save_positions; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index c4a74797ab4f..a66e8e4b2eb8 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -3891,6 +3891,12 @@ MSG_HASH( MENU_ENUM_LABEL_SSH_ENABLE, "ssh_enable" ) +#ifdef HAVE_RETROFLAG +MSG_HASH( + MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE, + "safeshutdown_enable" + ) +#endif #endif #ifdef HAVE_LAKKA_SWITCH diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 45422bd5bf29..2cbff60641a0 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -16840,6 +16840,24 @@ MSG_HASH( MENU_ENUM_SUBLABEL_TIMEZONE, "Select your time zone to adjust the date and time to your location." ) +#ifdef HAVE_RETROFLAG +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SAFESHUTDOWN_ENABLE, +#ifdef HAVE_RETROFLAG_RPI5 + "Retroflag Safe Shutdown" +#else + "Retroflag Safe Shutdown (Reboot required)" +#endif + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SAFESHUTDOWN_ENABLE, +#ifdef HAVE_RETROFLAG_RPI5 + "For use with compatible Retroflag case." +#else + "For use with compatible Retroflag case. Reboot is required when changing." +#endif + ) +#endif MSG_HASH( MENU_ENUM_LABEL_HELP_TIMEZONE, "Displays a list of available timezones. After selecting a time zone, time and date is adjusted to the selected time zone. It assumes, that system/hardware clock is set to UTC." diff --git a/lakka.h b/lakka.h index 625a7ab9460d..f149c344be19 100644 --- a/lakka.h +++ b/lakka.h @@ -18,13 +18,16 @@ #ifndef __RARCH_LAKKA_H #define __RARCH_LAKKA_H -#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf" -#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf" -#define LAKKA_BLUETOOTH_PATH "/storage/.cache/services/bluez.conf" -#define LAKKA_UPDATE_DIR "/storage/.update/" -#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/" -#define LAKKA_LOCALAP_PATH "/storage/.cache/services/localap.conf" -#define LAKKA_TIMEZONE_PATH "/storage/.cache/timezone" +#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf" +#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf" +#define LAKKA_BLUETOOTH_PATH "/storage/.cache/services/bluez.conf" +#ifdef HAVE_RETROFLAG +#define LAKKA_SAFESHUTDOWN_PATH "/storage/.cache/services/safeshutdown.conf" +#endif +#define LAKKA_UPDATE_DIR "/storage/.update/" +#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/" +#define LAKKA_LOCALAP_PATH "/storage/.cache/services/localap.conf" +#define LAKKA_TIMEZONE_PATH "/storage/.cache/timezone" #define DEFAULT_TIMEZONE "UTC" #define TIMEZONE_LENGTH 255 diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 9d821b72b9d7..1a1254f31de3 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -391,6 +391,9 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_samba_enable, MENU_ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_bluetooth_enable, MENU_ENUM_SUBLABEL_BLUETOOTH_ENABLE ) #endif DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_localap_enable, MENU_ENUM_SUBLABEL_LOCALAP_ENABLE ) +#ifdef HAVE_RETROFLAG +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_safeshutdown_enable, MENU_ENUM_SUBLABEL_SAFESHUTDOWN_ENABLE) +#endif DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_timezone, MENU_ENUM_SUBLABEL_TIMEZONE) #endif #ifdef HAVE_LAKKA_SWITCH @@ -5532,6 +5535,11 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_LOCALAP_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_localap_enable); break; +#ifdef HAVE_RETROFLAG + case MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_safeshutdown_enable); + break; +#endif case MENU_ENUM_LABEL_TIMEZONE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timezone); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 4a8320d83299..7f1727669460 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -10513,6 +10513,9 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_SAMBA_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_BLUETOOTH_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_LOCALAP_ENABLE, PARSE_ONLY_BOOL}, +#ifdef HAVE_RETROFLAG + {MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE, PARSE_ONLY_BOOL}, +#endif {MENU_ENUM_LABEL_TIMEZONE, PARSE_ONLY_STRING_OPTIONS}, }; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index f6c02b28b508..5a7f59a927b4 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -9487,6 +9487,29 @@ static void samba_enable_toggle_change_handler(rarch_setting_t *setting) *setting->value.target.boolean); } +#ifdef HAVE_RETROFLAG +static void safeshutdown_enable_toggle_change_handler(rarch_setting_t *setting) +{ + systemd_service_toggle(LAKKA_SAFESHUTDOWN_PATH, +#ifdef HAVE_RETROFLAG_RPI5 + (char*)"retroflag_picase_safeshutdown_pi5.service", +#else + (char*)"retroflag_picase_safeshutdown.service", +#endif + *setting->value.target.boolean); +#ifndef HAVE_RETROFLAG_RPI5 + if(*setting->value.target.boolean) + { + system("/usr/bin/retroflag_picase_install_gpio-poweroff_overlay.sh enable"); + } + else + { + system("/usr/bin/retroflag_picase_install_gpio-poweroff_overlay.sh disable"); + } +#endif +} +#endif + #ifdef HAVE_BLUETOOTH static void bluetooth_enable_toggle_change_handler( rarch_setting_t *setting) @@ -23919,6 +23942,24 @@ static bool setting_append_list( (*list)[list_info->index - 1].change_handler = localap_enable_toggle_change_handler; #endif +#ifdef HAVE_RETROFLAG + CONFIG_BOOL( + list, list_info, + &settings->bools.safeshutdown_enable, + MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE, + MENU_ENUM_LABEL_VALUE_SAFESHUTDOWN_ENABLE, + true, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + (*list)[list_info->index - 1].change_handler = safeshutdown_enable_toggle_change_handler; +#endif + CONFIG_STRING_OPTIONS( list, list_info, settings->arrays.timezone, diff --git a/msg_hash.h b/msg_hash.h index c23842bc7f75..ded0ca83895b 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2547,6 +2547,9 @@ enum msg_hash_enums MENU_LABEL(SAMBA_ENABLE), MENU_LABEL(BLUETOOTH_ENABLE), MENU_LABEL(LOCALAP_ENABLE), +#ifdef HAVE_RETROFLAG + MENU_LABEL(SAFESHUTDOWN_ENABLE), +#endif MENU_LBL_H(TIMEZONE), #endif #ifdef HAVE_LAKKA_SWITCH