RetroArch/led/drivers/led_overlay.c

60 lines
1.2 KiB
C
Raw Permalink Normal View History

#include <stdio.h>
#include "../led_driver.h"
#include "../led_defines.h"
#include "../../input/input_overlay.h"
#include "../../configuration.h"
#include "../../retroarch.h"
typedef struct
{
2018-01-05 12:27:52 +00:00
int setup[MAX_LEDS];
int map[MAX_LEDS];
} overlayled_t;
2020-07-20 18:22:13 +00:00
/* TODO/FIXME - static globals */
2020-09-22 01:05:58 +00:00
static overlayled_t ledoverlay_curins;
static overlayled_t *ledoverlay_cur = &ledoverlay_curins;
static void overlay_init(void)
{
2018-01-05 12:27:52 +00:00
int i;
settings_t *settings = config_get_ptr();
for (i = 0; i < MAX_LEDS; i++)
{
2020-09-22 01:05:58 +00:00
ledoverlay_cur->setup[i] = 0;
ledoverlay_cur->map[i] = settings->uints.led_map[i];
2018-01-05 12:27:52 +00:00
2020-09-22 01:05:58 +00:00
if (ledoverlay_cur->map[i] >= 0)
input_overlay_set_visibility(ledoverlay_cur->map[i],
2018-01-05 12:27:52 +00:00
OVERLAY_VISIBILITY_HIDDEN);
}
}
static void overlay_free(void)
{
}
static void overlay_set(int led, int state)
{
2018-01-05 12:27:52 +00:00
int gpio = 0;
if ((led < 0) || (led >= MAX_LEDS))
return;
2022-08-23 06:11:22 +00:00
if ((gpio = ledoverlay_cur->map[led]) < 0)
2018-01-05 12:27:52 +00:00
return;
input_overlay_set_visibility(gpio,
2019-02-03 23:49:35 +00:00
state ? OVERLAY_VISIBILITY_VISIBLE
2018-01-05 12:27:52 +00:00
: OVERLAY_VISIBILITY_HIDDEN);
}
2019-02-03 23:49:35 +00:00
const led_driver_t overlay_led_driver = {
2018-01-05 12:27:52 +00:00
overlay_init,
overlay_free,
overlay_set,
"Overlay"
2018-01-05 12:27:52 +00:00
};