From d81a0a3b062b8504b6780edc4ddc80e08c907c99 Mon Sep 17 00:00:00 2001 From: Dominggoes Isakh Date: Thu, 25 May 2017 14:49:46 +0200 Subject: [PATCH] liblights: Add support for variable touchkey brightness Change-Id: Icc5c589e88dc342ae50b432187bae65a9b3a23d7 --- liblights/include/samsung_lights.h | 3 +++ liblights/lights.c | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/liblights/include/samsung_lights.h b/liblights/include/samsung_lights.h index dc07b6fe..f9392c1f 100644 --- a/liblights/include/samsung_lights.h +++ b/liblights/include/samsung_lights.h @@ -30,6 +30,9 @@ #define BUTTON_BRIGHTNESS_NODE "/sys/class/sec/sec_touchkey/brightness" #define LED_BLINK_NODE "/sys/class/sec/led/led_blink" +// Set to 1 to enable variable button brightness +#define VAR_BUTTON_BRIGHTNESS 0 + /* * Brightness adjustment factors * diff --git a/liblights/lights.c b/liblights/lights.c index 7e64eceb..ad6edc63 100644 --- a/liblights/lights.c +++ b/liblights/lights.c @@ -145,12 +145,13 @@ static int set_light_buttons(struct light_device_t* dev __unused, struct light_state_t const* state) { int err = 0; - int on = (state->color & COLOR_MASK); - pthread_mutex_lock(&g_lock); + int brightness = (state->color & COLOR_MASK) ? 1 : 0; - err = set_cur_button_brightness(on ? 1 : 0); - +#ifdef VAR_BUTTON_BRIGHTNESS + brightness = rgb_to_brightness(state); +#endif + err = set_cur_button_brightness(brightness); pthread_mutex_unlock(&g_lock); return err;