Allow enable/disable overlay.

This commit is contained in:
Themaister 2012-12-20 15:37:04 +01:00
parent 47a98ef205
commit cc2e4015b5
2 changed files with 13 additions and 0 deletions

View File

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

View File

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