2014-10-04 23:31:48 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
|
|
|
* Copyright (C) 2014-2015 - Jay McCarthy
|
2014-10-04 23:31:48 +00: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-28 23:19:01 +00:00
|
|
|
#include <stdarg.h>
|
2015-11-23 20:58:39 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2015-03-15 03:30:46 +00:00
|
|
|
#include <retro_inline.h>
|
2015-11-28 23:19:01 +00:00
|
|
|
#include <retro_assert.h>
|
|
|
|
#include <queues/message_queue.h>
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
#include <rthreads/rthreads.h>
|
|
|
|
#endif
|
2015-06-13 17:12:10 +00:00
|
|
|
|
2015-06-22 09:45:00 +00:00
|
|
|
#include <compat/strl.h>
|
2015-06-14 16:46:00 +00:00
|
|
|
|
2015-11-11 20:10:13 +00:00
|
|
|
#ifdef HAVE_CHEEVOS
|
2015-10-09 16:29:57 +00:00
|
|
|
#include "cheevos.h"
|
2015-11-11 20:10:13 +00:00
|
|
|
#endif
|
2015-11-30 18:23:13 +00:00
|
|
|
#include "autosave.h"
|
2015-12-11 12:56:00 +00:00
|
|
|
#include "core_info.h"
|
2015-12-01 02:33:50 +00:00
|
|
|
#include "cheats.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
#include "configuration.h"
|
2014-10-04 23:31:48 +00:00
|
|
|
#include "performance.h"
|
2015-12-01 00:47:26 +00:00
|
|
|
#include "movie.h"
|
2015-01-09 16:40:47 +00:00
|
|
|
#include "retroarch.h"
|
2015-01-09 17:40:33 +00:00
|
|
|
#include "runloop.h"
|
2015-11-30 21:30:13 +00:00
|
|
|
#include "rewind.h"
|
2015-12-06 18:31:47 +00:00
|
|
|
#include "system.h"
|
2015-12-01 02:55:31 +00:00
|
|
|
#include "dir_list_special.h"
|
2015-11-23 18:40:09 +00:00
|
|
|
#include "audio/audio_driver.h"
|
2015-12-05 14:55:26 +00:00
|
|
|
#include "camera/camera_driver.h"
|
2015-12-05 15:12:29 +00:00
|
|
|
#include "record/record_driver.h"
|
|
|
|
#include "input/input_driver.h"
|
|
|
|
#include "ui/ui_companion_driver.h"
|
2015-12-05 15:54:03 +00:00
|
|
|
#include "libretro_version_1.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
|
2015-07-01 00:00:39 +00:00
|
|
|
#include "msg_hash.h"
|
|
|
|
|
2015-11-30 14:35:57 +00:00
|
|
|
#include "tasks/tasks.h"
|
2015-11-28 15:13:16 +00:00
|
|
|
#include "input/input_keyboard.h"
|
2014-10-04 23:31:48 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
2015-12-06 16:55:27 +00:00
|
|
|
#include "menu/menu_driver.h"
|
2014-10-04 23:31:48 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-20 19:32:53 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-23 20:25:28 +00:00
|
|
|
#include "netplay/netplay.h"
|
2014-10-20 19:32:53 +00:00
|
|
|
#endif
|
|
|
|
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "verbosity.h"
|
|
|
|
|
2015-12-07 12:56:33 +00:00
|
|
|
#ifdef HAVE_ZLIB
|
|
|
|
#define DEFAULT_EXT "zip"
|
|
|
|
#else
|
|
|
|
#define DEFAULT_EXT ""
|
|
|
|
#endif
|
|
|
|
|
2015-12-04 12:09:16 +00:00
|
|
|
typedef struct event_cmd_state
|
|
|
|
{
|
2015-12-07 10:23:32 +00:00
|
|
|
retro_input_t state[3];
|
2015-12-04 12:09:16 +00:00
|
|
|
} event_cmd_state_t;
|
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
static rarch_dir_list_t runloop_shader_dir;
|
|
|
|
|
2015-12-01 02:51:34 +00:00
|
|
|
static unsigned runloop_pending_windowed_scale;
|
2015-08-05 10:40:47 +00:00
|
|
|
|
2015-11-28 23:19:01 +00:00
|
|
|
static msg_queue_t *g_msg_queue;
|
|
|
|
|
2015-12-04 06:18:39 +00:00
|
|
|
global_t *global_get_ptr(void)
|
|
|
|
{
|
|
|
|
static struct global g_extern;
|
|
|
|
return &g_extern;
|
|
|
|
}
|
|
|
|
|
2015-12-07 12:56:33 +00:00
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
const char *runloop_msg_queue_pull(void)
|
2015-11-28 23:19:01 +00:00
|
|
|
{
|
|
|
|
const char *ret = NULL;
|
|
|
|
|
2015-12-04 07:40:42 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL);
|
2015-11-28 23:19:01 +00:00
|
|
|
|
|
|
|
ret = msg_queue_pull(g_msg_queue);
|
|
|
|
|
2015-12-04 07:40:42 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL);
|
2015-11-28 23:19:01 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
void runloop_msg_queue_push_new(uint32_t hash, unsigned prio, unsigned duration,
|
2015-11-28 23:19:01 +00:00
|
|
|
bool flush)
|
|
|
|
{
|
|
|
|
const char *msg = msg_hash_to_str(hash);
|
|
|
|
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, prio, duration, flush);
|
2015-11-28 23:19:01 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration,
|
2015-11-28 23:19:01 +00:00
|
|
|
bool flush)
|
|
|
|
{
|
2015-11-29 23:13:51 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
if(!settings->video.font_enable || !g_msg_queue)
|
2015-11-28 23:19:01 +00:00
|
|
|
return;
|
|
|
|
|
2015-12-04 07:40:42 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL);
|
2015-11-28 23:19:01 +00:00
|
|
|
|
|
|
|
if (flush)
|
|
|
|
msg_queue_clear(g_msg_queue);
|
|
|
|
msg_queue_push(g_msg_queue, msg, prio, duration);
|
|
|
|
|
2015-12-04 07:40:42 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL);
|
2015-11-28 23:19:01 +00:00
|
|
|
|
|
|
|
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, prio, duration, flush);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-07 09:05:58 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-07 14:36:58 +00:00
|
|
|
static bool runloop_cmd_get_state_menu_toggle_button_combo(
|
2015-12-07 09:05:58 +00: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)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return false;
|
|
|
|
case 1:
|
|
|
|
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_DOWN))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_Y))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_L))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_R))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_L3))
|
|
|
|
return false;
|
|
|
|
if (!BIT64_GET(input, RETRO_DEVICE_ID_JOYPAD_R3))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
#define runloop_cmd_triggered(cmd, id) BIT64_GET(cmd->state[2], id)
|
2015-12-07 09:05:58 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
#define runloop_cmd_press(cmd, id) BIT64_GET(cmd->state[0], id)
|
|
|
|
#define runloop_cmd_pressed(cmd, id) BIT64_GET(cmd->state[1], id)
|
2015-12-07 09:56:00 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-07 14:36:58 +00:00
|
|
|
#define runloop_cmd_menu_press(cmd) (BIT64_GET(cmd->state[2], RARCH_MENU_TOGGLE) || \
|
|
|
|
runloop_cmd_get_state_menu_toggle_button_combo( \
|
2015-12-07 10:23:32 +00:00
|
|
|
settings, cmd->state[0], \
|
|
|
|
cmd->state[1], cmd->state[2]))
|
2015-12-07 09:56:00 +00:00
|
|
|
#endif
|
2015-12-07 09:05:58 +00:00
|
|
|
|
2015-01-07 02:53:36 +00:00
|
|
|
/**
|
|
|
|
* check_pause:
|
|
|
|
* @pressed : was libretro pause key pressed?
|
|
|
|
* @frameadvance_pressed : was frameadvance key pressed?
|
|
|
|
*
|
2015-10-09 16:29:57 +00:00
|
|
|
* Check if libretro pause key was pressed. If so, pause or
|
2015-01-07 02:53:36 +00:00
|
|
|
* unpause the libretro core.
|
|
|
|
*
|
|
|
|
* Returns: true if libretro pause key was toggled, otherwise false.
|
|
|
|
**/
|
2015-11-23 14:01:49 +00:00
|
|
|
static bool check_pause(settings_t *settings,
|
2015-11-27 17:56:11 +00:00
|
|
|
bool focus, bool pause_pressed,
|
|
|
|
bool frameadvance_pressed)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
|
|
|
static bool old_focus = true;
|
2015-04-20 18:00:39 +00:00
|
|
|
enum event_command cmd = EVENT_CMD_NONE;
|
2015-12-04 06:56:53 +00:00
|
|
|
bool old_is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
|
2014-10-04 23:31:48 +00:00
|
|
|
|
|
|
|
/* FRAMEADVANCE will set us into pause mode. */
|
2015-12-04 06:56:53 +00:00
|
|
|
pause_pressed |= !old_is_paused && frameadvance_pressed;
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-03-21 07:27:30 +00:00
|
|
|
if (focus && pause_pressed)
|
2015-04-13 08:29:15 +00:00
|
|
|
cmd = EVENT_CMD_PAUSE_TOGGLE;
|
2014-10-04 23:31:48 +00:00
|
|
|
else if (focus && !old_focus)
|
2015-04-13 08:29:15 +00:00
|
|
|
cmd = EVENT_CMD_UNPAUSE;
|
2014-10-04 23:31:48 +00:00
|
|
|
else if (!focus && old_focus)
|
2015-04-13 08:29:15 +00:00
|
|
|
cmd = EVENT_CMD_PAUSE;
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2014-10-05 02:10:00 +00:00
|
|
|
old_focus = focus;
|
|
|
|
|
2015-04-13 08:29:15 +00:00
|
|
|
if (cmd != EVENT_CMD_NONE)
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(cmd);
|
2014-10-29 04:54:29 +00:00
|
|
|
|
2015-12-04 06:56:53 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) == old_is_paused)
|
2014-10-08 14:12:00 +00:00
|
|
|
return false;
|
2014-10-29 04:54:29 +00:00
|
|
|
|
2014-10-08 14:12:00 +00:00
|
|
|
return true;
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 15:29:46 +00:00
|
|
|
/**
|
|
|
|
* check_fast_forward_button:
|
|
|
|
* @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 16:29:57 +00:00
|
|
|
* Checks if the fast forward key has been pressed for this frame.
|
2015-01-07 15:29:46 +00:00
|
|
|
*
|
|
|
|
**/
|
2015-11-29 16:53:11 +00:00
|
|
|
static void check_fast_forward_button(bool fastforward_pressed,
|
2014-10-04 23:31:48 +00:00
|
|
|
bool hold_pressed, bool old_hold_pressed)
|
|
|
|
{
|
2015-01-07 02:53:36 +00:00
|
|
|
/* To avoid continous switching if we hold the button down, we require
|
2015-10-09 16:29:57 +00:00
|
|
|
* that the button must go from pressed to unpressed back to pressed
|
2015-01-07 02:53:36 +00:00
|
|
|
* to be able to toggle between then.
|
|
|
|
*/
|
2014-10-04 23:31:48 +00:00
|
|
|
if (fastforward_pressed)
|
2015-11-29 16:53:11 +00:00
|
|
|
{
|
|
|
|
if (input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL))
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, NULL);
|
|
|
|
else
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_SET_NONBLOCK_STATE, NULL);
|
|
|
|
}
|
2014-10-04 23:31:48 +00:00
|
|
|
else if (old_hold_pressed != hold_pressed)
|
2015-11-29 16:53:11 +00:00
|
|
|
{
|
|
|
|
if (hold_pressed)
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_SET_NONBLOCK_STATE, NULL);
|
|
|
|
else
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, NULL);
|
|
|
|
}
|
2014-10-05 03:39:50 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2015-12-11 10:04:16 +00:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL);
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 15:29:46 +00:00
|
|
|
/**
|
|
|
|
* check_stateslots:
|
|
|
|
* @pressed_increase : is state slot increase key pressed?
|
|
|
|
* @pressed_decrease : is state slot decrease key pressed?
|
|
|
|
*
|
2015-10-09 16:29:57 +00:00
|
|
|
* Checks if the state increase/decrease keys have been pressed
|
|
|
|
* for this frame.
|
2015-01-07 15:29:46 +00:00
|
|
|
**/
|
2015-07-12 17:06:24 +00:00
|
|
|
static void check_stateslots(settings_t *settings,
|
|
|
|
bool pressed_increase, bool pressed_decrease)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
2015-12-04 09:23:39 +00:00
|
|
|
char msg[128];
|
2014-10-05 03:50:04 +00:00
|
|
|
|
2014-10-04 23:31:48 +00:00
|
|
|
/* Save state slots */
|
|
|
|
if (pressed_increase)
|
2015-03-20 18:48:23 +00:00
|
|
|
settings->state_slot++;
|
2014-10-05 03:50:04 +00:00
|
|
|
else if (pressed_decrease)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
2015-03-20 18:48:23 +00:00
|
|
|
if (settings->state_slot > 0)
|
|
|
|
settings->state_slot--;
|
2014-10-04 23:59:15 +00:00
|
|
|
}
|
2014-10-05 03:50:04 +00:00
|
|
|
else
|
|
|
|
return;
|
2014-10-04 23:59:15 +00:00
|
|
|
|
2015-07-01 17:30:34 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s: %d",
|
|
|
|
msg_hash_to_str(MSG_STATE_SLOT),
|
2015-03-20 18:48:23 +00:00
|
|
|
settings->state_slot);
|
2014-10-04 23:59:15 +00:00
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2014-10-04 23:59:15 +00:00
|
|
|
|
2014-10-05 03:50:04 +00:00
|
|
|
RARCH_LOG("%s\n", msg);
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
2015-06-14 16:46:00 +00:00
|
|
|
#define SHADER_EXT_GLSL 0x7c976537U
|
|
|
|
#define SHADER_EXT_GLSLP 0x0f840c87U
|
|
|
|
#define SHADER_EXT_CG 0x0059776fU
|
|
|
|
#define SHADER_EXT_CGP 0x0b8865bfU
|
|
|
|
|
2015-12-07 13:45:15 +00:00
|
|
|
static void shader_dir_free(void)
|
2015-12-01 02:55:31 +00:00
|
|
|
{
|
2015-12-01 03:00:09 +00:00
|
|
|
dir_list_free(runloop_shader_dir.list);
|
|
|
|
runloop_shader_dir.list = NULL;
|
|
|
|
runloop_shader_dir.ptr = 0;
|
2015-12-01 02:55:31 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 13:45:15 +00:00
|
|
|
static bool shader_dir_init(void)
|
2015-12-01 02:55:31 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!*settings->video.shader_dir)
|
|
|
|
return false;
|
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
runloop_shader_dir.list = dir_list_new_special(NULL, DIR_LIST_SHADERS, NULL);
|
2015-12-01 02:55:31 +00:00
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
if (!runloop_shader_dir.list || runloop_shader_dir.list->size == 0)
|
2015-12-01 02:55:31 +00:00
|
|
|
{
|
|
|
|
event_command(EVENT_CMD_SHADER_DIR_DEINIT);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
runloop_shader_dir.ptr = 0;
|
|
|
|
dir_list_sort(runloop_shader_dir.list, false);
|
2015-12-01 02:55:31 +00:00
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
for (i = 0; i < runloop_shader_dir.list->size; i++)
|
2015-12-01 02:55:31 +00:00
|
|
|
RARCH_LOG("%s \"%s\"\n",
|
|
|
|
msg_hash_to_str(MSG_FOUND_SHADER),
|
2015-12-01 03:00:09 +00:00
|
|
|
runloop_shader_dir.list->elems[i].data);
|
2015-12-01 02:55:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-10 20:47:30 +00:00
|
|
|
/**
|
|
|
|
* check_shader_dir:
|
|
|
|
* @pressed_next : was next shader key pressed?
|
|
|
|
* @pressed_previous : was previous shader key pressed?
|
|
|
|
*
|
2015-10-09 16:29:57 +00:00
|
|
|
* Checks if any one of the shader keys has been pressed for this frame:
|
2015-01-10 20:47:30 +00:00
|
|
|
* a) Next shader index.
|
|
|
|
* b) Previous shader index.
|
|
|
|
*
|
|
|
|
* Will also immediately apply the shader.
|
|
|
|
**/
|
2015-12-01 02:51:34 +00:00
|
|
|
static void check_shader_dir(bool pressed_next, bool pressed_prev)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
2015-06-14 16:46:00 +00:00
|
|
|
uint32_t ext_hash;
|
2015-12-06 12:28:20 +00:00
|
|
|
char msg[128];
|
2015-06-12 15:00:37 +00:00
|
|
|
const char *shader = NULL;
|
|
|
|
const char *ext = NULL;
|
2014-10-04 23:31:48 +00:00
|
|
|
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
if (!runloop_shader_dir.list)
|
2014-10-04 23:31:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (pressed_next)
|
|
|
|
{
|
2015-12-01 03:00:09 +00:00
|
|
|
runloop_shader_dir.ptr = (runloop_shader_dir.ptr + 1) %
|
|
|
|
runloop_shader_dir.list->size;
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
else if (pressed_prev)
|
|
|
|
{
|
2015-12-01 03:00:09 +00:00
|
|
|
if (runloop_shader_dir.ptr == 0)
|
|
|
|
runloop_shader_dir.ptr = runloop_shader_dir.list->size - 1;
|
2014-10-04 23:31:48 +00:00
|
|
|
else
|
2015-12-01 03:00:09 +00:00
|
|
|
runloop_shader_dir.ptr--;
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
2014-10-05 03:46:27 +00:00
|
|
|
else
|
2014-10-04 23:31:48 +00:00
|
|
|
return;
|
|
|
|
|
2015-12-01 03:00:09 +00:00
|
|
|
shader = runloop_shader_dir.list->elems[runloop_shader_dir.ptr].data;
|
2015-06-14 16:46:00 +00:00
|
|
|
ext = path_get_extension(shader);
|
2015-07-01 22:56:51 +00:00
|
|
|
ext_hash = msg_hash_calculate(ext);
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-06-14 16:46:00 +00:00
|
|
|
switch (ext_hash)
|
|
|
|
{
|
|
|
|
case SHADER_EXT_GLSL:
|
|
|
|
case SHADER_EXT_GLSLP:
|
|
|
|
type = RARCH_SHADER_GLSL;
|
|
|
|
break;
|
|
|
|
case SHADER_EXT_CG:
|
|
|
|
case SHADER_EXT_CGP:
|
|
|
|
type = RARCH_SHADER_CG;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-07-01 17:30:34 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s #%u: \"%s\".",
|
|
|
|
msg_hash_to_str(MSG_SHADER),
|
2015-12-01 03:00:09 +00:00
|
|
|
(unsigned)runloop_shader_dir.ptr, shader);
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 120, true);
|
2015-07-01 17:30:34 +00:00
|
|
|
RARCH_LOG("%s \"%s\".\n",
|
|
|
|
msg_hash_to_str(MSG_APPLYING_SHADER),
|
|
|
|
shader);
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-02-10 16:20:02 +00:00
|
|
|
if (!video_driver_set_shader(type, shader))
|
2015-08-29 13:05:40 +00:00
|
|
|
RARCH_WARN("%s\n", msg_hash_to_str(MSG_FAILED_TO_APPLY_SHADER));
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 13:16:34 +00:00
|
|
|
/**
|
|
|
|
* rarch_game_specific_options:
|
|
|
|
* @cmd : Output variable with path to core options file.
|
|
|
|
*
|
|
|
|
* Environment callback function implementation.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if a game specific core options path has been found,
|
|
|
|
* otherwise false (0).
|
|
|
|
**/
|
|
|
|
static bool rarch_game_specific_options(char **output)
|
|
|
|
{
|
2015-12-10 21:30:25 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
rarch_system_info_t *system = NULL;
|
2015-12-07 13:16:34 +00:00
|
|
|
const char *core_name = NULL;
|
|
|
|
const char *game_name = NULL;
|
|
|
|
config_file_t *option_file = NULL;
|
|
|
|
char game_path[PATH_MAX_LENGTH] = {0};
|
|
|
|
char config_directory[PATH_MAX_LENGTH] = {0};
|
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
|
|
|
|
2015-12-07 13:16:34 +00:00
|
|
|
core_name = system ? system->info.library_name : NULL;
|
|
|
|
game_name = global ? path_basename(global->name.base) : NULL;
|
|
|
|
|
|
|
|
if (!core_name || !game_name)
|
|
|
|
return false;
|
|
|
|
if (core_name[0] == '\0' || game_name[0] == '\0')
|
|
|
|
return false;
|
|
|
|
|
|
|
|
RARCH_LOG("Per-Game Options: core name: %s\n", core_name);
|
|
|
|
RARCH_LOG("Per-Game Options: game name: %s\n", game_name);
|
|
|
|
|
|
|
|
/* Config directory: config_directory.
|
|
|
|
* Try config directory setting first,
|
|
|
|
* fallback to the location of the current configuration file. */
|
|
|
|
if (settings->menu_config_directory[0] != '\0')
|
|
|
|
strlcpy(config_directory, settings->menu_config_directory, sizeof(config_directory));
|
|
|
|
else if (global->path.config[0] != '\0')
|
|
|
|
fill_pathname_basedir(config_directory, global->path.config, sizeof(config_directory));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RARCH_WARN("Per-Game Options: no config directory set\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Concatenate strings into full paths for game_path */
|
|
|
|
fill_pathname_join(game_path, config_directory, core_name, sizeof(game_path));
|
|
|
|
fill_pathname_join(game_path, game_path, game_name, sizeof(game_path));
|
|
|
|
strlcat(game_path, ".opt", sizeof(game_path));
|
|
|
|
|
|
|
|
option_file = config_file_new(game_path);
|
|
|
|
if (!option_file)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
config_file_free(option_file);
|
|
|
|
|
|
|
|
RARCH_LOG("Per-Game Options: game-specific core options found at %s\n", game_path);
|
|
|
|
*output = strdup(game_path);
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-26 13:00:29 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
static void runloop_data_clear_state(void)
|
2015-11-30 22:29:46 +00:00
|
|
|
{
|
|
|
|
runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL);
|
|
|
|
rarch_task_init();
|
|
|
|
}
|
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
2015-12-04 07:43:05 +00:00
|
|
|
static char runloop_fullpath[PATH_MAX_LENGTH];
|
2015-12-10 21:30:25 +00:00
|
|
|
static rarch_system_info_t runloop_system;
|
2015-12-13 13:31:06 +00:00
|
|
|
static retro_keyboard_event_t runloop_key_event = NULL;
|
|
|
|
static unsigned runloop_max_frames = false;
|
|
|
|
static bool runloop_frame_time_last = 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_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;
|
2015-12-17 22:24:40 +00:00
|
|
|
static bool runloop_game_options_active = false;
|
2015-12-04 07:40:42 +00:00
|
|
|
#ifdef HAVE_THREADS
|
2015-12-13 13:31:06 +00:00
|
|
|
static slock_t *runloop_msg_queue_lock = NULL;
|
2015-12-04 07:40:42 +00:00
|
|
|
#endif
|
2015-12-13 13:31:06 +00:00
|
|
|
static core_info_t *core_info_current = NULL;
|
|
|
|
static core_info_list_t *core_info_curr_list = NULL;
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-09-26 12:57:46 +00:00
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
2015-12-11 09:17:18 +00:00
|
|
|
case RUNLOOP_CTL_DATA_ITERATE:
|
|
|
|
rarch_task_check();
|
|
|
|
return true;
|
2015-12-07 13:45:15 +00:00
|
|
|
case RUNLOOP_CTL_SHADER_DIR_DEINIT:
|
|
|
|
shader_dir_free();
|
|
|
|
return true;
|
|
|
|
case RUNLOOP_CTL_SHADER_DIR_INIT:
|
|
|
|
return shader_dir_init();
|
2015-12-07 12:56:33 +00:00
|
|
|
case RUNLOOP_CTL_SYSTEM_INFO_INIT:
|
2015-12-10 21:30:25 +00:00
|
|
|
core.retro_get_system_info(&runloop_system.info);
|
2015-12-07 12:56:33 +00:00
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
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";
|
2015-12-07 12:56:33 +00:00
|
|
|
|
|
|
|
#ifndef RARCH_CONSOLE
|
2015-12-10 21:30:25 +00:00
|
|
|
strlcpy(runloop_system.title_buf,
|
|
|
|
msg_hash_to_str(MSG_PROGRAM), sizeof(runloop_system.title_buf));
|
|
|
|
strlcat(runloop_system.title_buf, " : ", sizeof(runloop_system.title_buf));
|
2015-12-07 12:56:33 +00:00
|
|
|
#endif
|
2015-12-10 21:30:25 +00:00
|
|
|
strlcat(runloop_system.title_buf, runloop_system.info.library_name, sizeof(runloop_system.title_buf));
|
|
|
|
strlcat(runloop_system.title_buf, " ", sizeof(runloop_system.title_buf));
|
|
|
|
strlcat(runloop_system.title_buf, runloop_system.info.library_version, sizeof(runloop_system.title_buf));
|
|
|
|
strlcpy(runloop_system.valid_extensions, runloop_system.info.valid_extensions ?
|
|
|
|
runloop_system.info.valid_extensions : DEFAULT_EXT,
|
|
|
|
sizeof(runloop_system.valid_extensions));
|
|
|
|
runloop_system.block_extract = runloop_system.info.block_extract;
|
2015-12-07 12:56:33 +00:00
|
|
|
break;
|
2015-12-09 08:37:54 +00:00
|
|
|
case RUNLOOP_CTL_GET_CORE_OPTION_SIZE:
|
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2015-12-10 21:30:25 +00:00
|
|
|
*idx = core_option_size(runloop_system.core_options);
|
2015-12-09 08:37:54 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-12-09 08:34:19 +00:00
|
|
|
case RUNLOOP_CTL_HAS_CORE_OPTIONS:
|
2015-12-10 21:30:25 +00:00
|
|
|
return runloop_system.core_options;
|
2015-12-11 12:33:07 +00:00
|
|
|
case RUNLOOP_CTL_CURRENT_CORE_LIST_FREE:
|
2015-12-11 12:51:17 +00:00
|
|
|
if (core_info_curr_list)
|
|
|
|
core_info_list_free(core_info_curr_list);
|
|
|
|
core_info_curr_list = NULL;
|
|
|
|
return true;
|
|
|
|
case RUNLOOP_CTL_CURRENT_CORE_LIST_INIT:
|
|
|
|
core_info_curr_list = core_info_list_new();
|
|
|
|
return true;
|
|
|
|
case RUNLOOP_CTL_CURRENT_CORE_LIST_GET:
|
2015-12-11 12:33:07 +00:00
|
|
|
{
|
2015-12-11 12:51:17 +00:00
|
|
|
core_info_list_t **core = (core_info_list_t**)data;
|
|
|
|
if (!core)
|
2015-12-11 12:33:07 +00:00
|
|
|
return false;
|
2015-12-11 12:51:17 +00:00
|
|
|
*core = core_info_curr_list;
|
2015-12-11 12:33:07 +00:00
|
|
|
}
|
2015-12-16 02:28:55 +00:00
|
|
|
return true;
|
2015-12-11 12:24:14 +00:00
|
|
|
case RUNLOOP_CTL_CURRENT_CORE_FREE:
|
2015-12-11 12:28:23 +00:00
|
|
|
if (core_info_current)
|
|
|
|
free(core_info_current);
|
|
|
|
core_info_current = NULL;
|
2015-12-11 12:24:14 +00:00
|
|
|
return true;
|
|
|
|
case RUNLOOP_CTL_CURRENT_CORE_INIT:
|
2015-12-11 12:28:23 +00:00
|
|
|
core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t));
|
|
|
|
if (!core_info_current)
|
|
|
|
return false;
|
2015-12-11 12:24:14 +00:00
|
|
|
return true;
|
2015-12-11 12:19:40 +00:00
|
|
|
case RUNLOOP_CTL_CURRENT_CORE_GET:
|
|
|
|
{
|
|
|
|
core_info_t **core = (core_info_t**)data;
|
2015-12-11 12:28:23 +00:00
|
|
|
if (!core)
|
2015-12-11 12:19:40 +00:00
|
|
|
return false;
|
2015-12-11 12:28:23 +00:00
|
|
|
*core = core_info_current;
|
2015-12-11 12:19:40 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-12-10 21:30:25 +00:00
|
|
|
case RUNLOOP_CTL_SYSTEM_INFO_GET:
|
|
|
|
{
|
|
|
|
rarch_system_info_t **system = (rarch_system_info_t**)data;
|
|
|
|
if (!system)
|
|
|
|
return false;
|
|
|
|
*system = &runloop_system;
|
|
|
|
}
|
|
|
|
return true;
|
2015-12-07 12:56:33 +00:00
|
|
|
case RUNLOOP_CTL_SYSTEM_INFO_FREE:
|
2015-12-10 21:30:25 +00:00
|
|
|
if (runloop_system.core_options)
|
2015-12-07 12:56:33 +00:00
|
|
|
{
|
2015-12-10 21:30:25 +00:00
|
|
|
core_option_flush(runloop_system.core_options);
|
|
|
|
core_option_free(runloop_system.core_options);
|
2015-12-07 12:56:33 +00:00
|
|
|
}
|
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
runloop_system.core_options = NULL;
|
2015-12-07 13:02:01 +00:00
|
|
|
|
2015-12-07 12:56:33 +00:00
|
|
|
/* No longer valid. */
|
2015-12-10 21:30:25 +00:00
|
|
|
if (runloop_system.special)
|
|
|
|
free(runloop_system.special);
|
|
|
|
runloop_system.special = NULL;
|
|
|
|
if (runloop_system.ports)
|
|
|
|
free(runloop_system.ports);
|
|
|
|
runloop_system.ports = NULL;
|
|
|
|
|
2015-12-13 13:31:06 +00:00
|
|
|
runloop_key_event = NULL;
|
2015-12-10 21:30:25 +00:00
|
|
|
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
|
2015-12-07 12:56:33 +00:00
|
|
|
break;
|
2015-12-04 09:18:14 +00:00
|
|
|
case RUNLOOP_CTL_IS_FRAME_COUNT_END:
|
|
|
|
{
|
|
|
|
uint64_t *frame_count = NULL;
|
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
|
|
|
|
return runloop_max_frames && (*frame_count >= runloop_max_frames);
|
|
|
|
}
|
2015-12-04 11:26:39 +00:00
|
|
|
case RUNLOOP_CTL_SET_FRAME_TIME_LAST:
|
|
|
|
runloop_frame_time_last = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_FRAME_TIME_LAST:
|
|
|
|
runloop_frame_time_last = false;
|
|
|
|
break;
|
2015-12-10 20:43:44 +00:00
|
|
|
case RUNLOOP_CTL_SET_OVERRIDES_ACTIVE:
|
|
|
|
runloop_overrides_active = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE:
|
|
|
|
runloop_overrides_active = false;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_OVERRIDES_ACTIVE:
|
|
|
|
return runloop_overrides_active;
|
2015-12-17 22:24:40 +00: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 11:26:39 +00:00
|
|
|
case RUNLOOP_CTL_IS_FRAME_TIME_LAST:
|
|
|
|
return runloop_frame_time_last;
|
2015-12-04 08:54:12 +00: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 11:37:24 +00:00
|
|
|
case RUNLOOP_CTL_GET_PERFCNT:
|
2015-12-04 06:22:42 +00:00
|
|
|
{
|
2015-12-10 11:37:24 +00:00
|
|
|
bool **perfcnt = (bool**)data;
|
|
|
|
if (!perfcnt)
|
|
|
|
return false;
|
|
|
|
*perfcnt = &runloop_perfcnt_enable;
|
2015-12-04 06:22:42 +00:00
|
|
|
}
|
2015-12-10 11:37:24 +00:00
|
|
|
return true;
|
|
|
|
case RUNLOOP_CTL_SET_PERFCNT_ENABLE:
|
|
|
|
runloop_perfcnt_enable = true;
|
2015-11-30 20:56:35 +00:00
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_PERFCNT_ENABLE:
|
2015-12-10 11:37:24 +00:00
|
|
|
runloop_perfcnt_enable = false;
|
2015-11-30 20:56:35 +00:00
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_IS_PERFCNT_ENABLE:
|
2015-12-10 11:37:24 +00:00
|
|
|
return runloop_perfcnt_enable;
|
2015-12-01 02:46:56 +00:00
|
|
|
case RUNLOOP_CTL_GET_WINDOWED_SCALE:
|
|
|
|
{
|
|
|
|
unsigned **scale = (unsigned**)data;
|
|
|
|
if (!scale)
|
|
|
|
return false;
|
2015-12-01 02:51:34 +00:00
|
|
|
*scale = (unsigned*)&runloop_pending_windowed_scale;
|
2015-12-01 02:46:56 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_WINDOWED_SCALE:
|
2015-11-18 10:55:11 +00:00
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2015-12-01 02:51:34 +00:00
|
|
|
runloop_pending_windowed_scale = *idx;
|
2015-11-18 10:55:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_LIBRETRO_PATH:
|
2015-11-18 10:15:23 +00:00
|
|
|
{
|
|
|
|
const char *fullpath = (const char*)data;
|
|
|
|
if (!fullpath)
|
|
|
|
return false;
|
|
|
|
strlcpy(settings->libretro, fullpath, sizeof(settings->libretro));
|
|
|
|
}
|
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CLEAR_CONTENT_PATH:
|
2015-11-30 22:45:29 +00:00
|
|
|
*runloop_fullpath = '\0';
|
2015-11-18 10:43:25 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_GET_CONTENT_PATH:
|
2015-11-18 10:43:25 +00:00
|
|
|
{
|
|
|
|
char **fullpath = (char**)data;
|
|
|
|
if (!fullpath)
|
|
|
|
return false;
|
2015-11-30 22:45:29 +00:00
|
|
|
*fullpath = (char*)runloop_fullpath;
|
2015-11-18 10:43:25 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_CONTENT_PATH:
|
2015-11-18 10:15:23 +00:00
|
|
|
{
|
|
|
|
const char *fullpath = (const char*)data;
|
|
|
|
if (!fullpath)
|
|
|
|
return false;
|
2015-11-30 22:45:29 +00:00
|
|
|
strlcpy(runloop_fullpath, fullpath, sizeof(runloop_fullpath));
|
2015-11-18 10:15:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-12-04 07:40:42 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_FOCUS:
|
|
|
|
if (settings->pause_nonactive)
|
|
|
|
return video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL);
|
|
|
|
return true;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_IDLE_STATE:
|
2015-11-27 19:13:52 +00:00
|
|
|
{
|
|
|
|
event_cmd_state_t *cmd = (event_cmd_state_t*)data;
|
2015-12-04 07:40:42 +00:00
|
|
|
bool focused = runloop_ctl(RUNLOOP_CTL_CHECK_FOCUS, NULL);
|
2015-11-27 19:13:52 +00:00
|
|
|
|
|
|
|
check_pause(settings, focused,
|
2015-12-07 14:36:58 +00:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_PAUSE_TOGGLE),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE));
|
2015-11-27 19:13:52 +00:00
|
|
|
|
2015-12-04 07:40:42 +00:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_CHECK_PAUSE_STATE, cmd) || !focused)
|
2015-11-27 19:13:52 +00:00
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_STATE:
|
2015-09-26 13:24:05 +00:00
|
|
|
{
|
2015-12-07 09:58:10 +00:00
|
|
|
bool tmp = false;
|
2015-09-26 13:24:05 +00:00
|
|
|
event_cmd_state_t *cmd = (event_cmd_state_t*)data;
|
|
|
|
|
2015-12-04 02:07:05 +00:00
|
|
|
if (!cmd || runloop_idle)
|
2015-09-26 13:24:05 +00:00
|
|
|
return false;
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_SCREENSHOT))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_TAKE_SCREENSHOT);
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_MUTE))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_AUDIO_MUTE_TOGGLE);
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_OSK))
|
2015-11-30 02:23:35 +00:00
|
|
|
{
|
|
|
|
if (input_driver_ctl(RARCH_INPUT_CTL_IS_KEYBOARD_LINEFEED_ENABLED, NULL))
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_UNSET_KEYBOARD_LINEFEED_ENABLED, NULL);
|
|
|
|
else
|
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_SET_KEYBOARD_LINEFEED_ENABLED, NULL);
|
|
|
|
}
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_press(cmd, RARCH_VOLUME_UP))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_VOLUME_UP);
|
2015-12-07 14:36:58 +00:00
|
|
|
else if (runloop_cmd_press(cmd, RARCH_VOLUME_DOWN))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_VOLUME_DOWN);
|
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-07 14:36:58 +00:00
|
|
|
tmp = runloop_cmd_triggered(cmd, RARCH_NETPLAY_FLIP);
|
2015-12-07 10:04:32 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, &tmp);
|
2015-12-07 14:36:58 +00:00
|
|
|
tmp = runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY);
|
2015-12-07 10:04:32 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_FULLSCREEN_TOGGLE, &tmp);
|
2015-09-26 13:24:05 +00:00
|
|
|
#endif
|
2015-11-30 20:42:59 +00:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_CHECK_IDLE_STATE, data))
|
2015-11-27 17:56:11 +00:00
|
|
|
return false;
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-11-29 16:53:11 +00:00
|
|
|
check_fast_forward_button(
|
2015-12-07 14:36:58 +00: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));
|
2015-12-07 09:25:45 +00:00
|
|
|
check_stateslots(settings,
|
2015-12-07 14:36:58 +00:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_PLUS),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_MINUS)
|
2015-12-07 09:25:45 +00:00
|
|
|
);
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_SAVE_STATE_KEY))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_SAVE_STATE);
|
2015-12-07 14:36:58 +00:00
|
|
|
else if (runloop_cmd_triggered(cmd, RARCH_LOAD_STATE_KEY))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_LOAD_STATE);
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
state_manager_check_rewind(runloop_cmd_press(cmd, RARCH_REWIND));
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
tmp = runloop_cmd_press(cmd, RARCH_SLOWMOTION);
|
2015-12-07 09:58:10 +00:00
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_CHECK_SLOWMOTION, &tmp);
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE))
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE, NULL);
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 09:05:58 +00:00
|
|
|
check_shader_dir(
|
2015-12-07 14:36:58 +00:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_SHADER_PREV));
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_DISK_EJECT_TOGGLE))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_DISK_EJECT_TOGGLE);
|
2015-12-07 14:36:58 +00:00
|
|
|
else if (runloop_cmd_triggered(cmd, RARCH_DISK_NEXT))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_DISK_NEXT);
|
2015-12-07 14:36:58 +00:00
|
|
|
else if (runloop_cmd_triggered(cmd, RARCH_DISK_PREV))
|
2015-10-09 16:29:57 +00:00
|
|
|
event_command(EVENT_CMD_DISK_PREV);
|
2015-09-26 13:24:05 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_RESET))
|
2015-09-26 13:24:05 +00:00
|
|
|
event_command(EVENT_CMD_RESET);
|
|
|
|
|
2015-12-01 01:43:34 +00:00
|
|
|
cheat_manager_state_checks(
|
2015-12-07 14:36:58 +00:00
|
|
|
runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_PLUS),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_MINUS),
|
|
|
|
runloop_cmd_triggered(cmd, RARCH_CHEAT_TOGGLE));
|
2015-09-26 13:24:05 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_PAUSE_STATE:
|
2015-09-26 13:16:28 +00:00
|
|
|
{
|
|
|
|
bool check_is_oneshot;
|
|
|
|
event_cmd_state_t *cmd = (event_cmd_state_t*)data;
|
|
|
|
|
|
|
|
if (!cmd)
|
|
|
|
return false;
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
check_is_oneshot = runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE)
|
|
|
|
|| runloop_cmd_press(cmd, RARCH_REWIND);
|
2015-09-26 13:16:28 +00:00
|
|
|
|
2015-12-04 06:56:53 +00:00
|
|
|
if (!runloop_paused)
|
2015-09-26 13:16:28 +00:00
|
|
|
return true;
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY))
|
2015-09-26 13:16:28 +00:00
|
|
|
{
|
|
|
|
event_command(EVENT_CMD_FULLSCREEN_TOGGLE);
|
2015-11-20 14:34:10 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
2015-09-26 13:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!check_is_oneshot)
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_SLOWMOTION:
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
|
|
|
|
2015-12-04 06:42:37 +00:00
|
|
|
runloop_slowmotion = *ptr;
|
2015-09-26 12:57:46 +00:00
|
|
|
|
2015-12-04 06:42:37 +00:00
|
|
|
if (!runloop_slowmotion)
|
2015-09-26 12:57:46 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (settings->video.black_frame_insertion)
|
2015-11-20 14:34:10 +00:00
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
2015-09-26 12:57:46 +00:00
|
|
|
|
|
|
|
if (state_manager_frame_is_reversed())
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(MSG_SLOW_MOTION_REWIND, 0, 30, true);
|
2015-09-26 12:57:46 +00:00
|
|
|
else
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(MSG_SLOW_MOTION, 0, 30, true);
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_MOVIE:
|
2015-11-30 23:08:02 +00:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL))
|
2015-11-30 20:42:59 +00:00
|
|
|
return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK, NULL);
|
2015-11-30 23:04:04 +00:00
|
|
|
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-11-30 20:42:59 +00:00
|
|
|
return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_INIT, NULL);
|
|
|
|
return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_RECORD, NULL);
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_MOVIE_RECORD:
|
2015-11-30 23:04:04 +00:00
|
|
|
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-09-26 12:57:46 +00:00
|
|
|
return false;
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(
|
2015-09-26 12:57:46 +00:00
|
|
|
MSG_MOVIE_RECORD_STOPPED, 2, 180, true);
|
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED));
|
|
|
|
|
|
|
|
event_command(EVENT_CMD_BSV_MOVIE_DEINIT);
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_MOVIE_INIT:
|
2015-11-30 23:04:04 +00:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-09-26 12:57:46 +00:00
|
|
|
return false;
|
|
|
|
{
|
2015-12-06 12:28:20 +00:00
|
|
|
char msg[128];
|
|
|
|
char path[PATH_MAX_LENGTH];
|
2015-09-26 12:57:46 +00:00
|
|
|
|
|
|
|
settings->rewind_granularity = 1;
|
|
|
|
|
|
|
|
if (settings->state_slot > 0)
|
|
|
|
snprintf(path, sizeof(path), "%s%d",
|
2015-12-01 00:38:45 +00:00
|
|
|
bsv_movie_get_path(), settings->state_slot);
|
2015-09-26 12:57:46 +00:00
|
|
|
else
|
2015-12-01 00:38:45 +00:00
|
|
|
strlcpy(path, bsv_movie_get_path(), sizeof(path));
|
2015-09-26 12:57:46 +00:00
|
|
|
|
|
|
|
strlcat(path, ".bsv", sizeof(path));
|
|
|
|
|
|
|
|
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
|
|
|
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
|
|
|
path);
|
|
|
|
|
2015-12-01 00:38:45 +00:00
|
|
|
bsv_movie_init_handle(path, RARCH_MOVIE_RECORD);
|
2015-09-26 12:57:46 +00:00
|
|
|
|
2015-11-30 23:04:04 +00:00
|
|
|
if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-09-26 13:35:01 +00:00
|
|
|
return false;
|
2015-11-30 23:04:04 +00:00
|
|
|
else if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, 180, true);
|
2015-09-26 12:57:46 +00:00
|
|
|
RARCH_LOG("%s \"%s\".\n",
|
|
|
|
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
|
|
|
path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(
|
2015-09-26 12:57:46 +00:00
|
|
|
MSG_FAILED_TO_START_MOVIE_RECORD,
|
|
|
|
1, 180, true);
|
|
|
|
RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD));
|
|
|
|
}
|
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK:
|
2015-12-01 00:29:16 +00:00
|
|
|
if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL))
|
2015-09-26 12:57:46 +00:00
|
|
|
return false;
|
|
|
|
|
2015-12-07 14:32:14 +00:00
|
|
|
runloop_msg_queue_push_new(
|
2015-09-26 12:57:46 +00:00
|
|
|
MSG_MOVIE_PLAYBACK_ENDED, 1, 180, false);
|
|
|
|
RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED));
|
|
|
|
|
|
|
|
event_command(EVENT_CMD_BSV_MOVIE_DEINIT);
|
|
|
|
|
2015-11-30 23:16:48 +00:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL);
|
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL);
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_STATE_FREE:
|
2015-12-10 11:37:24 +00:00
|
|
|
runloop_perfcnt_enable = false;
|
2015-12-04 02:07:05 +00:00
|
|
|
runloop_idle = false;
|
2015-12-04 06:56:53 +00:00
|
|
|
runloop_paused = false;
|
2015-12-04 06:42:37 +00:00
|
|
|
runloop_slowmotion = false;
|
2015-12-07 07:34:57 +00:00
|
|
|
runloop_frame_time_last = false;
|
|
|
|
runloop_set_frame_limit = false;
|
2015-12-10 20:43:44 +00:00
|
|
|
runloop_overrides_active = false;
|
2015-12-04 09:18:14 +00:00
|
|
|
runloop_max_frames = 0;
|
2015-09-26 19:32:41 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_GLOBAL_FREE:
|
2015-12-04 06:18:39 +00:00
|
|
|
{
|
|
|
|
global_t *global;
|
|
|
|
event_command(EVENT_CMD_TEMPORARY_CONTENT_DEINIT);
|
|
|
|
event_command(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT);
|
|
|
|
event_command(EVENT_CMD_RECORD_DEINIT);
|
|
|
|
event_command(EVENT_CMD_LOG_FILE_DEINIT);
|
|
|
|
|
|
|
|
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
|
|
|
|
runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL);
|
2015-12-10 20:43:44 +00:00
|
|
|
runloop_overrides_active = false;
|
2015-12-04 06:18:39 +00:00
|
|
|
|
|
|
|
global = global_get_ptr();
|
|
|
|
memset(global, 0, sizeof(struct global));
|
|
|
|
}
|
2015-09-26 19:30:20 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_CLEAR_STATE:
|
2015-12-11 09:43:53 +00:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_DEINIT, NULL);
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL);
|
|
|
|
runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL);
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_MAX_FRAMES:
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
|
|
|
unsigned *ptr = (unsigned*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 09:18:14 +00:00
|
|
|
runloop_max_frames = *ptr;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_IS_IDLE:
|
2015-12-04 02:07:05 +00:00
|
|
|
return runloop_idle;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_IDLE:
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 02:07:05 +00:00
|
|
|
runloop_idle = *ptr;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_IS_SLOWMOTION:
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 06:42:37 +00:00
|
|
|
*ptr = runloop_slowmotion;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_SLOWMOTION:
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 06:42:37 +00:00
|
|
|
runloop_slowmotion = *ptr;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_PAUSED:
|
2015-09-26 12:57:46 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
if (!ptr)
|
|
|
|
return false;
|
2015-12-04 06:56:53 +00:00
|
|
|
runloop_paused = *ptr;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
2015-09-26 13:35:01 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_IS_PAUSED:
|
2015-12-04 06:56:53 +00:00
|
|
|
return runloop_paused;
|
2015-12-04 07:40:42 +00:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_FREE:
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_free(runloop_msg_queue_lock);
|
2015-12-07 06:48:14 +00:00
|
|
|
runloop_msg_queue_lock = NULL;
|
2015-12-07 06:52:11 +00:00
|
|
|
#endif
|
2015-12-04 07:40:42 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_DEINIT:
|
2015-12-04 09:23:39 +00:00
|
|
|
if (!g_msg_queue)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL);
|
|
|
|
|
|
|
|
msg_queue_free(g_msg_queue);
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL);
|
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_FREE, NULL);
|
|
|
|
|
|
|
|
g_msg_queue = NULL;
|
2015-11-28 23:15:51 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_INIT:
|
2015-11-30 20:42:59 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL);
|
2015-12-04 07:40:42 +00:00
|
|
|
g_msg_queue = msg_queue_new(8);
|
|
|
|
retro_assert(g_msg_queue);
|
|
|
|
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
runloop_msg_queue_lock = slock_new();
|
|
|
|
retro_assert(runloop_msg_queue_lock);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_LOCK:
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_lock(runloop_msg_queue_lock);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_MSG_QUEUE_UNLOCK:
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
slock_unlock(runloop_msg_queue_lock);
|
|
|
|
#endif
|
2015-11-28 23:15:51 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_PREPARE_DUMMY:
|
2015-11-28 23:29:41 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-07 15:01:18 +00:00
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL);
|
2015-11-28 23:29:41 +00:00
|
|
|
#endif
|
2015-12-07 15:01:18 +00:00
|
|
|
runloop_data_clear_state();
|
2015-11-28 23:29:41 +00:00
|
|
|
|
2015-12-07 15:01:18 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL);
|
2015-11-28 23:29:41 +00:00
|
|
|
|
2015-12-07 15:01:18 +00:00
|
|
|
rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL);
|
2015-11-28 23:29:41 +00:00
|
|
|
break;
|
2015-11-30 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_CORE_SHUTDOWN:
|
2015-12-04 07:00:51 +00:00
|
|
|
runloop_core_shutdown_initiated = true;
|
2015-11-30 14:43:49 +00:00
|
|
|
break;
|
2015-12-04 07:00:51 +00: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 11:44:12 +00: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 20:35:50 +00:00
|
|
|
case RUNLOOP_CTL_SET_EXEC:
|
2015-12-04 02:01:48 +00:00
|
|
|
runloop_exec = true;
|
|
|
|
break;
|
|
|
|
case RUNLOOP_CTL_UNSET_EXEC:
|
|
|
|
runloop_exec = false;
|
2015-11-30 14:46:39 +00:00
|
|
|
break;
|
2015-12-04 02:01:48 +00:00
|
|
|
case RUNLOOP_CTL_IS_EXEC:
|
|
|
|
return runloop_exec;
|
2015-11-30 22:29:46 +00:00
|
|
|
case RUNLOOP_CTL_DATA_DEINIT:
|
|
|
|
rarch_task_deinit();
|
|
|
|
break;
|
2015-12-07 13:13:07 +00:00
|
|
|
case RUNLOOP_CTL_IS_CORE_OPTION_UPDATED:
|
2015-12-10 21:30:25 +00:00
|
|
|
return runloop_system.core_options ?
|
|
|
|
core_option_updated(runloop_system.core_options) : false;
|
2015-12-09 08:21:49 +00:00
|
|
|
case RUNLOOP_CTL_CORE_OPTION_PREV:
|
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2015-12-10 21:30:25 +00:00
|
|
|
core_option_prev(runloop_system.core_options, *idx);
|
2015-12-09 08:21:49 +00:00
|
|
|
if (ui_companion_is_on_foreground())
|
|
|
|
ui_companion_driver_notify_refresh();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
case RUNLOOP_CTL_CORE_OPTION_NEXT:
|
|
|
|
{
|
|
|
|
unsigned *idx = (unsigned*)data;
|
|
|
|
if (!idx)
|
|
|
|
return false;
|
2015-12-10 21:30:25 +00:00
|
|
|
core_option_next(runloop_system.core_options, *idx);
|
2015-12-09 08:21:49 +00:00
|
|
|
if (ui_companion_is_on_foreground())
|
|
|
|
ui_companion_driver_notify_refresh();
|
|
|
|
}
|
|
|
|
return true;
|
2015-12-07 13:13:07 +00:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_GET:
|
|
|
|
{
|
|
|
|
struct retro_variable *var = (struct retro_variable*)data;
|
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
if (!runloop_system.core_options || !var)
|
2015-12-07 13:13:07 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
RARCH_LOG("Environ GET_VARIABLE %s:\n", var->key);
|
2015-12-10 21:30:25 +00:00
|
|
|
core_option_get(runloop_system.core_options, var);
|
2015-12-07 13:13:07 +00:00
|
|
|
RARCH_LOG("\t%s\n", var->value ? var->value : "N/A");
|
|
|
|
}
|
|
|
|
return true;
|
2015-12-07 13:16:34 +00:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_INIT:
|
|
|
|
{
|
|
|
|
char *game_options_path = NULL;
|
|
|
|
bool ret = false;
|
|
|
|
const struct retro_variable *vars = (const struct retro_variable*)data;
|
|
|
|
char buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
const char *options_path = settings->core_options_path;
|
|
|
|
|
|
|
|
if (!*options_path && *global->path.config)
|
|
|
|
{
|
|
|
|
fill_pathname_resolve_relative(buf, global->path.config,
|
|
|
|
"retroarch-core-options.cfg", sizeof(buf));
|
|
|
|
options_path = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (settings->game_specific_options)
|
|
|
|
ret = rarch_game_specific_options(&game_options_path);
|
|
|
|
|
|
|
|
if(ret)
|
|
|
|
{
|
2015-12-17 22:24:40 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE, NULL);
|
2015-12-10 21:30:25 +00:00
|
|
|
runloop_system.core_options = core_option_new(game_options_path, vars);
|
2015-12-07 13:16:34 +00:00
|
|
|
free(game_options_path);
|
|
|
|
}
|
|
|
|
else
|
2015-12-17 22:24:40 +00:00
|
|
|
{
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL);
|
2015-12-10 21:30:25 +00:00
|
|
|
runloop_system.core_options = core_option_new(options_path, vars);
|
2015-12-17 22:24:40 +00:00
|
|
|
}
|
2015-12-07 13:16:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
2015-12-07 13:13:07 +00:00
|
|
|
case RUNLOOP_CTL_CORE_OPTIONS_DEINIT:
|
2015-12-10 21:30:25 +00:00
|
|
|
if (!runloop_system.core_options)
|
2015-12-07 13:13:07 +00:00
|
|
|
return false;
|
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
core_option_flush(runloop_system.core_options);
|
|
|
|
core_option_free(runloop_system.core_options);
|
2015-12-07 13:13:07 +00:00
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
runloop_system.core_options = NULL;
|
2015-12-07 13:13:07 +00:00
|
|
|
return true;
|
2015-12-13 13:31:06 +00:00
|
|
|
case RUNLOOP_CTL_KEY_EVENT_GET:
|
|
|
|
{
|
|
|
|
retro_keyboard_event_t **key_event = (retro_keyboard_event_t**)data;
|
|
|
|
if (!key_event)
|
|
|
|
return false;
|
|
|
|
*key_event = &runloop_key_event;
|
|
|
|
}
|
|
|
|
break;
|
2015-12-07 13:13:07 +00:00
|
|
|
case RUNLOOP_CTL_NONE:
|
2015-09-26 13:35:01 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
|
|
|
|
2015-09-26 13:35:01 +00:00
|
|
|
return true;
|
2015-09-26 12:57:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-05 00:45:38 +00:00
|
|
|
|
2015-02-21 06:29:13 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-12-07 14:22:36 +00:00
|
|
|
static void runloop_iterate_linefeed_overlay(settings_t *settings)
|
2015-02-21 07:42:19 +00:00
|
|
|
{
|
2015-02-21 07:47:03 +00:00
|
|
|
static char prev_overlay_restore = false;
|
2015-11-30 02:14:26 +00:00
|
|
|
bool osk_enable = input_driver_ctl(RARCH_INPUT_CTL_IS_OSK_ENABLED, NULL);
|
2015-02-21 07:47:03 +00:00
|
|
|
|
2015-11-30 02:23:35 +00:00
|
|
|
if (osk_enable && !input_driver_ctl(RARCH_INPUT_CTL_IS_KEYBOARD_LINEFEED_ENABLED, NULL))
|
2015-02-21 07:42:19 +00:00
|
|
|
{
|
2015-11-30 02:14:26 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_UNSET_OSK_ENABLED, NULL);
|
2015-03-18 18:40:00 +00:00
|
|
|
prev_overlay_restore = true;
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_OVERLAY_DEINIT);
|
2015-02-21 07:42:19 +00:00
|
|
|
}
|
2015-11-30 02:23:35 +00:00
|
|
|
else if (!osk_enable && input_driver_ctl(RARCH_INPUT_CTL_IS_KEYBOARD_LINEFEED_ENABLED, NULL))
|
2015-02-21 07:42:19 +00:00
|
|
|
{
|
2015-11-30 02:14:26 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_SET_OSK_ENABLED, NULL);
|
2015-03-18 18:40:00 +00:00
|
|
|
prev_overlay_restore = false;
|
2015-04-13 09:26:02 +00:00
|
|
|
event_command(EVENT_CMD_OVERLAY_INIT);
|
2015-02-21 07:42:19 +00:00
|
|
|
}
|
2015-02-21 07:47:03 +00:00
|
|
|
else if (prev_overlay_restore)
|
|
|
|
{
|
2015-07-09 02:05:59 +00:00
|
|
|
if (!settings->input.overlay_hide_in_menu)
|
|
|
|
event_command(EVENT_CMD_OVERLAY_INIT);
|
2015-02-21 07:47:03 +00:00
|
|
|
prev_overlay_restore = false;
|
|
|
|
}
|
2015-02-21 07:42:19 +00:00
|
|
|
}
|
2015-02-21 07:52:29 +00:00
|
|
|
#endif
|
2015-02-21 07:42:19 +00:00
|
|
|
|
2015-03-24 09:01:17 +00:00
|
|
|
|
|
|
|
|
2015-10-09 16:29:57 +00:00
|
|
|
/* Time to exit out of the main loop?
|
2015-09-30 17:09:05 +00: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 14:22:36 +00:00
|
|
|
static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed)
|
2015-09-30 17:09:05 +00:00
|
|
|
{
|
2015-12-04 11:44:12 +00:00
|
|
|
bool time_to_exit = runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL) || quit_key_pressed;
|
2015-12-04 09:18:14 +00:00
|
|
|
time_to_exit = time_to_exit || (video_driver_ctl(RARCH_DISPLAY_CTL_IS_ALIVE, NULL) == false);
|
|
|
|
time_to_exit = time_to_exit || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL);
|
|
|
|
time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_FRAME_COUNT_END, NULL);
|
|
|
|
time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_EXEC, NULL);
|
|
|
|
|
|
|
|
if (!time_to_exit)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_EXEC, NULL))
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_EXEC, NULL);
|
|
|
|
|
2015-12-04 11:48:33 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_CORE_SHUTDOWN, NULL))
|
2015-09-30 17:09:05 +00:00
|
|
|
{
|
2015-12-04 11:48:33 +00:00
|
|
|
/* Quits out of RetroArch main loop.
|
|
|
|
* On special case, loads dummy core
|
|
|
|
* instead of exiting RetroArch completely.
|
|
|
|
* Aborts core shutdown if invoked.
|
|
|
|
*/
|
|
|
|
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
if (!settings->load_dummy_on_core_shutdown)
|
|
|
|
return -1;
|
2015-12-04 09:18:14 +00:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL))
|
|
|
|
return -1;
|
2015-09-30 17:09:05 +00:00
|
|
|
|
2015-12-04 11:44:12 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_SHUTDOWN, NULL);
|
2015-12-04 09:18:14 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_CORE_SHUTDOWN, NULL);
|
2015-09-30 17:09:05 +00:00
|
|
|
|
2015-12-04 09:18:14 +00:00
|
|
|
return 0;
|
2015-09-30 17:09:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-04 09:18:14 +00:00
|
|
|
return -1;
|
2015-09-30 17:09:05 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 02:53:36 +00:00
|
|
|
/**
|
2015-12-07 14:22:36 +00:00
|
|
|
* runloop_iterate:
|
2014-10-04 23:31:48 +00:00
|
|
|
*
|
2015-01-09 21:24:38 +00:00
|
|
|
* Run Libretro core in RetroArch for one frame.
|
2015-01-07 02:53:36 +00:00
|
|
|
*
|
2015-01-11 16:33:05 +00:00
|
|
|
* Returns: 0 on success, 1 if we have to wait until button input in order
|
2015-10-09 16:29:57 +00:00
|
|
|
* to wake up the loop, -1 if we forcibly quit out of the RetroArch iteration loop.
|
2015-01-07 02:53:36 +00:00
|
|
|
**/
|
2015-12-07 14:22:36 +00:00
|
|
|
int runloop_iterate(unsigned *sleep_ms)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
2015-08-05 13:54:21 +00:00
|
|
|
event_cmd_state_t cmd;
|
2015-12-07 09:05:58 +00:00
|
|
|
event_cmd_state_t *cmd_ptr = &cmd;
|
2015-09-26 19:03:38 +00:00
|
|
|
retro_time_t current, target, to_sleep_ms;
|
2015-12-04 11:27:37 +00:00
|
|
|
static retro_usec_t frame_time_last = 0;
|
2015-12-04 08:54:12 +00:00
|
|
|
static retro_time_t frame_limit_minimum_time = 0.0;
|
|
|
|
static retro_time_t frame_limit_last_time = 0.0;
|
|
|
|
static retro_input_t last_input = 0;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
global_t *global = global_get_ptr();
|
2015-12-10 21:30:25 +00:00
|
|
|
rarch_system_info_t *system = NULL;
|
2015-12-10 20:31:28 +00:00
|
|
|
|
|
|
|
cmd.state[1] = last_input;
|
|
|
|
cmd.state[0] = input_keys_pressed();
|
|
|
|
last_input = cmd.state[0];
|
2015-12-04 08:54:12 +00:00
|
|
|
|
2015-12-10 21:30:25 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
|
|
|
|
2015-12-04 11:26:39 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_FRAME_TIME_LAST, NULL))
|
|
|
|
{
|
|
|
|
frame_time_last = 0;
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_FRAME_TIME_LAST, NULL);
|
|
|
|
}
|
|
|
|
|
2015-12-04 08:54:12 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT, NULL))
|
|
|
|
{
|
|
|
|
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
|
|
|
|
float fastforward_ratio = (settings->fastforward_ratio == 0.0f)
|
|
|
|
? 1.0f : settings->fastforward_ratio;
|
|
|
|
|
|
|
|
frame_limit_last_time = retro_get_time_usec();
|
|
|
|
frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f
|
|
|
|
/ (av_info->timing.fps * fastforward_ratio));
|
|
|
|
|
|
|
|
runloop_ctl(RUNLOOP_CTL_UNSET_FRAME_LIMIT, NULL);
|
|
|
|
}
|
2015-06-26 17:37:03 +00:00
|
|
|
|
2015-11-29 16:23:30 +00:00
|
|
|
if (input_driver_ctl(RARCH_INPUT_CTL_IS_FLUSHING_INPUT, NULL))
|
2015-08-06 01:17:56 +00:00
|
|
|
{
|
2015-11-29 16:23:30 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT, NULL);
|
2015-12-10 20:31:28 +00:00
|
|
|
if (cmd.state[0])
|
2015-08-06 01:17:56 +00:00
|
|
|
{
|
2015-12-10 20:31:28 +00:00
|
|
|
cmd.state[0] = 0;
|
2015-08-06 01:20:15 +00:00
|
|
|
|
|
|
|
/* If core was paused before entering menu, evoke
|
|
|
|
* pause toggle to wake it up. */
|
2015-12-04 06:56:53 +00:00
|
|
|
if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
|
2015-12-10 20:31:28 +00:00
|
|
|
BIT64_SET(cmd.state[0], RARCH_PAUSE_TOGGLE);
|
2015-11-29 16:23:30 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
|
2015-08-06 01:17:56 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-06-25 11:06:06 +00:00
|
|
|
if (system->frame_time.callback)
|
2015-09-26 19:06:27 +00:00
|
|
|
{
|
|
|
|
/* Updates frame timing if frame timing callback is in use by the core.
|
|
|
|
* Limits frame time if fast forward ratio throttle is enabled. */
|
|
|
|
|
2015-12-04 06:42:37 +00:00
|
|
|
bool is_slowmotion;
|
2015-09-26 19:06:27 +00:00
|
|
|
retro_time_t current = retro_get_time_usec();
|
2015-12-04 11:26:39 +00:00
|
|
|
retro_time_t delta = current - frame_time_last;
|
2015-12-04 06:56:53 +00:00
|
|
|
bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) ||
|
2015-11-29 16:53:11 +00:00
|
|
|
input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) |
|
2015-12-05 15:05:35 +00:00
|
|
|
!!recording_driver_get_data_ptr();
|
2015-09-26 19:06:27 +00:00
|
|
|
|
2015-12-04 06:42:37 +00:00
|
|
|
runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, &is_slowmotion);
|
|
|
|
|
2015-12-04 11:26:39 +00:00
|
|
|
if (!frame_time_last || is_locked_fps)
|
2015-09-26 19:06:27 +00:00
|
|
|
delta = system->frame_time.reference;
|
|
|
|
|
2015-12-04 06:42:37 +00:00
|
|
|
if (!is_locked_fps && is_slowmotion)
|
2015-09-26 19:06:27 +00:00
|
|
|
delta /= settings->slowmotion_ratio;
|
|
|
|
|
2015-12-04 11:26:39 +00:00
|
|
|
frame_time_last = current;
|
2015-09-26 19:06:27 +00:00
|
|
|
|
|
|
|
if (is_locked_fps)
|
2015-12-04 11:26:39 +00:00
|
|
|
frame_time_last = 0;
|
2015-09-26 19:06:27 +00:00
|
|
|
|
|
|
|
system->frame_time.callback(delta);
|
|
|
|
}
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-12-10 20:31:28 +00:00
|
|
|
cmd.state[2] = cmd.state[0] & ~cmd.state[1]; /* trigger */
|
2015-10-22 16:29:35 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd_ptr, RARCH_OVERLAY_NEXT))
|
2015-09-26 13:08:52 +00:00
|
|
|
event_command(EVENT_CMD_OVERLAY_NEXT);
|
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd_ptr, RARCH_FULLSCREEN_TOGGLE_KEY))
|
2015-12-04 10:21:06 +00:00
|
|
|
{
|
|
|
|
bool fullscreen_toggled = !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
|
2015-10-27 23:55:11 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-05 12:49:22 +00:00
|
|
|
fullscreen_toggled = fullscreen_toggled || menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
|
2015-10-27 23:55:11 +00:00
|
|
|
#endif
|
2015-12-04 09:49:09 +00:00
|
|
|
|
2015-12-04 10:21:06 +00:00
|
|
|
if (fullscreen_toggled)
|
|
|
|
event_command(EVENT_CMD_FULLSCREEN_TOGGLE);
|
|
|
|
}
|
2015-09-26 13:08:52 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_triggered(cmd_ptr, RARCH_GRAB_MOUSE_TOGGLE))
|
2015-09-26 13:08:52 +00:00
|
|
|
event_command(EVENT_CMD_GRAB_MOUSE_TOGGLE);
|
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_cmd_menu_press(cmd_ptr) || (global->inited.core.type == CORE_TYPE_DUMMY))
|
2015-09-26 19:03:38 +00:00
|
|
|
{
|
2015-12-05 12:49:22 +00:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-09-26 19:03:38 +00:00
|
|
|
{
|
|
|
|
if (global->inited.main && (global->inited.core.type != CORE_TYPE_DUMMY))
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
2015-09-26 19:03:38 +00:00
|
|
|
}
|
|
|
|
else
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
|
2015-09-26 19:03:38 +00:00
|
|
|
}
|
2015-09-26 13:08:52 +00:00
|
|
|
#endif
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-02-21 06:29:13 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-12-07 14:22:36 +00:00
|
|
|
runloop_iterate_linefeed_overlay(settings);
|
2015-02-21 06:29:13 +00:00
|
|
|
#endif
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-12-07 14:36:58 +00:00
|
|
|
if (runloop_iterate_time_to_exit(runloop_cmd_press(cmd_ptr, RARCH_QUIT_KEY)) != 1)
|
2015-12-04 08:54:12 +00:00
|
|
|
{
|
|
|
|
frame_limit_last_time = 0.0;
|
2015-09-30 17:09:05 +00:00
|
|
|
return -1;
|
2015-12-04 08:54:12 +00:00
|
|
|
}
|
2015-08-27 10:43:35 +00:00
|
|
|
|
2015-10-09 16:29:57 +00:00
|
|
|
|
2015-08-27 10:48:35 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-12-05 12:49:22 +00:00
|
|
|
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
|
2015-08-27 10:48:35 +00:00
|
|
|
{
|
2015-12-04 07:40:42 +00:00
|
|
|
bool focused = runloop_ctl(RUNLOOP_CTL_CHECK_FOCUS, NULL) && !ui_companion_is_on_foreground();
|
2015-11-30 20:42:59 +00:00
|
|
|
bool is_idle = runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL);
|
2015-11-28 14:03:59 +00:00
|
|
|
|
2015-12-10 20:31:28 +00:00
|
|
|
if (menu_driver_iterate((enum menu_action)menu_input_frame_retropad(cmd.state[0], cmd.state[2])) == -1)
|
2015-11-30 20:28:55 +00:00
|
|
|
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
|
2015-11-28 02:22:20 +00:00
|
|
|
|
2015-11-28 14:57:27 +00:00
|
|
|
if (focused || !is_idle)
|
2015-12-10 18:43:25 +00:00
|
|
|
menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL);
|
2015-11-28 14:03:59 +00:00
|
|
|
|
2015-11-28 14:57:27 +00:00
|
|
|
if (!focused || is_idle)
|
2015-11-28 02:41:30 +00:00
|
|
|
{
|
|
|
|
*sleep_ms = 10;
|
|
|
|
return 1;
|
|
|
|
}
|
2015-11-28 02:22:20 +00:00
|
|
|
|
2015-09-26 19:03:38 +00:00
|
|
|
goto end;
|
2015-08-27 10:48:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-11-30 20:42:59 +00:00
|
|
|
if (!runloop_ctl(RUNLOOP_CTL_CHECK_STATE, &cmd))
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
2015-08-27 11:13:14 +00:00
|
|
|
/* RetroArch has been paused. */
|
2015-12-05 15:54:03 +00:00
|
|
|
retro_ctx.poll_cb();
|
2015-08-27 12:52:02 +00:00
|
|
|
*sleep_ms = 10;
|
2015-01-11 17:04:42 +00:00
|
|
|
return 1;
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(HAVE_THREADS)
|
|
|
|
lock_autosave();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:27:00 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_PRE_FRAME, NULL);
|
2014-10-04 23:31:48 +00:00
|
|
|
#endif
|
|
|
|
|
2015-11-30 23:04:04 +00:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-11-30 23:16:48 +00:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_START, NULL);
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-06-25 11:06:06 +00:00
|
|
|
if (system->camera_callback.caps)
|
2014-10-04 23:31:48 +00:00
|
|
|
driver_camera_poll();
|
|
|
|
|
|
|
|
/* Update binds for analog dpad modes. */
|
2015-03-20 18:48:23 +00:00
|
|
|
for (i = 0; i < settings->input.max_users; i++)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
2015-03-20 18:48:23 +00:00
|
|
|
if (!settings->input.analog_dpad_mode[i])
|
2014-10-04 23:31:48 +00:00
|
|
|
continue;
|
|
|
|
|
2015-03-20 18:48:23 +00: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-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 16:53:11 +00:00
|
|
|
if ((settings->video.frame_delay > 0) &&
|
|
|
|
!input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL))
|
2015-09-22 16:55:14 +00:00
|
|
|
retro_sleep(settings->video.frame_delay);
|
2014-10-04 23:31:48 +00:00
|
|
|
|
|
|
|
/* Run libretro for one frame. */
|
2015-10-06 17:34:09 +00:00
|
|
|
core.retro_run();
|
2015-10-16 16:04:59 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CHEEVOS
|
2015-10-09 18:29:50 +00:00
|
|
|
/* Test the achievements. */
|
|
|
|
cheevos_test();
|
2015-10-16 16:04:59 +00:00
|
|
|
#endif
|
2014-10-04 23:31:48 +00:00
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
for (i = 0; i < settings->input.max_users; i++)
|
2014-10-04 23:31:48 +00:00
|
|
|
{
|
2015-03-20 18:48:23 +00:00
|
|
|
if (!settings->input.analog_dpad_mode[i])
|
2014-10-04 23:31:48 +00:00
|
|
|
continue;
|
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
input_pop_analog_dpad(settings->input.binds[i]);
|
|
|
|
input_pop_analog_dpad(settings->input.autoconf_binds[i]);
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|
|
|
|
|
2015-11-30 23:04:04 +00:00
|
|
|
if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL))
|
2015-11-30 23:16:48 +00:00
|
|
|
bsv_movie_ctl(BSV_MOVIE_CTL_SET_FRAME_END, NULL);
|
2014-10-04 23:31:48 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_NETPLAY
|
2015-12-05 15:27:00 +00:00
|
|
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_POST_FRAME, NULL);
|
2014-10-04 23:31:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_THREADS)
|
|
|
|
unlock_autosave();
|
|
|
|
#endif
|
|
|
|
|
2015-09-28 16:12:02 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-09-26 19:03:38 +00:00
|
|
|
end:
|
2015-09-28 16:12:02 +00:00
|
|
|
#endif
|
2015-09-26 19:03:38 +00:00
|
|
|
if (!settings->fastforward_ratio)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
current = retro_get_time_usec();
|
|
|
|
target = frame_limit_last_time + frame_limit_minimum_time;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_limit_last_time = retro_get_time_usec();
|
|
|
|
|
|
|
|
return 0;
|
2014-10-04 23:31:48 +00:00
|
|
|
}
|