Skip to content

Commit 65df1c4

Browse files
ToKe79ShigeakiAsai
andauthored
RetroFlag cases for RPi implementation (for Lakka) (#18644)
This patch implements functionality (safe-shutdown, reset) to Lakka for Raspberry Pi devices using various RetroFlags cases for various Raspberry Pi models. Additional guards added to makefile to make sure that make options specific to Lakka are only used with Lakka. Co-authored-by: Shigeaki Asai <[email protected]>
1 parent 91902b1 commit 65df1c4

File tree

10 files changed

+137
-10
lines changed

10 files changed

+137
-10
lines changed

Makefile.common

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,15 +1087,39 @@ endif
10871087

10881088
ifeq ($(HAVE_LAKKA), 1)
10891089
DEFINES += -DHAVE_LAKKA
1090+
ifeq ($(HAVE_RETROFLAG), 1)
1091+
DEFINES += -DHAVE_RETROFLAG
1092+
ifeq ($(HAVE_RETROFLAG_RPI5), 1)
1093+
DEFINES += -DHAVE_RETROFLAG_RPI5
1094+
endif
1095+
else
1096+
ifeq ($(HAVE_RETROFLAG_RPI5), 1)
1097+
DEFINES += -DHAVE_RETROFLAG
1098+
DEFINES += -DHAVE_RETROFLAG_RPI5
1099+
endif
1100+
endif
10901101
ifneq ($(HAVE_LAKKA_PROJECT),)
10911102
DEFINES += -DHAVE_LAKKA_PROJECT=\"${HAVE_LAKKA_PROJECT}\"
10921103
else
1093-
$(error You asked for Lakka, but you did not specify a target device name in HAVE_LAKKA_PROJECT)
1104+
$(error You asked for Lakka, but you did not specify a target device name in HAVE_LAKKA_PROJECT.)
10941105
endif
10951106
ifneq ($(HAVE_LAKKA_SERVER),)
10961107
DEFINES += -DHAVE_LAKKA_SERVER=\"${HAVE_LAKKA_SERVER}\"
10971108
else
1098-
$(error You asked for Lakka, but you did not specify update server in HAVE_LAKKA_SERVER)
1109+
$(error You asked for Lakka, but you did not specify update server in HAVE_LAKKA_SERVER.)
1110+
endif
1111+
else
1112+
ifeq ($(HAVE_RETROFLAG), 1)
1113+
$(error You enabled Retroflag specific codepaths with HAVE_RETROFLAG, but not Lakka! Add HAVE_LAKKA=1 to continue.)
1114+
endif
1115+
ifeq ($(HAVE_RETROFLAG_RPI5), 1)
1116+
$(error You enabled Retroflag specific codepaths with HAVE_RETROFLAG_RPI5, but not Lakka! Add HAVE_LAKKA=1 to continue.)
1117+
endif
1118+
ifneq ($(HAVE_LAKKA_PROJECT),)
1119+
$(error You set Lakka project with HAVE_LAKKA_PROJECT, but did not enable Lakka! Add HAVE_LAKKA=1 to continue.)
1120+
endif
1121+
ifneq ($(HAVE_LAKKA_SERVER),)
1122+
$(error You set Lakka update server with HAVE_LAKKA_SERVER, but did not enable Lakka! Add HAVE_LAKKA=1 to continue.)
10991123
endif
11001124
endif
11011125

configuration.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,6 +3066,10 @@ void config_set_defaults(void *data)
30663066
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
30673067
configuration_set_bool(settings, settings->bools.localap_enable, false);
30683068
load_timezone(settings->arrays.timezone, TIMEZONE_LENGTH);
3069+
#ifdef HAVE_RETROFLAG
3070+
configuration_set_bool(settings,
3071+
settings->bools.safeshutdown_enable, filestream_exists(LAKKA_SAFESHUTDOWN_PATH));
3072+
#endif
30693073
#endif
30703074

30713075
#if __APPLE__
@@ -4430,6 +4434,10 @@ static bool config_load_file(global_t *global,
44304434
settings->bools.samba_enable, filestream_exists(LAKKA_SAMBA_PATH));
44314435
configuration_set_bool(settings,
44324436
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
4437+
#ifdef HAVE_RETROFLAG
4438+
configuration_set_bool(settings,
4439+
settings->bools.safeshutdown_enable, filestream_exists(LAKKA_SAFESHUTDOWN_PATH));
4440+
#endif
44334441
#endif
44344442

44354443
if ( !retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL)
@@ -5692,6 +5700,14 @@ bool config_save_file(const char *path)
56925700
RETRO_VFS_FILE_ACCESS_HINT_NONE));
56935701
else
56945702
filestream_delete(LAKKA_BLUETOOTH_PATH);
5703+
#ifdef HAVE_RETROFLAG
5704+
if (settings->bools.safeshutdown_enable)
5705+
filestream_close(filestream_open(LAKKA_SAFESHUTDOWN_PATH,
5706+
RETRO_VFS_FILE_ACCESS_WRITE,
5707+
RETRO_VFS_FILE_ACCESS_HINT_NONE));
5708+
else
5709+
filestream_delete(LAKKA_SAFESHUTDOWN_PATH);
5710+
#endif
56955711
#endif
56965712

