RetroArch/led/drivers/led_overlay.c

62 lines
1.2 KiB
C
Raw 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 13:27:52 +01:00
int setup[MAX_LEDS];
int map[MAX_LEDS];
} overlayled_t;
2020-07-20 20:22:13 +02:00
/* TODO/FIXME - static globals */
2020-09-22 03:05:58 +02:00
static overlayled_t ledoverlay_curins;
static overlayled_t *ledoverlay_cur = &ledoverlay_curins;
static void overlay_init(void)
{
2018-01-05 13:27:52 +01:00
int i;
settings_t *settings = config_get_ptr();
for (i = 0; i < MAX_LEDS; i++)
{
2020-09-22 03:05:58 +02:00
ledoverlay_cur->setup[i] = 0;
ledoverlay_cur->map[i] = settings->uints.led_map[i];
2018-01-05 13:27:52 +01:00
2020-09-22 03:05:58 +02:00
if (ledoverlay_cur->map[i] >= 0)
input_overlay_set_visibility(ledoverlay_cur->map[i],
2018-01-05 13:27:52 +01:00
OVERLAY_VISIBILITY_HIDDEN);
}
}
static void overlay_free(void)
{
}
static void overlay_set(int led, int state)
{
2018-01-05 13:27:52 +01:00
int gpio = 0;
if ((led < 0) || (led >= MAX_LEDS))
return;
2020-09-22 03:05:58 +02:00
gpio = ledoverlay_cur->map[led];
2018-01-05 13:27:52 +01:00
if (gpio < 0)
return;
input_overlay_set_visibility(gpio,
2019-02-03 15:49:35 -08:00
state ? OVERLAY_VISIBILITY_VISIBLE
2018-01-05 13:27:52 +01:00
: OVERLAY_VISIBILITY_HIDDEN);
}
2019-02-03 15:49:35 -08:00
const led_driver_t overlay_led_driver = {
2018-01-05 13:27:52 +01:00
overlay_init,
overlay_free,
overlay_set,
"Overlay"
2018-01-05 13:27:52 +01:00
};