mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Add poll-type - can change it only at compile-time right now
This commit is contained in:
parent
cce5d3e900
commit
9ad50f91e8
@ -599,6 +599,7 @@ static bool event_init_core(void)
|
|||||||
if (!event_init_content())
|
if (!event_init_content())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
core.poll_type = POLL_TYPE_LATE;
|
||||||
retro_init_libretro_cbs(&retro_ctx);
|
retro_init_libretro_cbs(&retro_ctx);
|
||||||
rarch_ctl(RARCH_CTL_INIT_SYSTEM_AV_INFO, NULL);
|
rarch_ctl(RARCH_CTL_INIT_SYSTEM_AV_INFO, NULL);
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ bool rarch_environment_cb(unsigned cmd, void *data);
|
|||||||
|
|
||||||
struct retro_core_t
|
struct retro_core_t
|
||||||
{
|
{
|
||||||
|
unsigned poll_type;
|
||||||
void (*retro_init)(void);
|
void (*retro_init)(void);
|
||||||
void (*retro_deinit)(void);
|
void (*retro_deinit)(void);
|
||||||
unsigned (*retro_api_version)(void);
|
unsigned (*retro_api_version)(void);
|
||||||
|
@ -37,6 +37,21 @@
|
|||||||
|
|
||||||
struct retro_callbacks retro_ctx;
|
struct retro_callbacks retro_ctx;
|
||||||
|
|
||||||
|
static bool input_polled;
|
||||||
|
|
||||||
|
static int16_t input_state_poll(unsigned port,
|
||||||
|
unsigned device, unsigned idx, unsigned id)
|
||||||
|
{
|
||||||
|
if (core.poll_type == POLL_TYPE_LATE)
|
||||||
|
{
|
||||||
|
if (!input_polled)
|
||||||
|
input_poll();
|
||||||
|
|
||||||
|
input_polled = true;
|
||||||
|
}
|
||||||
|
return input_state(port, device, idx, id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retro_set_default_callbacks:
|
* retro_set_default_callbacks:
|
||||||
* @data : pointer to retro_callbacks object
|
* @data : pointer to retro_callbacks object
|
||||||
@ -53,7 +68,7 @@ void retro_set_default_callbacks(void *data)
|
|||||||
cbs->frame_cb = video_driver_frame;
|
cbs->frame_cb = video_driver_frame;
|
||||||
cbs->sample_cb = audio_driver_sample;
|
cbs->sample_cb = audio_driver_sample;
|
||||||
cbs->sample_batch_cb = audio_driver_sample_batch;
|
cbs->sample_batch_cb = audio_driver_sample_batch;
|
||||||
cbs->state_cb = input_state;
|
cbs->state_cb = input_state_poll;
|
||||||
cbs->poll_cb = input_poll;
|
cbs->poll_cb = input_poll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +83,27 @@ void retro_uninit_libretro_cbs(void)
|
|||||||
cbs->poll_cb = NULL;
|
cbs->poll_cb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void retro_run_core(void)
|
||||||
|
{
|
||||||
|
switch (core.poll_type)
|
||||||
|
{
|
||||||
|
case POLL_TYPE_EARLY:
|
||||||
|
input_poll();
|
||||||
|
break;
|
||||||
|
case POLL_TYPE_LATE:
|
||||||
|
input_polled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
core.retro_run();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void input_poll_maybe(void)
|
||||||
|
{
|
||||||
|
if (core.poll_type == POLL_TYPE_NORMAL)
|
||||||
|
input_poll();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retro_init_libretro_cbs:
|
* retro_init_libretro_cbs:
|
||||||
* @data : pointer to retro_callbacks object
|
* @data : pointer to retro_callbacks object
|
||||||
@ -88,8 +124,8 @@ void retro_init_libretro_cbs(void *data)
|
|||||||
core.retro_set_video_refresh(video_driver_frame);
|
core.retro_set_video_refresh(video_driver_frame);
|
||||||
core.retro_set_audio_sample(audio_driver_sample);
|
core.retro_set_audio_sample(audio_driver_sample);
|
||||||
core.retro_set_audio_sample_batch(audio_driver_sample_batch);
|
core.retro_set_audio_sample_batch(audio_driver_sample_batch);
|
||||||
core.retro_set_input_state(input_state);
|
core.retro_set_input_state(input_state_poll);
|
||||||
core.retro_set_input_poll(input_poll);
|
core.retro_set_input_poll(input_poll_maybe);
|
||||||
|
|
||||||
retro_set_default_callbacks(cbs);
|
retro_set_default_callbacks(cbs);
|
||||||
|
|
||||||
@ -97,6 +133,9 @@ void retro_init_libretro_cbs(void *data)
|
|||||||
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Force normal poll type for netplay. */
|
||||||
|
core.poll_type = POLL_TYPE_NORMAL;
|
||||||
|
|
||||||
if (global->netplay.is_spectate)
|
if (global->netplay.is_spectate)
|
||||||
{
|
{
|
||||||
core.retro_set_input_state(
|
core.retro_set_input_state(
|
||||||
|
@ -24,6 +24,17 @@ extern "C" {
|
|||||||
|
|
||||||
#include "libretro.h"
|
#include "libretro.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* Polling is performed before call to retro_run */
|
||||||
|
POLL_TYPE_EARLY = 0,
|
||||||
|
/* Polling is performed when requested. */
|
||||||
|
POLL_TYPE_NORMAL,
|
||||||
|
/* Polling is performed on first call to retro_input_state
|
||||||
|
* per frame. */
|
||||||
|
POLL_TYPE_LATE
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct retro_callbacks
|
typedef struct retro_callbacks
|
||||||
{
|
{
|
||||||
retro_video_refresh_t frame_cb;
|
retro_video_refresh_t frame_cb;
|
||||||
@ -60,6 +71,9 @@ void retro_set_default_callbacks(void *data);
|
|||||||
**/
|
**/
|
||||||
void retro_set_rewind_callbacks(void);
|
void retro_set_rewind_callbacks(void);
|
||||||
|
|
||||||
|
/* Runs the core for one frame. Use instead of core.retro_run(). */
|
||||||
|
void retro_run_core(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retro_flush_audio:
|
* retro_flush_audio:
|
||||||
* @data : pointer to audio buffer.
|
* @data : pointer to audio buffer.
|
||||||
|
@ -321,7 +321,7 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
|||||||
if (!libretro_input_is_blocked)
|
if (!libretro_input_is_blocked)
|
||||||
input_driver_ctl(RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL);
|
input_driver_ctl(RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL);
|
||||||
|
|
||||||
core.retro_run();
|
retro_run_core();
|
||||||
|
|
||||||
input_driver_ctl(RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL);
|
input_driver_ctl(RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL);
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "../gfx/video_context_driver.h"
|
#include "../gfx/video_context_driver.h"
|
||||||
#include "../gfx/font_driver.h"
|
#include "../gfx/font_driver.h"
|
||||||
#include "../gfx/video_common.h"
|
#include "../gfx/video_common.h"
|
||||||
|
#include "../libretro_version_1.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -77,7 +77,7 @@ static void netplay_net_post_frame(netplay_t *netplay)
|
|||||||
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
|
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
|
||||||
lock_autosave();
|
lock_autosave();
|
||||||
#endif
|
#endif
|
||||||
core.retro_run();
|
retro_run_core();
|
||||||
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
|
#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE)
|
||||||
unlock_autosave();
|
unlock_autosave();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1424,7 +1424,7 @@ int runloop_iterate(unsigned *sleep_ms)
|
|||||||
retro_sleep(settings->video.frame_delay);
|
retro_sleep(settings->video.frame_delay);
|
||||||
|
|
||||||
/* Run libretro for one frame. */
|
/* Run libretro for one frame. */
|
||||||
core.retro_run();
|
retro_run_core();
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
/* Test the achievements. */
|
/* Test the achievements. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user