mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Allow enable/disable overlay.
This commit is contained in:
parent
47a98ef205
commit
cc2e4015b5
@ -23,6 +23,7 @@ struct input_overlay
|
|||||||
{
|
{
|
||||||
void *iface_data;
|
void *iface_data;
|
||||||
const video_overlay_interface_t *iface;
|
const video_overlay_interface_t *iface;
|
||||||
|
bool enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
input_overlay_t *input_overlay_new(const char *overlay)
|
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);
|
free(img.pixels);
|
||||||
|
|
||||||
ol->iface->enable(ol->iface_data, true);
|
ol->iface->enable(ol->iface_data, true);
|
||||||
|
ol->enable = true;
|
||||||
|
|
||||||
return ol;
|
return ol;
|
||||||
|
|
||||||
@ -65,6 +67,12 @@ error:
|
|||||||
return NULL;
|
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
|
struct overlay_desc
|
||||||
{
|
{
|
||||||
float x;
|
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)
|
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.
|
// norm_x and norm_y is in [-0x7fff, 0x7fff] range, like RETRO_DEVICE_POINTER.
|
||||||
float x = (float)(norm_x + 0x7fff) / 0xffff;
|
float x = (float)(norm_x + 0x7fff) / 0xffff;
|
||||||
float y = (float)(norm_y + 0x7fff) / 0xffff;
|
float y = (float)(norm_y + 0x7fff) / 0xffff;
|
||||||
|
@ -29,6 +29,8 @@ typedef struct input_overlay input_overlay_t;
|
|||||||
input_overlay_t *input_overlay_new(const char *overlay);
|
input_overlay_t *input_overlay_new(const char *overlay);
|
||||||
void input_overlay_free(input_overlay_t *ol);
|
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().
|
// norm_x and norm_y are the result of input_translate_coord_viewport().
|
||||||
// Resulting state is a bitmask of (1 << key_bind_id).
|
// 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);
|
uint64_t input_overlay_poll(input_overlay_t *ol, int16_t norm_x, int16_t norm_y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user