From 041bfecf21cb39c8428c0ac3a8e06d4a2c78fb44 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 17 Feb 2013 15:00:38 +0100 Subject: [PATCH] Avoid "double-tapping" overlay on overlay_next. --- input/overlay.c | 16 ++++++++++++++++ input/overlay.h | 3 +++ retroarch.c | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/input/overlay.c b/input/overlay.c index 7ce145247c..b14fdcb0ff 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -66,6 +66,8 @@ struct input_overlay const video_overlay_interface_t *iface; bool enable; + bool blocked; + struct overlay *overlays; const struct overlay *active; size_t index; @@ -390,7 +392,10 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) uint64_t input_overlay_poll(input_overlay_t *ol, int16_t norm_x, int16_t norm_y) { if (!ol->enable) + { + ol->blocked = false; return 0; + } // norm_x and norm_y is in [-0x7fff, 0x7fff] range, like RETRO_DEVICE_POINTER. float x = (float)(norm_x + 0x7fff) / 0xffff; @@ -408,9 +413,19 @@ uint64_t input_overlay_poll(input_overlay_t *ol, int16_t norm_x, int16_t norm_y) state |= ol->active->descs[i].key_mask; } + if (!state) + ol->blocked = false; + else if (ol->blocked) + state = 0; + return state; } +void input_overlay_poll_clear(input_overlay_t *ol) +{ + ol->blocked = false; +} + void input_overlay_next(input_overlay_t *ol) { ol->index = (ol->index + 1) % ol->size; @@ -420,6 +435,7 @@ void input_overlay_next(input_overlay_t *ol) ol->iface->vertex_geom(ol->iface_data, ol->active->mod_x, ol->active->mod_y, ol->active->mod_w, ol->active->mod_h); ol->iface->full_screen(ol->iface_data, ol->active->full_screen); + ol->blocked = true; } bool input_overlay_full_screen(input_overlay_t *ol) diff --git a/input/overlay.h b/input/overlay.h index c8d25fe1db..b6362ada30 100644 --- a/input/overlay.h +++ b/input/overlay.h @@ -37,6 +37,9 @@ bool input_overlay_full_screen(input_overlay_t *ol); // Resulting state is a bitmask of (1 << key_bind_id). uint64_t input_overlay_poll(input_overlay_t *ol, int16_t norm_x, int16_t norm_y); +// Call when there is nothing to poll. Allows overlay to clear certain state. +void input_overlay_poll_clear(input_overlay_t *ol); + // Sets a modulating factor for alpha channel. Default is 1.0. // The alpha factor is applied for all overlays. void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); diff --git a/retroarch.c b/retroarch.c index dd20006b7d..06dd7de0cd 100644 --- a/retroarch.c +++ b/retroarch.c @@ -482,6 +482,7 @@ static inline void input_poll_overlay(void) unsigned device = input_overlay_full_screen(driver.overlay) ? RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER; + bool polled = false; for (unsigned i = 0; input_input_state_func(NULL, 0, device, i, RETRO_DEVICE_ID_POINTER_PRESSED); i++) @@ -492,7 +493,11 @@ static inline void input_poll_overlay(void) device, i, RETRO_DEVICE_ID_POINTER_Y); driver.overlay_state |= input_overlay_poll(driver.overlay, x, y); + polled = true; } + + if (!polled) + input_overlay_poll_clear(driver.overlay); } #endif