mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Add concept of meta "level" for hotkeys.
Used by retroarch-joyconfig to make misc key config easier.
This commit is contained in:
parent
69aa79b1e9
commit
dfdcfac588
@ -40,7 +40,12 @@ Also writes an autoconfigure file for the joypad which was configured. It can be
|
||||
|
||||
.TP
|
||||
\fB--misc, -m\fR
|
||||
Also configure some binds that aren't directly related to RetroPad, such as save states, fullscreen toggling, etc.
|
||||
Also configure some binds that aren't directly related to RetroPad, such as save states, RGUI menu toggle, etc.
|
||||
Only configures some of the most useful binds.
|
||||
|
||||
.TP
|
||||
\fB--allmisc, -M\fR
|
||||
Same as --misc, but goes through every bind available (40+). Very exhaustive.
|
||||
|
||||
.TP
|
||||
\fB-t SECONDS, --timeout SECONDS\fR
|
||||
|
@ -545,8 +545,8 @@ static const char *bind_player_prefix[MAX_PLAYERS] = {
|
||||
"input_player8",
|
||||
};
|
||||
|
||||
#define DECLARE_BIND(x, bind, desc) { true, false, #x, desc, bind }
|
||||
#define DECLARE_META_BIND(x, bind, desc) { true, true, #x, desc, bind }
|
||||
#define DECLARE_BIND(x, bind, desc) { true, 0, #x, desc, bind }
|
||||
#define DECLARE_META_BIND(level, x, bind, desc) { true, level, #x, desc, bind }
|
||||
|
||||
const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = {
|
||||
DECLARE_BIND(b, RETRO_DEVICE_ID_JOYPAD_B, "B button (down)"),
|
||||
@ -575,38 +575,38 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = {
|
||||
DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)"),
|
||||
DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)"),
|
||||
|
||||
DECLARE_META_BIND(toggle_fast_forward, RARCH_FAST_FORWARD_KEY, "Fast forward toggle"),
|
||||
DECLARE_META_BIND(hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, "Fast forward hold"),
|
||||
DECLARE_META_BIND(load_state, RARCH_LOAD_STATE_KEY, "Load state"),
|
||||
DECLARE_META_BIND(save_state, RARCH_SAVE_STATE_KEY, "Save state"),
|
||||
DECLARE_META_BIND(toggle_fullscreen, RARCH_FULLSCREEN_TOGGLE_KEY, "Fullscreen toggle"),
|
||||
DECLARE_META_BIND(exit_emulator, RARCH_QUIT_KEY, "Quit RetroArch"),
|
||||
DECLARE_META_BIND(state_slot_increase, RARCH_STATE_SLOT_PLUS, "Savestate slot +"),
|
||||
DECLARE_META_BIND(state_slot_decrease, RARCH_STATE_SLOT_MINUS, "Savestate slot -"),
|
||||
DECLARE_META_BIND(rewind, RARCH_REWIND, "Rewind"),
|
||||
DECLARE_META_BIND(movie_record_toggle, RARCH_MOVIE_RECORD_TOGGLE, "Movie record toggle"),
|
||||
DECLARE_META_BIND(pause_toggle, RARCH_PAUSE_TOGGLE, "Pause toggle"),
|
||||
DECLARE_META_BIND(frame_advance, RARCH_FRAMEADVANCE, "Frameadvance"),
|
||||
DECLARE_META_BIND(reset, RARCH_RESET, "Reset game"),
|
||||
DECLARE_META_BIND(shader_next, RARCH_SHADER_NEXT, "Next shader"),
|
||||
DECLARE_META_BIND(shader_prev, RARCH_SHADER_PREV, "Previous shader"),
|
||||
DECLARE_META_BIND(cheat_index_plus, RARCH_CHEAT_INDEX_PLUS, "Cheat index +"),
|
||||
DECLARE_META_BIND(cheat_index_minus, RARCH_CHEAT_INDEX_MINUS, "Cheat index -"),
|
||||
DECLARE_META_BIND(cheat_toggle, RARCH_CHEAT_TOGGLE, "Cheat toggle"),
|
||||
DECLARE_META_BIND(screenshot, RARCH_SCREENSHOT, "Take screenshot"),
|
||||
DECLARE_META_BIND(dsp_config, RARCH_DSP_CONFIG, "DSP config"),
|
||||
DECLARE_META_BIND(audio_mute, RARCH_MUTE, "Audio mute toggle"),
|
||||
DECLARE_META_BIND(netplay_flip_players, RARCH_NETPLAY_FLIP, "Netplay flip players"),
|
||||
DECLARE_META_BIND(slowmotion, RARCH_SLOWMOTION, "Slow motion"),
|
||||
DECLARE_META_BIND(enable_hotkey, RARCH_ENABLE_HOTKEY, "Enable hotkeys"),
|
||||
DECLARE_META_BIND(volume_up, RARCH_VOLUME_UP, "Volume +"),
|
||||
DECLARE_META_BIND(volume_down, RARCH_VOLUME_DOWN, "Volume -"),
|
||||
DECLARE_META_BIND(overlay_next, RARCH_OVERLAY_NEXT, "Overlay next"),
|
||||
DECLARE_META_BIND(disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, "Disk eject toggle"),
|
||||
DECLARE_META_BIND(disk_next, RARCH_DISK_NEXT, "Disk next"),
|
||||
DECLARE_META_BIND(grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, "Grab mouse toggle"),
|
||||
DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, "Fast forward toggle"),
|
||||
DECLARE_META_BIND(2, hold_fast_forward, RARCH_FAST_FORWARD_HOLD_KEY, "Fast forward hold"),
|
||||
DECLARE_META_BIND(1, load_state, RARCH_LOAD_STATE_KEY, "Load state"),
|
||||
DECLARE_META_BIND(1, save_state, RARCH_SAVE_STATE_KEY, "Save state"),
|
||||
DECLARE_META_BIND(2, toggle_fullscreen, RARCH_FULLSCREEN_TOGGLE_KEY, "Fullscreen toggle"),
|
||||
DECLARE_META_BIND(2, exit_emulator, RARCH_QUIT_KEY, "Quit RetroArch"),
|
||||
DECLARE_META_BIND(2, state_slot_increase, RARCH_STATE_SLOT_PLUS, "Savestate slot +"),
|
||||
DECLARE_META_BIND(2, state_slot_decrease, RARCH_STATE_SLOT_MINUS, "Savestate slot -"),
|
||||
DECLARE_META_BIND(1, rewind, RARCH_REWIND, "Rewind"),
|
||||
DECLARE_META_BIND(2, movie_record_toggle, RARCH_MOVIE_RECORD_TOGGLE, "Movie record toggle"),
|
||||
DECLARE_META_BIND(2, pause_toggle, RARCH_PAUSE_TOGGLE, "Pause toggle"),
|
||||
DECLARE_META_BIND(2, frame_advance, RARCH_FRAMEADVANCE, "Frameadvance"),
|
||||
DECLARE_META_BIND(2, reset, RARCH_RESET, "Reset game"),
|
||||
DECLARE_META_BIND(2, shader_next, RARCH_SHADER_NEXT, "Next shader"),
|
||||
DECLARE_META_BIND(2, shader_prev, RARCH_SHADER_PREV, "Previous shader"),
|
||||
DECLARE_META_BIND(2, cheat_index_plus, RARCH_CHEAT_INDEX_PLUS, "Cheat index +"),
|
||||
DECLARE_META_BIND(2, cheat_index_minus, RARCH_CHEAT_INDEX_MINUS, "Cheat index -"),
|
||||
DECLARE_META_BIND(2, cheat_toggle, RARCH_CHEAT_TOGGLE, "Cheat toggle"),
|
||||
DECLARE_META_BIND(2, screenshot, RARCH_SCREENSHOT, "Take screenshot"),
|
||||
DECLARE_META_BIND(2, dsp_config, RARCH_DSP_CONFIG, "DSP config"),
|
||||
DECLARE_META_BIND(2, audio_mute, RARCH_MUTE, "Audio mute toggle"),
|
||||
DECLARE_META_BIND(2, netplay_flip_players, RARCH_NETPLAY_FLIP, "Netplay flip players"),
|
||||
DECLARE_META_BIND(2, slowmotion, RARCH_SLOWMOTION, "Slow motion"),
|
||||
DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, "Enable hotkeys"),
|
||||
DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, "Volume +"),
|
||||
DECLARE_META_BIND(2, volume_down, RARCH_VOLUME_DOWN, "Volume -"),
|
||||
DECLARE_META_BIND(2, overlay_next, RARCH_OVERLAY_NEXT, "Overlay next"),
|
||||
DECLARE_META_BIND(2, disk_eject_toggle, RARCH_DISK_EJECT_TOGGLE, "Disk eject toggle"),
|
||||
DECLARE_META_BIND(2, disk_next, RARCH_DISK_NEXT, "Disk next"),
|
||||
DECLARE_META_BIND(2, grab_mouse_toggle, RARCH_GRAB_MOUSE_TOGGLE, "Grab mouse toggle"),
|
||||
#ifdef HAVE_RGUI
|
||||
DECLARE_META_BIND(menu_toggle, RARCH_MENU_TOGGLE, "RGUI menu toggle"),
|
||||
DECLARE_META_BIND(1, menu_toggle, RARCH_MENU_TOGGLE, "RGUI menu toggle"),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,13 @@ unsigned input_translate_rk_to_keysym(enum retro_key key);
|
||||
struct input_bind_map
|
||||
{
|
||||
bool valid;
|
||||
bool meta; // Meta binds get input as prefix, not input_playerN"
|
||||
|
||||
// Meta binds get input as prefix, not input_playerN".
|
||||
// 0 = libretro related.
|
||||
// 1 = Common hotkey.
|
||||
// 2 = Uncommon/obscure hotkey.
|
||||
unsigned meta;
|
||||
|
||||
const char *base;
|
||||
const char *desc;
|
||||
unsigned retro_key;
|
||||
|
@ -39,14 +39,14 @@ static int g_timeout = 0;
|
||||
static char *g_in_path = NULL;
|
||||
static char *g_out_path = NULL;
|
||||
static char *g_auto_path = NULL;
|
||||
static bool g_use_misc = false;
|
||||
static int g_meta_level = 0;
|
||||
|
||||
static void print_help(void)
|
||||
{
|
||||
puts("==================");
|
||||
puts("retroarch-joyconfig");
|
||||
puts("==================");
|
||||
puts("Usage: retroarch-joyconfig [ -p/--player <1-8> | -j/--joypad <num> | -i/--input <file> | -o/--output <file> | -h/--help ]");
|
||||
puts("=====================");
|
||||
puts(" retroarch-joyconfig");
|
||||
puts("=====================");
|
||||
puts("Usage: retroarch-joyconfig [ options ... ]");
|
||||
puts("");
|
||||
puts("-p/--player: Which player to configure for (1 up to and including 8).");
|
||||
puts("-j/--joypad: Which joypad to use when configuring (first joypad is 0).");
|
||||
@ -54,7 +54,9 @@ static void print_help(void)
|
||||
puts("\tIf not selected, an empty config will be used as a base.");
|
||||
puts("-o/--output: Output file to write to. If not selected, config file will be dumped to stdout.");
|
||||
puts("-a/--autoconfig: Outputs an autoconfig file for joypad which was configured.");
|
||||
puts("-m/--misc: Also configure various keybinds that are not directly libretro related. These configurations are for player 1 only.");
|
||||
puts("-M/--allmisc: Also configure various keybinds that are not directly libretro related.");
|
||||
puts("\tThese configurations are for player 1 only.");
|
||||
puts("-m/--misc: Same as --allmisc, but exposes a smaller subset of misc binds which are deemed most useful for regular use.");
|
||||
puts("-t/--timeout: Adds a timeout of N seconds to each bind. If timed out, the bind will not be used.");
|
||||
puts("-h/--help: This help.");
|
||||
}
|
||||
@ -157,12 +159,15 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||
fprintf(stderr, "Configuring binds for player #%d on joypad #%d.\n\n",
|
||||
player + 1, joypad);
|
||||
|
||||
for (unsigned i = 0, timeout_cnt = 0; input_config_bind_map[i].valid &&
|
||||
(g_use_misc || !input_config_bind_map[i].meta); i++, timeout_cnt = 0)
|
||||
for (unsigned i = 0, timeout_cnt = 0; input_config_bind_map[i].valid; i++, timeout_cnt = 0)
|
||||
{
|
||||
if (i == RARCH_TURBO_ENABLE)
|
||||
continue;
|
||||
|
||||
unsigned meta_level = input_config_bind_map[i].meta;
|
||||
if (meta_level > g_meta_level)
|
||||
continue;
|
||||
|
||||
fprintf(stderr, "%s\n", input_config_bind_map[i].desc);
|
||||
|
||||
unsigned player_index = input_config_bind_map[i].meta ? 0 : player;
|
||||
@ -308,7 +313,7 @@ out:
|
||||
|
||||
static void parse_input(int argc, char *argv[])
|
||||
{
|
||||
char optstring[] = "i:o:a:p:j:t:hm";
|
||||
char optstring[] = "i:o:a:p:j:t:hmM";
|
||||
struct option opts[] = {
|
||||
{ "input", 1, NULL, 'i' },
|
||||
{ "output", 1, NULL, 'o' },
|
||||
@ -317,6 +322,7 @@ static void parse_input(int argc, char *argv[])
|
||||
{ "joypad", 1, NULL, 'j' },
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "misc", 0, NULL, 'm' },
|
||||
{ "allmisc", 0, NULL, 'M' },
|
||||
{ "timeout", 1, NULL, 't' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
@ -351,7 +357,11 @@ static void parse_input(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
g_use_misc = true;
|
||||
g_meta_level = 1;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
g_meta_level = 2;
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
|
Loading…
x
Reference in New Issue
Block a user