(Menu) Add a first Lakka Service setting: SSH Enable

This commit is contained in:
Jean-André Santoni 2016-03-22 05:46:36 +07:00
parent 1cb8faf6c9
commit 24af521bf1
6 changed files with 72 additions and 4 deletions

View File

@ -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)
fopen(LAKKA_SSH_PATH, "ab+");
else
remove(LAKKA_SSH_PATH);
#endif
config_set_float(conf, "fastforward_ratio", settings->fastforward_ratio);
config_set_float(conf, "slowmotion_ratio", settings->slowmotion_ratio);

View File

@ -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;
/**

22
lakka.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_LAKKA_H
#define __RARCH_LAKKA_H
#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf"
#endif

View File

@ -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:

View File

@ -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

View File

@ -52,6 +52,7 @@
#include "../input/input_autodetect.h"
#include "../config.def.h"
#include "../performance.h"
#include "../lakka.h"
#include "../tasks/tasks_internal.h"
@ -3079,6 +3080,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)
fopen(LAKKA_SSH_PATH, "ab+");
else
remove(LAKKA_SSH_PATH);
return;
}
#endif
enum settings_list_type
{
@ -6500,10 +6518,10 @@ static bool setting_append_list(
CONFIG_BOOL(
list, list_info,
&global->netplay.enable,
menu_hash_to_str(MENU_LABEL_NETPLAY_ENABLE),
menu_hash_to_str(MENU_LABEL_VALUE_NETPLAY_ENABLE),
false,
&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,
@ -6511,6 +6529,7 @@ static bool setting_append_list(
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