Skip to content

Commit

Permalink
(LED code) Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Dec 27, 2017
1 parent c8a1348 commit eb62b61
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 123 deletions.
14 changes: 14 additions & 0 deletions led/led_defines.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/* 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/>.
*/

#ifndef __OUTPUT_DEFINES__H
#define __OUTPUT_DEFINES__H

Expand Down
78 changes: 40 additions & 38 deletions led/led_driver.c
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
/* 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/>.
*/

#include <stdio.h>
#include <string/stdstring.h>

#include "led_driver.h"
#include "configuration.h"
#include "verbosity.h"
#include "../configuration.h"
#include "../verbosity.h"

extern led_driver_t *null_led_driver;
#if HAVE_RPILED
extern led_driver_t *rpi_led_driver;
#endif
led_driver_t *current_led_driver = NULL;
static led_driver_t *current_led_driver = NULL;

bool led_driver_init(void)
{
char *drivername = NULL;
settings_t *settings = config_get_ptr();
drivername = settings->arrays.led_driver;

if(drivername == NULL)
drivername = "null";
settings_t *settings = config_get_ptr();
char *drivername = settings ? settings->arrays.led_driver : NULL;

if(!drivername)
drivername = "null";

current_led_driver = null_led_driver;

#if HAVE_RPILED
if(!strcmp("rpi",drivername))
{
current_led_driver = rpi_led_driver;
}
else
if(string_is_equal("rpi", drivername))
current_led_driver = rpi_led_driver;
#endif
{
current_led_driver = null_led_driver;
}

RARCH_LOG("[LED]: LED driver = '%s' %p\n",drivername,current_led_driver);

if(current_led_driver != NULL)
{
(*current_led_driver->init)();
}

return true;

RARCH_LOG("[LED]: LED driver = '%s' %p\n",
drivername,current_led_driver);

if(current_led_driver)
(*current_led_driver->init)();

return true;
}

void led_driver_free(void)
{
if(current_led_driver != NULL)
{
(*current_led_driver->free)();
}
if(current_led_driver)
(*current_led_driver->free)();
}

void led_driver_set_led(int led,int value)
{
if(current_led_driver != NULL)
{
(*current_led_driver->set_led)(led,value);
}
if(current_led_driver)
(*current_led_driver->set_led)(led,value);
}
17 changes: 17 additions & 0 deletions led/led_driver.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/* 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/>.
*/

#ifndef __LED_DRIVER__H
#define __LED_DRIVER__H

Expand Down Expand Up @@ -32,4 +46,7 @@ void led_driver_free(void);

void led_driver_set_led(int led,int value);

extern led_driver_t *null_led_driver;
extern led_driver_t *rpi_led_driver;

#endif
33 changes: 25 additions & 8 deletions led/null_led_driver.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
/* 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/>.
*/

#include "led_driver.h"
#include "verbosity.h"
#include "../verbosity.h"

static void null_init(void) { }
static void null_free(void) { }
static void null_set(int led,int state) { }

static void null_init(void)
{
RARCH_LOG("[LED]: using null LED driver\n");
}
static void null_free(void) {}
static void null_set(int led,int state) {}
static led_driver_t null_led_driver_ins = {
null_init,
null_free,
null_set
};

static led_driver_t null_led_driver_ins = { null_init, null_free, null_set };
led_driver_t *null_led_driver = &null_led_driver_ins;

Loading

0 comments on commit eb62b61

Please sign in to comment.