Avoid "double-tapping" overlay on overlay_next.

This commit is contained in:
Themaister 2013-02-17 15:00:38 +01:00
parent d487162cb0
commit 041bfecf21
3 changed files with 24 additions and 0 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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