mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 18:40:09 +00:00
Wrap settings->input.libretro_device
This commit is contained in:
parent
f4e5f896a2
commit
e1e83b17b7
@ -63,6 +63,7 @@
|
|||||||
|
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
#include "input/input_config.h"
|
||||||
#include "frontend/frontend_driver.h"
|
#include "frontend/frontend_driver.h"
|
||||||
#include "audio/audio_driver.h"
|
#include "audio/audio_driver.h"
|
||||||
#include "record/record_driver.h"
|
#include "record/record_driver.h"
|
||||||
@ -1126,8 +1127,7 @@ static void command_event_init_controllers(void)
|
|||||||
const char *ident = NULL;
|
const char *ident = NULL;
|
||||||
bool set_controller = false;
|
bool set_controller = false;
|
||||||
const struct retro_controller_description *desc = NULL;
|
const struct retro_controller_description *desc = NULL;
|
||||||
unsigned device =
|
unsigned device = input_config_get_device(i);
|
||||||
settings->input.libretro_device[i];
|
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
{
|
{
|
||||||
@ -1146,7 +1146,7 @@ static void command_event_init_controllers(void)
|
|||||||
|
|
||||||
if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE)
|
if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE)
|
||||||
{
|
{
|
||||||
/* Do not fix settings->input.libretro_device[i],
|
/* Do not fix device,
|
||||||
* because any use of dummy core will reset this,
|
* because any use of dummy core will reset this,
|
||||||
* which is not a good idea. */
|
* which is not a good idea. */
|
||||||
RARCH_WARN("Input device ID %u is unknown to this "
|
RARCH_WARN("Input device ID %u is unknown to this "
|
||||||
|
@ -1191,7 +1191,7 @@ static void config_set_defaults(void)
|
|||||||
settings->input.joypad_map[i] = i;
|
settings->input.joypad_map[i] = i;
|
||||||
settings->input.analog_dpad_mode[i] = ANALOG_DPAD_NONE;
|
settings->input.analog_dpad_mode[i] = ANALOG_DPAD_NONE;
|
||||||
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &i))
|
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &i))
|
||||||
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
|
input_config_set_device(i, RETRO_DEVICE_JOYPAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
video_driver_reset_custom_viewport();
|
video_driver_reset_custom_viewport();
|
||||||
@ -3054,7 +3054,7 @@ bool config_save_file(const char *path)
|
|||||||
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
|
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
|
||||||
config_set_int(conf, cfg, settings->input.joypad_map[i]);
|
config_set_int(conf, cfg, settings->input.joypad_map[i]);
|
||||||
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
|
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
|
||||||
config_set_int(conf, cfg, settings->input.libretro_device[i]);
|
config_set_int(conf, cfg, input_config_get_device(i));
|
||||||
snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1);
|
snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1);
|
||||||
config_set_int(conf, cfg, settings->input.analog_dpad_mode[i]);
|
config_set_int(conf, cfg, settings->input.analog_dpad_mode[i]);
|
||||||
}
|
}
|
||||||
@ -3309,7 +3309,7 @@ bool config_save_overrides(int override_type)
|
|||||||
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
|
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
|
||||||
config_set_int(conf, cfg, overrides->input.joypad_map[i]);
|
config_set_int(conf, cfg, overrides->input.joypad_map[i]);
|
||||||
}
|
}
|
||||||
if (settings->input.libretro_device[i] != overrides->input.libretro_device[i])
|
if (input_config_get_device(i) != overrides->input.libretro_device[i])
|
||||||
{
|
{
|
||||||
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
|
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
|
||||||
config_set_int(conf, cfg, overrides->input.libretro_device[i]);
|
config_set_int(conf, cfg, overrides->input.libretro_device[i]);
|
||||||
|
@ -505,6 +505,18 @@ void input_config_clear_device_name(unsigned port)
|
|||||||
settings->input.device_names[port][0] = '\0';
|
settings->input.device_names[port][0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned *input_config_get_device_ptr(unsigned port)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
return &settings->input.libretro_device[port];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned input_config_get_device(unsigned port)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
return settings->input.libretro_device[port];
|
||||||
|
}
|
||||||
|
|
||||||
void input_config_set_device(unsigned port, unsigned id)
|
void input_config_set_device(unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
@ -71,6 +71,10 @@ void input_config_set_device_name(unsigned port, const char *name);
|
|||||||
|
|
||||||
void input_config_clear_device_name(unsigned port);
|
void input_config_clear_device_name(unsigned port);
|
||||||
|
|
||||||
|
unsigned *input_config_get_device_ptr(unsigned port);
|
||||||
|
|
||||||
|
unsigned input_config_get_device(unsigned port);
|
||||||
|
|
||||||
void input_config_set_device(unsigned port, unsigned id);
|
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);
|
||||||
|
@ -422,25 +422,24 @@ static void setting_get_string_representation_uint_aspect_ratio_index(void *data
|
|||||||
static void setting_get_string_representation_uint_libretro_device(void *data,
|
static void setting_get_string_representation_uint_libretro_device(void *data,
|
||||||
char *s, size_t len)
|
char *s, size_t len)
|
||||||
{
|
{
|
||||||
unsigned index_offset;
|
unsigned index_offset, device;
|
||||||
const struct retro_controller_description *desc = NULL;
|
const struct retro_controller_description *desc = NULL;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
rarch_system_info_t *system = runloop_get_system_info();
|
rarch_system_info_t *system = runloop_get_system_info();
|
||||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
if (!setting)
|
if (!setting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
index_offset = setting->index_offset;
|
index_offset = setting->index_offset;
|
||||||
|
device = input_config_get_device(index_offset);
|
||||||
|
|
||||||
if (system)
|
if (system)
|
||||||
{
|
{
|
||||||
if (index_offset < system->ports.size)
|
if (index_offset < system->ports.size)
|
||||||
desc = libretro_find_controller_description(
|
desc = libretro_find_controller_description(
|
||||||
&system->ports.data[index_offset],
|
&system->ports.data[index_offset],
|
||||||
settings->input.libretro_device
|
device);
|
||||||
[index_offset]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc)
|
if (desc)
|
||||||
@ -449,8 +448,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data,
|
|||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
/* Find generic name. */
|
/* Find generic name. */
|
||||||
|
switch (device)
|
||||||
switch (settings->input.libretro_device[index_offset])
|
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_NONE:
|
case RETRO_DEVICE_NONE:
|
||||||
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE);
|
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE);
|
||||||
@ -1155,7 +1153,7 @@ static int setting_action_left_libretro_device_type(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current_device = settings->input.libretro_device[port];
|
current_device = input_config_get_device(port);
|
||||||
current_idx = 0;
|
current_idx = 0;
|
||||||
for (i = 0; i < types; i++)
|
for (i = 0; i < types; i++)
|
||||||
{
|
{
|
||||||
@ -1221,7 +1219,7 @@ static int setting_action_right_libretro_device_type(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current_device = settings->input.libretro_device[port];
|
current_device = input_config_get_device(port);
|
||||||
current_idx = 0;
|
current_idx = 0;
|
||||||
for (i = 0; i < types; i++)
|
for (i = 0; i < types; i++)
|
||||||
{
|
{
|
||||||
@ -1960,7 +1958,7 @@ static bool setting_append_list_input_player_options(
|
|||||||
|
|
||||||
CONFIG_UINT_ALT(
|
CONFIG_UINT_ALT(
|
||||||
list, list_info,
|
list, list_info,
|
||||||
&settings->input.libretro_device[user],
|
input_config_get_device_ptr(user),
|
||||||
key_type[user],
|
key_type[user],
|
||||||
label_type[user],
|
label_type[user],
|
||||||
user,
|
user,
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "../../retroarch.h"
|
#include "../../retroarch.h"
|
||||||
#include "../../runloop.h"
|
#include "../../runloop.h"
|
||||||
#include "../../version.h"
|
#include "../../version.h"
|
||||||
|
#include "../../input/input_config.h"
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
#include "../../menu/widgets/menu_input_dialog.h"
|
#include "../../menu/widgets/menu_input_dialog.h"
|
||||||
@ -514,14 +515,13 @@ bool netplay_handshake_info(netplay_t *netplay, struct netplay_connection *conne
|
|||||||
bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *connection)
|
bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *connection)
|
||||||
{
|
{
|
||||||
/* If we're the server, now we send sync info */
|
/* If we're the server, now we send sync info */
|
||||||
|
size_t i;
|
||||||
|
int matchct;
|
||||||
|
uint32_t device;
|
||||||
uint32_t cmd[5];
|
uint32_t cmd[5];
|
||||||
uint32_t connected_players;
|
uint32_t connected_players;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
size_t i;
|
|
||||||
uint32_t device;
|
|
||||||
retro_ctx_memory_info_t mem_info;
|
retro_ctx_memory_info_t mem_info;
|
||||||
size_t nicklen, nickmangle;
|
size_t nicklen, nickmangle;
|
||||||
int matchct;
|
|
||||||
bool nick_matched;
|
bool nick_matched;
|
||||||
|
|
||||||
autosave_lock();
|
autosave_lock();
|
||||||
@ -552,7 +552,7 @@ bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *conne
|
|||||||
/* Now send the device info */
|
/* Now send the device info */
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
{
|
{
|
||||||
device = htonl(settings->input.libretro_device[i]);
|
device = htonl(input_config_get_device(i));
|
||||||
if (!netplay_send(&connection->send_packet_buffer, connection->fd,
|
if (!netplay_send(&connection->send_packet_buffer, connection->fd,
|
||||||
&device, sizeof(device)))
|
&device, sizeof(device)))
|
||||||
return false;
|
return false;
|
||||||
@ -626,7 +626,6 @@ bool netplay_handshake_pre_nick(netplay_t *netplay,
|
|||||||
struct nick_buf_s nick_buf;
|
struct nick_buf_s nick_buf;
|
||||||
ssize_t recvd;
|
ssize_t recvd;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
msg[0] = '\0';
|
msg[0] = '\0';
|
||||||
|
|
||||||
@ -655,6 +654,7 @@ bool netplay_handshake_pre_nick(netplay_t *netplay,
|
|||||||
|
|
||||||
if (netplay->is_server)
|
if (netplay->is_server)
|
||||||
{
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
if (settings->netplay.password[0] || settings->netplay.spectate_password[0])
|
if (settings->netplay.password[0] || settings->netplay.spectate_password[0])
|
||||||
{
|
{
|
||||||
/* There's a password, so just put them in PRE_PASSWORD mode */
|
/* There's a password, so just put them in PRE_PASSWORD mode */
|
||||||
@ -721,6 +721,7 @@ bool netplay_handshake_pre_password(netplay_t *netplay,
|
|||||||
/* Calculate the correct password hash(es) and compare */
|
/* Calculate the correct password hash(es) and compare */
|
||||||
correct = false;
|
correct = false;
|
||||||
snprintf(password, sizeof(password), "%08X", connection->salt);
|
snprintf(password, sizeof(password), "%08X", connection->salt);
|
||||||
|
|
||||||
if (settings->netplay.password[0])
|
if (settings->netplay.password[0])
|
||||||
{
|
{
|
||||||
strlcpy(password + 8, settings->netplay.password, sizeof(password)-8);
|
strlcpy(password + 8, settings->netplay.password, sizeof(password)-8);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user