1.1 --- a/pkg/landfall-examples/letux400_backlight/Makefile Thu Dec 31 19:15:34 2020 +0100
1.2 +++ b/pkg/landfall-examples/letux400_backlight/Makefile Thu Dec 31 19:16:17 2020 +0100
1.3 @@ -14,7 +14,7 @@
1.4
1.5 # Individual interfaces.
1.6
1.7 -CLIENT_INTERFACES_CC = backlight
1.8 +CLIENT_INTERFACES_CC = activation backlight
1.9
1.10 # Generated and plain source files.
1.11
2.1 --- a/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Thu Dec 31 19:15:34 2020 +0100
2.2 +++ b/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Thu Dec 31 19:16:17 2020 +0100
2.3 @@ -1,7 +1,8 @@
2.4 /*
2.5 * Access the keypad to modify the backlight on the Letux 400.
2.6 *
2.7 - * Fn+Volume Down/Up adjusts the brightness.
2.8 + * Fn+Down/Up adjusts the brightness.
2.9 + * Zzz+Down/Up disables/enables the backlight.
2.10 *
2.11 * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk>
2.12 *
2.13 @@ -24,14 +25,12 @@
2.14 #include <l4/devices/input-keypad-client.h>
2.15 #include <l4/devices/keypad-loader.h>
2.16
2.17 -#include <l4/re/env>
2.18 -#include <l4/sys/capability>
2.19 +#include <l4/re/env.h>
2.20
2.21 #include <l4/re/event_enums.h>
2.22 #include <l4/util/util.h>
2.23
2.24 -#include <stdio.h>
2.25 -
2.26 +#include "activation_client.h"
2.27 #include "backlight_client.h"
2.28
2.29 /* Backlight level. */
2.30 @@ -48,9 +47,11 @@
2.31 /* Key state. */
2.32
2.33 static int modifier_set = 0;
2.34 +static int enable_modifier_set = 0;
2.35
2.36 /* Backlight references. */
2.37
2.38 +Activation *activation_device;
2.39 Backlight *backlight_device;
2.40
2.41
2.42 @@ -61,12 +62,14 @@
2.43 {
2.44 (void) priv;
2.45
2.46 - /* Track the state of the modifier key. */
2.47 + /* Track the state of the modifier keys. */
2.48
2.49 - if (event.code == L4RE_KEY_SLEEP)
2.50 + if (event.code == L4RE_KEY_FN)
2.51 modifier_set = event.value;
2.52 + else if (event.code == L4RE_KEY_SLEEP)
2.53 + enable_modifier_set = event.value;
2.54
2.55 - if (!event.value || !modifier_set)
2.56 + if (!event.value || !(modifier_set || enable_modifier_set))
2.57 return;
2.58
2.59 /* Upon keypress events, test controls and update the backlight. */
2.60 @@ -74,14 +77,24 @@
2.61 switch (event.code)
2.62 {
2.63 case L4RE_KEY_DOWN:
2.64 - if (backlight_level < Letux400_backlight_min_level + Letux400_backlight_step)
2.65 + if (enable_modifier_set)
2.66 + {
2.67 + activation_device->disable();
2.68 + return;
2.69 + }
2.70 + else if (backlight_level < Letux400_backlight_min_level + Letux400_backlight_step)
2.71 backlight_level = Letux400_backlight_min_level;
2.72 else
2.73 backlight_level -= Letux400_backlight_step;
2.74 break;
2.75
2.76 case L4RE_KEY_UP:
2.77 - if (backlight_level > Letux400_backlight_max_level - Letux400_backlight_step)
2.78 + if (enable_modifier_set)
2.79 + {
2.80 + activation_device->enable();
2.81 + return;
2.82 + }
2.83 + else if (backlight_level > Letux400_backlight_max_level - Letux400_backlight_step)
2.84 backlight_level = Letux400_backlight_max_level;
2.85 else
2.86 backlight_level += Letux400_backlight_step;
2.87 @@ -109,7 +122,11 @@
2.88 l4_cap_idx_t backlight = l4re_env_get_cap("backlight");
2.89 if (!l4_is_valid_cap(backlight)) return 1;
2.90
2.91 - /* Use only the backlight interface with the backlight. */
2.92 + /* NOTE: The component framework should permit the use of a compound client
2.93 + object. */
2.94 +
2.95 + client_Activation activation_obj(backlight);
2.96 + activation_device = &activation_obj;
2.97
2.98 client_Backlight backlight_obj(backlight);
2.99 backlight_device = &backlight_obj;