mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
add hotkey to toggle netplay hosting
This commit is contained in:
parent
4bb81bbb1b
commit
19ced73596
63
command.c
63
command.c
@ -224,6 +224,7 @@ static const struct cmd_map map[] = {
|
||||
{ "OSK", RARCH_OSK },
|
||||
{ "FPS_TOGGLE", RARCH_FPS_TOGGLE },
|
||||
{ "SEND_DEBUG_INFO", RARCH_SEND_DEBUG_INFO },
|
||||
{ "NETPLAY_HOST_TOGGLE", RARCH_NETPLAY_HOST_TOGGLE },
|
||||
{ "NETPLAY_GAME_WATCH", RARCH_NETPLAY_GAME_WATCH },
|
||||
{ "VOLUME_UP", RARCH_VOLUME_UP },
|
||||
{ "VOLUME_DOWN", RARCH_VOLUME_DOWN },
|
||||
@ -2113,6 +2114,24 @@ TODO: Add a setting for these tweaks */
|
||||
break;
|
||||
case CMD_EVENT_SEND_DEBUG_INFO:
|
||||
rarch_send_debug_info();
|
||||
break;
|
||||
case CMD_EVENT_NETPLAY_HOST_TOGGLE:
|
||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL))
|
||||
{
|
||||
command_event(CMD_EVENT_NETPLAY_DISCONNECT, NULL);
|
||||
}
|
||||
else if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) &&
|
||||
!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) &&
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL))
|
||||
{
|
||||
command_event(CMD_EVENT_NETPLAY_DISCONNECT, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
command_event(CMD_EVENT_NETPLAY_ENABLE_HOST, NULL);
|
||||
}
|
||||
|
||||
break;
|
||||
case CMD_EVENT_FPS_TOGGLE:
|
||||
{
|
||||
@ -2672,6 +2691,50 @@ TODO: Add a setting for these tweaks */
|
||||
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
||||
break;
|
||||
case CMD_EVENT_NETPLAY_ENABLE_HOST:
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
bool contentless = false;
|
||||
bool is_inited = false;
|
||||
|
||||
content_get_status(&contentless, &is_inited);
|
||||
|
||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL);
|
||||
|
||||
/* If we haven't yet started, this will load on its own */
|
||||
if (!is_inited)
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED),
|
||||
1, 480, true,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Enable Netplay itself */
|
||||
if (!command_event(CMD_EVENT_NETPLAY_INIT, NULL))
|
||||
return false;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case CMD_EVENT_NETPLAY_DISCONNECT:
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISCONNECT, NULL);
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL);
|
||||
|
||||
/* Re-enable rewind if it was enabled
|
||||
TODO: Add a setting for these tweaks */
|
||||
if (settings->bools.rewind_enable)
|
||||
command_event(CMD_EVENT_REWIND_INIT, NULL);
|
||||
if (settings->uints.autosave_interval != 0)
|
||||
command_event(CMD_EVENT_AUTOSAVE_INIT, NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
#else
|
||||
case CMD_EVENT_NETPLAY_DEINIT:
|
||||
case CMD_EVENT_NETWORK_DEINIT:
|
||||
|
@ -87,6 +87,8 @@ enum event_command
|
||||
CMD_EVENT_FPS_TOGGLE,
|
||||
/* Gathers diagnostic info about the system and RetroArch configuration, then sends it to our servers. */
|
||||
CMD_EVENT_SEND_DEBUG_INFO,
|
||||
/* Toggles netplay hosting. */
|
||||
CMD_EVENT_NETPLAY_HOST_TOGGLE,
|
||||
/* Initializes overlay. */
|
||||
CMD_EVENT_OVERLAY_INIT,
|
||||
/* Deinitializes overlay. */
|
||||
@ -190,6 +192,10 @@ enum event_command
|
||||
CMD_EVENT_NETPLAY_DEINIT,
|
||||
/* Switch between netplay gaming and watching. */
|
||||
CMD_EVENT_NETPLAY_GAME_WATCH,
|
||||
/* Start hosting netplay. */
|
||||
CMD_EVENT_NETPLAY_ENABLE_HOST,
|
||||
/* Disconnect from the netplay host. */
|
||||
CMD_EVENT_NETPLAY_DISCONNECT,
|
||||
/* Initializes BSV movie. */
|
||||
CMD_EVENT_BSV_MOVIE_INIT,
|
||||
/* Deinitializes BSV movie. */
|
||||
|
@ -89,6 +89,7 @@ static const struct retro_keybind retro_keybinds_1[] = {
|
||||
{ true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
@ -169,6 +170,7 @@ static const struct retro_keybind retro_keybinds_1[] = {
|
||||
{ true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE, RETROK_F3, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO, RETROK_F10, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
{ true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, NO_BTN, 0, AXIS_NONE },
|
||||
|
@ -99,6 +99,7 @@ enum
|
||||
RARCH_OSK,
|
||||
RARCH_FPS_TOGGLE,
|
||||
RARCH_SEND_DEBUG_INFO,
|
||||
RARCH_NETPLAY_HOST_TOGGLE,
|
||||
RARCH_NETPLAY_GAME_WATCH,
|
||||
RARCH_ENABLE_HOTKEY,
|
||||
RARCH_VOLUME_UP,
|
||||
|
@ -354,6 +354,7 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = {
|
||||
DECLARE_META_BIND(2, osk_toggle, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK),
|
||||
DECLARE_META_BIND(2, fps_toggle, RARCH_FPS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE),
|
||||
DECLARE_META_BIND(2, send_debug_info, RARCH_SEND_DEBUG_INFO, MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO),
|
||||
DECLARE_META_BIND(2, netplay_host_toggle, RARCH_NETPLAY_HOST_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE),
|
||||
DECLARE_META_BIND(2, netplay_game_watch, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH),
|
||||
DECLARE_META_BIND(2, enable_hotkey, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY),
|
||||
DECLARE_META_BIND(2, volume_up, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP),
|
||||
@ -1020,12 +1021,13 @@ void input_menu_keys_pressed(void *data, input_bits_t *p_new_state)
|
||||
|
||||
if (!menu_input_dialog_get_display_kb())
|
||||
{
|
||||
unsigned ids[17][2];
|
||||
unsigned ids[18][2];
|
||||
const struct retro_keybind *quitkey = &input_config_binds[0][RARCH_QUIT_KEY];
|
||||
const struct retro_keybind *fskey = &input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY];
|
||||
const struct retro_keybind *companionkey = &input_config_binds[0][RARCH_UI_COMPANION_TOGGLE];
|
||||
const struct retro_keybind *fpskey = &input_config_binds[0][RARCH_FPS_TOGGLE];
|
||||
const struct retro_keybind *debugkey = &input_config_binds[0][RARCH_SEND_DEBUG_INFO];
|
||||
const struct retro_keybind *netplaykey = &input_config_binds[0][RARCH_NETPLAY_HOST_TOGGLE];
|
||||
|
||||
ids[0][0] = RETROK_SPACE;
|
||||
ids[0][1] = RETRO_DEVICE_ID_JOYPAD_START;
|
||||
@ -1061,6 +1063,8 @@ void input_menu_keys_pressed(void *data, input_bits_t *p_new_state)
|
||||
ids[15][1] = RARCH_FPS_TOGGLE;
|
||||
ids[16][0] = debugkey->key;
|
||||
ids[16][1] = RARCH_SEND_DEBUG_INFO;
|
||||
ids[17][0] = netplaykey->key;
|
||||
ids[17][1] = RARCH_NETPLAY_HOST_TOGGLE;
|
||||
|
||||
if (settings->bools.input_menu_swap_ok_cancel_buttons)
|
||||
{
|
||||
@ -1068,7 +1072,7 @@ void input_menu_keys_pressed(void *data, input_bits_t *p_new_state)
|
||||
ids[12][1] = RETRO_DEVICE_ID_JOYPAD_B;
|
||||
}
|
||||
|
||||
for (i = 0; i < 17; i++)
|
||||
for (i = 0; i < 18; i++)
|
||||
{
|
||||
if (current_input->input_state(current_input_data,
|
||||
joypad_info, binds, 0,
|
||||
|
@ -112,6 +112,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
|
||||
snprintf(s, len,
|
||||
"Sends diagnostic info about your device and RetroArch configuration to our servers for analysis.");
|
||||
break;
|
||||
case RARCH_NETPLAY_HOST_TOGGLE:
|
||||
snprintf(s, len,
|
||||
"Toggles netplay hosting on/off.");
|
||||
break;
|
||||
case RARCH_NETPLAY_GAME_WATCH:
|
||||
snprintf(s, len,
|
||||
"Netplay toggle play/spectate mode.");
|
||||
|
@ -1281,6 +1281,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE,
|
||||
"FPS toggle"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE,
|
||||
"Netplay hosting toggle"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,
|
||||
"Fullscreen toggle"
|
||||
|
@ -5162,29 +5162,7 @@ static int action_ok_netplay_enable_host(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
#ifdef HAVE_NETWORKING
|
||||
bool contentless = false;
|
||||
bool is_inited = false;
|
||||
file_list_t *list = menu_entries_get_selection_buf_ptr(0);
|
||||
|
||||
content_get_status(&contentless, &is_inited);
|
||||
|
||||
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||
generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT);
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL);
|
||||
|
||||
netplay_refresh_rooms_menu(list);
|
||||
/* If we haven't yet started, this will load on its own */
|
||||
if (!is_inited)
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED),
|
||||
1, 480, true,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Enable Netplay itself */
|
||||
if (command_event(CMD_EVENT_NETPLAY_INIT, NULL))
|
||||
if (command_event(CMD_EVENT_NETPLAY_ENABLE_HOST, NULL))
|
||||
return generic_action_ok_command(CMD_EVENT_RESUME);
|
||||
#endif
|
||||
return -1;
|
||||
@ -5266,17 +5244,8 @@ static int action_ok_netplay_disconnect(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
#ifdef HAVE_NETWORKING
|
||||
settings_t *settings = config_get_ptr();
|
||||
generic_action_ok_command(CMD_EVENT_NETPLAY_DISCONNECT);
|
||||
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISCONNECT, NULL);
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL);
|
||||
|
||||
/* Re-enable rewind if it was enabled
|
||||
TODO: Add a setting for these tweaks */
|
||||
if (settings->bools.rewind_enable)
|
||||
generic_action_ok_command(CMD_EVENT_REWIND_INIT);
|
||||
if (settings->uints.autosave_interval != 0)
|
||||
generic_action_ok_command(CMD_EVENT_AUTOSAVE_INIT);
|
||||
return generic_action_ok_command(CMD_EVENT_RESUME);
|
||||
|
||||
#else
|
||||
|
@ -718,6 +718,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_OSK,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_FPS_TOGGLE,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_SEND_DEBUG_INFO,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_HOST_TOGGLE,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY,
|
||||
MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP,
|
||||
|
12
retroarch.c
12
retroarch.c
@ -3830,6 +3830,18 @@ static enum runloop_state runloop_check_state(
|
||||
old_pressed = pressed;
|
||||
}
|
||||
|
||||
/* Check if we have pressed the netplay host toggle button */
|
||||
{
|
||||
static bool old_pressed = false;
|
||||
bool pressed = BIT256_GET(
|
||||
current_input, RARCH_NETPLAY_HOST_TOGGLE);
|
||||
|
||||
if (pressed && !old_pressed)
|
||||
command_event(CMD_EVENT_NETPLAY_HOST_TOGGLE, NULL);
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
|
||||
if (menu_driver_is_alive())
|
||||
{
|
||||
if (!settings->bools.menu_throttle_framerate && !fastforward_ratio)
|
||||
|
Loading…
x
Reference in New Issue
Block a user