2018-01-04 12:45:01 -05:00
|
|
|
#include <stdio.h>
|
2018-01-10 16:52:32 -08:00
|
|
|
#include "../led_driver.h"
|
|
|
|
#include "../led_defines.h"
|
2018-01-04 12:45:01 -05:00
|
|
|
|
2019-06-17 15:10:22 +02:00
|
|
|
#include "../../input/input_overlay.h"
|
|
|
|
|
2018-01-10 16:52:32 -08:00
|
|
|
#include "../../configuration.h"
|
2019-06-17 15:10:22 +02:00
|
|
|
#include "../../retroarch.h"
|
2018-01-04 12:45:01 -05:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2018-01-05 13:27:52 +01:00
|
|
|
int setup[MAX_LEDS];
|
|
|
|
int map[MAX_LEDS];
|
2018-01-04 12:45:01 -05:00
|
|
|
} 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;
|
2018-01-04 12:45:01 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2018-01-04 12:45:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void overlay_free(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-01-10 16:52:32 -08:00
|
|
|
static void overlay_set(int led, int state)
|
2018-01-04 12:45:01 -05:00
|
|
|
{
|
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);
|
2018-01-04 12:45:01 -05:00
|
|
|
}
|
|
|
|
|
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,
|
2018-01-10 16:52:32 -08:00
|
|
|
overlay_set,
|
|
|
|
"Overlay"
|
2018-01-05 13:27:52 +01:00
|
|
|
};
|