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;