This commit is contained in:
twinaphex 2016-03-04 19:29:22 +01:00
parent 05ce32efe4
commit 2d158b809c
7 changed files with 49 additions and 41 deletions

View File

@ -340,9 +340,9 @@ static void event_init_controllers(void)
const struct retro_controller_description *desc = NULL;
unsigned device = settings->input.libretro_device[i];
if (i < info->num_ports)
if (i < info->ports.size)
desc = libretro_find_controller_description(
&info->ports[i], device);
&info->ports.data[i], device);
if (desc)
ident = desc->desc;

View File

@ -1444,8 +1444,8 @@ static const struct retro_subsystem_info *init_content_file_subsystem(
{
global_t *global = global_get_ptr();
const struct retro_subsystem_info *special =
libretro_find_subsystem_info(system->special,
system->num_special, global->subsystem);
libretro_find_subsystem_info(system->subsystem.data,
system->subsystem.size, global->subsystem);
if (!special)
{

View File

@ -1133,16 +1133,16 @@ bool rarch_environment_cb(unsigned cmd, void *data)
}
}
free(system->special);
system->special = (struct retro_subsystem_info*)
calloc(i, sizeof(*system->special));
free(system->subsystem.data);
system->subsystem.data = (struct retro_subsystem_info*)
calloc(i, sizeof(*system->subsystem.data));
if (!system->special)
if (!system->subsystem.data)
return false;
memcpy(system->special, info,
i * sizeof(*system->special));
system->num_special = i;
memcpy(system->subsystem.data, info,
i * sizeof(*system->subsystem.data));
system->subsystem.size = i;
break;
}
@ -1162,15 +1162,15 @@ bool rarch_environment_cb(unsigned cmd, void *data)
info[i].types[j].id);
}
free(system->ports);
system->ports = (struct retro_controller_info*)
calloc(i, sizeof(*system->ports));
if (!system->ports)
free(system->ports.data);
system->ports.data = (struct retro_controller_info*)
calloc(i, sizeof(*system->ports.data));
if (!system->ports.data)
return false;
memcpy(system->ports, info,
i * sizeof(*system->ports));
system->num_ports = i;
memcpy(system->ports.data, info,
i * sizeof(*system->ports.data));
system->ports.size = i;
break;
}

View File

@ -1003,9 +1003,9 @@ static void setting_get_string_representation_uint_libretro_device(void *data,
index_offset = menu_setting_get_index_offset(setting);
if (index_offset < system->num_ports)
if (index_offset < system->ports.size)
desc = libretro_find_controller_description(
&system->ports[index_offset],
&system->ports.data[index_offset],
settings->input.libretro_device
[index_offset]);
@ -2235,11 +2235,11 @@ static int setting_action_start_libretro_device_type(void *data)
/* Only push RETRO_DEVICE_ANALOG as default if we use an
* older core which doesn't use SET_CONTROLLER_INFO. */
if (!system->num_ports)
if (!system->ports.size)
devices[types++] = RETRO_DEVICE_ANALOG;
desc = port < system->num_ports ?
&system->ports[port] : NULL;
desc = port < system->ports.size ?
&system->ports.data[port] : NULL;
if (desc)
{
@ -2385,11 +2385,11 @@ static int setting_action_left_libretro_device_type(
/* Only push RETRO_DEVICE_ANALOG as default if we use an
* older core which doesn't use SET_CONTROLLER_INFO. */
if (!system->num_ports)
if (!system->ports.size)
devices[types++] = RETRO_DEVICE_ANALOG;
if (port < system->num_ports)
desc = &system->ports[port];
if (port < system->ports.size)
desc = &system->ports.data[port];
if (desc)
{
@ -2450,11 +2450,11 @@ static int setting_action_right_libretro_device_type(
/* Only push RETRO_DEVICE_ANALOG as default if we use an
* older core which doesn't use SET_CONTROLLER_INFO. */
if (!system->num_ports)
if (!system->ports.size)
devices[types++] = RETRO_DEVICE_ANALOG;
if (port < system->num_ports)
desc = &system->ports[port];
if (port < system->ports.size)
desc = &system->ports.data[port];
if (desc)
{

View File

@ -1033,8 +1033,8 @@ static void rarch_init_savefile_paths(void)
unsigned i, j;
const struct retro_subsystem_info *info =
libretro_find_subsystem_info(
system->special,
system->num_special,
system->subsystem.data,
system->subsystem.size,
global->subsystem);
/* We'll handle this error gracefully later. */

View File

@ -499,12 +499,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
runloop_system.core_options = NULL;
/* No longer valid. */
if (runloop_system.special)
free(runloop_system.special);
runloop_system.special = NULL;
if (runloop_system.ports)
free(runloop_system.ports);
runloop_system.ports = NULL;
if (runloop_system.subsystem.data)
free(runloop_system.subsystem.data);
runloop_system.subsystem.data = NULL;
if (runloop_system.ports.data)
free(runloop_system.ports.data);
runloop_system.subsystem.size = 0;
runloop_system.ports.data = NULL;
runloop_system.ports.size = 0;
runloop_key_event = NULL;
runloop_frontend_key_event = NULL;

View File

@ -47,11 +47,17 @@ typedef struct rarch_system_info
core_option_manager_t *core_options;
struct retro_subsystem_info *special;
unsigned num_special;
struct
{
struct retro_subsystem_info *data;
unsigned size;
} subsystem;
struct retro_controller_info *ports;
unsigned num_ports;
struct
{
struct retro_controller_info *data;
unsigned size;
} ports;
} rarch_system_info_t;
#ifdef __cplusplus