Revert "remove inter-frame input polling"

This reverts commit 089c3016cc.
This commit is contained in:
Anthony Pesch 2017-07-05 00:24:43 -04:00
parent ca02533471
commit f007ca1f4a
5 changed files with 29 additions and 1 deletions

View File

@ -62,7 +62,6 @@ struct emu {
struct render_backend *r, *r2;
struct imgui *imgui;
struct microprofile *mp;
struct trace_writer *trace_writer;
/* hosts which support creating multiple gl contexts will render video on
@ -565,6 +564,12 @@ static void emu_paint(struct emu *emu) {
/*
* dreamcast guest interface
*/
static void emu_guest_poll_input(void *userdata) {
struct emu *emu = userdata;
input_poll(emu->host);
}
static void emu_guest_vertical_blank(void *userdata) {
struct emu *emu = userdata;
@ -827,6 +832,7 @@ struct emu *emu_create(struct host *host) {
emu->dc->start_render = &emu_guest_start_render;
emu->dc->finish_render = &emu_guest_finish_render;
emu->dc->vertical_blank = &emu_guest_vertical_blank;
emu->dc->poll_input = &emu_guest_poll_input;
/* start up the video thread */
emu->multi_threaded = video_supports_multiple_contexts(emu->host);

View File

@ -16,6 +16,14 @@
#include "guest/scheduler.h"
#include "guest/sh4/sh4.h"
void dc_poll_input(struct dreamcast *dc) {
if (!dc->poll_input) {
return;
}
dc->poll_input(dc->userdata);
}
void dc_vertical_blank(struct dreamcast *dc) {
if (!dc->vertical_blank) {
return;

View File

@ -126,6 +126,7 @@ typedef void (*push_audio_cb)(void *, const int16_t *, int);
typedef void (*start_render_cb)(void *, struct tile_context *);
typedef void (*finish_render_cb)(void *);
typedef void (*vertical_blank_cb)(void *);
typedef void (*poll_input_cb)(void *);
struct dreamcast {
int running;
@ -155,6 +156,7 @@ struct dreamcast {
start_render_cb start_render;
finish_render_cb finish_render;
vertical_blank_cb vertical_blank;
poll_input_cb poll_input;
};
struct dreamcast *dc_create();
@ -193,5 +195,6 @@ void dc_push_audio(struct dreamcast *dc, const int16_t *data, int frames);
void dc_start_render(struct dreamcast *dc, struct tile_context *ctx);
void dc_finish_render(struct dreamcast *dc);
void dc_vertical_blank(struct dreamcast *dc);
void dc_poll_input(struct dreamcast *dc);
#endif

View File

@ -33,6 +33,12 @@ struct controller {
struct maple_cond cnd;
};
static void controller_update(struct controller *ctrl) {
/* dc_poll_input will call into controller_input if new values are
available */
dc_poll_input(ctrl->dc);
}
static int controller_input(struct maple_device *dev, int button,
int16_t value) {
struct controller *ctrl = (struct controller *)dev;
@ -95,6 +101,8 @@ static int controller_frame(struct maple_device *dev,
}
case MAPLE_REQ_GETCOND: {
controller_update(ctrl);
res->header.command = MAPLE_RES_TRANSFER;
res->header.recv_addr = frame->header.send_addr;
res->header.send_addr = frame->header.recv_addr;

View File

@ -858,6 +858,9 @@ int main(int argc, char **argv) {
if (emu_load_game(emu, load)) {
while (!g_host->closed) {
/* even though the emulator itself will poll for events when updating
controller input, the main loop needs to also poll to ensure the
close event is received */
host_poll_events(g_host);
/* only step the emulator if the available audio is running low. this