1 /*  RetroArch - A frontend for libretro.
2  *
3  *  RetroArch is free software: you can redistribute it and/or modify it under the terms
4  *  of the GNU General Public License as published by the Free Software Found-
5  *  ation, either version 3 of the License, or (at your option) any later version.
6  *
7  *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  *  PURPOSE.  See the GNU General Public License for more details.
10  *
11  *  You should have received a copy of the GNU General Public License along with RetroArch.
12  *  If not, see <http://www.gnu.org/licenses/>.
13  */
14 
15 #include <stdio.h>
16 #include <string/stdstring.h>
17 
18 #include "led_driver.h"
19 
20 static const led_driver_t *current_led_driver = NULL;
21 
null_led_init(void)22 static void null_led_init(void) { }
null_led_free(void)23 static void null_led_free(void) { }
null_led_set(int led,int state)24 static void null_led_set(int led, int state) { }
25 
26 static const led_driver_t null_led_driver = {
27    null_led_init,
28    null_led_free,
29    null_led_set,
30    "null"
31 };
32 
led_driver_init(const char * led_driver)33 void led_driver_init(const char *led_driver)
34 {
35    const char *drivername = led_driver;
36 
37    if (!drivername)
38       drivername          = (const char*)"null";
39 
40    current_led_driver     = &null_led_driver;
41 
42 #ifdef HAVE_OVERLAY
43    if (string_is_equal("overlay", drivername))
44       current_led_driver  = &overlay_led_driver;
45 #endif
46 
47 #ifdef HAVE_RPILED
48    if (string_is_equal("rpi", drivername))
49       current_led_driver  = &rpi_led_driver;
50 #endif
51 
52 #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
53    if (string_is_equal("keyboard", drivername))
54       current_led_driver  = &keyboard_led_driver;
55 #endif
56 
57    if (current_led_driver)
58       (*current_led_driver->init)();
59 }
60 
led_driver_free(void)61 void led_driver_free(void)
62 {
63    if (current_led_driver)
64       (*current_led_driver->free)();
65 }
66 
led_driver_set_led(int led,int value)67 void led_driver_set_led(int led, int value)
68 {
69    if (current_led_driver)
70       (*current_led_driver->set_led)(led, value);
71 }
72