Landfall

Change of pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc

20:b38cf791d6af
pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc
     1.1 --- a/pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc	Fri May 25 22:14:36 2018 +0200
     1.2 +++ b/pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc	Fri May 25 23:07:48 2018 +0200
     1.3 @@ -42,6 +42,7 @@
     1.4  /* Key state. */
     1.5  
     1.6  static int modifier_set = 0;
     1.7 +static int enable_modifier_set = 0;
     1.8  
     1.9  /* Backlight device abstractions. */
    1.10  
    1.11 @@ -55,12 +56,14 @@
    1.12  {
    1.13    (void) priv;
    1.14  
    1.15 -  /* Track the state of the modifier key. */
    1.16 +  /* Track the state of the modifier keys. */
    1.17  
    1.18    if (event.code == L4RE_KEY_FN)
    1.19      modifier_set = event.value;
    1.20 +  else if (event.code == L4RE_KEY_RIGHTALT)
    1.21 +    enable_modifier_set = event.value;
    1.22  
    1.23 -  if (!event.value || !modifier_set)
    1.24 +  if (!event.value || !(modifier_set || enable_modifier_set))
    1.25      return;
    1.26  
    1.27    /* Upon keypress events, test controls and update the backlight. */
    1.28 @@ -68,14 +71,24 @@
    1.29    switch (event.code)
    1.30    {
    1.31      case L4RE_KEY_VOLUMEDOWN:
    1.32 -      if (backlight_level < Qi_lb60_backlight_min_level + Qi_lb60_backlight_step)
    1.33 +      if (enable_modifier_set)
    1.34 +      {
    1.35 +        backlight_device->disable();
    1.36 +        return;
    1.37 +      }
    1.38 +      else if (backlight_level < Qi_lb60_backlight_min_level + Qi_lb60_backlight_step)
    1.39          backlight_level = Qi_lb60_backlight_min_level;
    1.40        else
    1.41          backlight_level -= Qi_lb60_backlight_step;
    1.42        break;
    1.43  
    1.44      case L4RE_KEY_VOLUMEUP:
    1.45 -      if (backlight_level > Qi_lb60_backlight_max_level - Qi_lb60_backlight_step)
    1.46 +      if (enable_modifier_set)
    1.47 +      {
    1.48 +        backlight_device->enable();
    1.49 +        return;
    1.50 +      }
    1.51 +      else if (backlight_level > Qi_lb60_backlight_max_level - Qi_lb60_backlight_step)
    1.52          backlight_level = Qi_lb60_backlight_max_level;
    1.53        else
    1.54          backlight_level += Qi_lb60_backlight_step;