Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: adbhid - capslock and power button fix

If the adbhid module parameter restore_capslock_events is used,
pressing the power button may confuse the capslock state. This is
because the power button release scancode (0xff) is sometimes the same
as the capslock press/release scancode.

This fix adds yet another flag to track the state of the power button
so that it works independently of capslock.

Signed-off-by: Rodney Lorrimar <rodney@rodney.id.au>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by

Rodney Lorrimar and committed by
Dmitry Torokhov
5b7c407b 2e75f044

+12 -3
+12 -3
drivers/macintosh/adbhid.c
··· 225 225 #define FLAG_CAPSLOCK_TRANSLATE 0x00000008 226 226 #define FLAG_CAPSLOCK_DOWN 0x00000010 227 227 #define FLAG_CAPSLOCK_IGNORE_NEXT 0x00000020 228 + #define FLAG_POWER_KEY_PRESSED 0x00000040 228 229 229 230 static struct adbhid *adbhid[16]; 230 231 ··· 302 301 ahid->flags |= FLAG_CAPSLOCK_TRANSLATE 303 302 | FLAG_CAPSLOCK_DOWN; 304 303 } 305 - } else if (scancode == 0xff) { 304 + } else if (scancode == 0xff && 305 + !(ahid->flags & FLAG_POWER_KEY_PRESSED)) { 306 306 /* Scancode 0xff usually signifies that the capslock 307 - * key was either pressed or released. */ 307 + * key was either pressed or released, or that the 308 + * power button was released. */ 308 309 if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) { 309 310 keycode = ADB_KEY_CAPSLOCK; 310 311 if (ahid->flags & FLAG_CAPSLOCK_DOWN) { ··· 320 317 } 321 318 } else { 322 319 printk(KERN_INFO "Spurious caps lock event " 323 - "(scancode 0xff)."); 320 + "(scancode 0xff).\n"); 324 321 } 325 322 } 326 323 } ··· 347 344 } 348 345 break; 349 346 case ADB_KEY_POWER: 347 + /* Keep track of the power key state */ 348 + if (up_flag) 349 + ahid->flags &= ~FLAG_POWER_KEY_PRESSED; 350 + else 351 + ahid->flags |= FLAG_POWER_KEY_PRESSED; 352 + 350 353 /* Fn + Command will produce a bogus "power" keycode */ 351 354 if (ahid->flags & FLAG_FN_KEY_PRESSED) { 352 355 keycode = ADB_KEY_CMD;