mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 05:43:34 +00:00
Use input_config_set_device
This commit is contained in:
parent
b4cdad1a6f
commit
aa59b33931
@ -495,6 +495,14 @@ void input_config_set_device_name(unsigned port, const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void input_config_set_device(unsigned port, unsigned id)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (settings)
|
||||||
|
settings->input.libretro_device[port] = id;
|
||||||
|
}
|
||||||
|
|
||||||
bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real)
|
bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
@ -519,3 +527,4 @@ const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned i
|
|||||||
return &settings->input.autoconf_binds[joy_idx][id];
|
return &settings->input.autoconf_binds[joy_idx][id];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,8 @@ void input_config_parse_joy_axis(void *data, const char *prefix,
|
|||||||
|
|
||||||
void input_config_set_device_name(unsigned port, const char *name);
|
void input_config_set_device_name(unsigned port, const char *name);
|
||||||
|
|
||||||
|
void input_config_set_device(unsigned port, unsigned id);
|
||||||
|
|
||||||
const char *input_config_get_device_name(unsigned port);
|
const char *input_config_get_device_name(unsigned port);
|
||||||
|
|
||||||
const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned id);
|
const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned id);
|
||||||
|
@ -1022,7 +1022,6 @@ static int setting_action_start_libretro_device_type(void *data)
|
|||||||
unsigned devices[128], types = 0, port = 0;
|
unsigned devices[128], types = 0, port = 0;
|
||||||
const struct retro_controller_info *desc = NULL;
|
const struct retro_controller_info *desc = NULL;
|
||||||
rarch_system_info_t *system = NULL;
|
rarch_system_info_t *system = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||||
|
|
||||||
if (setting_generic_action_start_default(setting) != 0)
|
if (setting_generic_action_start_default(setting) != 0)
|
||||||
@ -1062,7 +1061,7 @@ static int setting_action_start_libretro_device_type(void *data)
|
|||||||
|
|
||||||
current_device = RETRO_DEVICE_JOYPAD;
|
current_device = RETRO_DEVICE_JOYPAD;
|
||||||
|
|
||||||
settings->input.libretro_device[port] = current_device;
|
input_config_set_device(port, current_device);
|
||||||
|
|
||||||
pad.port = port;
|
pad.port = port;
|
||||||
pad.device = current_device;
|
pad.device = current_device;
|
||||||
@ -1176,7 +1175,7 @@ static int setting_action_left_libretro_device_type(
|
|||||||
current_device = devices
|
current_device = devices
|
||||||
[(current_idx + types - 1) % types];
|
[(current_idx + types - 1) % types];
|
||||||
|
|
||||||
settings->input.libretro_device[port] = current_device;
|
input_config_set_device(port, current_device);
|
||||||
|
|
||||||
pad.port = port;
|
pad.port = port;
|
||||||
pad.device = current_device;
|
pad.device = current_device;
|
||||||
@ -1243,7 +1242,7 @@ static int setting_action_right_libretro_device_type(
|
|||||||
current_device = devices
|
current_device = devices
|
||||||
[(current_idx + 1) % types];
|
[(current_idx + 1) % types];
|
||||||
|
|
||||||
settings->input.libretro_device[port] = current_device;
|
input_config_set_device(port, current_device);
|
||||||
|
|
||||||
pad.port = port;
|
pad.port = port;
|
||||||
pad.device = current_device;
|
pad.device = current_device;
|
||||||
|
81
retroarch.c
81
retroarch.c
@ -67,6 +67,7 @@
|
|||||||
#include "core_info.h"
|
#include "core_info.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
#include "input/input_config.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
#include "dirs.h"
|
#include "dirs.h"
|
||||||
@ -401,7 +402,6 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
const char *optstring = NULL;
|
const char *optstring = NULL;
|
||||||
bool explicit_menu = false;
|
bool explicit_menu = false;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
const struct option opts[] = {
|
const struct option opts[] = {
|
||||||
@ -545,7 +545,8 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
retroarch_fail(1, "retroarch_parse_input()");
|
retroarch_fail(1, "retroarch_parse_input()");
|
||||||
}
|
}
|
||||||
new_port = port -1;
|
new_port = port -1;
|
||||||
settings->input.libretro_device[new_port] = id;
|
|
||||||
|
input_config_set_device(new_port, id);
|
||||||
|
|
||||||
retroarch_override_setting_set(
|
retroarch_override_setting_set(
|
||||||
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port);
|
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port);
|
||||||
@ -564,7 +565,7 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
new_port = port - 1;
|
new_port = port - 1;
|
||||||
|
|
||||||
settings->input.libretro_device[new_port] = RETRO_DEVICE_ANALOG;
|
input_config_set_device(new_port, RETRO_DEVICE_ANALOG);
|
||||||
retroarch_override_setting_set(
|
retroarch_override_setting_set(
|
||||||
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port);
|
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port);
|
||||||
}
|
}
|
||||||
@ -606,7 +607,7 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
retroarch_fail(1, "retroarch_parse_input()");
|
retroarch_fail(1, "retroarch_parse_input()");
|
||||||
}
|
}
|
||||||
new_port = port - 1;
|
new_port = port - 1;
|
||||||
settings->input.libretro_device[port - 1] = RETRO_DEVICE_NONE;
|
input_config_set_device(port - 1, RETRO_DEVICE_NONE);
|
||||||
retroarch_override_setting_set(
|
retroarch_override_setting_set(
|
||||||
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port);
|
RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port);
|
||||||
}
|
}
|
||||||
@ -631,6 +632,8 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
case 'L':
|
case 'L':
|
||||||
if (path_is_directory(optarg))
|
if (path_is_directory(optarg))
|
||||||
{
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
path_clear(RARCH_PATH_CORE);
|
path_clear(RARCH_PATH_CORE);
|
||||||
strlcpy(settings->directory.libretro, optarg,
|
strlcpy(settings->directory.libretro, optarg,
|
||||||
sizeof(settings->directory.libretro));
|
sizeof(settings->directory.libretro));
|
||||||
@ -698,31 +701,43 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
retroarch_override_setting_set(
|
{
|
||||||
RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL);
|
settings_t *settings = config_get_ptr();
|
||||||
retroarch_override_setting_set(
|
retroarch_override_setting_set(
|
||||||
RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL);
|
RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL);
|
||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
retroarch_override_setting_set(
|
||||||
strlcpy(settings->netplay.server, optarg,
|
RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL);
|
||||||
sizeof(settings->netplay.server));
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
||||||
|
strlcpy(settings->netplay.server, optarg,
|
||||||
|
sizeof(settings->netplay.server));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RA_OPT_STATELESS:
|
case RA_OPT_STATELESS:
|
||||||
settings->netplay.stateless_mode = true;
|
{
|
||||||
retroarch_override_setting_set(
|
settings_t *settings = config_get_ptr();
|
||||||
RARCH_OVERRIDE_SETTING_NETPLAY_STATELESS_MODE, NULL);
|
settings->netplay.stateless_mode = true;
|
||||||
|
retroarch_override_setting_set(
|
||||||
|
RARCH_OVERRIDE_SETTING_NETPLAY_STATELESS_MODE, NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RA_OPT_CHECK_FRAMES:
|
case RA_OPT_CHECK_FRAMES:
|
||||||
retroarch_override_setting_set(
|
{
|
||||||
RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, NULL);
|
settings_t *settings = config_get_ptr();
|
||||||
settings->netplay.check_frames = strtoul(optarg, NULL, 0);
|
retroarch_override_setting_set(
|
||||||
|
RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, NULL);
|
||||||
|
settings->netplay.check_frames = strtoul(optarg, NULL, 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RA_OPT_PORT:
|
case RA_OPT_PORT:
|
||||||
retroarch_override_setting_set(
|
{
|
||||||
RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT, NULL);
|
settings_t *settings = config_get_ptr();
|
||||||
settings->netplay.port = strtoul(optarg, NULL, 0);
|
retroarch_override_setting_set(
|
||||||
|
RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT, NULL);
|
||||||
|
settings->netplay.port = strtoul(optarg, NULL, 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(HAVE_NETWORK_CMD)
|
#if defined(HAVE_NETWORK_CMD)
|
||||||
@ -772,9 +787,12 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RA_OPT_NICK:
|
case RA_OPT_NICK:
|
||||||
rarch_ctl(RARCH_CTL_USERNAME_SET, NULL);
|
{
|
||||||
strlcpy(settings->username, optarg,
|
settings_t *settings = config_get_ptr();
|
||||||
sizeof(settings->username));
|
rarch_ctl(RARCH_CTL_USERNAME_SET, NULL);
|
||||||
|
strlcpy(settings->username, optarg,
|
||||||
|
sizeof(settings->username));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RA_OPT_APPENDCONFIG:
|
case RA_OPT_APPENDCONFIG:
|
||||||
@ -1109,7 +1127,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
|||||||
static bool rarch_bps_pref = false;
|
static bool rarch_bps_pref = false;
|
||||||
static bool rarch_ips_pref = false;
|
static bool rarch_ips_pref = false;
|
||||||
static bool rarch_patch_blocked = false;
|
static bool rarch_patch_blocked = false;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
#ifdef HAVE_THREAD_STORAGE
|
#ifdef HAVE_THREAD_STORAGE
|
||||||
static sthread_tls_t rarch_tls;
|
static sthread_tls_t rarch_tls;
|
||||||
const void *MAGIC_POINTER = (void*)0xB16B00B5;
|
const void *MAGIC_POINTER = (void*)0xB16B00B5;
|
||||||
@ -1239,7 +1256,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
|
input_config_set_device(i, RETRO_DEVICE_JOYPAD);
|
||||||
}
|
}
|
||||||
runloop_ctl(RUNLOOP_CTL_HTTPSERVER_INIT, NULL);
|
runloop_ctl(RUNLOOP_CTL_HTTPSERVER_INIT, NULL);
|
||||||
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_INIT, NULL);
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_INIT, NULL);
|
||||||
@ -1306,8 +1323,11 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
|||||||
menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL);
|
menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
if (settings->input.overlay_hide_in_menu)
|
{
|
||||||
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
settings_t *settings = config_get_ptr();
|
||||||
|
if (settings->input.overlay_hide_in_menu)
|
||||||
|
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case RARCH_CTL_MENU_RUNNING_FINISHED:
|
case RARCH_CTL_MENU_RUNNING_FINISHED:
|
||||||
@ -1316,8 +1336,11 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
|||||||
#endif
|
#endif
|
||||||
video_driver_set_texture_enable(false, false);
|
video_driver_set_texture_enable(false, false);
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
if (settings && settings->input.overlay_hide_in_menu)
|
{
|
||||||
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
|
settings_t *settings = config_get_ptr();
|
||||||
|
if (settings && settings->input.overlay_hide_in_menu)
|
||||||
|
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case RARCH_CTL_IS_MAIN_THREAD:
|
case RARCH_CTL_IS_MAIN_THREAD:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user