diff --git a/input/overlay.c b/input/overlay.c index 2039b6bfd3..d92313681b 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -23,6 +23,7 @@ struct input_overlay { void *iface_data; const video_overlay_interface_t *iface; + bool enable; }; input_overlay_t *input_overlay_new(const char *overlay) @@ -57,6 +58,7 @@ input_overlay_t *input_overlay_new(const char *overlay) free(img.pixels); ol->iface->enable(ol->iface_data, true); + ol->enable = true; return ol; @@ -65,6 +67,12 @@ error: return NULL; } +void input_overlay_enable(input_overlay_t *ol, bool enable) +{ + ol->enable = enable; + ol->iface->enable(ol->iface_data, enable); +} + struct overlay_desc { float x; @@ -96,6 +104,9 @@ static const struct overlay_desc descs[] = { uint64_t input_overlay_poll(input_overlay_t *ol, int16_t norm_x, int16_t norm_y) { + if (!ol->enable) + return 0; + // norm_x and norm_y is in [-0x7fff, 0x7fff] range, like RETRO_DEVICE_POINTER. float x = (float)(norm_x + 0x7fff) / 0xffff; float y = (float)(norm_y + 0x7fff) / 0xffff; diff --git a/input/overlay.h b/input/overlay.h index 4c020f82ae..85c875470e 100644 --- a/input/overlay.h +++ b/input/overlay.h @@ -29,6 +29,8 @@ typedef struct input_overlay input_overlay_t; input_overlay_t *input_overlay_new(const char *overlay); void input_overlay_free(input_overlay_t *ol); +void input_overlay_enable(input_overlay_t *ol, bool enable); + // norm_x and norm_y are the result of input_translate_coord_viewport(). // 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);