Add some testing of new controller info API to libretro-test.

This commit is contained in:
Themaister 2014-04-12 13:59:19 +02:00
parent a14f0a2760
commit aafe28bb14
4 changed files with 50 additions and 32 deletions

View File

@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
*
* 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.
@ -134,7 +134,7 @@ static dylib_t libretro_get_system_info_lib(const char *path, struct retro_syste
if (!lib)
return NULL;
void (*proc)(struct retro_system_info*) =
void (*proc)(struct retro_system_info*) =
(void (*)(struct retro_system_info*))dylib_proc(lib, "retro_get_system_info");
if (!proc)
@ -222,7 +222,7 @@ static bool find_first_libretro(char *path, size_t size,
continue;
}
struct string_list *supported_ext = string_split(info.valid_extensions, "|");
struct string_list *supported_ext = string_split(info.valid_extensions, "|");
if (string_list_find_elem(supported_ext, ext))
{
@ -411,7 +411,7 @@ void init_libretro_sym(bool dummy)
function_t sym = dylib_proc(NULL, "retro_init");
if (sym)
{
RARCH_ERR("Serious problem. RetroArch wants to load libretro dyamically, but it is already linked.\n");
RARCH_ERR("Serious problem. RetroArch wants to load libretro dyamically, but it is already linked.\n");
RARCH_ERR("This could happen if other modules RetroArch depends on link against libretro directly.\n");
RARCH_ERR("Proceeding could cause a crash. Aborting ...\n");
rarch_fail(1, "init_libretro_sym()");
@ -483,7 +483,7 @@ function_t dylib_proc(dylib_t lib, const char *proc)
#else
void *ptr_sym = NULL;
if (lib)
ptr_sym = dlsym(lib, proc);
ptr_sym = dlsym(lib, proc);
else
{
void *handle = dlopen(NULL, RTLD_LAZY);
@ -652,7 +652,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY:
*(const char**)data = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL;
RARCH_LOG("Environ SAVE_DIRECTORY: \"%s\".\n", g_extern.savefile_dir);
break;
break;
case RETRO_ENVIRONMENT_SET_PIXEL_FORMAT:
{
@ -672,7 +672,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
default:
return false;
}
g_extern.system.pix_fmt = pix_fmt;
break;
}
@ -719,7 +719,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
}
case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
{
RARCH_LOG("Environ SET_KEYBOARD_CALLBACK.\n");
@ -801,12 +801,12 @@ bool rarch_environment_cb(unsigned cmd, void *data)
#ifdef HAVE_DYNAMIC
*path = g_settings.libretro;
#else
*path = NULL;
*path = NULL;
#endif
break;
}
//FIXME - PS3 audio driver needs to be fixed so that threaded audio works correctly
//FIXME - PS3 audio driver needs to be fixed so that threaded audio works correctly
//(audio is already on a thread for PS3 audio driver so that's probably the problem)
#if defined(HAVE_THREADS) && !defined(__CELLOS_LV2__)
case RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK:
@ -971,7 +971,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
RARCH_LOG("Controller port: %u\n", i);
for (j = 0; j < info[i].num_types; j++)
RARCH_LOG(" %s (ident: %s, ID: %u)\n", info[i].types[j].desc, info[i].types[j].ident, info[i].types[j].id);
RARCH_LOG(" %s (ID: %u)\n", info[i].types[j].desc, info[i].types[j].id);
}
free(g_extern.system.ports);

View File

@ -2,7 +2,7 @@
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2014 - Daniel De Matteis
* Copyright (C) 2012-2014 - Michael Lelli
*
*
* 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.
@ -89,7 +89,7 @@ unsigned menu_type_is(unsigned type)
unsigned ret = 0;
bool type_found;
type_found =
type_found =
type == RGUI_SETTINGS ||
type == RGUI_SETTINGS_GENERAL_OPTIONS ||
type == RGUI_SETTINGS_CORE_OPTIONS ||
@ -273,7 +273,7 @@ static int shader_manager_toggle_setting(void *data, unsigned setting, unsigned
else if ((dist_shader % 3) == 0 || setting == RGUI_SETTINGS_SHADER_PRESET)
{
dist_shader /= 3;
struct gfx_shader_pass *pass = setting == RGUI_SETTINGS_SHADER_PRESET ?
struct gfx_shader_pass *pass = setting == RGUI_SETTINGS_SHADER_PRESET ?
&rgui->shader.pass[dist_shader] : NULL;
switch (action)
{
@ -558,7 +558,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
g_settings.block_sram_overwrite = false;
break;
case RGUI_SETTINGS_PER_CORE_CONFIG:
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT
|| action == RGUI_ACTION_LEFT)
g_settings.core_specific_config = !g_settings.core_specific_config;
else if (action == RGUI_ACTION_START)
@ -1071,7 +1071,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
// FIXME: The array indices here look totally wrong ... Fixed it so it looks kind of sane for now.
if (keybind_action != KEYBINDS_ACTION_NONE)
driver.input->set_keybinds(driver.input_data, g_settings.input.device[port], port,
setting - RGUI_SETTINGS_BIND_BEGIN, keybind_action);
setting - RGUI_SETTINGS_BIND_BEGIN, keybind_action);
}
else
{
@ -1334,17 +1334,17 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
if (g_extern.console.screen.resolutions.current.idx)
{
g_extern.console.screen.resolutions.current.idx--;
g_extern.console.screen.resolutions.current.id =
g_extern.console.screen.resolutions.current.id =
g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx];
}
}
else if (action == RGUI_ACTION_RIGHT)
{
if (g_extern.console.screen.resolutions.current.idx + 1 <
if (g_extern.console.screen.resolutions.current.idx + 1 <
g_extern.console.screen.resolutions.count)
{
g_extern.console.screen.resolutions.current.idx++;
g_extern.console.screen.resolutions.current.id =
g_extern.console.screen.resolutions.current.id =
g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx];
}
}
@ -2201,14 +2201,24 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
}
case RGUI_SETTINGS_BIND_DEVICE_TYPE:
{
const char *name;
switch (g_settings.input.libretro_device[rgui->current_pad])
const struct retro_controller_description *desc = NULL;
if (rgui->current_pad < g_extern.system.num_ports)
{
case RETRO_DEVICE_NONE: name = "None"; break;
case RETRO_DEVICE_JOYPAD: name = "Joypad"; break;
case RETRO_DEVICE_ANALOG: name = "Joypad w/ Analog"; break;
case RETRO_DEVICE_MOUSE: name = "Mouse"; break;
default: name = "Unknown"; break;
desc = libretro_find_controller_description(&g_extern.system.ports[rgui->current_pad],
g_settings.input.libretro_device[rgui->current_pad]);
}
const char *name = desc ? desc->desc : NULL;
if (!name) // Find generic name.
{
switch (g_settings.input.libretro_device[rgui->current_pad])
{
case RETRO_DEVICE_NONE: name = "None"; break;
case RETRO_DEVICE_JOYPAD: name = "Joypad"; break;
case RETRO_DEVICE_ANALOG: name = "Joypad w/ Analog"; break;
case RETRO_DEVICE_MOUSE: name = "Mouse"; break;
default: name = "Unknown"; break;
}
}
strlcpy(type_str, name, type_str_size);

View File

@ -39,8 +39,7 @@ unsigned retro_api_version(void)
void retro_set_controller_port_device(unsigned port, unsigned device)
{
(void)port;
(void)device;
logging.log(RETRO_LOG_INFO, "Plugging device %u into port %u.\n", device, port);
}
void retro_get_system_info(struct retro_system_info *info)
@ -130,6 +129,18 @@ void retro_set_environment(retro_environment_t cb)
};
cb(RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO, (void*)types);
static const struct retro_controller_description controllers[] = {
{ "Dummy Controller #1", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0) },
{ "Dummy Controller #2", RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1) },
};
static const struct retro_controller_info ports[] = {
{ controllers, 2 },
{ NULL, 0 },
};
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
}
void retro_set_audio_sample(retro_audio_sample_t cb)
@ -261,7 +272,7 @@ static void render_checkered(void)
for (unsigned x = 0; x < 320; x++)
{
unsigned index_x = ((x - x_coord) >> 4) & 1;
line[x] = (index_y ^ index_x) ? color_r : color_g;
line[x] = (index_y ^ index_x) ? color_r : color_g;
}
}

View File

@ -644,9 +644,6 @@ struct retro_controller_description
// set to the particular device type the core uses.
const char *desc;
// A computer-friendly short string identifier ([a-z]).
const char *ident;
// Device type passed to retro_set_controller_port_device(). If the device type is a sub-class of a generic input device type,
// use the RETRO_DEVICE_SUBCLASS macro to create an ID. E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1).
unsigned id;