From 97a82ee3eca1be69bd2d08e8fd9db09c0807ae5d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 23 Nov 2022 23:00:29 -0500 Subject: plugins HAVE_BACKLIGHT helper remove ifdefs in favor of dummy functions lessen the ifdef hell Change-Id: I52f830284e4599f3fc3a75c27dda27058b8de1a3 --- apps/plugins/lib/helper.c | 48 +++++++++++++++++++++++++++++++++++++++++------ apps/plugins/lib/helper.h | 10 ---------- 2 files changed, 42 insertions(+), 16 deletions(-) (limited to 'apps/plugins/lib') diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 018c1616c8..92d9ec905e 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c @@ -58,7 +58,12 @@ void backlight_use_settings(void) backlight_timeout_plugged); #endif /* CONFIG_CHARGING */ } -#endif /* HAVE_BACKLIGHT */ +#else /* HAVE_BACKLIGHT */ +/* DUMMY FUNCTIONS */ +void backlight_force_on(void){} +void backlight_ignore_timeout(void){} +void backlight_use_settings(void){} +#endif /* !HAVE_BACKLIGHT */ #ifdef HAVE_SW_POWEROFF static bool original_sw_poweroff_state = true; @@ -73,7 +78,11 @@ void sw_poweroff_restore(void) { rb->button_set_sw_poweroff_state(original_sw_poweroff_state); } -#endif +#else /* HAVE_SW_POWEROFF */ +/* DUMMY FUNCTIONS */ +void sw_poweroff_disable(void){} +void sw_poweroff_restore(void){} +#endif /* !HAVE_SW_POWEROFF */ #ifdef HAVE_REMOTE_LCD /* Force the backlight on */ @@ -106,7 +115,12 @@ void remote_backlight_use_settings(void) remote_backlight_timeout_plugged); #endif /* CONFIG_CHARGING */ } -#endif /* HAVE_REMOTE_LCD */ +#else /* HAVE_REMOTE_LCD */ +/* DUMMY FUNCTIONS */ +void remote_backlight_force_on(void){} +void remote_backlight_ignore_timeout(void){} +void remote_backlight_use_settings(void){} +#endif /* !HAVE_REMOTE_LCD */ #ifdef HAVE_BUTTON_LIGHT /* Force the buttonlight on */ @@ -133,7 +147,13 @@ void buttonlight_use_settings(void) { rb->buttonlight_set_timeout(rb->global_settings->buttonlight_timeout); } -#endif /* HAVE_BUTTON_LIGHT */ +#else /* HAVE_BUTTON_LIGHT */ +/* DUMMY FUNCTIONS */ +void buttonlight_force_on(void){} +void buttonlight_force_off(void){} +void buttonlight_ignore_timeout(void){} +void buttonlight_use_settings(void){} +#endif /* !HAVE_BUTTON_LIGHT */ #ifdef HAVE_BACKLIGHT_BRIGHTNESS void backlight_brightness_set(int brightness) @@ -145,7 +165,15 @@ void backlight_brightness_use_setting(void) { rb->backlight_set_brightness(rb->global_settings->brightness); } -#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ +#else /* HAVE_BACKLIGHT_BRIGHTNESS */ +/* DUMMY FUNCTIONS */ +void backlight_brightness_set(int brightness) +{ + (void)brightness; +} +void backlight_brightness_use_setting(void){} + +#endif /* !HAVE_BACKLIGHT_BRIGHTNESS */ #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS void buttonlight_brightness_set(int brightness) @@ -157,4 +185,12 @@ void buttonlight_brightness_use_setting(void) { rb->buttonlight_set_brightness(rb->global_settings->buttonlight_brightness); } -#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ +#else /* HAVE_BUTTONLIGHT_BRIGHTNESS */ +/* DUMMY FUNCTIONS */ +void buttonlight_brightness_set(int brightness) +{ + (void)brightness; +} + +void buttonlight_brightness_use_setting(void){} +#endif /* !HAVE_BUTTONLIGHT_BRIGHTNESS */ diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index 00ad8ac087..e59325d5d9 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h @@ -32,39 +32,29 @@ void backlight_force_on(void); void backlight_ignore_timeout(void); void backlight_use_settings(void); -#ifdef HAVE_SW_POWEROFF /** * Disable and restore software poweroff (i.e. holding PLAY on iPods). * Only call _restore() if _disable() was called earlier! */ void sw_poweroff_disable(void); void sw_poweroff_restore(void); -#endif -#ifdef HAVE_REMOTE_LCD void remote_backlight_force_on(void); void remote_backlight_ignore_timeout(void); void remote_backlight_use_settings(void); -#endif -#ifdef HAVE_BUTTON_LIGHT void buttonlight_force_on(void); void buttonlight_force_off(void); void buttonlight_ignore_timeout(void); void buttonlight_use_settings(void); -#endif /** * Backlight brightness adjustment settings */ -#ifdef HAVE_BACKLIGHT_BRIGHTNESS void backlight_brightness_set(int brightness); void backlight_brightness_use_setting(void); -#endif -#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS void buttonlight_brightness_set(int brightness); void buttonlight_brightness_use_setting(void); -#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ #endif /* _LIB_HELPER_H_ */ -- cgit v1.2.3