56975713
for (i = 0; i < MAX_USERS; i++)

configuration.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,15 +1095,20 @@ typedef struct settings
10951095
bool savestates_in_content_dir;
10961096
bool screenshots_in_content_dir;
10971097
bool systemfiles_in_content_dir;
1098-
bool ssh_enable;
10991098
#ifdef HAVE_LAKKA_SWITCH
11001099
bool switch_oc;
11011100
bool switch_cec;
11021101
bool bluetooth_ertm_disable;
11031102
#endif
1103+
#ifdef HAVE_LAKKA
1104+
bool ssh_enable;
11041105
bool samba_enable;
11051106
bool bluetooth_enable;
1107+
#ifdef HAVE_RETROFLAG
1108+
bool safeshutdown_enable;
1109+
#endif
11061110
bool localap_enable;
1111+
#endif
11071112

11081113
bool video_window_show_decorations;
11091114
bool video_window_save_positions;

intl/msg_hash_lbl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,6 +3891,12 @@ MSG_HASH(
38913891
MENU_ENUM_LABEL_SSH_ENABLE,
38923892
"ssh_enable"
38933893
)
3894+
#ifdef HAVE_RETROFLAG
3895+
MSG_HASH(
3896+
MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE,
3897+
"safeshutdown_enable"
3898+
)
3899+
#endif
38943900
#endif
38953901

38963902
#ifdef HAVE_LAKKA_SWITCH

intl/msg_hash_us.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16840,6 +16840,24 @@ MSG_HASH(
1684016840
MENU_ENUM_SUBLABEL_TIMEZONE,
1684116841
"Select your time zone to adjust the date and time to your location."
1684216842
)
16843+
#ifdef HAVE_RETROFLAG
16844+
MSG_HASH(
16845+
MENU_ENUM_LABEL_VALUE_SAFESHUTDOWN_ENABLE,
16846+
#ifdef HAVE_RETROFLAG_RPI5
16847+
"Retroflag Safe Shutdown"
16848+
#else
16849+
"Retroflag Safe Shutdown (Reboot required)"
16850+
#endif
16851+
)
16852+
MSG_HASH(
16853+
MENU_ENUM_SUBLABEL_SAFESHUTDOWN_ENABLE,
16854+
#ifdef HAVE_RETROFLAG_RPI5
16855+
"For use with compatible Retroflag case."
16856+
#else
16857+
"For use with compatible Retroflag case. Reboot is required when changing."
16858+
#endif
16859+
)
16860+
#endif
1684316861
MSG_HASH(
1684416862
MENU_ENUM_LABEL_HELP_TIMEZONE,
1684516863
"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."

lakka.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
#ifndef __RARCH_LAKKA_H
1919
#define __RARCH_LAKKA_H
2020

21-
#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf"
22-
#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf"
23-
#define LAKKA_BLUETOOTH_PATH "/storage/.cache/services/bluez.conf"
24-
#define LAKKA_UPDATE_DIR "/storage/.update/"
25-
#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/"
26-
#define LAKKA_LOCALAP_PATH "/storage/.cache/services/localap.conf"
27-
#define LAKKA_TIMEZONE_PATH "/storage/.cache/timezone"
21+
#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf"
22+
#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf"
23+
#define LAKKA_BLUETOOTH_PATH "/storage/.cache/services/bluez.conf"
24+
#ifdef HAVE_RETROFLAG
25+
#define LAKKA_SAFESHUTDOWN_PATH "/storage/.cache/services/safeshutdown.conf"
26+
#endif
27+
#define LAKKA_UPDATE_DIR "/storage/.update/"
28+
#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/"
29+
#define LAKKA_LOCALAP_PATH "/storage/.cache/services/localap.conf"
30+
#define LAKKA_TIMEZONE_PATH "/storage/.cache/timezone"
2831

2932
#define DEFAULT_TIMEZONE "UTC"
3033
#define TIMEZONE_LENGTH 255

menu/cbs/menu_cbs_sublabel.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_samba_enable, MENU_
391391
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_bluetooth_enable, MENU_ENUM_SUBLABEL_BLUETOOTH_ENABLE )
392392
#endif
393393
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_localap_enable, MENU_ENUM_SUBLABEL_LOCALAP_ENABLE )
394+
#ifdef HAVE_RETROFLAG
395+
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_safeshutdown_enable, MENU_ENUM_SUBLABEL_SAFESHUTDOWN_ENABLE)
396+
#endif
394397
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_timezone, MENU_ENUM_SUBLABEL_TIMEZONE)
395398
#endif
396399
#ifdef HAVE_LAKKA_SWITCH
@@ -5532,6 +5535,11 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
55325535
case MENU_ENUM_LABEL_LOCALAP_ENABLE:
55335536
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_localap_enable);
55345537
break;
5538+
#ifdef HAVE_RETROFLAG
5539+
case MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE:
5540+
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_safeshutdown_enable);
5541+
break;
5542+
#endif
55355543
case MENU_ENUM_LABEL_TIMEZONE:
55365544
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timezone);
55375545
break;

