2014-10-05 01:31:48 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 04:06:50 +01:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2015-01-07 17:46:50 +01:00
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
|
|
|
* Copyright (C) 2014-2015 - Jay McCarthy
|
2014-10-05 01:31:48 +02:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-11-29 00:19:01 +01:00
|
|
|
#include <stdarg.h>
|
2015-11-23 21:58:39 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2016-09-08 06:07:43 +02:00
|
|
|
#include <compat/strl.h>
|
2015-03-15 04:30:46 +01:00
|
|
|
#include <retro_inline.h>
|
2015-11-29 00:19:01 +01:00
|
|
|
#include <retro_assert.h>
|
2016-09-08 06:07:43 +02:00
|
|
|
#include <file/file_path.h>
|
2015-11-29 00:19:01 +01:00
|
|
|
#include <queues/message_queue.h>
|
2016-02-09 18:13:47 +01:00
|
|
|
#include <queues/task_queue.h>
|
2015-12-26 07:07:01 +01:00
|
|
|
#include <string/stdstring.h>
|
2016-05-10 20:31:27 +02:00
|
|
|
#include <features/features_cpu.h>
|
2015-06-13 19:12:10 +02:00
|
|
|
|
2016-09-08 06:07:43 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
#include <rthreads/rthreads.h>
|
|
|
|
#endif
|
2015-06-14 18:46:00 +02:00
|
|
|
|
2015-11-11 21:10:13 +01:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2015-10-09 13:29:57 -03:00
|
|
|
#include "cheevos.h"
|
2015-11-11 21:10:13 +01:00
|
|
|
#endif
|
2016-09-08 06:07:43 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "menu/menu_display.h"
|
|
|
|
#include "menu/menu_driver.h"
|
2016-09-16 16:39:30 +02:00
|
|
|
#include "menu/menu_event.h"
|
2016-09-15 15:57:25 +02:00
|
|
|
#include "menu/widgets/menu_dialog.h"
|
2016-09-08 06:07:43 +02:00
|
|
|
#endif
|
|
|
|
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-09-08 06:07:43 +02:00
|
|
|
#include "network/netplay/netplay.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_HTTPSERVER) && defined(HAVE_ZLIB)
|
2016-09-12 17:21:00 +02:00
|
|
|
#include "network/httpserver/httpserver.h"
|
2016-09-08 06:07:43 +02:00
|
|
|
#endif
|
|
|
|
|
2015-11-30 19:23:13 +01:00
|
|
|
#include "autosave.h"
|
2015-12-11 13:56:00 +01:00
|
|
|
#include "core_info.h"
|
2015-06-13 19:12:10 +02:00
|
|
|
#include "configuration.h"
|
2016-09-11 16:31:23 +02:00
|
|
|
#include "driver.h"
|
2015-12-01 01:47:26 +01:00
|
|
|
#include "movie.h"
|
2016-09-17 14:49:35 +02:00
|
|
|
#include "dirs.h"
|
2016-09-17 12:35:29 +02:00
|
|
|
#include "paths.h"
|
2015-01-09 17:40:47 +01:00
|
|
|
#include "retroarch.h"
|
2015-01-09 18:40:33 +01:00
|
|
|
#include "runloop.h"
|
2016-06-20 05:29:53 +02:00
|
|
|
#include "file_path_special.h"
|
2016-05-10 01:25:47 +02:00
|
|
|
#include "managers/core_option_manager.h"
|
2016-05-09 18:20:52 +02:00
|
|
|
#include "managers/cheat_manager.h"
|
|
|
|
#include "managers/state_manager.h"
|
2016-03-20 17:28:24 +01:00
|
|
|
#include "list_special.h"
|
2015-11-23 19:40:09 +01:00
|
|
|
#include "audio/audio_driver.h"
|
2015-12-05 15:55:26 +01:00
|
|
|
#include "camera/camera_driver.h"
|
2015-12-05 16:12:29 +01:00
|
|
|
#include "record/record_driver.h"
|
|
|
|
#include "input/input_driver.h"
|
|
|
|
#include "ui/ui_companion_driver.h"
|
2016-05-08 05:29:10 +02:00
|
|
|
#include "core.h"
|
2015-06-13 19:12:10 +02:00
|
|
|
|
2015-07-01 02:00:39 +02:00
|
|
|
#include "msg_hash.h"
|
|
|
|
|
2015-11-28 16:13:16 +01:00
|
|
|
#include "input/input_keyboard.h"
|
2016-05-16 13:43:14 +02:00
|
|
|
#include "tasks/tasks_internal.h"
|
2015-11-23 12:03:38 +01:00
|
|
|
#include "verbosity.h"
|
|
|
|
|
2016-09-06 08:38:26 +02:00
|
|
|
#ifdef HAVE_ZLIB
|
|
|
|
#define DEFAULT_EXT "zip"
|
|
|
|
#else
|
|
|
|
#define DEFAULT_EXT ""
|
|
|
|
#endif
|
|
|
|
|
2016-09-05 11:35:27 -04:00
|
|
|
#define runloop_cmd_triggered(cmd, id) BIT64_GET(cmd->state[2].state, id)
|
2015-12-26 11:10:13 +01:00
|
|
|
|
2016-06-25 09:04:00 +02:00
|
|
|
#define runloop_cmd_press(cmd, id) BIT64_GET(cmd->state[0].state, id)
|
|
|
|
#define runloop_cmd_pressed(cmd, id) BIT64_GET(cmd->state[1].state, id)
|
2015-12-26 11:10:13 +01:00
|
|
|
#ifdef HAVE_MENU
|
2016-06-25 09:04:00 +02:00
|
|
|
#define runloop_cmd_menu_press(cmd) (BIT64_GET(cmd->state[2].state, RARCH_MENU_TOGGLE) || \
|
2015-12-26 11:10:13 +01:00
|
|
|
runloop_cmd_get_state_menu_toggle_button_combo( \
|
|
|
|
settings, cmd->state[0], \
|
|
|
|
cmd->state[1], cmd->state[2]))
|
|
|
|
#endif
|
|
|
|
|
2015-12-04 13:09:16 +01:00
|
|
|
typedef struct event_cmd_state
|
|
|
|
{
|
2015-12-07 11:23:32 +01:00
|
|
|
retro_input_t state[3];
|
2015-12-04 13:09:16 +01:00
|
|
|
} event_cmd_state_t;
|
|
|
|
|
2016-09-06 08:38:26 +02:00
|
|
|
static rarch_system_info_t runloop_system;
|
2016-05-08 01:41:32 +02:00
|
|
|
static struct retro_frame_time_callback runloop_frame_time;
|
2016-09-16 12:49:26 +02:00
|
|
|
static retro_keyboard_event_t runloop_key_event = NULL;
|
|
|
|
static retro_keyboard_event_t runloop_frontend_key_event = NULL;
|
|
|
|
static core_option_manager_t *runloop_core_options = NULL;
|
2016-05-08 01:41:32 +02:00
|
|
|
#ifdef HAVE_THREADS
|
2016-09-16 12:49:26 +02:00
|
|
|
static slock_t *_runloop_msg_queue_lock = NULL;
|
2016-05-08 01:41:32 +02:00
|
|
|
#endif
|
2016-09-16 12:49:26 +02:00
|
|
|
static msg_queue_t *runloop_msg_queue = NULL;
|
|
|
|
static unsigned runloop_pending_windowed_scale = 0;
|
|
|
|
static retro_usec_t runloop_frame_time_last = 0;
|
|
|
|
static unsigned runloop_max_frames = false;
|
|
|
|
static bool runloop_force_nonblock = false;
|
|
|
|
static bool runloop_frame_time_last_enable = false;
|
|
|
|
static bool runloop_set_frame_limit = false;
|
|
|
|
static bool runloop_paused = false;
|
|
|
|
static bool runloop_idle = false;
|
|
|
|
static bool runloop_exec = false;
|
|
|
|
static bool runloop_quit_confirm = false;
|
|
|
|
static bool runloop_slowmotion = false;
|
|
|
|
static bool runloop_shutdown_initiated = false;
|
|
|
|
static bool runloop_core_shutdown_initiated = false;
|
|
|
|
static bool runloop_perfcnt_enable = false;
|
|
|
|
static bool runloop_overrides_active = false;
|
|
|
|
static bool runloop_game_options_active = false;
|
2016-03-04 17:54:54 +01:00
|
|
|
|
2015-12-04 07:18:39 +01:00
|
|
|
global_t *global_get_ptr(void)
|
|
|
|
{
|
|
|
|
static struct global g_extern;
|
|
|
|
return &g_extern;
|
|
|
|
}
|
|
|
|
|
2016-05-08 06:09:39 +02:00
|
|
|
static void runloop_msg_queue_lock(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_lock(_runloop_msg_queue_lock);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void runloop_msg_queue_unlock(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_unlock(_runloop_msg_queue_lock);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-10 01:41:58 +02:00
|
|
|
static bool runloop_msg_queue_push_internal(runloop_ctx_msg_info_t *msg_info)
|
|
|
|
{
|
|
|
|
if (!msg_info || !runloop_msg_queue)
|
|
|
|
return false;
|
|
|
|
msg_queue_push(runloop_msg_queue, msg_info->msg,
|
|
|
|
msg_info->prio, msg_info->duration);
|
|
|
|
|
|
|
|
if (ui_companion_is_on_foreground())
|
|
|
|
{
|
|
|
|
const ui_companion_driver_t *ui = ui_companion_get_ptr();
|
|
|
|
if (ui->msg_queue_push)
|
|
|
|
ui->msg_queue_push(msg_info->msg,
|
|
|
|
msg_info->prio, msg_info->duration, msg_info->flush);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-26 05:44:21 +01:00
|
|
|
void runloop_msg_queue_push(const char *msg,
|
|
|
|
unsigned prio, unsigned duration,
|
2015-11-29 00:19:01 +01:00
|
|
|
bool flush)
|
|
|
|
{
|
2016-02-03 17:56:40 +01:00
|
|
|
runloop_ctx_msg_info_t msg_info;
|
2015-11-30 00:13:51 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-09-29 12:11:00 +02:00
|
|
|
|
|
|
|
if (!settings || !settings->video.font_enable)
|
2015-11-29 00:19:01 +01:00
|
|
|
return;
|
|
|
|
|
2016-05-08 06:09:39 +02:00
|
|
|
runloop_msg_queue_lock();
|
2015-11-29 00:19:01 +01:00
|
|
|
|
|
|
|
if (flush)
|
2016-02-03 17:50:53 +01:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_CLEAR, NULL);
|
2015-11-29 00:19:01 +01:00
|
|
|
|
2016-02-03 17:56:40 +01:00
|
|
|
msg_info.msg = msg;
|
|
|
|
msg_info.prio = prio;
|
|
|
|
msg_info.duration = duration;
|
|
|
|
msg_info.flush = flush;
|
2015-11-29 00:19:01 +01:00
|
|
|
|
2016-05-10 01:41:58 +02:00
|
|
|
runloop_msg_queue_push_internal(&msg_info);
|
2016-02-03 17:50:53 +01:00
|
|
|
|
2016-05-08 06:09:39 +02:00
|
|
|
runloop_msg_queue_unlock();
|
2015-11-29 00:19:01 +01:00
|
|
|
}
|
|
|
|
|
2016-05-08 05:21:31 +02:00
|
|
|
char* runloop_msg_queue_pull(void)
|
2016-05-07 19:47:20 -05:00
|
|
|
{
|
|
|
|
runloop_ctx_msg_info_t msg_info;
|
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PULL, &msg_info);
|
|
|
|
|
|
|
|
return strdup(msg_info.msg);
|
|
|
|
}
|
|
|
|
|
2016-05-08 06:58:52 +02:00
|
|
|
/* Checks if slowmotion toggle/hold was being pressed and/or held. */
|
|
|
|
static bool runloop_check_slowmotion(bool *ptr)
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2016-09-29 12:11:00 +02:00
|
|
|
|
2016-05-08 06:58:52 +02:00
|
|
|
if (!ptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
runloop_slowmotion = *ptr;
|
|
|
|
|
|
|
|
if (!runloop_slowmotion)
|
|
|
|
return false;
|
|
|
|
|
2016-09-29 12:11:00 +02:00
|
|
|
if (settings && settings->video.black_frame_insertion)
|
2016-05-08 14:00:51 +02:00
|
|
|
video_driver_cached_frame_render();
|
2016-05-08 06:58:52 +02:00
|
|
|
|
|
|
|
if (state_manager_frame_is_reversed())
|
2016-07-19 18:34:17 +02:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 2, 30, true);
|
2016-05-08 06:58:52 +02:00
|
|
|
else
|
2016-07-19 18:34:17 +02:00
|
|
|
runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION), 2, 30, true);
|
2016-05-08 06:58:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-07 10:05:58 +01:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-07 15:36:58 +01:00
|
|
|
static bool runloop_cmd_get_state_menu_toggle_button_combo(
|
2015-12-07 10:05:58 +01:00
|
|
|
settings_t *settings,
|
|
|
|
retro_input_t input, retro_input_t old_input,
|
|
|
|
retro_input_t trigger_input)
|
|
|
|
{
|
|
|
|
switch (settings->input.menu_toggle_gamepad_combo)
|
|
|
|
{
|
2016-08-02 16:45:50 +02:00
|
|
|
case INPUT_TOGGLE_NONE:
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
2016-08-02 16:45:50 +02:00
|
|
|
case INPUT_TOGGLE_DOWN_Y_L_R:
|
2016-06-25 09:04:00 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_DOWN))
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
2016-06-25 09:04:00 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_Y))
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
2016-06-25 09:04:00 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_L))
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
2016-06-25 09:04:00 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_R))
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
|
|
|
break;
|
2016-08-02 16:45:50 +02:00
|
|
|
case INPUT_TOGGLE_L3_R3:
|
2016-06-25 09:04:00 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_L3))
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
2016-06-25 09:04:00 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_R3))
|
2015-12-07 10:05:58 +01:00
|
|
|
return false;
|
2016-06-30 19:17:06 +02:00
|
|
|
break;
|
2016-08-02 16:48:54 +02:00
|
|
|
case INPUT_TOGGLE_L1_R1_START_SELECT:
|
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_START))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_SELECT))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_L))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_R))
|
|
|
|
return false;
|
|
|
|
break;
|
2016-08-02 16:45:50 +02:00
|
|
|
case INPUT_TOGGLE_START_SELECT:
|
2016-06-29 10:46:07 +02:00
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_START))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input.state, RETRO_DEVICE_ID_JOYPAD_SELECT))
|
|
|
|
return false;
|
2015-12-07 10:05:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_set_flushing_input();
|
2015-12-07 10:05:58 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-07 03:53:36 +01:00
|
|
|
/**
|
2016-05-10 01:44:13 +02:00
|
|
|
* runloop_check_pause:
|
2015-01-07 03:53:36 +01:00
|
|
|
* @pressed : was libretro pause key pressed?
|
|
|
|
* @frameadvance_pressed : was frameadvance key pressed?
|
|
|
|
*
|
2015-10-09 13:29:57 -03:00
|
|
|
* Check if libretro pause key was pressed. If so, pause or
|
2015-01-07 03:53:36 +01:00
|
|
|
* unpause the libretro core.
|
|
|
|
*
|
|
|
|
* Returns: true if libretro pause key was toggled, otherwise false.
|
|
|
|
**/
|
2016-09-29 12:11:00 +02:00
|
|
|
static bool runloop_check_pause(
|
2015-11-27 18:56:11 +01:00
|
|
|
bool focus, bool pause_pressed,
|
|
|
|
bool frameadvance_pressed)
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
|
|
|
static bool old_focus = true;
|
2016-05-09 20:51:53 +02:00
|
|
|
enum event_command cmd = CMD_EVENT_NONE;
|
2015-12-04 07:56:53 +01:00
|
|
|
bool old_is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
|
2014-10-05 01:31:48 +02:00
|
|
|
|
|
|
|
/* FRAMEADVANCE will set us into pause mode. */
|
2015-12-04 07:56:53 +01:00
|
|
|
pause_pressed |= !old_is_paused && frameadvance_pressed;
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2015-03-21 08:27:30 +01:00
|
|
|
if (focus && pause_pressed)
|
2016-05-09 20:51:53 +02:00
|
|
|
cmd = CMD_EVENT_PAUSE_TOGGLE;
|
2014-10-05 01:31:48 +02:00
|
|
|
else if (focus && !old_focus)
|
2016-05-09 20:51:53 +02:00
|
|
|
cmd = CMD_EVENT_UNPAUSE;
|
2014-10-05 01:31:48 +02:00
|
|
|
else if (!focus && old_focus)
|
2016-05-09 20:51:53 +02:00
|
|
|
cmd = CMD_EVENT_PAUSE;
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2014-10-05 04:10:00 +02:00
|
|
|
old_focus = focus;
|
|
|
|
|
2016-05-09 20:51:53 +02:00
|
|
|
if (cmd != CMD_EVENT_NONE)
|
2016-05-09 20:20:50 +02:00
|
|
|
command_event(cmd, NULL);
|
2014-10-29 05:54:29 +01:00
|
|
|
|
2015-12-04 07:56:53 +01:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) == old_is_paused)
|
2014-10-08 16:12:00 +02:00
|
|
|
return false;
|
2014-10-29 05:54:29 +01:00
|
|
|
|
2014-10-08 16:12:00 +02:00
|
|
|
return true;
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
2015-01-07 16:29:46 +01:00
|
|
|
/**
|
2016-05-10 01:44:13 +02:00
|
|
|
* runloop_check_fast_forward_button:
|
2015-01-07 16:29:46 +01:00
|
|
|
* @fastforward_pressed : is fastforward key pressed?
|
|
|
|
* @hold_pressed : is fastforward key pressed and held?
|
|
|
|
* @old_hold_pressed : was fastforward key pressed and held the last frame?
|
|
|
|
*
|
2015-10-09 13:29:57 -03:00
|
|
|
* Checks if the fast forward key has been pressed for this frame.
|
2015-01-07 16:29:46 +01:00
|
|
|
*
|
|
|
|
**/
|
2016-05-10 01:44:13 +02:00
|
|
|
static void runloop_check_fast_forward_button(bool fastforward_pressed,
|
2014-10-05 01:31:48 +02:00
|
|
|
bool hold_pressed, bool old_hold_pressed)
|
|
|
|
{
|
2015-01-07 03:53:36 +01:00
|
|
|
/* To avoid continous switching if we hold the button down, we require
|
2015-10-09 13:29:57 -03:00
|
|
|
* that the button must go from pressed to unpressed back to pressed
|
2015-01-07 03:53:36 +01:00
|
|
|
* to be able to toggle between then.
|
|
|
|
*/
|
2014-10-05 01:31:48 +02:00
|
|
|
if (fastforward_pressed)
|
2015-11-29 17:53:11 +01:00
|
|
|
{
|
2016-05-08 23:12:04 +02:00
|
|
|
if (input_driver_is_nonblock_state())
|
|
|
|
input_driver_unset_nonblock_state();
|
2015-11-29 17:53:11 +01:00
|
|
|
else
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_set_nonblock_state();
|
2015-11-29 17:53:11 +01:00
|
|
|
}
|
2014-10-05 01:31:48 +02:00
|
|
|
else if (old_hold_pressed != hold_pressed)
|
2015-11-29 17:53:11 +01:00
|
|
|
{
|
|
|
|
if (hold_pressed)
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_set_nonblock_state();
|
2015-11-29 17:53:11 +01:00
|
|
|
else
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_unset_nonblock_state();
|
2015-11-29 17:53:11 +01:00
|
|
|
}
|
2014-10-05 05:39:50 +02:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2015-12-11 11:04:16 +01:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL);
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
2015-01-07 16:29:46 +01:00
|
|
|
/**
|
2016-05-10 01:44:13 +02:00
|
|
|
* runloop_check_stateslots:
|
2015-01-07 16:29:46 +01:00
|
|
|
* @pressed_increase : is state slot increase key pressed?
|
|
|
|
* @pressed_decrease : is state slot decrease key pressed?
|
|
|
|
*
|
2015-10-09 13:29:57 -03:00
|
|
|
* Checks if the state increase/decrease keys have been pressed
|
|
|
|
* for this frame.
|
2015-01-07 16:29:46 +01:00
|
|
|
**/
|
2016-05-10 01:44:13 +02:00
|
|
|
static void runloop_check_stateslots(settings_t *settings,
|
2015-07-12 19:06:24 +02:00
|
|
|
bool pressed_increase, bool pressed_decrease)
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
2016-06-03 04:37:10 +02:00
|
|
|
char msg[128] = {0};
|
2014-10-05 05:50:04 +02:00
|
|
|
|
2014-10-05 01:31:48 +02:00
|
|
|
/* Save state slots */
|
|
|
|
if (pressed_increase)
|
2015-03-20 19:48:23 +01:00
|
|
|
settings->state_slot++;
|
2014-10-05 05:50:04 +02:00
|
|
|
else if (pressed_decrease)
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
2015-03-20 19:48:23 +01:00
|
|
|
if (settings->state_slot > 0)
|
|
|
|
settings->state_slot--;
|
2014-10-05 01:59:15 +02:00
|
|
|
}
|
2014-10-05 05:50:04 +02:00
|
|
|
else
|
|
|
|
return;
|
2014-10-05 01:59:15 +02:00
|
|
|
|
2015-07-01 19:30:34 +02:00
|
|
|
snprintf(msg, sizeof(msg), "%s: %d",
|
|
|
|
msg_hash_to_str(MSG_STATE_SLOT),
|
2015-03-20 19:48:23 +01:00
|
|
|
settings->state_slot);
|
2014-10-05 01:59:15 +02:00
|
|
|
|
2016-07-19 18:34:17 +02:00
|
|
|
runloop_msg_queue_push(msg, 2, 180, true);
|
2014-10-05 01:59:15 +02:00
|
|
|
|
2014-10-05 05:50:04 +02:00
|
|
|
RARCH_LOG("%s\n", msg);
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
2015-12-07 14:16:34 +01:00
|
|
|
/**
|
|
|
|
* rarch_game_specific_options:
|
|
|
|
*
|
2016-09-05 11:35:27 -04:00
|
|
|
* Returns: true (1) if a game specific core
|
2016-01-26 02:24:59 +01:00
|
|
|
* options path has been found,
|
2015-12-07 14:16:34 +01:00
|
|
|
* otherwise false (0).
|
|
|
|
**/
|
|
|
|
static bool rarch_game_specific_options(char **output)
|
|
|
|
{
|
2016-06-03 04:37:10 +02:00
|
|
|
char game_path[PATH_MAX_LENGTH] = {0};
|
2016-09-05 11:35:27 -04:00
|
|
|
|
2016-07-01 06:02:57 +02:00
|
|
|
if (!retroarch_validate_game_options(game_path,
|
|
|
|
sizeof(game_path), false))
|
2016-01-26 02:24:59 +01:00
|
|
|
return false;
|
2015-12-07 14:16:34 +01:00
|
|
|
|
2016-09-18 21:57:51 +02:00
|
|
|
if (!config_file_exists(game_path))
|
2015-12-07 14:16:34 +01:00
|
|
|
return false;
|
|
|
|
|
2016-07-01 06:02:57 +02:00
|
|
|
RARCH_LOG("%s %s\n",
|
|
|
|
msg_hash_to_str(MSG_GAME_SPECIFIC_CORE_OPTIONS_FOUND_AT),
|
|
|
|
game_path);
|
2015-12-07 14:16:34 +01:00
|
|
|
*output = strdup(game_path);
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-26 15:00:29 +02:00
|
|
|
|
2016-05-15 10:14:23 +02:00
|
|
|
static bool runloop_is_focused(void)
|
|
|
|
{
|
|
|
|
settings_t *settings = config_get_ptr();
|
2016-09-25 05:00:54 +02:00
|
|
|
if (settings && settings->pause_nonactive)
|
2016-05-15 10:14:23 +02:00
|
|
|
return video_driver_is_focused();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool runloop_check_pause_state(event_cmd_state_t *cmd)
|
|
|
|
{
|
|
|
|
bool check_is_oneshot = false;
|
|
|
|
|
|
|
|
if (!cmd)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
check_is_oneshot = runloop_cmd_triggered(cmd,
|
2016-09-05 11:35:27 -04:00
|
|
|
RARCH_FRAMEADVANCE)
|
2016-05-15 10:14:23 +02:00
|
|
|
|| runloop_cmd_press(cmd, RARCH_REWIND);
|
|
|
|
|
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY))
|
|
|
|
{
|
|
|
|
command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
|
|
|
|
video_driver_cached_frame_render();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!check_is_oneshot)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool runloop_check_idle_state(event_cmd_state_t *cmd)
|
|
|
|
{
|
|
|
|
bool focused = runloop_is_focused();
|
|
|
|
|
2016-09-29 12:11:00 +02:00
|
|
|
runloop_check_pause(focused,
|
2016-05-15 10:14:23 +02:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_PAUSE_TOGGLE),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE));
|
|
|
|
|
|
|
|
if (!runloop_check_pause_state(cmd) || !focused)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-23 03:19:33 +02:00
|
|
|
static bool runloop_check_state(event_cmd_state_t *cmd)
|
2016-04-10 15:40:46 +02:00
|
|
|
{
|
|
|
|
bool tmp = false;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!cmd || runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_SCREENSHOT))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_TAKE_SCREENSHOT, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_MUTE))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_AUDIO_MUTE_TOGGLE, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_OSK))
|
|
|
|
{
|
|
|
|
if (input_keyboard_ctl(
|
|
|
|
RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
|
|
|
|
input_keyboard_ctl(
|
|
|
|
RARCH_INPUT_KEYBOARD_CTL_UNSET_LINEFEED_ENABLED, NULL);
|
|
|
|
else
|
|
|
|
input_keyboard_ctl(
|
|
|
|
RARCH_INPUT_KEYBOARD_CTL_SET_LINEFEED_ENABLED, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (runloop_cmd_press(cmd, RARCH_VOLUME_UP))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_VOLUME_UP, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
else if (runloop_cmd_press(cmd, RARCH_VOLUME_DOWN))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_VOLUME_DOWN, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-04-10 15:40:46 +02:00
|
|
|
tmp = runloop_cmd_triggered(cmd, RARCH_NETPLAY_FLIP);
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, &tmp);
|
|
|
|
tmp = runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY);
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_FULLSCREEN_TOGGLE, &tmp);
|
|
|
|
#endif
|
2016-05-15 10:14:23 +02:00
|
|
|
if (!runloop_check_idle_state(cmd))
|
2016-04-10 15:40:46 +02:00
|
|
|
return false;
|
|
|
|
|
2016-05-10 01:44:13 +02:00
|
|
|
runloop_check_fast_forward_button(
|
2016-04-10 15:40:46 +02:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_FAST_FORWARD_KEY),
|
|
|
|
runloop_cmd_press (cmd, RARCH_FAST_FORWARD_HOLD_KEY),
|
|
|
|
runloop_cmd_pressed (cmd, RARCH_FAST_FORWARD_HOLD_KEY));
|
2016-05-10 01:44:13 +02:00
|
|
|
runloop_check_stateslots(settings,
|
2016-04-10 15:40:46 +02:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_PLUS),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_MINUS)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_SAVE_STATE_KEY))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_SAVE_STATE, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
else if (runloop_cmd_triggered(cmd, RARCH_LOAD_STATE_KEY))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_LOAD_STATE, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
|
|
|
if(!settings->cheevos.hardcore_mode_enable)
|
|
|
|
#endif
|
|
|
|
state_manager_check_rewind(runloop_cmd_press(cmd, RARCH_REWIND));
|
|
|
|
|
|
|
|
tmp = runloop_cmd_press(cmd, RARCH_SLOWMOTION);
|
|
|
|
|
2016-05-08 06:58:52 +02:00
|
|
|
runloop_check_slowmotion(&tmp);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE))
|
2016-09-17 01:54:33 +02:00
|
|
|
bsv_movie_check();
|
2016-09-05 11:35:27 -04:00
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT) ||
|
2016-07-17 23:46:35 -05:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_SHADER_PREV))
|
2016-09-23 03:19:33 +02:00
|
|
|
dir_check_shader(
|
2016-07-17 23:46:35 -05:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_SHADER_PREV));
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_DISK_EJECT_TOGGLE))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_DISK_EJECT_TOGGLE, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
else if (runloop_cmd_triggered(cmd, RARCH_DISK_NEXT))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_DISK_NEXT, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
else if (runloop_cmd_triggered(cmd, RARCH_DISK_PREV))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_DISK_PREV, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_RESET))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_RESET, NULL);
|
2016-04-10 15:40:46 +02:00
|
|
|
|
|
|
|
cheat_manager_state_checks(
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_PLUS),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_MINUS),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_CHEAT_TOGGLE));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-08 06:36:52 +02:00
|
|
|
static bool runloop_is_frame_count_end(void)
|
|
|
|
{
|
2016-05-08 14:00:51 +02:00
|
|
|
uint64_t *frame_count =
|
|
|
|
video_driver_get_frame_count_ptr();
|
2016-05-08 06:36:52 +02:00
|
|
|
return runloop_max_frames && (*frame_count >= runloop_max_frames);
|
|
|
|
}
|
|
|
|
|
2015-11-30 21:42:59 +01:00
|
|
|
bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
2015-09-26 14:57:46 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
2016-05-12 09:37:21 +02:00
|
|
|
case RUNLOOP_CTL_SYSTEM_INFO_INIT:
|
2016-09-06 08:38:26 +02:00
|
|
|
core_get_system_info(&runloop_system.info);
|
|
|
|
|
|
|
|
if (!runloop_system.info.library_name)
|
|
|
|
runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN);
|
|
|
|
if (!runloop_system.info.library_version)
|
|
|
|
runloop_system.info.library_version = "v0";
|
|
|
|
|
2016-05-12 09:37:21 +02:00
|
|
|
video_driver_set_title_buf();
|
2016-09-06 08:38:26 +02:00
|
|
|
|
|
|
|
strlcpy(runloop_system.valid_extensions,
|
|
|
|
runloop_system.info.valid_extensions ?
|
|
|
|
runloop_system.info.valid_extensions : DEFAULT_EXT,
|
|
|
|
sizeof(runloop_system.valid_extensions));
|
2016-05-12 09:37:21 +02:00
|
|
|
break;
|
2015-12-09 09:37:54 +01:00
|
|
|
case RUNLOOP_CTL_GET_CORE_OPTION_SIZE:
|
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2016-05-10 01:21:55 +02:00
|
|
|
*idx = core_option_manager_size(runloop_core_options);
|
2015-12-09 09:37:54 +01:00
|
|
|
}
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-12-09 09:34:19 +01:00
|
|
|
case RUNLOOP_CTL_HAS_CORE_OPTIONS:
|
2016-04-06 02:30:20 +02:00
|
|
|
return runloop_core_options;
|
2016-05-15 10:09:41 +02:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_LIST_GET:
|
2016-04-06 02:30:20 +02:00
|
|
|
{
|
|
|
|
core_option_manager_t **coreopts = (core_option_manager_t**)data;
|
|
|
|
if (!coreopts)
|
|
|
|
return false;
|
|
|
|
*coreopts = runloop_core_options;
|
|
|
|
}
|
|
|
|
break;
|
2016-09-06 08:38:26 +02:00
|
|
|
case RUNLOOP_CTL_SYSTEM_INFO_GET:
|
|
|
|
{
|
|
|
|
rarch_system_info_t **system = (rarch_system_info_t**)data;
|
|
|
|
if (!system)
|
|
|
|
return false;
|
|
|
|
*system = &runloop_system;
|
|
|
|
}
|
|
|
|
break;
|
2016-05-12 09:37:21 +02:00
|
|
|
case RUNLOOP_CTL_SYSTEM_INFO_FREE:
|
2016-09-06 08:38:26 +02:00
|
|
|
|
|
|
|
/* No longer valid. */
|
|
|
|
if (runloop_system.subsystem.data)
|
|
|
|
free(runloop_system.subsystem.data);
|
|
|
|
runloop_system.subsystem.data = NULL;
|
|
|
|
runloop_system.subsystem.size = 0;
|
|
|
|
|
|
|
|
if (runloop_system.ports.data)
|
|
|
|
free(runloop_system.ports.data);
|
|
|
|
runloop_system.ports.data = NULL;
|
|
|
|
runloop_system.ports.size = 0;
|
|
|
|
|
|
|
|
if (runloop_system.mmaps.descriptors)
|
|
|
|
free((void *)runloop_system.mmaps.descriptors);
|
|
|
|
runloop_system.mmaps.descriptors = NULL;
|
|
|
|
runloop_system.mmaps.num_descriptors = 0;
|
2016-09-05 11:35:27 -04:00
|
|
|
|
2016-05-12 09:37:21 +02:00
|
|
|
runloop_key_event = NULL;
|
|
|
|
runloop_frontend_key_event = NULL;
|
2016-09-06 08:38:26 +02:00
|
|
|
|
2016-05-12 09:37:21 +02:00
|
|
|
audio_driver_unset_callback();
|
2016-09-06 08:38:26 +02:00
|
|
|
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
|
2016-05-12 09:37:21 +02:00
|
|
|
break;
|
2015-12-04 12:26:39 +01:00
|
|
|
case RUNLOOP_CTL_SET_FRAME_TIME_LAST:
|
2016-03-12 14:47:10 +01:00
|
|
|
runloop_frame_time_last_enable = true;
|
2015-12-04 12:26:39 +01:00
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_FRAME_TIME_LAST:
|
2016-03-12 14:47:10 +01:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_IS_FRAME_TIME_LAST, NULL))
|
|
|
|
return false;
|
|
|
|
runloop_frame_time_last = 0;
|
|
|
|
runloop_frame_time_last_enable = false;
|
2015-12-04 12:26:39 +01:00
|
|
|
break;
|
2015-12-10 21:43:44 +01:00
|
|
|
case RUNLOOP_CTL_SET_OVERRIDES_ACTIVE:
|
|
|
|
runloop_overrides_active = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE:
|
2016-09-05 11:35:27 -04:00
|
|
|
runloop_overrides_active = false;
|
2015-12-10 21:43:44 +01:00
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_OVERRIDES_ACTIVE:
|
|
|
|
return runloop_overrides_active;
|
2015-12-17 17:24:40 -05:00
|
|
|
case RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE:
|
|
|
|
runloop_game_options_active = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE:
|
|
|
|
runloop_game_options_active = false;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_GAME_OPTIONS_ACTIVE:
|
|
|
|
return runloop_game_options_active;
|
2015-12-04 12:26:39 +01:00
|
|
|
case RUNLOOP_CTL_IS_FRAME_TIME_LAST:
|
2016-03-12 14:47:10 +01:00
|
|
|
return runloop_frame_time_last_enable;
|
2015-12-04 09:54:12 +01:00
|
|
|
case RUNLOOP_CTL_SET_FRAME_LIMIT:
|
|
|
|
runloop_set_frame_limit = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_FRAME_LIMIT:
|
|
|
|
runloop_set_frame_limit = false;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT:
|
|
|
|
return runloop_set_frame_limit;
|
2015-12-10 12:37:24 +01:00
|
|
|
case RUNLOOP_CTL_GET_PERFCNT:
|
2015-12-04 07:22:42 +01:00
|
|
|
{
|
2015-12-10 12:37:24 +01:00
|
|
|
bool **perfcnt = (bool**)data;
|
|
|
|
if (!perfcnt)
|
|
|
|
return false;
|
|
|
|
*perfcnt = &runloop_perfcnt_enable;
|
2015-12-04 07:22:42 +01:00
|
|
|
}
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-12-10 12:37:24 +01:00
|
|
|
case RUNLOOP_CTL_SET_PERFCNT_ENABLE:
|
|
|
|
runloop_perfcnt_enable = true;
|
2015-11-30 21:56:35 +01:00
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_PERFCNT_ENABLE:
|
2015-12-10 12:37:24 +01:00
|
|
|
runloop_perfcnt_enable = false;
|
2015-11-30 21:56:35 +01:00
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_PERFCNT_ENABLE:
|
2015-12-10 12:37:24 +01:00
|
|
|
return runloop_perfcnt_enable;
|
2016-03-04 19:20:00 +01:00
|
|
|
case RUNLOOP_CTL_SET_NONBLOCK_FORCED:
|
|
|
|
runloop_force_nonblock = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_NONBLOCK_FORCED:
|
|
|
|
runloop_force_nonblock = false;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_NONBLOCK_FORCED:
|
|
|
|
return runloop_force_nonblock;
|
2016-03-04 17:54:54 +01:00
|
|
|
case RUNLOOP_CTL_SET_FRAME_TIME:
|
|
|
|
{
|
|
|
|
const struct retro_frame_time_callback *info =
|
|
|
|
(const struct retro_frame_time_callback*)data;
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-03-18 00:32:02 +01:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2016-03-04 17:54:54 +01:00
|
|
|
/* retro_run() will be called in very strange and
|
|
|
|
* mysterious ways, have to disable it. */
|
2016-09-29 10:07:41 +02:00
|
|
|
if (global && global->netplay.enable)
|
2016-03-04 17:54:54 +01:00
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
runloop_frame_time = *info;
|
|
|
|
}
|
|
|
|
break;
|
2015-12-01 03:46:56 +01:00
|
|
|
case RUNLOOP_CTL_GET_WINDOWED_SCALE:
|
|
|
|
{
|
|
|
|
unsigned **scale = (unsigned**)data;
|
|
|
|
if (!scale)
|
|
|
|
return false;
|
2015-12-01 03:51:34 +01:00
|
|
|
*scale = (unsigned*)&runloop_pending_windowed_scale;
|
2015-12-01 03:46:56 +01:00
|
|
|
}
|
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_WINDOWED_SCALE:
|
2015-11-18 11:55:11 +01:00
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2015-12-01 03:51:34 +01:00
|
|
|
runloop_pending_windowed_scale = *idx;
|
2015-11-18 11:55:11 +01:00
|
|
|
}
|
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_LIBRETRO_PATH:
|
2016-09-29 07:46:21 +02:00
|
|
|
return path_set(RARCH_PATH_CORE, (const char*)data);
|
2016-04-06 01:29:32 +02:00
|
|
|
case RUNLOOP_CTL_FRAME_TIME_FREE:
|
2016-09-17 14:25:29 +02:00
|
|
|
memset(&runloop_frame_time, 0,
|
|
|
|
sizeof(struct retro_frame_time_callback));
|
2016-04-06 01:29:32 +02:00
|
|
|
runloop_frame_time_last = 0;
|
|
|
|
runloop_max_frames = 0;
|
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_STATE_FREE:
|
2016-03-12 14:47:10 +01:00
|
|
|
runloop_perfcnt_enable = false;
|
|
|
|
runloop_idle = false;
|
|
|
|
runloop_paused = false;
|
|
|
|
runloop_slowmotion = false;
|
|
|
|
runloop_frame_time_last_enable = false;
|
|
|
|
runloop_set_frame_limit = false;
|
|
|
|
runloop_overrides_active = false;
|
2016-04-06 01:29:32 +02:00
|
|
|
runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL);
|
2015-09-26 21:32:41 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_GLOBAL_FREE:
|
2015-12-04 07:18:39 +01:00
|
|
|
{
|
2016-01-22 14:43:11 +01:00
|
|
|
global_t *global = NULL;
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_TEMPORARY_CONTENT_DEINIT, NULL);
|
2016-09-25 15:49:09 +02:00
|
|
|
|
|
|
|
path_deinit_subsystem();
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
|
|
|
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
|
2015-12-04 07:18:39 +01:00
|
|
|
|
|
|
|
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
|
2016-09-28 07:27:39 +02:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_SRAM_LOAD_DISABLED, NULL);
|
|
|
|
rarch_ctl(RARCH_CTL_UNSET_SRAM_SAVE_DISABLED, NULL);
|
2016-09-28 07:17:14 +02:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_SRAM_ENABLE, NULL);
|
2016-09-29 05:46:31 +02:00
|
|
|
rarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
|
|
|
|
rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
|
|
|
|
rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
|
|
|
|
rarch_ctl(RARCH_CTL_UNSET_PATCH_BLOCKED, NULL);
|
2016-09-30 04:31:19 +02:00
|
|
|
path_clear(RARCH_PATH_CONTENT);
|
2016-09-30 06:11:11 +02:00
|
|
|
path_clear(RARCH_PATH_SAVEFILE);
|
|
|
|
path_clear(RARCH_PATH_SAVESTATE);
|
|
|
|
path_clear(RARCH_PATH_CHEATFILE);
|
|
|
|
path_clear(RARCH_PATH_REMAPFILE);
|
2016-09-30 06:22:56 +02:00
|
|
|
path_clear(RARCH_PATH_SERVER);
|
2016-09-30 06:11:11 +02:00
|
|
|
path_clear(RARCH_PATH_IPS);
|
|
|
|
path_clear(RARCH_PATH_UPS);
|
|
|
|
path_clear(RARCH_PATH_BPS);
|
2016-09-30 06:33:57 +02:00
|
|
|
path_clear(RARCH_PATH_RECORD);
|
|
|
|
path_clear(RARCH_PATH_RECORD_CONFIG);
|
2015-12-10 21:43:44 +01:00
|
|
|
runloop_overrides_active = false;
|
2015-12-04 07:18:39 +01:00
|
|
|
|
2016-05-08 01:33:57 +02:00
|
|
|
core_unset_input_descriptors();
|
2016-04-06 00:20:14 +02:00
|
|
|
|
2015-12-04 07:18:39 +01:00
|
|
|
global = global_get_ptr();
|
2016-09-17 14:41:49 +02:00
|
|
|
path_clear_all();
|
2016-09-17 14:49:35 +02:00
|
|
|
dir_clear_all();
|
2015-12-04 07:18:39 +01:00
|
|
|
memset(global, 0, sizeof(struct global));
|
2016-08-01 20:41:42 +02:00
|
|
|
retroarch_override_setting_free_state();
|
2015-12-04 07:18:39 +01:00
|
|
|
}
|
2015-09-26 21:30:20 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_CLEAR_STATE:
|
2015-12-11 10:43:53 +01:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_DEINIT, NULL);
|
2015-11-30 21:42:59 +01:00
|
|
|
runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL);
|
|
|
|
runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL);
|
2015-09-26 15:35:01 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_MAX_FRAMES:
|
2015-09-26 14:57:46 +02:00
|
|
|
{
|
|
|
|
unsigned *ptr = (unsigned*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 10:18:14 +01:00
|
|
|
runloop_max_frames = *ptr;
|
2015-09-26 14:57:46 +02:00
|
|
|
}
|
2015-09-26 15:35:01 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_IS_IDLE:
|
2015-12-04 03:07:05 +01:00
|
|
|
return runloop_idle;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_IDLE:
|
2015-09-26 14:57:46 +02:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 03:07:05 +01:00
|
|
|
runloop_idle = *ptr;
|
2015-09-26 14:57:46 +02:00
|
|
|
}
|
2015-09-26 15:35:01 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_IS_SLOWMOTION:
|
2016-02-29 01:33:14 +01:00
|
|
|
return runloop_slowmotion;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_SLOWMOTION:
|
2015-09-26 14:57:46 +02:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 07:42:37 +01:00
|
|
|
runloop_slowmotion = *ptr;
|
2015-09-26 14:57:46 +02:00
|
|
|
}
|
2015-09-26 15:35:01 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_PAUSED:
|
2015-09-26 14:57:46 +02:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 07:56:53 +01:00
|
|
|
runloop_paused = *ptr;
|
2015-09-26 14:57:46 +02:00
|
|
|
}
|
2015-09-26 15:35:01 +02:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_IS_PAUSED:
|
2015-12-04 07:56:53 +01:00
|
|
|
return runloop_paused;
|
2016-02-03 17:48:01 +01:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_PULL:
|
2016-05-08 06:09:39 +02:00
|
|
|
runloop_msg_queue_lock();
|
2016-02-03 17:48:01 +01:00
|
|
|
{
|
|
|
|
const char **ret = (const char**)data;
|
|
|
|
if (!ret)
|
|
|
|
return false;
|
2016-02-03 17:56:40 +01:00
|
|
|
*ret = msg_queue_pull(runloop_msg_queue);
|
2016-02-03 17:48:01 +01:00
|
|
|
}
|
2016-05-08 06:09:39 +02:00
|
|
|
runloop_msg_queue_unlock();
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2016-02-03 17:50:53 +01:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_CLEAR:
|
2016-02-03 17:56:40 +01:00
|
|
|
msg_queue_clear(runloop_msg_queue);
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_DEINIT:
|
2016-02-03 17:56:40 +01:00
|
|
|
if (!runloop_msg_queue)
|
2015-12-04 10:23:39 +01:00
|
|
|
return true;
|
|
|
|
|
2016-05-08 06:09:39 +02:00
|
|
|
runloop_msg_queue_lock();
|
2015-12-04 10:23:39 +01:00
|
|
|
|
2016-02-03 17:56:40 +01:00
|
|
|
msg_queue_free(runloop_msg_queue);
|
2015-12-04 10:23:39 +01:00
|
|
|
|
2016-05-08 06:09:39 +02:00
|
|
|
runloop_msg_queue_unlock();
|
2016-09-29 10:22:46 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_free(_runloop_msg_queue_lock);
|
|
|
|
_runloop_msg_queue_lock = NULL;
|
|
|
|
#endif
|
2015-12-04 10:23:39 +01:00
|
|
|
|
2016-02-03 17:56:40 +01:00
|
|
|
runloop_msg_queue = NULL;
|
2015-11-29 00:15:51 +01:00
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_INIT:
|
2015-11-30 21:42:59 +01:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL);
|
2016-02-03 17:56:40 +01:00
|
|
|
runloop_msg_queue = msg_queue_new(8);
|
|
|
|
retro_assert(runloop_msg_queue);
|
2015-12-04 08:40:42 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_THREADS
|
2016-05-08 06:09:39 +02:00
|
|
|
_runloop_msg_queue_lock = slock_new();
|
|
|
|
retro_assert(_runloop_msg_queue_lock);
|
2015-12-04 08:40:42 +01:00
|
|
|
#endif
|
2015-11-29 00:15:51 +01:00
|
|
|
break;
|
2016-02-09 17:41:19 +01:00
|
|
|
case RUNLOOP_CTL_TASK_INIT:
|
|
|
|
{
|
2016-02-09 18:38:57 +01:00
|
|
|
#ifdef HAVE_THREADS
|
2016-07-24 11:12:26 +02:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
bool threaded_enable = settings->threaded_data_runloop_enable;
|
|
|
|
#else
|
|
|
|
bool threaded_enable = false;
|
2016-02-09 18:38:57 +01:00
|
|
|
#endif
|
2016-07-06 16:35:00 +02:00
|
|
|
task_queue_ctl(TASK_QUEUE_CTL_DEINIT, NULL);
|
2016-02-09 18:26:27 +01:00
|
|
|
task_queue_ctl(TASK_QUEUE_CTL_INIT, &threaded_enable);
|
2016-02-09 17:41:19 +01:00
|
|
|
}
|
|
|
|
break;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_CORE_SHUTDOWN:
|
2015-12-04 08:00:51 +01:00
|
|
|
runloop_core_shutdown_initiated = true;
|
2015-11-30 15:43:49 +01:00
|
|
|
break;
|
2015-12-04 08:00:51 +01:00
|
|
|
case RUNLOOP_CTL_UNSET_CORE_SHUTDOWN:
|
|
|
|
runloop_core_shutdown_initiated = false;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_CORE_SHUTDOWN:
|
|
|
|
return runloop_core_shutdown_initiated;
|
2015-12-04 12:44:12 +01:00
|
|
|
case RUNLOOP_CTL_SET_SHUTDOWN:
|
|
|
|
runloop_shutdown_initiated = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_SHUTDOWN:
|
|
|
|
runloop_shutdown_initiated = false;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_SHUTDOWN:
|
|
|
|
return runloop_shutdown_initiated;
|
2015-11-30 21:35:50 +01:00
|
|
|
case RUNLOOP_CTL_SET_EXEC:
|
2015-12-04 03:01:48 +01:00
|
|
|
runloop_exec = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_EXEC:
|
|
|
|
runloop_exec = false;
|
2015-11-30 15:46:39 +01:00
|
|
|
break;
|
2015-12-04 03:01:48 +01:00
|
|
|
case RUNLOOP_CTL_IS_EXEC:
|
|
|
|
return runloop_exec;
|
2015-11-30 23:29:46 +01:00
|
|
|
case RUNLOOP_CTL_DATA_DEINIT:
|
2016-02-09 18:26:27 +01:00
|
|
|
task_queue_ctl(TASK_QUEUE_CTL_DEINIT, NULL);
|
2015-11-30 23:29:46 +01:00
|
|
|
break;
|
2015-12-07 14:13:07 +01:00
|
|
|
case RUNLOOP_CTL_IS_CORE_OPTION_UPDATED:
|
2016-04-06 02:30:20 +02:00
|
|
|
if (!runloop_core_options)
|
2016-01-23 19:42:05 +01:00
|
|
|
return false;
|
2016-05-10 01:21:55 +02:00
|
|
|
return core_option_manager_updated(runloop_core_options);
|
2015-12-09 09:21:49 +01:00
|
|
|
case RUNLOOP_CTL_CORE_OPTION_PREV:
|
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_prev(runloop_core_options, *idx);
|
2015-12-09 09:21:49 +01:00
|
|
|
if (ui_companion_is_on_foreground())
|
|
|
|
ui_companion_driver_notify_refresh();
|
|
|
|
}
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-12-09 09:21:49 +01:00
|
|
|
case RUNLOOP_CTL_CORE_OPTION_NEXT:
|
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_next(runloop_core_options, *idx);
|
2015-12-09 09:21:49 +01:00
|
|
|
if (ui_companion_is_on_foreground())
|
|
|
|
ui_companion_driver_notify_refresh();
|
|
|
|
}
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-12-07 14:13:07 +01:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_GET:
|
|
|
|
{
|
|
|
|
struct retro_variable *var = (struct retro_variable*)data;
|
|
|
|
|
2016-04-06 02:30:20 +02:00
|
|
|
if (!runloop_core_options || !var)
|
2015-12-07 14:13:07 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
RARCH_LOG("Environ GET_VARIABLE %s:\n", var->key);
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_get(runloop_core_options, var);
|
2016-09-05 11:35:27 -04:00
|
|
|
RARCH_LOG("\t%s\n", var->value ? var->value :
|
2016-06-29 02:40:05 +02:00
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE));
|
2015-12-07 14:13:07 +01:00
|
|
|
}
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-12-07 14:16:34 +01:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_INIT:
|
|
|
|
{
|
2016-09-28 08:08:35 +02:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-12-07 14:16:34 +01:00
|
|
|
char *game_options_path = NULL;
|
|
|
|
bool ret = false;
|
2016-09-05 11:35:27 -04:00
|
|
|
const struct retro_variable *vars =
|
2016-01-26 05:44:21 +01:00
|
|
|
(const struct retro_variable*)data;
|
2015-12-07 14:16:34 +01:00
|
|
|
|
2016-09-25 05:00:54 +02:00
|
|
|
if (settings && settings->game_specific_options)
|
2015-12-07 14:16:34 +01:00
|
|
|
ret = rarch_game_specific_options(&game_options_path);
|
|
|
|
|
|
|
|
if(ret)
|
|
|
|
{
|
2015-12-17 17:24:40 -05:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE, NULL);
|
2016-09-05 11:35:27 -04:00
|
|
|
runloop_core_options =
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_new(game_options_path, vars);
|
2015-12-07 14:16:34 +01:00
|
|
|
free(game_options_path);
|
|
|
|
}
|
|
|
|
else
|
2015-12-17 17:24:40 -05:00
|
|
|
{
|
2016-09-28 08:08:35 +02:00
|
|
|
char buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
const char *options_path = NULL;
|
|
|
|
|
|
|
|
if (settings)
|
|
|
|
options_path = settings->path.core_options;
|
|
|
|
|
2016-09-30 04:43:16 +02:00
|
|
|
if (options_path && string_is_empty(options_path) && !path_is_empty(RARCH_PATH_CONFIG))
|
2016-09-28 08:08:35 +02:00
|
|
|
{
|
2016-09-29 08:31:41 +02:00
|
|
|
fill_pathname_resolve_relative(buf, path_get(RARCH_PATH_CONFIG),
|
2016-09-28 08:08:35 +02:00
|
|
|
file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf));
|
|
|
|
options_path = buf;
|
|
|
|
}
|
|
|
|
|
2015-12-17 17:24:40 -05:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL);
|
2016-09-05 11:35:27 -04:00
|
|
|
runloop_core_options =
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_new(options_path, vars);
|
2015-12-17 17:24:40 -05:00
|
|
|
}
|
2015-12-07 14:16:34 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2016-04-06 02:30:20 +02:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_FREE:
|
|
|
|
if (runloop_core_options)
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_free(runloop_core_options);
|
2016-04-06 02:30:20 +02:00
|
|
|
runloop_core_options = NULL;
|
|
|
|
break;
|
2015-12-07 14:13:07 +01:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_DEINIT:
|
2016-01-31 01:54:12 -05:00
|
|
|
{
|
2016-04-06 02:30:20 +02:00
|
|
|
if (!runloop_core_options)
|
2016-03-02 05:29:12 +01:00
|
|
|
return false;
|
2016-01-31 01:54:12 -05:00
|
|
|
|
2016-03-02 05:29:12 +01:00
|
|
|
/* check if game options file was just created and flush
|
|
|
|
to that file instead */
|
2016-09-30 04:43:16 +02:00
|
|
|
if(!path_is_empty(RARCH_PATH_CORE_OPTIONS))
|
2016-03-02 05:29:12 +01:00
|
|
|
{
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_flush_game_specific(runloop_core_options,
|
2016-09-29 08:34:08 +02:00
|
|
|
path_get(RARCH_PATH_CORE_OPTIONS));
|
2016-09-30 04:31:19 +02:00
|
|
|
path_clear(RARCH_PATH_CORE_OPTIONS);
|
2016-03-02 05:29:12 +01:00
|
|
|
}
|
|
|
|
else
|
2016-05-10 01:21:55 +02:00
|
|
|
core_option_manager_flush(runloop_core_options);
|
2016-01-31 01:54:12 -05:00
|
|
|
|
2016-03-02 05:29:12 +01:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_GAME_OPTIONS_ACTIVE, NULL))
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL);
|
|
|
|
|
2016-04-06 02:30:20 +02:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_FREE, NULL);
|
2016-03-02 05:29:12 +01:00
|
|
|
}
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-12-13 14:31:06 +01:00
|
|
|
case RUNLOOP_CTL_KEY_EVENT_GET:
|
|
|
|
{
|
2016-09-05 11:35:27 -04:00
|
|
|
retro_keyboard_event_t **key_event =
|
2016-01-26 05:44:21 +01:00
|
|
|
(retro_keyboard_event_t**)data;
|
2015-12-13 14:31:06 +01:00
|
|
|
if (!key_event)
|
|
|
|
return false;
|
|
|
|
*key_event = &runloop_key_event;
|
|
|
|
}
|
|
|
|
break;
|
2016-01-21 01:52:02 +01:00
|
|
|
case RUNLOOP_CTL_FRONTEND_KEY_EVENT_GET:
|
|
|
|
{
|
2016-09-05 11:35:27 -04:00
|
|
|
retro_keyboard_event_t **key_event =
|
2016-01-26 05:44:21 +01:00
|
|
|
(retro_keyboard_event_t**)data;
|
2016-01-21 19:45:43 +01:00
|
|
|
if (!key_event)
|
2016-01-21 01:52:02 +01:00
|
|
|
return false;
|
|
|
|
*key_event = &runloop_frontend_key_event;
|
|
|
|
}
|
|
|
|
break;
|
2016-07-31 22:45:01 +01:00
|
|
|
case RUNLOOP_CTL_HTTPSERVER_INIT:
|
|
|
|
#if defined(HAVE_HTTPSERVER) && defined(HAVE_ZLIB)
|
|
|
|
httpserver_init(8888);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_HTTPSERVER_DESTROY:
|
|
|
|
#if defined(HAVE_HTTPSERVER) && defined(HAVE_ZLIB)
|
|
|
|
httpserver_destroy();
|
|
|
|
#endif
|
|
|
|
break;
|
2015-12-07 14:13:07 +01:00
|
|
|
case RUNLOOP_CTL_NONE:
|
2015-09-26 15:35:01 +02:00
|
|
|
default:
|
2016-02-11 01:47:24 +01:00
|
|
|
break;
|
2015-09-26 14:57:46 +02:00
|
|
|
}
|
|
|
|
|
2015-09-26 15:35:01 +02:00
|
|
|
return true;
|
2015-09-26 14:57:46 +02:00
|
|
|
}
|
|
|
|
|
2016-09-04 15:31:50 -04:00
|
|
|
|
2015-02-21 07:29:13 +01:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-12-07 15:22:36 +01:00
|
|
|
static void runloop_iterate_linefeed_overlay(settings_t *settings)
|
2015-02-21 08:42:19 +01:00
|
|
|
{
|
2015-02-21 08:47:03 +01:00
|
|
|
static char prev_overlay_restore = false;
|
2016-05-08 23:12:04 +02:00
|
|
|
bool osk_enable = input_driver_is_onscreen_keyboard_enabled();
|
2015-02-21 08:47:03 +01:00
|
|
|
|
2016-03-23 06:18:09 +01:00
|
|
|
if (osk_enable && !input_keyboard_ctl(
|
|
|
|
RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
|
2015-02-21 08:42:19 +01:00
|
|
|
{
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_unset_onscreen_keyboard_enabled();
|
2015-03-18 19:40:00 +01:00
|
|
|
prev_overlay_restore = true;
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
|
2015-02-21 08:42:19 +01:00
|
|
|
}
|
2016-03-23 06:18:09 +01:00
|
|
|
else if (!osk_enable && input_keyboard_ctl(
|
|
|
|
RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
|
2015-02-21 08:42:19 +01:00
|
|
|
{
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_set_onscreen_keyboard_enabled();
|
2015-03-18 19:40:00 +01:00
|
|
|
prev_overlay_restore = false;
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
|
2015-02-21 08:42:19 +01:00
|
|
|
}
|
2015-02-21 08:47:03 +01:00
|
|
|
else if (prev_overlay_restore)
|
|
|
|
{
|
2015-07-09 04:05:59 +02:00
|
|
|
if (!settings->input.overlay_hide_in_menu)
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
|
2015-02-21 08:47:03 +01:00
|
|
|
prev_overlay_restore = false;
|
|
|
|
}
|
2015-02-21 08:42:19 +01:00
|
|
|
}
|
2015-02-21 08:52:29 +01:00
|
|
|
#endif
|
2015-02-21 08:42:19 +01:00
|
|
|
|
2015-03-24 10:01:17 +01:00
|
|
|
|
2016-01-20 03:31:19 +01:00
|
|
|
/* Loads dummy core instead of exiting RetroArch completely.
|
|
|
|
* Aborts core shutdown if invoked. */
|
|
|
|
static int runloop_iterate_time_to_exit_load_dummy(void)
|
|
|
|
{
|
2016-05-16 17:19:16 +02:00
|
|
|
content_ctx_info_t content_info = {0};
|
2016-09-03 08:27:58 +02:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-09-03 08:22:41 +02:00
|
|
|
|
|
|
|
if (!settings->load_dummy_on_core_shutdown)
|
|
|
|
return -1;
|
|
|
|
|
2016-05-27 18:14:47 +02:00
|
|
|
if (!task_push_content_load_default(
|
2016-05-16 17:19:16 +02:00
|
|
|
NULL, NULL,
|
|
|
|
&content_info,
|
|
|
|
CORE_TYPE_DUMMY,
|
|
|
|
CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE,
|
|
|
|
NULL, NULL))
|
2016-01-20 03:31:19 +01:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_SHUTDOWN, NULL);
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_CORE_SHUTDOWN, NULL);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2015-03-24 10:01:17 +01:00
|
|
|
|
2016-09-05 01:04:15 -04:00
|
|
|
bool runloop_is_quit_confirm(void)
|
|
|
|
{
|
|
|
|
return runloop_quit_confirm;
|
|
|
|
}
|
|
|
|
|
|
|
|
void runloop_set_quit_confirm(bool on)
|
|
|
|
{
|
|
|
|
runloop_quit_confirm = on;
|
|
|
|
}
|
|
|
|
|
2015-10-09 13:29:57 -03:00
|
|
|
/* Time to exit out of the main loop?
|
2015-09-30 19:09:05 +02:00
|
|
|
* Reasons for exiting:
|
|
|
|
* a) Shutdown environment callback was invoked.
|
|
|
|
* b) Quit key was pressed.
|
|
|
|
* c) Frame count exceeds or equals maximum amount of frames to run.
|
|
|
|
* d) Video driver no longer alive.
|
|
|
|
* e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better)
|
|
|
|
*/
|
2015-12-07 15:22:36 +01:00
|
|
|
static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed)
|
2015-09-30 19:09:05 +02:00
|
|
|
{
|
2016-02-03 17:10:54 +01:00
|
|
|
bool time_to_exit = runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL);
|
|
|
|
time_to_exit = time_to_exit || quit_key_pressed;
|
2016-05-08 14:00:51 +02:00
|
|
|
time_to_exit = time_to_exit || !video_driver_is_alive();
|
2015-12-04 10:18:14 +01:00
|
|
|
time_to_exit = time_to_exit || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL);
|
2016-05-08 06:36:52 +02:00
|
|
|
time_to_exit = time_to_exit || runloop_is_frame_count_end();
|
2015-12-04 10:18:14 +01:00
|
|
|
time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_EXEC, NULL);
|
|
|
|
|
|
|
|
if (!time_to_exit)
|
|
|
|
return 1;
|
|
|
|
|
2016-09-05 01:04:15 -04:00
|
|
|
#ifdef HAVE_MENU
|
2016-09-25 05:00:54 +02:00
|
|
|
if (!runloop_is_quit_confirm())
|
2016-09-05 01:04:15 -04:00
|
|
|
{
|
2016-09-25 05:00:54 +02:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-09-05 12:46:28 -04:00
|
|
|
|
2016-09-25 05:00:54 +02:00
|
|
|
if (settings && settings->confirm_on_exit)
|
2016-09-05 11:35:27 -04:00
|
|
|
{
|
2016-09-25 05:00:54 +02:00
|
|
|
if (menu_dialog_is_active())
|
|
|
|
return 1;
|
2016-09-05 01:04:15 -04:00
|
|
|
|
2016-09-25 05:00:54 +02:00
|
|
|
if (content_is_inited())
|
|
|
|
{
|
|
|
|
if(menu_display_toggle_get_reason() != MENU_TOGGLE_REASON_USER)
|
|
|
|
menu_display_toggle_set_reason(MENU_TOGGLE_REASON_MESSAGE);
|
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_dialog_show_message(MENU_DIALOG_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT);
|
|
|
|
return 1;
|
|
|
|
}
|
2016-09-05 01:04:15 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-04 10:18:14 +01:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_EXEC, NULL))
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_EXEC, NULL);
|
|
|
|
|
2015-12-26 11:08:44 +01:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_IS_CORE_SHUTDOWN, NULL))
|
|
|
|
return -1;
|
|
|
|
|
2016-01-20 03:31:19 +01:00
|
|
|
/* Quits out of RetroArch main loop. */
|
2016-09-03 08:22:41 +02:00
|
|
|
return runloop_iterate_time_to_exit_load_dummy();
|
2015-09-30 19:09:05 +02:00
|
|
|
}
|
|
|
|
|
2016-09-04 15:31:50 -04:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
static int runloop_iterate_menu(enum menu_action action, unsigned *sleep_ms)
|
|
|
|
{
|
|
|
|
menu_ctx_iterate_t iter;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
bool focused = runloop_is_focused() &&
|
|
|
|
!ui_companion_is_on_foreground();
|
|
|
|
bool is_idle = runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL);
|
|
|
|
|
|
|
|
iter.action = action;
|
|
|
|
|
|
|
|
if (!menu_driver_ctl(RARCH_MENU_CTL_ITERATE, &iter))
|
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
|
|
|
|
|
|
|
if (focused || !is_idle)
|
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL);
|
|
|
|
|
|
|
|
if (!focused || is_idle)
|
|
|
|
{
|
|
|
|
*sleep_ms = 10;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!settings->menu.throttle_framerate && !settings->fastforward_ratio)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-07 03:53:36 +01:00
|
|
|
/**
|
2015-12-07 15:22:36 +01:00
|
|
|
* runloop_iterate:
|
2014-10-05 01:31:48 +02:00
|
|
|
*
|
2015-01-09 22:24:38 +01:00
|
|
|
* Run Libretro core in RetroArch for one frame.
|
2015-01-07 03:53:36 +01:00
|
|
|
*
|
2016-09-05 11:35:27 -04:00
|
|
|
* Returns: 0 on success, 1 if we have to wait until
|
|
|
|
* button input in order to wake up the loop,
|
2016-01-26 05:44:21 +01:00
|
|
|
* -1 if we forcibly quit out of the RetroArch iteration loop.
|
2015-01-07 03:53:36 +01:00
|
|
|
**/
|
2015-12-07 15:22:36 +01:00
|
|
|
int runloop_iterate(unsigned *sleep_ms)
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
|
|
|
unsigned i;
|
2015-08-05 15:54:21 +02:00
|
|
|
event_cmd_state_t cmd;
|
2015-09-26 21:03:38 +02:00
|
|
|
retro_time_t current, target, to_sleep_ms;
|
2016-06-25 09:04:00 +02:00
|
|
|
static retro_input_t last_input = {0};
|
2016-02-26 22:29:10 +01:00
|
|
|
event_cmd_state_t *cmd_ptr = &cmd;
|
2015-12-04 09:54:12 +01:00
|
|
|
static retro_time_t frame_limit_minimum_time = 0.0;
|
|
|
|
static retro_time_t frame_limit_last_time = 0.0;
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-12-10 21:31:28 +01:00
|
|
|
|
|
|
|
cmd.state[1] = last_input;
|
|
|
|
cmd.state[0] = input_keys_pressed();
|
|
|
|
last_input = cmd.state[0];
|
2015-12-04 09:54:12 +01:00
|
|
|
|
2016-03-12 14:47:10 +01:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_FRAME_TIME_LAST, NULL);
|
2015-12-04 12:26:39 +01:00
|
|
|
|
2015-12-04 09:54:12 +01:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT, NULL))
|
|
|
|
{
|
2016-09-05 11:35:27 -04:00
|
|
|
struct retro_system_av_info *av_info =
|
2016-01-26 05:44:21 +01:00
|
|
|
video_viewport_get_system_av_info();
|
2016-09-05 11:35:27 -04:00
|
|
|
float fastforward_ratio =
|
|
|
|
(settings->fastforward_ratio == 0.0f)
|
2016-07-25 12:30:41 +02:00
|
|
|
? 1.0f : settings->fastforward_ratio;
|
2015-12-04 09:54:12 +01:00
|
|
|
|
2016-05-10 09:17:04 +02:00
|
|
|
frame_limit_last_time = cpu_features_get_time_usec();
|
2016-09-05 11:35:27 -04:00
|
|
|
frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f
|
2015-12-04 09:54:12 +01:00
|
|
|
/ (av_info->timing.fps * fastforward_ratio));
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_FRAME_LIMIT, NULL);
|
|
|
|
}
|
2015-06-26 19:37:03 +02:00
|
|
|
|
2016-05-08 23:12:04 +02:00
|
|
|
if (input_driver_is_flushing_input())
|
2015-08-06 03:17:56 +02:00
|
|
|
{
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_unset_flushing_input();
|
2016-06-25 09:04:00 +02:00
|
|
|
if (cmd.state[0].state)
|
2015-08-06 03:17:56 +02:00
|
|
|
{
|
2016-06-25 09:04:00 +02:00
|
|
|
cmd.state[0].state = 0;
|
2015-08-06 03:20:15 +02:00
|
|
|
|
|
|
|
/* If core was paused before entering menu, evoke
|
|
|
|
* pause toggle to wake it up. */
|
2015-12-04 07:56:53 +01:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
2016-06-25 09:04:00 +02:00
|
|
|
BIT64_SET(cmd.state[0].state, RARCH_PAUSE_TOGGLE);
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_set_flushing_input();
|
2015-08-06 03:17:56 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-05 11:35:27 -04:00
|
|
|
|
2016-05-08 06:31:12 +02:00
|
|
|
if (runloop_frame_time.callback)
|
|
|
|
{
|
|
|
|
/* Updates frame timing if frame timing callback is in use by the core.
|
|
|
|
* Limits frame time if fast forward ratio throttle is enabled. */
|
|
|
|
|
2016-05-10 09:17:04 +02:00
|
|
|
retro_time_t current = cpu_features_get_time_usec();
|
2016-05-08 06:31:12 +02:00
|
|
|
retro_time_t delta = current - runloop_frame_time_last;
|
|
|
|
bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) ||
|
2016-05-08 23:12:04 +02:00
|
|
|
input_driver_is_nonblock_state()) |
|
|
|
|
!!recording_driver_get_data_ptr();
|
2016-05-08 06:31:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (!runloop_frame_time_last || is_locked_fps)
|
|
|
|
delta = runloop_frame_time.reference;
|
|
|
|
|
|
|
|
if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL))
|
2016-07-25 12:30:41 +02:00
|
|
|
delta /= settings->slowmotion_ratio;
|
2016-05-08 06:31:12 +02:00
|
|
|
|
|
|
|
runloop_frame_time_last = current;
|
|
|
|
|
|
|
|
if (is_locked_fps)
|
|
|
|
runloop_frame_time_last = 0;
|
|
|
|
|
|
|
|
runloop_frame_time.callback(delta);
|
|
|
|
}
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2016-06-25 09:04:00 +02:00
|
|
|
cmd.state[2].state = cmd.state[0].state & ~cmd.state[1].state; /* trigger */
|
2015-10-22 18:29:35 +02:00
|
|
|
|
2015-12-07 15:36:58 +01:00
|
|
|
if (runloop_cmd_triggered(cmd_ptr, RARCH_OVERLAY_NEXT))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_OVERLAY_NEXT, NULL);
|
2015-09-26 15:08:52 +02:00
|
|
|
|
2015-12-07 15:36:58 +01:00
|
|
|
if (runloop_cmd_triggered(cmd_ptr, RARCH_FULLSCREEN_TOGGLE_KEY))
|
2015-12-04 11:21:06 +01:00
|
|
|
{
|
|
|
|
bool fullscreen_toggled = !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
|
2015-10-28 00:55:11 +01:00
|
|
|
#ifdef HAVE_MENU
|
2016-09-05 11:35:27 -04:00
|
|
|
fullscreen_toggled = fullscreen_toggled ||
|
2016-01-26 05:44:21 +01:00
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
|
2015-10-28 00:55:11 +01:00
|
|
|
#endif
|
2015-12-04 10:49:09 +01:00
|
|
|
|
2015-12-04 11:21:06 +01:00
|
|
|
if (fullscreen_toggled)
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
|
2015-12-04 11:21:06 +01:00
|
|
|
}
|
2015-09-26 15:08:52 +02:00
|
|
|
|
2015-12-07 15:36:58 +01:00
|
|
|
if (runloop_cmd_triggered(cmd_ptr, RARCH_GRAB_MOUSE_TOGGLE))
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);
|
2015-09-26 15:08:52 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
2016-09-05 11:35:27 -04:00
|
|
|
if (runloop_cmd_menu_press(cmd_ptr) ||
|
2016-01-26 05:44:21 +01:00
|
|
|
rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
2015-09-26 21:03:38 +02:00
|
|
|
{
|
2015-12-05 13:49:22 +01:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-09-26 21:03:38 +02:00
|
|
|
{
|
2016-09-05 11:35:27 -04:00
|
|
|
if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
|
2016-01-26 05:44:21 +01:00
|
|
|
!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
|
2015-11-30 21:28:55 +01:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
2015-09-26 21:03:38 +02:00
|
|
|
}
|
|
|
|
else
|
2016-09-05 11:35:27 -04:00
|
|
|
{
|
|
|
|
menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER);
|
2015-11-30 21:28:55 +01:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
2016-09-05 11:35:27 -04:00
|
|
|
}
|
2015-09-26 21:03:38 +02:00
|
|
|
}
|
2015-09-26 15:08:52 +02:00
|
|
|
#endif
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2015-02-21 07:29:13 +01:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-12-07 15:22:36 +01:00
|
|
|
runloop_iterate_linefeed_overlay(settings);
|
2015-02-21 07:29:13 +01:00
|
|
|
#endif
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2016-01-26 05:44:21 +01:00
|
|
|
if (runloop_iterate_time_to_exit(
|
|
|
|
runloop_cmd_press(cmd_ptr, RARCH_QUIT_KEY)) != 1)
|
2015-12-04 09:54:12 +01:00
|
|
|
{
|
|
|
|
frame_limit_last_time = 0.0;
|
2016-08-20 22:11:06 -04:00
|
|
|
command_event(CMD_EVENT_QUIT, NULL);
|
2015-09-30 19:09:05 +02:00
|
|
|
return -1;
|
2015-12-04 09:54:12 +01:00
|
|
|
}
|
2015-08-27 12:43:35 +02:00
|
|
|
|
2015-08-27 12:48:35 +02:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-05 13:49:22 +01:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-08-27 12:48:35 +02:00
|
|
|
{
|
2016-09-17 12:05:00 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
core_poll();
|
|
|
|
ret = runloop_iterate_menu((enum menu_action)
|
2016-09-16 12:43:09 +02:00
|
|
|
menu_event(cmd.state[0], cmd.state[2]),
|
|
|
|
sleep_ms);
|
2016-01-07 00:11:58 +01:00
|
|
|
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-09-14 14:27:28 -04:00
|
|
|
/* FIXME: This is an ugly way to tell Netplay this... */
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL);
|
|
|
|
#endif
|
|
|
|
|
2016-07-11 02:46:16 +02:00
|
|
|
if (ret == -1)
|
|
|
|
goto end;
|
2016-09-05 11:35:27 -04:00
|
|
|
|
2016-07-11 02:46:16 +02:00
|
|
|
return ret;
|
2015-08-27 12:48:35 +02:00
|
|
|
}
|
|
|
|
#endif
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2016-09-23 03:19:33 +02:00
|
|
|
if (!runloop_check_state(&cmd))
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
2015-08-27 13:13:14 +02:00
|
|
|
/* RetroArch has been paused. */
|
2016-09-17 12:05:00 +02:00
|
|
|
core_poll();
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-09-14 14:27:28 -04:00
|
|
|
/* FIXME: This is an ugly way to tell Netplay this... */
|
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL);
|
|
|
|
#endif
|
2015-08-27 14:52:02 +02:00
|
|
|
*sleep_ms = 10;
|
2015-01-11 18:04:42 +01:00
|
|
|
return 1;
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(HAVE_THREADS)
|
2016-05-09 08:17:35 +02:00
|
|
|
autosave_lock();
|
2014-10-05 01:31:48 +02:00
|
|
|
#endif
|
|
|
|
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2016-09-14 14:25:54 -04:00
|
|
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_PRE_FRAME, NULL))
|
|
|
|
{
|
|
|
|
/* Paused due to Netplay */
|
2016-09-25 18:46:39 +02:00
|
|
|
core_poll();
|
2016-09-14 14:25:54 -04:00
|
|
|
*sleep_ms = 10;
|
|
|
|
return 1;
|
|
|
|
}
|
2014-10-05 01:31:48 +02:00
|
|
|
#endif
|
|
|
|
|
2015-12-01 00:04:04 +01:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-12-01 00:16:48 +01:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_START, NULL);
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2016-03-04 19:42:30 +01:00
|
|
|
camera_driver_ctl(RARCH_CAMERA_CTL_POLL, NULL);
|
2014-10-05 01:31:48 +02:00
|
|
|
|
|
|
|
/* Update binds for analog dpad modes. */
|
2015-03-20 19:48:23 +01:00
|
|
|
for (i = 0; i < settings->input.max_users; i++)
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
2015-03-20 19:48:23 +01:00
|
|
|
if (!settings->input.analog_dpad_mode[i])
|
2014-10-05 01:31:48 +02:00
|
|
|
continue;
|
|
|
|
|
2015-03-20 19:48:23 +01:00
|
|
|
input_push_analog_dpad(settings->input.binds[i],
|
|
|
|
settings->input.analog_dpad_mode[i]);
|
|
|
|
input_push_analog_dpad(settings->input.autoconf_binds[i],
|
|
|
|
settings->input.analog_dpad_mode[i]);
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
2016-09-05 11:35:27 -04:00
|
|
|
if ((settings->video.frame_delay > 0) &&
|
2016-05-08 23:12:04 +02:00
|
|
|
!input_driver_is_nonblock_state())
|
2015-09-22 18:55:14 +02:00
|
|
|
retro_sleep(settings->video.frame_delay);
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2016-05-08 01:33:57 +02:00
|
|
|
core_run();
|
2015-10-16 18:04:59 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2016-05-08 00:15:04 +02:00
|
|
|
cheevos_test();
|
2015-10-16 18:04:59 +02:00
|
|
|
#endif
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2015-03-20 19:48:23 +01:00
|
|
|
for (i = 0; i < settings->input.max_users; i++)
|
2014-10-05 01:31:48 +02:00
|
|
|
{
|
2015-03-20 19:48:23 +01:00
|
|
|
if (!settings->input.analog_dpad_mode[i])
|
2014-10-05 01:31:48 +02:00
|
|
|
continue;
|
|
|
|
|
2015-03-20 19:48:23 +01:00
|
|
|
input_pop_analog_dpad(settings->input.binds[i]);
|
|
|
|
input_pop_analog_dpad(settings->input.autoconf_binds[i]);
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
2015-12-01 00:04:04 +01:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-12-01 00:16:48 +01:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_END, NULL);
|
2014-10-05 01:31:48 +02:00
|
|
|
|
2016-09-29 21:07:10 +02:00
|
|
|
#ifdef HAVE_NETWORKING
|
2015-12-05 16:27:00 +01:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_POST_FRAME, NULL);
|
2014-10-05 01:31:48 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_THREADS)
|
2016-05-09 08:17:35 +02:00
|
|
|
autosave_unlock();
|
2014-10-05 01:31:48 +02:00
|
|
|
#endif
|
|
|
|
|
2016-07-25 12:30:41 +02:00
|
|
|
if (!settings->fastforward_ratio)
|
2016-02-21 12:11:08 +01:00
|
|
|
return 0;
|
2015-09-28 18:12:02 +02:00
|
|
|
#ifdef HAVE_MENU
|
2015-09-26 21:03:38 +02:00
|
|
|
end:
|
2015-09-28 18:12:02 +02:00
|
|
|
#endif
|
2015-09-26 21:03:38 +02:00
|
|
|
|
2016-05-10 09:17:04 +02:00
|
|
|
current = cpu_features_get_time_usec();
|
2016-09-05 11:35:27 -04:00
|
|
|
target = frame_limit_last_time +
|
2016-01-26 05:44:21 +01:00
|
|
|
frame_limit_minimum_time;
|
2015-09-26 21:03:38 +02:00
|
|
|
to_sleep_ms = (target - current) / 1000;
|
|
|
|
|
|
|
|
if (to_sleep_ms > 0)
|
|
|
|
{
|
|
|
|
*sleep_ms = (unsigned)to_sleep_ms;
|
|
|
|
/* Combat jitter a bit. */
|
|
|
|
frame_limit_last_time += frame_limit_minimum_time;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-10 09:17:04 +02:00
|
|
|
frame_limit_last_time = cpu_features_get_time_usec();
|
2015-09-26 21:03:38 +02:00
|
|
|
|
|
|
|
return 0;
|
2014-10-05 01:31:48 +02:00
|
|
|
}
|