forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 2
/
led_overlay.c
70 lines (55 loc) · 1.39 KB
/
led_overlay.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#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
{
int setup[MAX_LEDS];
int map[MAX_LEDS];
} overlayled_t;
static overlayled_t curins;
static overlayled_t *cur = &curins;
static void overlay_init(void)
{
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)
{
int gpio = 0;
if ((led < 0) || (led >= MAX_LEDS))
{
RARCH_WARN("[LED]: invalid led %d\n", led);
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 = {
overlay_init,
overlay_free,
overlay_set,
"Overlay"
};