Add input_libretro_device_pN setting.

Allows input device type to be saved in a config, which tremendously helps usability
for PlayStation 1 cores.
This commit is contained in:
Themaister 2013-09-22 11:08:09 +02:00
parent 13fac45830
commit 086caef070
7 changed files with 79 additions and 15 deletions

View File

@ -15,6 +15,11 @@ retroarch-joyconfig \- Tool to configure joypad bindings for \fBretroarch\fR.
\fBretroarch-joyconfig is a simple tool that allows updating or creating a configuration file for \fBretroarch\fR.
It reads in necessary joypad bindings for a certain player and joypad.
.SH "EXAMPLE COMMANDLINES"
retroarch-joyconfig -p 1 -j 0
retroarch-joyconfig -j 0 -a ~/.config/retroarch/autoconfig/pad.cfg
.SH "GENERAL OPTIONS"
.TP

View File

@ -16,6 +16,9 @@ retroarch \- A simple frontend for the libretro API.
libretro provides emulation of a game system, and can be implemented by any frontend.
\fBretroarch\fR focuses on exposing needed functionality for the game system through the use of command line and configuration files.
.SH "EXAMPLE COMMANDLINE"
retroarch --config ~/.config/retroarch/retroarch.cfg --libretro /path/to/libretro/core.so /path/to/rom.rom --verbose
.SH "GENERAL OPTIONS"
.TP
@ -113,30 +116,37 @@ When using Sufami, save ram paths will be inferred from the Sufami BIOS path, no
.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.
If set explicitly here, overrides config file for that port.
.TP
\fB--scope, -p\fR
Connects a Super Scope into port 2 of an emulated SNES. It is controlled with your mouse.
If set explicitly here, overrides config file for that port.
.TP
\fB--justifier, -j\fR
Connects a Konami Justifier into port 2 of an emulated SNES. It is controlled with your mouse.
If set explicitly here, overrides config file for that port.
.TP
\fB--justifiers, -J\fR
Connects two Konami Justifier into port 2 of an emulated SNES. Currently, only player 1 is controlled with the mouse.
If set explicitly here, overrides config file for that port.
.TP
\fB--multitap, -4\fR
Connects a four-way multitap into an emulated SNES. This allows for up to 5 players.
If set explicitly here, overrides config file for that port.
.TP
\fB--dualanalog PORT, -A PORT\fR
Connects a DualAnalog controller into port PORT. Possible values are 1 to 8.
If set explicitly here, overrides config file for that port.
.TP
\fB--record PATH, -r PATH\fR

View File

