Merge pull request #5247 from fr500/master

Input remapping improvements
This commit is contained in:
Twinaphex 2017-08-06 12:42:31 +02:00 committed by GitHub
commit 1a7247c1bb
13 changed files with 189 additions and 13 deletions

View File

@ -4,6 +4,11 @@
- ANDROID: Provide default save / system / state / screenshot locations
- AUDIO: Audio mixer supports MOD/S3M/XM file types now!
- INPUT: input swap override flag (for remotes) is cleared correctly
- INPUT: allow specifying libretro device in remap files
- INPUT: allow specifying analog dpad mode in remap files
- INPUT: allow saving libretro device to remap files
- INPUT: allow saving analog dpad mode to remap files
- INPUT: allow removing core and game remap files from the menu
- COMMON: Add 'Delete Core' option to Core Information menu.
- COMMON: Allow Max Timing Skew to be set to 0.
- COMMON: Change the "content dir" behavior so it works on either a flag or an empty directory setting, now platform drivers can provide defaults for save / system / state / screenshot dirs and still allow the content dir functionality, these settings are under settings / saving and flagged as advanced

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2017 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -1053,6 +1054,7 @@ static void command_event_deinit_core(bool reinit)
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
command_event(CMD_EVENT_RESTORE_REMAPS, NULL);
}
static void command_event_init_cheats(void)
@ -1226,7 +1228,7 @@ static bool command_event_init_core(enum rarch_core_type *data)
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
/* Auto-remap: apply shader preset files */
/* Auto-shaders: apply shader preset files */
if(settings->bools.auto_shaders_enable)
config_load_shader_preset();
@ -1287,6 +1289,11 @@ static void command_event_restore_default_shader_preset(void)
path_clear(RARCH_PATH_DEFAULT_SHADER_PRESET);
}
static void command_event_restore_remaps(void)
{
input_remapping_set_defaults();
}
static bool command_event_save_auto_state(void)
{
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
@ -1797,6 +1804,7 @@ bool command_event(enum event_command cmd, void *data)
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
command_event(CMD_EVENT_RESTORE_REMAPS, NULL);
if (is_inited)
if (!task_push_start_dummy_core(&content_info))
@ -2589,6 +2597,8 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_DISABLE_OVERRIDES:
command_event_disable_overrides();
break;
case CMD_EVENT_RESTORE_REMAPS:
command_event_restore_remaps();
case CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET:
command_event_restore_default_shader_preset();
break;

View File

@ -218,6 +218,7 @@ enum event_command
CMD_EVENT_MIXER_VOLUME_UP,
CMD_EVENT_MIXER_VOLUME_DOWN,
CMD_EVENT_DISABLE_OVERRIDES,
CMD_EVENT_RESTORE_REMAPS,
CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET,
CMD_EVENT_LIBUI_TEST
};

View File

@ -2,6 +2,7 @@
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2017 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -2930,6 +2931,7 @@ bool config_load_remap(void)
if (input_remapping_load_file(new_conf, game_path))
{
runloop_msg_queue_push("Game remap file loaded.", 1, 100, true);
rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL);
return true;
}
}
@ -2949,6 +2951,7 @@ bool config_load_remap(void)
if (input_remapping_load_file(new_conf, core_path))
{
runloop_msg_queue_push("Core remap file loaded.", 1, 100, true);
rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL);
return true;
}
}

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2015-2017 - Andrés Suárez
*
* 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-
@ -23,6 +24,9 @@
#include "../configuration.h"
#include "../retroarch.h"
static unsigned old_analog_dpad_mode[MAX_USERS];
static unsigned old_libretro_device[MAX_USERS];
/**
* input_remapping_load_file:
* @data : Path to config file.
@ -46,6 +50,9 @@ bool input_remapping_load_file(void *data, const char *path)
for (i = 0; i < MAX_USERS; i++)
{
old_analog_dpad_mode[i] = settings->uints.input_analog_dpad_mode[i];
old_libretro_device[i] = settings->uints.input_libretro_device[i];
char buf[64];
char key_ident[RARCH_FIRST_CUSTOM_BIND + 4][128] = {{0}};
char key_strings[RARCH_FIRST_CUSTOM_BIND + 4][128] =
@ -82,6 +89,12 @@ bool input_remapping_load_file(void *data, const char *path)
settings->uints.input_remap_ids[i][RARCH_FIRST_CUSTOM_BIND + j] =
key_remap;
}
snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1);
CONFIG_GET_INT_BASE(conf, settings, uints.input_analog_dpad_mode[i], buf);
snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1);
CONFIG_GET_INT_BASE(conf, settings, uints.input_libretro_device[i], buf);
}
config_file_free(conf);
@ -158,6 +171,10 @@ bool input_remapping_save_file(const char *path)
config_unset(conf,key_ident[j]);
}
}
snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1);
config_set_int(conf, buf, input_config_get_device(i));
snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1);
config_set_int(conf, buf, settings->uints.input_analog_dpad_mode[i]);
}
ret = config_file_write(conf, remap_file);
@ -166,6 +183,24 @@ bool input_remapping_save_file(const char *path)
return ret;
}
bool input_remapping_remove_file(const char *path)
{
bool ret;
char buf[PATH_MAX_LENGTH];
char remap_file[PATH_MAX_LENGTH];
config_file_t *conf = NULL;
settings_t *settings = config_get_ptr();
buf[0] = remap_file[0] = '\0';
fill_pathname_join(buf, settings->paths.directory_input_remapping,
path, sizeof(buf));
fill_pathname_noext(remap_file, buf, ".rmp", sizeof(remap_file));
return remove(remap_file) == 0 ? true : false;
}
void input_remapping_set_defaults(void)
{
unsigned i, j;
@ -180,5 +215,7 @@ void input_remapping_set_defaults(void)
}
for (j = 0; j < 4; j++)
settings->uints.input_remap_ids[i][RARCH_FIRST_CUSTOM_BIND + j] = j;
settings->uints.input_analog_dpad_mode[i] = old_analog_dpad_mode[i];
settings->uints.input_libretro_device[i] = old_libretro_device[i];
}
}

View File

@ -44,6 +44,8 @@ bool input_remapping_load_file(void *data, const char *path);
**/
bool input_remapping_save_file(const char *path);
bool input_remapping_remove_file(const char *path);
void input_remapping_set_defaults(void);
RETRO_END_DECLS

