# HG changeset patch # User Paul Boddie # Date 1609438577 -3600 # Node ID e9f3994b0cb34667ec654b6420aa55a36c6694ea # Parent 728a78e453bb386c20e5ee269050cfb31d7e065a Added backlight disable/enable control, adjusting the keys involved. diff -r 728a78e453bb -r e9f3994b0cb3 pkg/landfall-examples/letux400_backlight/Makefile --- a/pkg/landfall-examples/letux400_backlight/Makefile Thu Dec 31 19:15:34 2020 +0100 +++ b/pkg/landfall-examples/letux400_backlight/Makefile Thu Dec 31 19:16:17 2020 +0100 @@ -14,7 +14,7 @@ # Individual interfaces. -CLIENT_INTERFACES_CC = backlight +CLIENT_INTERFACES_CC = activation backlight # Generated and plain source files. diff -r 728a78e453bb -r e9f3994b0cb3 pkg/landfall-examples/letux400_backlight/letux400_backlight.cc --- a/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Thu Dec 31 19:15:34 2020 +0100 +++ b/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Thu Dec 31 19:16:17 2020 +0100 @@ -1,7 +1,8 @@ /* * Access the keypad to modify the backlight on the Letux 400. * - * Fn+Volume Down/Up adjusts the brightness. + * Fn+Down/Up adjusts the brightness. + * Zzz+Down/Up disables/enables the backlight. * * Copyright (C) 2018, 2020 Paul Boddie * @@ -24,14 +25,12 @@ #include #include -#include -#include +#include #include #include -#include - +#include "activation_client.h" #include "backlight_client.h" /* Backlight level. */ @@ -48,9 +47,11 @@ /* Key state. */ static int modifier_set = 0; +static int enable_modifier_set = 0; /* Backlight references. */ +Activation *activation_device; Backlight *backlight_device; @@ -61,12 +62,14 @@ { (void) priv; - /* Track the state of the modifier key. */ + /* Track the state of the modifier keys. */ - if (event.code == L4RE_KEY_SLEEP) + if (event.code == L4RE_KEY_FN) modifier_set = event.value; + else if (event.code == L4RE_KEY_SLEEP) + enable_modifier_set = event.value; - if (!event.value || !modifier_set) + if (!event.value || !(modifier_set || enable_modifier_set)) return; /* Upon keypress events, test controls and update the backlight. */ @@ -74,14 +77,24 @@ switch (event.code) { case L4RE_KEY_DOWN: - if (backlight_level < Letux400_backlight_min_level + Letux400_backlight_step) + if (enable_modifier_set) + { + activation_device->disable(); + return; + } + else if (backlight_level < Letux400_backlight_min_level + Letux400_backlight_step) backlight_level = Letux400_backlight_min_level; else backlight_level -= Letux400_backlight_step; break; case L4RE_KEY_UP: - if (backlight_level > Letux400_backlight_max_level - Letux400_backlight_step) + if (enable_modifier_set) + { + activation_device->enable(); + return; + } + else if (backlight_level > Letux400_backlight_max_level - Letux400_backlight_step) backlight_level = Letux400_backlight_max_level; else backlight_level += Letux400_backlight_step; @@ -109,7 +122,11 @@ l4_cap_idx_t backlight = l4re_env_get_cap("backlight"); if (!l4_is_valid_cap(backlight)) return 1; - /* Use only the backlight interface with the backlight. */ + /* NOTE: The component framework should permit the use of a compound client + object. */ + + client_Activation activation_obj(backlight); + activation_device = &activation_obj; client_Backlight backlight_obj(backlight); backlight_device = &backlight_obj;