menu/menu_displaylist.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10513,6 +10513,9 @@ unsigned menu_displaylist_build_list(
1051310513
{MENU_ENUM_LABEL_SAMBA_ENABLE, PARSE_ONLY_BOOL},
1051410514
{MENU_ENUM_LABEL_BLUETOOTH_ENABLE, PARSE_ONLY_BOOL},
1051510515
{MENU_ENUM_LABEL_LOCALAP_ENABLE, PARSE_ONLY_BOOL},
10516+
#ifdef HAVE_RETROFLAG
10517+
{MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE, PARSE_ONLY_BOOL},
10518+
#endif
1051610519
{MENU_ENUM_LABEL_TIMEZONE, PARSE_ONLY_STRING_OPTIONS},
1051710520
};
1051810521

menu/menu_setting.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9487,6 +9487,29 @@ static void samba_enable_toggle_change_handler(rarch_setting_t *setting)
94879487
*setting->value.target.boolean);
94889488
}
94899489

9490+
#ifdef HAVE_RETROFLAG
9491+
static void safeshutdown_enable_toggle_change_handler(rarch_setting_t *setting)
9492+
{
9493+
systemd_service_toggle(LAKKA_SAFESHUTDOWN_PATH,
9494+
#ifdef HAVE_RETROFLAG_RPI5
9495+
(char*)"retroflag_picase_safeshutdown_pi5.service",
9496+
#else
9497+
(char*)"retroflag_picase_safeshutdown.service",
9498+
#endif
9499+
*setting->value.target.boolean);
9500+
#ifndef HAVE_RETROFLAG_RPI5
9501+
if(*setting->value.target.boolean)
9502+
{
9503+
system("/usr/bin/retroflag_picase_install_gpio-poweroff_overlay.sh enable");
9504+
}
9505+
else
9506+
{
9507+
system("/usr/bin/retroflag_picase_install_gpio-poweroff_overlay.sh disable");
9508+
}
9509+
#endif
9510+
}
9511+
#endif
9512+
94909513
#ifdef HAVE_BLUETOOTH
94919514
static void bluetooth_enable_toggle_change_handler(
94929515
rarch_setting_t *setting)
@@ -23919,6 +23942,24 @@ static bool setting_append_list(
2391923942
(*list)[list_info->index - 1].change_handler = localap_enable_toggle_change_handler;
2392023943
#endif
2392123944

23945+
#ifdef HAVE_RETROFLAG
23946+
CONFIG_BOOL(
23947+
list, list_info,
23948+
&settings->bools.safeshutdown_enable,
23949+
MENU_ENUM_LABEL_SAFESHUTDOWN_ENABLE,
23950+
MENU_ENUM_LABEL_VALUE_SAFESHUTDOWN_ENABLE,
23951+
true,
23952+
MENU_ENUM_LABEL_VALUE_OFF,
23953+
MENU_ENUM_LABEL_VALUE_ON,
23954+
&group_info,
23955+
&subgroup_info,
23956+
parent_group,
23957+
general_write_handler,
23958+
general_read_handler,
23959+
SD_FLAG_NONE);
23960+
(*list)[list_info->index - 1].change_handler = safeshutdown_enable_toggle_change_handler;
23961+
#endif
23962+
2392223963
CONFIG_STRING_OPTIONS(
2392323964
list, list_info,
2392423965
settings->arrays.timezone,

msg_hash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,9 @@ enum msg_hash_enums
25472547
MENU_LABEL(SAMBA_ENABLE),
25482548
MENU_LABEL(BLUETOOTH_ENABLE),
25492549
MENU_LABEL(LOCALAP_ENABLE),
2550+
#ifdef HAVE_RETROFLAG
2551+
MENU_LABEL(SAFESHUTDOWN_ENABLE),
2552+
#endif
25502553
MENU_LBL_H(TIMEZONE),
25512554
#endif
25522555
#ifdef HAVE_LAKKA_SWITCH

0 commit comments

Comments
 (0)