mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Refactor libretro device type handling.
Show devices in RGUI.
This commit is contained in:
parent
9eda39417f
commit
9e2392051d
@ -36,6 +36,7 @@ int main(int argc, char *argv[])
|
||||
return rarch_main(argc, argv);
|
||||
#else
|
||||
|
||||
rarch_main_clear_state();
|
||||
rarch_init_msg_queue();
|
||||
|
||||
int init_ret;
|
||||
|
@ -138,6 +138,7 @@ typedef enum
|
||||
RGUI_SETTINGS_QUIT_RARCH,
|
||||
|
||||
RGUI_SETTINGS_BIND_DEVICE,
|
||||
RGUI_SETTINGS_BIND_DEVICE_TYPE,
|
||||
RGUI_SETTINGS_BIND_DPAD_EMULATION,
|
||||
RGUI_SETTINGS_BIND_UP,
|
||||
RGUI_SETTINGS_BIND_DOWN,
|
||||
|
@ -584,6 +584,25 @@ static void render_text(rgui_handle_t *rgui)
|
||||
strlcpy(type_str, "Disabled", sizeof(type_str));
|
||||
break;
|
||||
}
|
||||
case RGUI_SETTINGS_BIND_DEVICE_TYPE:
|
||||
{
|
||||
const char *name;
|
||||
switch (g_extern.libretro_device[port])
|
||||
{
|
||||
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_JOYPAD_MULTITAP: name = "Multitap"; break;
|
||||
case RETRO_DEVICE_MOUSE: name = "Mouse"; break;
|
||||
case RETRO_DEVICE_LIGHTGUN_JUSTIFIER: name = "Justifier"; break;
|
||||
case RETRO_DEVICE_LIGHTGUN_JUSTIFIERS: name = "Justifiers"; break;
|
||||
case RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE: name = "SuperScope"; break;
|
||||
default: name = "Unknown"; break;
|
||||
}
|
||||
|
||||
strlcpy(type_str, name, sizeof(type_str));
|
||||
break;
|
||||
}
|
||||
case RGUI_SETTINGS_BIND_DPAD_EMULATION:
|
||||
switch (g_settings.input.dpad_emulation[port])
|
||||
{
|
||||
@ -1427,6 +1446,7 @@ static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
|
||||
{
|
||||
rgui_list_clear(rgui->selection_buf);
|
||||
rgui_list_push(rgui->selection_buf, "Device", RGUI_SETTINGS_BIND_DEVICE, 0);
|
||||
rgui_list_push(rgui->selection_buf, "Device Type", RGUI_SETTINGS_BIND_DEVICE_TYPE, 0);
|
||||
|
||||
if (driver.input && driver.input->set_keybinds)
|
||||
{
|
||||
|
@ -310,13 +310,7 @@ struct global
|
||||
bool video_active;
|
||||
bool force_fullscreen;
|
||||
|
||||
bool disconnect_device[MAX_PLAYERS];
|
||||
bool has_mouse[MAX_PLAYERS];
|
||||
bool has_dualanalog[MAX_PLAYERS];
|
||||
bool has_scope;
|
||||
bool has_justifier;
|
||||
bool has_justifiers;
|
||||
bool has_multitap;
|
||||
unsigned libretro_device[MAX_PLAYERS];
|
||||
|
||||
bool rom_file_temporary;
|
||||
char last_rom[PATH_MAX];
|
||||
|
88
retroarch.c
88
retroarch.c
@ -905,15 +905,15 @@ static void parse_input(int argc, char *argv[])
|
||||
exit(0);
|
||||
|
||||
case '4':
|
||||
g_extern.has_multitap = true;
|
||||
g_extern.libretro_device[1] = RETRO_DEVICE_JOYPAD_MULTITAP;
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
g_extern.has_justifier = true;
|
||||
g_extern.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_JUSTIFIER;
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
g_extern.has_justifiers = true;
|
||||
g_extern.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_JUSTIFIERS;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
@ -924,7 +924,7 @@ static void parse_input(int argc, char *argv[])
|
||||
print_help();
|
||||
rarch_fail(1, "parse_input()");
|
||||
}
|
||||
g_extern.has_dualanalog[port - 1] = true;
|
||||
g_extern.libretro_device[port - 1] = RETRO_DEVICE_ANALOG;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@ -978,7 +978,7 @@ static void parse_input(int argc, char *argv[])
|
||||
print_help();
|
||||
rarch_fail(1, "parse_input()");
|
||||
}
|
||||
g_extern.has_mouse[port - 1] = true;
|
||||
g_extern.libretro_device[port - 1] = RETRO_DEVICE_MOUSE;
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
@ -989,11 +989,11 @@ static void parse_input(int argc, char *argv[])
|
||||
print_help();
|
||||
rarch_fail(1, "parse_input()");
|
||||
}
|
||||
g_extern.disconnect_device[port - 1] = true;
|
||||
g_extern.libretro_device[port - 1] = RETRO_DEVICE_NONE;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
g_extern.has_scope = true;
|
||||
g_extern.libretro_device[1] = RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
@ -1190,42 +1190,47 @@ static void init_controllers(void)
|
||||
{
|
||||
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
if (g_extern.disconnect_device[i])
|
||||
{
|
||||
RARCH_LOG("Disconnecting device from port %u.\n", i + 1);
|
||||
pretro_set_controller_port_device(i, RETRO_DEVICE_NONE);
|
||||
}
|
||||
else if (g_extern.has_dualanalog[i])
|
||||
{
|
||||
RARCH_LOG("Connecting dualanalog to port %u.\n", i + 1);
|
||||
pretro_set_controller_port_device(i, RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
else if (g_extern.has_mouse[i])
|
||||
{
|
||||
RARCH_LOG("Connecting mouse to port %u.\n", i + 1);
|
||||
pretro_set_controller_port_device(i, RETRO_DEVICE_MOUSE);
|
||||
}
|
||||
}
|
||||
unsigned device = g_extern.libretro_device[i];
|
||||
|
||||
if (g_extern.has_justifier)
|
||||
// This is default, don't bother.
|
||||
if (device == RETRO_DEVICE_JOYPAD)
|
||||
continue;
|
||||
|
||||
pretro_set_controller_port_device(i, device);
|
||||
|
||||
switch (device)
|
||||
{
|
||||
RARCH_LOG("Connecting Justifier to port 2.\n");
|
||||
pretro_set_controller_port_device(1, RETRO_DEVICE_LIGHTGUN_JUSTIFIER);
|
||||
case RETRO_DEVICE_NONE:
|
||||
RARCH_LOG("Disconnecting device from port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
RARCH_LOG("Connecting dualanalog to port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
RARCH_LOG("Connecting mouse to port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_LIGHTGUN_JUSTIFIER:
|
||||
RARCH_LOG("Connecting Justifier to port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_LIGHTGUN_JUSTIFIERS:
|
||||
RARCH_LOG("Connecting Justifiers to port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_JOYPAD_MULTITAP:
|
||||
RARCH_LOG("Connecting Multitap to port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
case RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE:
|
||||
RARCH_LOG("Connecting scope to port %u.\n", i + 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (g_extern.has_justifiers)
|
||||
{
|
||||
RARCH_LOG("Connecting Justifiers to port 2.\n");
|
||||
pretro_set_controller_port_device(1, RETRO_DEVICE_LIGHTGUN_JUSTIFIERS);
|
||||
}
|
||||
else if (g_extern.has_multitap)
|
||||
{
|
||||
RARCH_LOG("Connecting Multitap to port 2.\n");
|
||||
pretro_set_controller_port_device(1, RETRO_DEVICE_JOYPAD_MULTITAP);
|
||||
}
|
||||
else if (g_extern.has_scope)
|
||||
{
|
||||
RARCH_LOG("Connecting scope to port 2.\n");
|
||||
pretro_set_controller_port_device(1, RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2744,6 +2749,9 @@ static void init_state(void)
|
||||
g_extern.video_active = true;
|
||||
g_extern.audio_active = true;
|
||||
g_extern.game_type = RARCH_CART_NORMAL;
|
||||
|
||||
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||
g_extern.libretro_device[i] = RETRO_DEVICE_JOYPAD;
|
||||
}
|
||||
|
||||
void rarch_main_clear_state(void)
|
||||
|
Loading…
Reference in New Issue
Block a user