Hello Julien, I've been having some fun diving into your code and making a few adjustments. I've attached four very small patches (plus an alternative) to this email. I'll also print them below and describe my reasoning for their content; I hope you don't mind my doing so.
--- pommed/evdev.h.orig 2010-11-13 05:42:17.000000000 -0500 +++ pommed/evdev.h 2011-02-03 16:38:40.000000000 -0500 @@ -9,8 +9,10 @@ /****** ADB Devices ******/ /* Keyboard as found on the PowerBook3,2 */ -#define ADB_PRODUCT_ID_KEYBOARD 0x22c4 -/* Special PowerBook buttons as found on the PowerBook3,2 */ +#define ADB_PRODUCT_ID_KEYBOARD_32 0x22c4 +/* Keyboard as found on the Powerbook5,4 */ +#define ADB_PRODUCT_ID_KEYBOARD_54 0x22c3 +/* Special PowerBook buttons as found on the PowerBook3,2 and 5,4 */ #define ADB_PRODUCT_ID_PBBUTTONS 0x771f ^ This adds the pid for the Powerbook5,4's ADB keyboard. --- pommed/evdev.c.orig 2010-11-13 05:42:17.000000000 -0500 +++ pommed/evdev.c 2011-02-03 16:42:09.000000000 -0500 @@ -343,7 +343,8 @@ if (id[ID_VENDOR] != 0x0001) return 0; - if (product == ADB_PRODUCT_ID_KEYBOARD) + if ((product == ADB_PRODUCT_ID_KEYBOARD_32) + || (product == ADB_PRODUCT_ID_KEYBOARD_54)) { logdebug(" -> ADB keyboard\n"); ^ This patch and the one above it solve the main bug I was posting, which turns out was caused by rejecting the keyboard as not being an internal one. That caused the auto-timer to time out regardless of keyboard activity. --- pommed/pmac/kbd_backlight.c.orig 2010-11-13 05:42:17.000000000 -0500 +++ pommed/pmac/kbd_backlight.c 2011-02-03 20:27:42.000000000 -0500 @@ -228,7 +228,7 @@ { fadeval += step; - adb_write_kbd_value(fd, (unsigned char)val); + adb_write_kbd_value(fd, (unsigned char)fadeval); logdebug("KBD backlight value faded to %d\n", (int)fadeval); ^ I stumbled-upon this one by mistake. I noticed that "fadeval" wasn't being used in the for loop, and that it was used in this context by kbd_lmu_backlight_set(), a similar function to this one. --- pommed/evdev.c.orig 2011-02-03 22:21:13.000000000 -0500 +++ pommed/evdev.c 2011-02-03 22:38:13.000000000 -0500 @@ -170,6 +170,9 @@ break; kbd_backlight_step(STEP_DOWN); + if ((kbd_bck_info.level == KBD_BACKLIGHT_OFF) + && !(kbd_bck_info.inhibit & KBD_INHIBIT_USER)) + kbd_backlight_inhibit_set(KBD_INHIBIT_USER); break; case KEY_KBDILLUMUP: @@ -178,6 +181,8 @@ if (!has_kbd_backlight()) break; + if (kbd_bck_info.inhibit & KBD_INHIBIT_USER) + kbd_backlight_inhibit_clear(KBD_INHIBIT_USER); kbd_backlight_step(STEP_UP); break; ^ The first part of this last patch has the effect of inhibiting the keyboard backlight if the user turns down the brightness with the dimming key all the way to zero. This stops the backlight from doing that boucing effect, caused by the ALS reactivating the backlight as soon as it is reaches zero brightness. Pressing the toggle button turns the backlight back on, as does the brightness increase button... ^ The second part allows the "brightness up" key to re-enable the backlight if it has been turned-off by the user using the keyboard. patch2_alt-pommed-evdev.c.diff is an alternative to the fourth patch above (patch2-pommed-evdev.c.diff) with less condition testing, but probably not as good perfomance-wise. Either one should be applied after the first three. Just as a note, I'm running the modified pommed right now and its working great. Although, after toggling the backlight on for the first time under a certain conditions, the backlight can be a bit low even if it was bright before, but subsequent toggles behave normally as far as I can tell. I don't know what causes that. I hope that you like these patches and apply them to Squeeze. I release them under the same liscense as pommed, or a later one at your discretion. : ) Thanks for a great program! -Andrew
--- pommed/evdev.h.orig 2010-11-13 05:42:17.000000000 -0500 +++ pommed/evdev.h 2011-02-03 16:38:40.000000000 -0500 @@ -9,8 +9,10 @@ /****** ADB Devices ******/ /* Keyboard as found on the PowerBook3,2 */ -#define ADB_PRODUCT_ID_KEYBOARD 0x22c4 -/* Special PowerBook buttons as found on the PowerBook3,2 */ +#define ADB_PRODUCT_ID_KEYBOARD_32 0x22c4 +/* Keyboard as found on the Powerbook5,4 */ +#define ADB_PRODUCT_ID_KEYBOARD_54 0x22c3 +/* Special PowerBook buttons as found on the PowerBook3,2 and 5,4 */ #define ADB_PRODUCT_ID_PBBUTTONS 0x771f
--- pommed/evdev.c.orig 2010-11-13 05:42:17.000000000 -0500 +++ pommed/evdev.c 2011-02-03 16:42:09.000000000 -0500 @@ -343,7 +343,8 @@ if (id[ID_VENDOR] != 0x0001) return 0; - if (product == ADB_PRODUCT_ID_KEYBOARD) + if ((product == ADB_PRODUCT_ID_KEYBOARD_32) + || (product == ADB_PRODUCT_ID_KEYBOARD_54)) { logdebug(" -> ADB keyboard\n");
--- pommed/pmac/kbd_backlight.c.orig 2010-11-13 05:42:17.000000000 -0500 +++ pommed/pmac/kbd_backlight.c 2011-02-03 20:27:42.000000000 -0500 @@ -228,7 +228,7 @@ { fadeval += step; - adb_write_kbd_value(fd, (unsigned char)val); + adb_write_kbd_value(fd, (unsigned char)fadeval); logdebug("KBD backlight value faded to %d\n", (int)fadeval);
--- pommed/evdev.c.orig 2011-02-03 22:21:13.000000000 -0500 +++ pommed/evdev.c 2011-02-03 22:38:13.000000000 -0500 @@ -170,6 +170,9 @@ break; kbd_backlight_step(STEP_DOWN); + if ((kbd_bck_info.level == KBD_BACKLIGHT_OFF) + && !(kbd_bck_info.inhibit & KBD_INHIBIT_USER)) + kbd_backlight_inhibit_set(KBD_INHIBIT_USER); break; case KEY_KBDILLUMUP: @@ -178,6 +181,8 @@ if (!has_kbd_backlight()) break; + if (kbd_bck_info.inhibit & KBD_INHIBIT_USER) + kbd_backlight_inhibit_clear(KBD_INHIBIT_USER); kbd_backlight_step(STEP_UP); break;
--- pommed/evdev.c.orig 2011-02-03 21:12:40.000000000 -0500 +++ pommed/evdev.c 2011-02-03 21:15:52.000000000 -0500 @@ -170,6 +170,8 @@ break; kbd_backlight_step(STEP_DOWN); + if (kbd_bck_info.level == KBD_BACKLIGHT_OFF) + kbd_backlight_inhibit_set(KBD_INHIBIT_USER); break; case KEY_KBDILLUMUP: @@ -178,6 +180,7 @@ if (!has_kbd_backlight()) break; + kbd_backlight_inhibit_clear(KBD_INHIBIT_USER); kbd_backlight_step(STEP_UP); break;