@ -797,7 +797,7 @@ static void render_text(rgui_handle_t *rgui)
case RGUI_SETTINGS_BIND_DEVICE_TYPE:
{
const char *name;
switch (g_extern.libretro_device[port])
switch (g_settings.input.libretro_device[port])
{
case RETRO_DEVICE_NONE: name = "None"; break;
case RETRO_DEVICE_JOYPAD: name = "Joypad"; break;
@ -1276,7 +1276,7 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
RETRO_DEVICE_LIGHTGUN_JUSTIFIERS,
};
unsigned current_device = g_extern.libretro_device[port];
unsigned current_device = g_settings.input.libretro_device[port];
unsigned current_index = 0;
for (unsigned i = 0; i < ARRAY_SIZE(device_types); i++)
{
@ -1309,7 +1309,7 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
if (updated)
{
g_extern.libretro_device[port] = current_device;
g_settings.input.libretro_device[port] = current_device;
pretro_set_controller_port_device(port, current_device);
}

View File

@ -227,6 +227,8 @@ struct settings
struct retro_keybind autoconf_binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
bool autoconfigured[MAX_PLAYERS];
unsigned libretro_device[MAX_PLAYERS];
float axis_threshold;
int joypad_map[MAX_PLAYERS];
unsigned device[MAX_PLAYERS];
@ -319,8 +321,6 @@ struct global
bool video_active;
bool force_fullscreen;
unsigned libretro_device[MAX_PLAYERS];
bool rom_file_temporary;
char last_rom[PATH_MAX];
enum rarch_game_type game_type;
@ -331,6 +331,7 @@ struct global
char sufami_rom_path[2][PATH_MAX];
bool has_set_save_path;
bool has_set_state_path;
bool has_set_libretro_device[MAX_PLAYERS];
#ifdef HAVE_RMENU
char menu_texture_path[PATH_MAX];

View File

@ -901,15 +901,18 @@ static void parse_input(int argc, char *argv[])
exit(0);
case '4':
g_extern.libretro_device[1] = RETRO_DEVICE_JOYPAD_MULTITAP;
g_settings.input.libretro_device[1] = RETRO_DEVICE_JOYPAD_MULTITAP;
g_extern.has_set_libretro_device[1] = true;
break;
case 'j':
g_extern.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_JUSTIFIER;
g_settings.input.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_JUSTIFIER;
g_extern.has_set_libretro_device[1] = true;
break;
case 'J':
g_extern.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_JUSTIFIERS;
g_settings.input.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_JUSTIFIERS;
g_extern.has_set_libretro_device[1] = true;
break;
case 'A':
@ -920,7 +923,8 @@ static void parse_input(int argc, char *argv[])
print_help();
rarch_fail(1, "parse_input()");
}
g_extern.libretro_device[port - 1] = RETRO_DEVICE_ANALOG;
g_settings.input.libretro_device[port - 1] = RETRO_DEVICE_ANALOG;
g_extern.has_set_libretro_device[port - 1] = true;
break;
case 's':
@ -974,7 +978,8 @@ static void parse_input(int argc, char *argv[])
print_help();
rarch_fail(1, "parse_input()");
}
g_extern.libretro_device[port - 1] = RETRO_DEVICE_MOUSE;
g_settings.input.libretro_device[port - 1] = RETRO_DEVICE_MOUSE;
g_extern.has_set_libretro_device[port - 1] = true;
break;
case 'N':
@ -985,11 +990,13 @@ static void parse_input(int argc, char *argv[])
print_help();
rarch_fail(1, "parse_input()");
}
g_extern.libretro_device[port - 1] = RETRO_DEVICE_NONE;
g_settings.input.libretro_device[port - 1] = RETRO_DEVICE_NONE;
g_extern.has_set_libretro_device[port - 1] = true;
break;
case 'p':
g_extern.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE;
g_settings.input.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE;
g_extern.has_set_libretro_device[1] = true;
break;
case 'c':
@ -1186,7 +1193,7 @@ static void init_controllers(void)
{
for (unsigned i = 0; i < MAX_PLAYERS; i++)
{
unsigned device = g_extern.libretro_device[i];
unsigned device = g_settings.input.libretro_device[i];
// This is default, don't bother.
if (device == RETRO_DEVICE_JOYPAD)
@ -2807,9 +2814,13 @@ static void init_state(void)
g_extern.video_active = true;
g_extern.audio_active = true;
g_extern.game_type = RARCH_CART_NORMAL;
}
static void init_state_first(void)
{
init_state();
for (unsigned i = 0; i < MAX_PLAYERS; i++)
g_extern.libretro_device[i] = RETRO_DEVICE_JOYPAD;
g_settings.input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
}
void rarch_main_clear_state(void)
@ -2821,7 +2832,7 @@ void rarch_main_clear_state(void)
memset(&g_extern, 0, sizeof(g_extern));
init_state();
init_state_first();
}
#ifdef HAVE_ZLIB

View File

@ -236,6 +236,31 @@
# Enable debug input key reporting on-screen.
# input_debug_enable = false
# Sets which libretro device is used for a player.
# Devices are indentified with a number.
# This is normally saved by RGUI.
# Device IDs are found in libretro.h.
# These settings are overridden by explicit command-line arguments which refer to input devices.
# None: 0
# Joypad (RetroPad): 1
# Mouse: 2
# Keyboard: 3
# Generic Lightgun: 4
# Joypad w/ Analog (RetroPad + Analog sticks): 5
# Multitap (SNES specific): 257
# Super Scope (SNES specific): 260
# Justifier (SNES specific): 516
# Justifiers (SNES specific): 772
# input_libretro_device_p1 =
# input_libretro_device_p2 =
# input_libretro_device_p3 =
# input_libretro_device_p4 =
# input_libretro_device_p5 =
# input_libretro_device_p6 =
# input_libretro_device_p7 =
# input_libretro_device_p8 =
# Keyboard input. Will recognize normal keypresses and special keys like "left", "right", and so on.
# Keyboard input, Joypad and Joyaxis will all obey the "nul" bind, which disables the bind completely,
# rather than relying on a default.

View File

@ -263,7 +263,11 @@ void config_set_defaults(void)
#endif
for (int i = 0; i < MAX_PLAYERS; i++)
{
g_settings.input.joypad_map[i] = i;
if (!g_extern.has_set_libretro_device[i])
g_settings.input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
}
g_extern.console.screen.viewports.custom_vp.width = 0;
g_extern.console.screen.viewports.custom_vp.height = 0;
@ -634,6 +638,12 @@ bool config_load_file(const char *path)
char buf[64];
snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i + 1);
CONFIG_GET_INT(input.joypad_map[i], buf);
if (!g_extern.has_set_libretro_device[i])
{
snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1);
CONFIG_GET_INT(input.libretro_device[i], buf);
}
}
// Audio settings.
@ -1106,6 +1116,8 @@ bool config_save_file(const char *path)
config_set_int(conf, cfg, g_settings.input.device[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
config_set_int(conf, cfg, g_settings.input.joypad_map[i]);
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
config_set_int(conf, cfg, g_settings.input.libretro_device[i]);
}
config_file_write(conf, path);