Ludovic Rousseau <[EMAIL PROTECTED]> wrote: Hi,
> I propose to configure the keyboard backlight off key so that the level > is toggled between 0 and the previous value. > This should work even if automatic keyboard backlight is _not_ used. Could you please try the attached patch (on top of pommed 1.3 or SVN), and tell me whether the behaviour is OK for you ? With the code changes in the keyboard backlight, it's now easier and cleaner to implement that feature. As for the automatic backlight algorithm, if you have ideas you'd like to share, feel free ! It's not easy to get it right, and even OS X isn't perfect in this regard. Thanks, JB. -- Julien BLACHE - Debian & GNU/Linux Developer - <[EMAIL PROTECTED]> Public key available on <http://www.jblache.org> - KeyID: F5D6 5169 GPG Fingerprint : 935A 79F1 C8B3 3521 FD62 7CC7 CD61 4FD7 F5D6 5169
Index: pmac/kbd_backlight.c =================================================================== --- pmac/kbd_backlight.c (revision 313) +++ pmac/kbd_backlight.c (working copy) @@ -93,7 +93,7 @@ int ret; unsigned char buf[8]; - if (kbd_bck_info.inhibit) + if (kbd_bck_info.inhibit ^ KBD_INHIBIT_CFG) return; curval = kbd_backlight_get(); @@ -182,7 +182,7 @@ int val; int newval; - if (kbd_bck_info.inhibit) + if (kbd_bck_info.inhibit ^ KBD_INHIBIT_CFG) return; if (lmuaddr == 0) @@ -230,8 +230,10 @@ if (kbd_cfg.auto_on) kbd_bck_info.inhibit = 0; else - kbd_bck_info.inhibit = KBD_INHIBIT_USER; + kbd_bck_info.inhibit = KBD_INHIBIT_CFG; + kbd_bck_info.toggle_lvl = kbd_cfg.auto_lvl; + kbd_bck_info.inhibit_lvl = 0; kbd_bck_info.auto_on = 0; Index: evdev.c =================================================================== --- evdev.c (revision 317) +++ evdev.c (working copy) @@ -129,7 +129,10 @@ if (!has_kbd_backlight()) break; - kbd_backlight_inhibit_toggle(KBD_INHIBIT_USER); + if (kbd_cfg.auto_on) + kbd_backlight_inhibit_toggle(KBD_INHIBIT_USER); + else + kbd_backlight_toggle(); break; case K_KBD_BCK_DOWN: Index: kbd_backlight.h =================================================================== --- kbd_backlight.h (revision 313) +++ kbd_backlight.h (working copy) @@ -29,6 +29,7 @@ #define KBD_INHIBIT_USER (1 << 0) #define KBD_INHIBIT_LID (1 << 1) +#define KBD_INHIBIT_CFG (1 << 2) #define KBD_USER 0 @@ -43,6 +44,8 @@ int inhibit; int inhibit_lvl; + int toggle_lvl; /* backlight level for simple toggle */ + int auto_on; /* automatic */ int r_sens; /* right sensor */ int l_sens; /* left sensor */ @@ -66,6 +69,9 @@ /* In kbd_auto.c */ void +kbd_backlight_toggle(void); + +void kbd_backlight_inhibit_set(int mask); void Index: mactel/kbd_backlight.c =================================================================== --- mactel/kbd_backlight.c (revision 313) +++ mactel/kbd_backlight.c (working copy) @@ -95,7 +95,7 @@ FILE *fp; - if (kbd_bck_info.inhibit) + if (kbd_bck_info.inhibit ^ KBD_INHIBIT_CFG) return; curval = kbd_backlight_get(); @@ -159,7 +159,7 @@ int val; int newval; - if (kbd_bck_info.inhibit) + if (kbd_bck_info.inhibit ^ KBD_INHIBIT_CFG) return; val = kbd_backlight_get(); @@ -202,8 +202,10 @@ if (kbd_cfg.auto_on) kbd_bck_info.inhibit = 0; else - kbd_bck_info.inhibit = KBD_INHIBIT_USER; + kbd_bck_info.inhibit = KBD_INHIBIT_CFG; + kbd_bck_info.toggle_lvl = kbd_cfg.auto_lvl; + kbd_bck_info.inhibit_lvl = 0; kbd_bck_info.auto_on = 0; Index: kbd_auto.c =================================================================== --- kbd_auto.c (revision 313) +++ kbd_auto.c (working copy) @@ -19,7 +19,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +/* simple backlight toggle */ void +kbd_backlight_toggle(void) +{ + int curval; + + curval = kbd_backlight_get(); + + if (curval != KBD_BACKLIGHT_OFF) + { + kbd_bck_info.toggle_lvl = curval; + kbd_backlight_set(KBD_BACKLIGHT_OFF, KBD_USER); + } + else + { + kbd_backlight_set(kbd_bck_info.toggle_lvl, KBD_USER); + } +} + + +/***** Automatic backlight *****/ + +void kbd_backlight_inhibit_set(int mask) { if (!kbd_bck_info.inhibit)