2017-12-27 20:17:47 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-12-27 16:05:12 +00:00
|
|
|
#include <stdio.h>
|
2017-12-27 20:17:47 +00:00
|
|
|
#include <string/stdstring.h>
|
|
|
|
|
2017-12-27 16:05:12 +00:00
|
|
|
#include "led_driver.h"
|
2017-12-27 20:17:47 +00:00
|
|
|
#include "../configuration.h"
|
|
|
|
#include "../verbosity.h"
|
2017-12-27 16:05:12 +00:00
|
|
|
|
2018-01-11 00:52:32 +00:00
|
|
|
static const led_driver_t *current_led_driver = NULL;
|
2017-12-27 16:05:12 +00:00
|
|
|
|
|
|
|
bool led_driver_init(void)
|
|
|
|
{
|
2017-12-27 20:17:47 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
char *drivername = settings ? settings->arrays.led_driver : NULL;
|
|
|
|
|
|
|
|
if(!drivername)
|
2017-12-27 21:21:39 +00:00
|
|
|
drivername = (char*)"null";
|
2017-12-27 20:17:47 +00:00
|
|
|
|
2018-01-11 00:52:32 +00:00
|
|
|
current_led_driver = &null_led_driver;
|
2017-12-27 16:05:12 +00:00
|
|
|
|
2018-01-05 15:10:34 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2018-01-11 00:52:32 +00:00
|
|
|
if(string_is_equal("overlay", drivername))
|
|
|
|
current_led_driver = &overlay_led_driver;
|
2018-01-05 15:10:34 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-04 17:45:01 +00:00
|
|
|
#if HAVE_RPILED
|
2018-01-05 15:10:34 +00:00
|
|
|
if(string_is_equal("rpi", drivername))
|
2018-01-11 00:52:32 +00:00
|
|
|
current_led_driver = &rpi_led_driver;
|
2017-12-27 16:05:12 +00:00
|
|
|
#endif
|
2017-12-27 20:17:47 +00:00
|
|
|
|
|
|
|
RARCH_LOG("[LED]: LED driver = '%s' %p\n",
|
2018-01-11 00:52:32 +00:00
|
|
|
drivername, current_led_driver);
|
2017-12-27 20:17:47 +00:00
|
|
|
|
|
|
|
if(current_led_driver)
|
|
|
|
(*current_led_driver->init)();
|
|
|
|
|
|
|
|
return true;
|
2017-12-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void led_driver_free(void)
|
|
|
|
{
|
2018-01-05 12:28:50 +00:00
|
|
|
if(current_led_driver)
|
|
|
|
(*current_led_driver->free)();
|
2017-12-27 16:05:12 +00:00
|
|
|
}
|
|
|
|
|
2018-01-11 00:52:32 +00:00
|
|
|
void led_driver_set_led(int led, int value)
|
2017-12-27 16:05:12 +00:00
|
|
|
{
|
2018-01-05 12:28:50 +00:00
|
|
|
if(current_led_driver)
|
2018-01-11 00:52:32 +00:00
|
|
|
(*current_led_driver->set_led)(led, value);
|
2017-12-27 16:05:12 +00:00
|
|
|
}
|