Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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++)
Expand Down
7 changes: 6 additions & 1 deletion configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
17 changes: 10 additions & 7 deletions lakka.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions menu/cbs/menu_cbs_sublabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down
41 changes: 41 additions & 0 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading