Allow toggling available device types in RGUI.

This commit is contained in:
Themaister 2014-04-12 14:12:06 +02:00
parent aafe28bb14
commit 6d6ec8b35a
4 changed files with 25 additions and 34 deletions

View File

@ -123,11 +123,6 @@ If a ROM is skipped, use a blank ("") command line argument.
ROMs must be loaded in an order which depends on the particular subsystem used.
See verbose log output to learn how a particular subsystem wants ROMs to be loaded.
.TP
\fB--mouse PORT, -m PORT\fR
Connects a mouse into port number PORT. Possible values for PORT are 1 to 8.
If set explicitly here, overrides config file for that port.
.TP
\fB--nodevice PORT, -N PORT\fR
Disconnects an input device from port number PORT. Possible values for PORT are 1 to 8. This may be needed for some odd games to run properly.

View File

@ -929,19 +929,30 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
break;
case RGUI_SETTINGS_BIND_DEVICE_TYPE:
{
static const unsigned device_types[] = {
RETRO_DEVICE_NONE,
RETRO_DEVICE_JOYPAD,
RETRO_DEVICE_ANALOG,
RETRO_DEVICE_MOUSE,
};
unsigned current_device, current_index, i;
unsigned types = 0;
unsigned devices[128];
devices[types++] = RETRO_DEVICE_NONE;
devices[types++] = RETRO_DEVICE_JOYPAD;
devices[types++] = RETRO_DEVICE_ANALOG;
const struct retro_controller_info *desc = port < g_extern.system.num_ports ? &g_extern.system.ports[port] : NULL;
if (desc)
{
for (i = 0; i < desc->num_types; i++)
{
unsigned id = desc->types[i].id;
if (types < ARRAY_SIZE(devices) && id != RETRO_DEVICE_NONE && id != RETRO_DEVICE_JOYPAD && id != RETRO_DEVICE_ANALOG)
devices[types++] = id;
}
}
current_device = g_settings.input.libretro_device[port];
current_index = 0;
for (i = 0; i < ARRAY_SIZE(device_types); i++)
for (i = 0; i < types; i++)
{
if (current_device == device_types[i])
if (current_device == devices[i])
{
current_index = i;
break;
@ -956,12 +967,12 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
break;
case RGUI_ACTION_LEFT:
current_device = device_types[(current_index + ARRAY_SIZE(device_types) - 1) % ARRAY_SIZE(device_types)];
current_device = devices[(current_index + types - 1) % types];
break;
case RGUI_ACTION_RIGHT:
case RGUI_ACTION_OK:
current_device = device_types[(current_index + 1) % ARRAY_SIZE(device_types)];
current_device = devices[(current_index + 1) % types];
break;
default:
@ -2216,7 +2227,6 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
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;
}
}

View File

@ -133,10 +133,11 @@ void retro_set_environment(retro_environment_t cb)
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) },
{ "Augmented Joypad", RETRO_DEVICE_JOYPAD }, // Test overriding generic description in UI.
};
static const struct retro_controller_info ports[] = {
{ controllers, 2 },
{ controllers, 3 },
{ NULL, 0 },
};

View File

@ -783,7 +783,6 @@ static void print_help(void)
printf("\t-N/--nodevice: Disconnects controller device connected to port (1 to %d).\n", MAX_PLAYERS);
printf("\t-A/--dualanalog: Connect a DualAnalog controller to port (1 to %d).\n", MAX_PLAYERS);
printf("\t-m/--mouse: Connect a mouse into controller port (1 to %d).\n", MAX_PLAYERS);
printf("\t-d/--device: Connect a generic device into port of the device (1 to %d).\n", MAX_PLAYERS);
puts("\t\tFormat is port:ID, where ID is an unsigned number corresponding to the particular device.\n");
@ -929,7 +928,6 @@ static void parse_input(int argc, char *argv[])
{ "verbose", 0, NULL, 'v' },
{ "config", 1, NULL, 'c' },
{ "appendconfig", 1, &val, 'C' },
{ "mouse", 1, NULL, 'm' },
{ "nodevice", 1, NULL, 'N' },
{ "dualanalog", 1, NULL, 'A' },
{ "device", 1, NULL, 'd' },
@ -984,7 +982,7 @@ static void parse_input(int argc, char *argv[])
#define BSV_MOVIE_ARG
#endif
const char *optstring = "hs:fvS:m:A:c:U:DN:d:" BSV_MOVIE_ARG NETPLAY_ARG DYNAMIC_ARG FFMPEG_RECORD_ARG;
const char *optstring = "hs:fvS:A:c:U:DN:d:" BSV_MOVIE_ARG NETPLAY_ARG DYNAMIC_ARG FFMPEG_RECORD_ARG;
for (;;)
{
@ -1053,18 +1051,6 @@ static void parse_input(int argc, char *argv[])
g_extern.verbose = true;
break;
case 'm':
port = strtol(optarg, NULL, 0);
if (port < 1 || port > MAX_PLAYERS)
{
RARCH_ERR("Connect mouse to a valid port.\n");
print_help();
rarch_fail(1, "parse_input()");
}
g_settings.input.libretro_device[port - 1] = RETRO_DEVICE_MOUSE;
g_extern.has_set_libretro_device[port - 1] = true;
break;
case 'N':
port = strtol(optarg, NULL, 0);
if (port < 1 || port > MAX_PLAYERS)
@ -1277,7 +1263,6 @@ static void init_controllers(void)
{
switch (device)
{
case RETRO_DEVICE_MOUSE: ident = "mouse"; break;
case RETRO_DEVICE_ANALOG: ident = "analog"; break;
default: ident = "Unknown"; break;
}