A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 196 lines 5.6 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2007 by Peter D'Hoye 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21 22#include "plugin.h" 23#include "helper.h" 24 25int talk_val(long n, int unit, bool enqueue) 26{ 27 #define NODECIMALS 0 28 return rb->talk_value_decimal(n, unit, NODECIMALS, enqueue); 29} 30 31#ifdef HAVE_BACKLIGHT 32/* Force the backlight on */ 33void backlight_force_on(void) 34{ 35 rb->backlight_set_timeout(0); 36#if CONFIG_CHARGING 37 rb->backlight_set_timeout_plugged(0); 38#endif /* CONFIG_CHARGING */ 39} 40 41/* Turn off backlight timeout */ 42void backlight_ignore_timeout(void) 43{ 44 if (rb->global_settings->backlight_timeout > 0) 45 rb->backlight_set_timeout(0); 46#if CONFIG_CHARGING 47 if (rb->global_settings->backlight_timeout_plugged > 0) 48 rb->backlight_set_timeout_plugged(0); 49#endif /* CONFIG_CHARGING */ 50} 51 52/* Reset backlight operation to its settings */ 53void backlight_use_settings(void) 54{ 55 rb->backlight_set_timeout(rb->global_settings->backlight_timeout); 56#if CONFIG_CHARGING 57 rb->backlight_set_timeout_plugged(rb->global_settings-> 58 backlight_timeout_plugged); 59#endif /* CONFIG_CHARGING */ 60} 61#else /* HAVE_BACKLIGHT */ 62/* DUMMY FUNCTIONS */ 63void backlight_force_on(void){} 64void backlight_ignore_timeout(void){} 65void backlight_use_settings(void){} 66#endif /* !HAVE_BACKLIGHT */ 67 68#ifdef HAVE_SW_POWEROFF 69static bool original_sw_poweroff_state = true; 70 71void sw_poweroff_disable(void) 72{ 73 original_sw_poweroff_state = rb->button_get_sw_poweroff_state(); 74 rb->button_set_sw_poweroff_state(false); 75} 76 77void sw_poweroff_restore(void) 78{ 79 rb->button_set_sw_poweroff_state(original_sw_poweroff_state); 80} 81#else /* HAVE_SW_POWEROFF */ 82/* DUMMY FUNCTIONS */ 83void sw_poweroff_disable(void){} 84void sw_poweroff_restore(void){} 85#endif /* !HAVE_SW_POWEROFF */ 86 87#ifdef HAVE_REMOTE_LCD 88/* Force the backlight on */ 89void remote_backlight_force_on(void) 90{ 91 rb->remote_backlight_set_timeout(0); 92#if CONFIG_CHARGING 93 rb->remote_backlight_set_timeout_plugged(0); 94#endif /* CONFIG_CHARGING */ 95} 96 97/* Turn off backlight timeout */ 98void remote_backlight_ignore_timeout(void) 99{ 100 if (rb->global_settings->remote_backlight_timeout > 0) 101 rb->remote_backlight_set_timeout(0); 102#if CONFIG_CHARGING 103 if (rb->global_settings->remote_backlight_timeout_plugged > 0) 104 rb->remote_backlight_set_timeout_plugged(0); 105#endif /* CONFIG_CHARGING */ 106} 107 108/* Reset backlight operation to its settings */ 109void remote_backlight_use_settings(void) 110{ 111 rb->remote_backlight_set_timeout(rb->global_settings-> 112 remote_backlight_timeout); 113#if CONFIG_CHARGING 114 rb->remote_backlight_set_timeout_plugged(rb->global_settings-> 115 remote_backlight_timeout_plugged); 116#endif /* CONFIG_CHARGING */ 117} 118#else /* HAVE_REMOTE_LCD */ 119/* DUMMY FUNCTIONS */ 120void remote_backlight_force_on(void){} 121void remote_backlight_ignore_timeout(void){} 122void remote_backlight_use_settings(void){} 123#endif /* !HAVE_REMOTE_LCD */ 124 125#ifdef HAVE_BUTTON_LIGHT 126/* Force the buttonlight on */ 127void buttonlight_force_on(void) 128{ 129 rb->buttonlight_set_timeout(0); 130} 131 132/* Force the buttonlight off */ 133void buttonlight_force_off(void) 134{ 135 rb->buttonlight_set_timeout(-1); 136} 137 138/* Turn off backlight timeout */ 139void buttonlight_ignore_timeout(void) 140{ 141 if (rb->global_settings->buttonlight_timeout > 0) 142 rb->buttonlight_set_timeout(0); 143} 144 145/* Reset buttonlight operation to its settings */ 146void buttonlight_use_settings(void) 147{ 148 rb->buttonlight_set_timeout(rb->global_settings->buttonlight_timeout); 149} 150#else /* HAVE_BUTTON_LIGHT */ 151/* DUMMY FUNCTIONS */ 152void buttonlight_force_on(void){} 153void buttonlight_force_off(void){} 154void buttonlight_ignore_timeout(void){} 155void buttonlight_use_settings(void){} 156#endif /* !HAVE_BUTTON_LIGHT */ 157 158#ifdef HAVE_BACKLIGHT_BRIGHTNESS 159void backlight_brightness_set(int brightness) 160{ 161 rb->backlight_set_brightness(brightness); 162} 163 164void backlight_brightness_use_setting(void) 165{ 166 rb->backlight_set_brightness(rb->global_settings->brightness); 167} 168#else /* HAVE_BACKLIGHT_BRIGHTNESS */ 169/* DUMMY FUNCTIONS */ 170void backlight_brightness_set(int brightness) 171{ 172 (void)brightness; 173} 174void backlight_brightness_use_setting(void){} 175 176#endif /* !HAVE_BACKLIGHT_BRIGHTNESS */ 177 178#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 179void buttonlight_brightness_set(int brightness) 180{ 181 rb->buttonlight_set_brightness(brightness); 182} 183 184void buttonlight_brightness_use_setting(void) 185{ 186 rb->buttonlight_set_brightness(rb->global_settings->buttonlight_brightness); 187} 188#else /* HAVE_BUTTONLIGHT_BRIGHTNESS */ 189/* DUMMY FUNCTIONS */ 190void buttonlight_brightness_set(int brightness) 191{ 192 (void)brightness; 193} 194 195void buttonlight_brightness_use_setting(void){} 196#endif /* !HAVE_BUTTONLIGHT_BRIGHTNESS */