diff --git a/configuration.c b/configuration.c index 66982a89e4..8507187e07 100644 --- a/configuration.c +++ b/configuration.c @@ -35,6 +35,7 @@ #include "retroarch.h" #include "system.h" #include "verbosity.h" +#include "lakka.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -599,6 +600,10 @@ static void config_set_defaults(void) settings->content_history_size = default_content_history_size; settings->libretro_log_level = libretro_log_level; +#ifdef HAVE_LAKKA + settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH); +#endif + #ifdef HAVE_MENU if (first_initialized) settings->menu_show_start_screen = default_menu_show_start_screen; @@ -1724,6 +1729,10 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, settings, stdin_cmd_enable, "stdin_cmd_enable"); #endif +#ifdef HAVE_LAKKA + settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH); +#endif + #ifdef HAVE_NETWORK_GAMEPAD CONFIG_GET_BOOL_BASE(conf, settings, network_remote_enable, "network_remote_enable"); for (i = 0; i < MAX_USERS; i++) @@ -2844,6 +2853,13 @@ bool config_save_file(const char *path) settings->network_cmd_port); #endif +#ifdef HAVE_LAKKA + if (settings->ssh_enable) + fclose(fopen(LAKKA_SSH_PATH, "w")); + else + remove(LAKKA_SSH_PATH); +#endif + config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio); config_set_float(conf, "slowmotion_ratio", settings->slowmotion_ratio); diff --git a/configuration.h b/configuration.h index 6f2346f8bc..d519e50ef3 100644 --- a/configuration.h +++ b/configuration.h @@ -399,6 +399,11 @@ typedef struct settings unsigned int user_language; bool config_save_on_exit; + +#ifdef HAVE_LAKKA + bool ssh_enable; +#endif + } settings_t; /** diff --git a/lakka.h b/lakka.h new file mode 100644 index 0000000000..926087516f --- /dev/null +++ b/lakka.h @@ -0,0 +1,22 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef __RARCH_LAKKA_H +#define __RARCH_LAKKA_H + +#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf" + +#endif diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index f58f755653..b4dbf4e0cd 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -262,6 +262,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) return "netplay_tcp_udp_port"; case MENU_LABEL_NETPLAY_ENABLE: return "netplay_enable"; + case MENU_LABEL_SSH_ENABLE: + return "ssh_enable"; case MENU_LABEL_NETPLAY_DELAY_FRAMES: return "netplay_delay_frames"; case MENU_LABEL_NETPLAY_MODE: @@ -1008,6 +1010,8 @@ const char *menu_hash_to_str_us(uint32_t hash) return "Netplay TCP/UDP Port"; case MENU_LABEL_VALUE_NETPLAY_ENABLE: return "Netplay Enable"; + case MENU_LABEL_VALUE_SSH_ENABLE: + return "SSH Enable"; case MENU_LABEL_VALUE_NETPLAY_DELAY_FRAMES: return "Netplay Delay Frames"; case MENU_LABEL_VALUE_NETPLAY_MODE: @@ -1636,6 +1640,8 @@ const char *menu_hash_to_str_us(uint32_t hash) return "Updater"; case MENU_LABEL_VALUE_NETWORK_SETTINGS: return "Network"; + case MENU_LABEL_VALUE_LAKKA_SERVICES: + return "Lakka Services"; case MENU_LABEL_VALUE_PLAYLIST_SETTINGS: return "Playlists"; case MENU_LABEL_VALUE_USER_SETTINGS: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ae93953a39..2b79867bf9 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3347,6 +3347,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_hash_to_str(MENU_LABEL_VALUE_CORE_UPDATER_SETTINGS), PARSE_ONLY_GROUP, false); ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_VALUE_NETWORK_SETTINGS), PARSE_ONLY_GROUP, false); +#ifdef HAVE_LAKKA + ret = menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_VALUE_LAKKA_SERVICES), PARSE_ONLY_GROUP, false); +#endif ret = menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_PLAYLIST_SETTINGS), PARSE_ACTION, false); ret = menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 6e16abc243..fb5f445142 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -399,6 +399,8 @@ extern "C" { #define MENU_LABEL_VALUE_AUDIO_LATENCY 0x89900e38U #define MENU_LABEL_NETPLAY_ENABLE 0x607fbd68U #define MENU_LABEL_VALUE_NETPLAY_ENABLE 0xbc3e81a9U +#define MENU_LABEL_SSH_ENABLE 0xd9854a79U +#define MENU_LABEL_VALUE_SSH_ENABLE 0x0430627aU #define MENU_LABEL_NETPLAY_CLIENT_SWAP_INPUT 0xd87bbba9U #define MENU_LABEL_VALUE_NETPLAY_CLIENT_SWAP_INPUT 0x57e5be2dU #define MENU_LABEL_NETPLAY_DELAY_FRAMES 0x86b2c48dU @@ -897,6 +899,7 @@ extern "C" { #define MENU_LABEL_VALUE_CORE_UPDATER_SETTINGS 0x124ad454U #define MENU_LABEL_NETWORK_SETTINGS 0x8b50d180U #define MENU_LABEL_VALUE_NETWORK_SETTINGS 0x8b50d180U +#define MENU_LABEL_VALUE_LAKKA_SERVICES 0x0c113d6dU #define MENU_LABEL_ARCHIVE_SETTINGS 0x78e85398U #define MENU_LABEL_USER_SETTINGS 0xcdc9a8f5U #define MENU_LABEL_VALUE_USER_SETTINGS 0xcdc9a8f5U diff --git a/menu/menu_setting.c b/menu/menu_setting.c index c57720f970..8a2a0055a7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -53,6 +53,7 @@ #include "../input/input_autodetect.h" #include "../config.def.h" #include "../performance.h" +#include "../lakka.h" #include "../tasks/tasks_internal.h" @@ -3089,6 +3090,23 @@ static void overlay_enable_toggle_change_handler(void *data) } #endif +#ifdef HAVE_LAKKA +static void ssh_enable_toggle_change_handler(void *data) +{ + settings_t *settings = config_get_ptr(); + rarch_setting_t *setting = (rarch_setting_t *)data; + + if (!setting) + return; + + if (settings && settings->ssh_enable) + fclose(fopen(LAKKA_SSH_PATH, "w")); + else + remove(LAKKA_SSH_PATH); + + return; +} +#endif enum settings_list_type { @@ -3116,6 +3134,7 @@ enum settings_list_type SETTINGS_LIST_CHEEVOS, SETTINGS_LIST_CORE_UPDATER, SETTINGS_LIST_NETPLAY, + SETTINGS_LIST_LAKKA_SERVICES, SETTINGS_LIST_USER, SETTINGS_LIST_USER_ACCOUNTS, SETTINGS_LIST_USER_ACCOUNTS_CHEEVOS, @@ -6493,6 +6512,36 @@ static bool setting_append_list( #endif END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); +#endif + } + break; + case SETTINGS_LIST_LAKKA_SERVICES: + { +#if defined(HAVE_LAKKA) + START_GROUP(list, list_info, &group_info, + menu_hash_to_str(MENU_LABEL_VALUE_LAKKA_SERVICES), + parent_group); + + parent_group = menu_hash_to_str(MENU_LABEL_VALUE_SETTINGS); + + START_SUB_GROUP(list, list_info, "Lakka Services", &group_info, &subgroup_info, parent_group); + + CONFIG_BOOL( + list, list_info, + &settings->ssh_enable, + menu_hash_to_str(MENU_LABEL_SSH_ENABLE), + menu_hash_to_str(MENU_LABEL_VALUE_SSH_ENABLE), + true, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].change_handler = ssh_enable_toggle_change_handler; + END_SUB_GROUP(list, list_info, parent_group); + END_GROUP(list, list_info, parent_group); #endif } break; @@ -7226,6 +7275,7 @@ static rarch_setting_t *menu_setting_new_internal(rarch_setting_info_t *list_inf SETTINGS_LIST_CHEEVOS, SETTINGS_LIST_CORE_UPDATER, SETTINGS_LIST_NETPLAY, + SETTINGS_LIST_LAKKA_SERVICES, SETTINGS_LIST_USER, SETTINGS_LIST_USER_ACCOUNTS, SETTINGS_LIST_USER_ACCOUNTS_CHEEVOS,