View File

@ -821,6 +821,10 @@ MSG_HASH(MENU_ENUM_LABEL_REMAP_FILE_SAVE_CORE,
"remap_file_save_core")
MSG_HASH(MENU_ENUM_LABEL_REMAP_FILE_SAVE_GAME,
"remap_file_save_game")
MSG_HASH(MENU_ENUM_LABEL_REMAP_FILE_REMOVE_CORE,
"remap_file_remove_core")
MSG_HASH(MENU_ENUM_LABEL_REMAP_FILE_REMOVE_GAME,
"remap_file_remove_game")
MSG_HASH(MENU_ENUM_LABEL_RESTART_CONTENT,
"restart_content")
MSG_HASH(MENU_ENUM_LABEL_RESTART_RETROARCH,

View File

@ -1217,6 +1217,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_SAVE_CORE,
"Save Core Remap File")
MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_SAVE_GAME,
"Save Game Remap File")
MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_REMOVE_CORE,
"Delete Core Remap File")
MSG_HASH(MENU_ENUM_LABEL_VALUE_REMAP_FILE_REMOVE_GAME,
"Delete Game Remap File")
MSG_HASH(MENU_ENUM_LABEL_VALUE_REQUIRED,
"Required")
MSG_HASH(MENU_ENUM_LABEL_VALUE_RESTART_CONTENT,
@ -1953,6 +1957,8 @@ MSG_HASH(MSG_ERROR_SAVING_CORE_OPTIONS_FILE,
"Error saving core options file.")
MSG_HASH(MSG_ERROR_SAVING_REMAP_FILE,
"Error saving remap file.")
MSG_HASH(MSG_ERROR_REMOVING_REMAP_FILE,
"Error removing remap file.")
MSG_HASH(MSG_ERROR_SAVING_SHADER_PRESET,
"Error saving shader preset.")
MSG_HASH(MSG_EXTERNAL_APPLICATION_DIR,
@ -2145,6 +2151,8 @@ MSG_HASH(MSG_REDIRECTING_SAVESTATE_TO,
"Redirecting savestate to")
MSG_HASH(MSG_REMAP_FILE_SAVED_SUCCESSFULLY,
"Remap file saved successfully.")
MSG_HASH(MSG_REMAP_FILE_REMOVED_SUCCESSFULLY,
"Remap file removed successfully.")
MSG_HASH(MSG_REMOVED_DISK_FROM_TRAY,
"Removed disk from tray.")
MSG_HASH(MSG_REMOVING_TEMPORARY_CONTENT_FILE,

View File

@ -1,6 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Brad Parker
* Copyright (C) 2015-2017 - Andrés Suárez
*
* 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-
@ -2090,10 +2091,12 @@ static int action_ok_cheat_file_save_as(const char *path,
enum
{
ACTION_OK_REMAP_FILE_SAVE_CORE = 0,
ACTION_OK_REMAP_FILE_SAVE_GAME
ACTION_OK_REMAP_FILE_SAVE_GAME,
ACTION_OK_REMAP_FILE_REMOVE_CORE,
ACTION_OK_REMAP_FILE_REMOVE_GAME
};
static int generic_action_ok_remap_file_save(const char *path,
static int generic_action_ok_remap_file_operation(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx,
unsigned action_type)
{
@ -2118,10 +2121,12 @@ static int generic_action_ok_remap_file_save(const char *path,
switch (action_type)
{
case ACTION_OK_REMAP_FILE_SAVE_CORE:
case ACTION_OK_REMAP_FILE_REMOVE_CORE:
if (!string_is_empty(core_name))
fill_pathname_join(file, core_name, core_name, sizeof(file));
break;
case ACTION_OK_REMAP_FILE_SAVE_GAME:
case ACTION_OK_REMAP_FILE_REMOVE_GAME:
if (!string_is_empty(core_name))
fill_pathname_join(file, core_name,
path_basename(path_get(RARCH_PATH_BASENAME)), sizeof(file));
@ -2131,32 +2136,74 @@ static int generic_action_ok_remap_file_save(const char *path,
if(!path_file_exists(directory))
path_mkdir(directory);
if(input_remapping_save_file(file))
runloop_msg_queue_push(
msg_hash_to_str(MSG_REMAP_FILE_SAVED_SUCCESSFULLY),
1, 100, true);
else
runloop_msg_queue_push(
msg_hash_to_str(MSG_ERROR_SAVING_REMAP_FILE),
1, 100, true);
if (action_type < ACTION_OK_REMAP_FILE_REMOVE_CORE)
{
if(input_remapping_save_file(file))
{
if (action_type == ACTION_OK_REMAP_FILE_SAVE_CORE)
rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL);
else
rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL);
runloop_msg_queue_push(
msg_hash_to_str(MSG_REMAP_FILE_SAVED_SUCCESSFULLY),
1, 100, true);
}
else
runloop_msg_queue_push(
msg_hash_to_str(MSG_ERROR_SAVING_REMAP_FILE),
1, 100, true);
}
else
{
RARCH_LOG("removing %s", file);
if(input_remapping_remove_file(file))
{
if (action_type == ACTION_OK_REMAP_FILE_REMOVE_CORE)
rarch_ctl(RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE, NULL);
else
rarch_ctl(RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE, NULL);
runloop_msg_queue_push(
msg_hash_to_str(MSG_REMAP_FILE_REMOVED_SUCCESSFULLY),
1, 100, true);
}
else
runloop_msg_queue_push(
msg_hash_to_str(MSG_ERROR_REMOVING_REMAP_FILE),
1, 100, true);
}
return 0;
}
static int action_ok_remap_file_save_core(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_remap_file_save(path, label, type,
return generic_action_ok_remap_file_operation(path, label, type,
idx, entry_idx, ACTION_OK_REMAP_FILE_SAVE_CORE);
}
static int action_ok_remap_file_save_game(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_remap_file_save(path, label, type,
return generic_action_ok_remap_file_operation(path, label, type,
idx, entry_idx, ACTION_OK_REMAP_FILE_SAVE_GAME);
}
static int action_ok_remap_file_remove_core(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_remap_file_operation(path, label, type,
idx, entry_idx, ACTION_OK_REMAP_FILE_REMOVE_CORE);
}
static int action_ok_remap_file_remove_game(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_remap_file_operation(path, label, type,
idx, entry_idx, ACTION_OK_REMAP_FILE_REMOVE_GAME);
}
int action_ok_path_use_directory(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -4766,6 +4813,12 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_REMAP_FILE_SAVE_GAME:
BIND_ACTION_OK(cbs, action_ok_remap_file_save_game);
break;
case MENU_ENUM_LABEL_REMAP_FILE_REMOVE_CORE:
BIND_ACTION_OK(cbs, action_ok_remap_file_remove_core);
break;
case MENU_ENUM_LABEL_REMAP_FILE_REMOVE_GAME:
BIND_ACTION_OK(cbs, action_ok_remap_file_remove_game);
break;
case MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST:
BIND_ACTION_OK(cbs, action_ok_content_collection_list);
break;

View File

@ -1,6 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2015-2017 - Andrés Suárez
* Copyright (C) 2016-2017 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -3372,6 +3373,24 @@ static int menu_displaylist_parse_options_remappings(
MENU_ENUM_LABEL_REMAP_FILE_SAVE_GAME,
MENU_SETTING_ACTION, 0, 0);
if (rarch_ctl(RARCH_CTL_IS_REMAPS_CORE_ACTIVE, NULL))
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REMAP_FILE_REMOVE_CORE),
msg_hash_to_str(MENU_ENUM_LABEL_REMAP_FILE_REMOVE_CORE),
MENU_ENUM_LABEL_REMAP_FILE_REMOVE_CORE,
MENU_SETTING_ACTION, 0, 0);
}
if (rarch_ctl(RARCH_CTL_IS_REMAPS_GAME_ACTIVE, NULL))
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REMAP_FILE_REMOVE_GAME),
msg_hash_to_str(MENU_ENUM_LABEL_REMAP_FILE_REMOVE_GAME),
MENU_ENUM_LABEL_REMAP_FILE_REMOVE_GAME,
MENU_SETTING_ACTION, 0, 0);
}
system = runloop_get_system_info();
if (system)

View File

@ -287,8 +287,10 @@ enum msg_hash_enums
MSG_INPUT_PRESET_FILENAME,
MSG_INPUT_CHEAT_FILENAME,
MSG_REMAP_FILE_SAVED_SUCCESSFULLY,
MSG_REMAP_FILE_REMOVED_SUCCESSFULLY,
MSG_SHADER_PRESET_SAVED_SUCCESSFULLY,
MSG_ERROR_SAVING_REMAP_FILE,
MSG_ERROR_REMOVING_REMAP_FILE,
MSG_ERROR_SAVING_SHADER_PRESET,
MSG_FAILED_TO_CREATE_THE_DIRECTORY,
MSG_ERROR_SAVING_CORE_OPTIONS_FILE,
@ -1370,6 +1372,8 @@ enum msg_hash_enums
MENU_LABEL(REMAP_FILE_SAVE_CORE),
MENU_LABEL(REMAP_FILE_SAVE_GAME),
MENU_LABEL(REMAP_FILE_REMOVE_CORE),
MENU_LABEL(REMAP_FILE_REMOVE_GAME),
MENU_LABEL(RESTART_CONTENT),
MENU_LABEL(RESUME),
MENU_LABEL(RESUME_CONTENT),

View File

@ -2,6 +2,7 @@
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2012-2015 - Michael Lelli
* Copyright (C) 2015-2017 - Andrés Suárez
*
* 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-
@ -236,6 +237,8 @@ static bool runloop_shutdown_initiated = false;
static bool runloop_core_shutdown_initiated = false;
static bool runloop_perfcnt_enable = false;
static bool runloop_overrides_active = false;
static bool runloop_remaps_core_active = false;
static bool runloop_remaps_game_active = false;
static bool runloop_game_options_active = false;
static bool runloop_missing_bios = false;
static bool runloop_autosave = false;
@ -310,6 +313,8 @@ static void global_free(void)
rarch_ups_pref = false;
rarch_patch_blocked = false;
runloop_overrides_active = false;
runloop_remaps_core_active = false;
runloop_remaps_game_active = false;
core_unset_input_descriptors();
@ -1587,6 +1592,22 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
break;
case RARCH_CTL_IS_OVERRIDES_ACTIVE:
return runloop_overrides_active;
case RARCH_CTL_SET_REMAPS_CORE_ACTIVE:
runloop_remaps_core_active = true;
break;
case RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE:
runloop_remaps_core_active = false;
break;
case RARCH_CTL_IS_REMAPS_CORE_ACTIVE:
return runloop_remaps_core_active;
case RARCH_CTL_SET_REMAPS_GAME_ACTIVE:
runloop_remaps_game_active = true;
break;
case RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE:
runloop_remaps_game_active = false;
break;
case RARCH_CTL_IS_REMAPS_GAME_ACTIVE:
return runloop_remaps_game_active;
case RARCH_CTL_SET_MISSING_BIOS:
runloop_missing_bios = true;
break;
@ -2161,6 +2182,7 @@ bool retroarch_main_quit(void)
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
command_event(CMD_EVENT_RESTORE_REMAPS, NULL);
}
runloop_shutdown_initiated = true;

View File

@ -98,6 +98,14 @@ enum rarch_ctl_state
RARCH_CTL_SET_OVERRIDES_ACTIVE,
RARCH_CTL_UNSET_OVERRIDES_ACTIVE,
RARCH_CTL_IS_REMAPS_CORE_ACTIVE,
RARCH_CTL_SET_REMAPS_CORE_ACTIVE,
RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE,
RARCH_CTL_IS_REMAPS_GAME_ACTIVE,
RARCH_CTL_SET_REMAPS_GAME_ACTIVE,
RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE,
RARCH_CTL_IS_MISSING_BIOS,
RARCH_CTL_SET_MISSING_BIOS,
RARCH_CTL_UNSET_MISSING_BIOS,