mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 19:21:06 +00:00
Adjust brightness according to the limit
Seems like some platforms feature non-standard maximums, but the variable is correclty exported for us to use
This commit is contained in:
parent
a83af11754
commit
e1385c0187
@ -1325,19 +1325,25 @@ static void frontend_unix_get_lakka_version(char *s,
|
|||||||
|
|
||||||
static void frontend_unix_set_screen_brightness(int value)
|
static void frontend_unix_set_screen_brightness(int value)
|
||||||
{
|
{
|
||||||
int brightness = 0;
|
char *buffer = NULL;
|
||||||
char svalue[16] = {0};
|
char svalue[16] = {0};
|
||||||
#if defined(HAVE_LAKKA_SWITCH)
|
unsigned int max_brightness = 100;
|
||||||
/* Values from 0 to 100 */
|
#if !defined(HAVE_LAKKA_SWITCH)
|
||||||
brightness = value;
|
filestream_read_file("/sys/devices/platform/backlight/backlight/backlight/max_brightness",
|
||||||
#elif defined(HAVE_ODROIDGO2)
|
&buffer, NULL);
|
||||||
/* GOA screen PWM value does not linearly relate to perceived brightness */
|
if (buffer)
|
||||||
brightness = (pow(1.0369f, value) - 1) * 7;
|
{
|
||||||
#endif
|
sscanf(buffer, "%u", &max_brightness);
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
snprintf(svalue, sizeof(svalue), "%d\n", brightness);
|
/* Calculate the brightness */
|
||||||
|
value = (value * max_brightness) / 100;
|
||||||
|
|
||||||
|
snprintf(svalue, sizeof(svalue), "%d\n", value);
|
||||||
filestream_write_file("/sys/class/backlight/backlight/brightness",
|
filestream_write_file("/sys/class/backlight/backlight/brightness",
|
||||||
svalue, strlen(svalue));
|
svalue, strlen(svalue));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user