RetroArch/led/drivers/led_overlay.c

71 lines
1.4 KiB
C
Raw Normal View History

#include <stdio.h>
#include "../led_driver.h"
#include "../led_defines.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#include "../../gfx/video_driver.h"
#include "../../input/input_overlay.h"
typedef struct
{
2018-01-05 12:27:52 +00:00
int setup[MAX_LEDS];
int map[MAX_LEDS];
} overlayled_t;
static overlayled_t curins;
static overlayled_t *cur = &curins;
static void overlay_init(void)
{
2018-01-05 12:27:52 +00:00
int i;
settings_t *settings = config_get_ptr();
RARCH_LOG("[LED]: overlay LED driver init\n");
for (i = 0; i < MAX_LEDS; i++)
{
cur->setup[i] = 0;
cur->map[i] = settings->uints.led_map[i];
RARCH_LOG("[LED]: overlay map[%d]=%d\n",i,cur->map[i]);
if (cur->map[i] >= 0)
input_overlay_set_visibility(cur->map[i],
OVERLAY_VISIBILITY_HIDDEN);
}
}
static void overlay_free(void)
{
RARCH_LOG("[LED]: overlay LED driver free\n");
}
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))
{
RARCH_WARN("[LED]: invalid led %d\n", led);
2018-01-05 12:27:52 +00:00
return;
}
gpio = cur->map[led];
if (gpio < 0)
return;
input_overlay_set_visibility(gpio,
state ? OVERLAY_VISIBILITY_VISIBLE
: OVERLAY_VISIBILITY_HIDDEN);
RARCH_LOG("[LED]: set visibility %d %d\n", gpio, state);
}
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
};