aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
authorRodney Lorrimar <rodney@rodney.id.au>2008-05-05 11:59:24 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-05-16 14:50:10 -0400
commit5b7c407baa9501e49ebd3b6eac30cd4bcb60ca9d (patch)
tree4aa4bb8ff87d1a01058a8c9061ecf09b15f8c930 /drivers/macintosh
parent2e75f044c717b85f65d74c8c90624428ba31078c (diff)
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>
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/adbhid.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index 6e9afe26db8..b7f41d3823a 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -225,6 +225,7 @@ struct adbhid {
225#define FLAG_CAPSLOCK_TRANSLATE 0x00000008 225#define FLAG_CAPSLOCK_TRANSLATE 0x00000008
226#define FLAG_CAPSLOCK_DOWN 0x00000010 226#define FLAG_CAPSLOCK_DOWN 0x00000010
227#define FLAG_CAPSLOCK_IGNORE_NEXT 0x00000020 227#define FLAG_CAPSLOCK_IGNORE_NEXT 0x00000020
228#define FLAG_POWER_KEY_PRESSED 0x00000040
228 229
229static struct adbhid *adbhid[16]; 230static struct adbhid *adbhid[16];
230 231
@@ -301,9 +302,11 @@ adbhid_input_keycode(int id, int scancode, int repeat)
301 ahid->flags |= FLAG_CAPSLOCK_TRANSLATE 302 ahid->flags |= FLAG_CAPSLOCK_TRANSLATE
302 | FLAG_CAPSLOCK_DOWN; 303 | FLAG_CAPSLOCK_DOWN;
303 } 304 }
304 } else if (scancode == 0xff) { 305 } else if (scancode == 0xff &&
306 !(ahid->flags & FLAG_POWER_KEY_PRESSED)) {
305 /* Scancode 0xff usually signifies that the capslock 307 /* Scancode 0xff usually signifies that the capslock
306 * key was either pressed or released. */ 308 * key was either pressed or released, or that the
309 * power button was released. */
307 if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) { 310 if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) {
308 keycode = ADB_KEY_CAPSLOCK; 311 keycode = ADB_KEY_CAPSLOCK;
309 if (ahid->flags & FLAG_CAPSLOCK_DOWN) { 312 if (ahid->flags & FLAG_CAPSLOCK_DOWN) {
@@ -317,7 +320,7 @@ adbhid_input_keycode(int id, int scancode, int repeat)
317 } 320 }
318 } else { 321 } else {
319 printk(KERN_INFO "Spurious caps lock event " 322 printk(KERN_INFO "Spurious caps lock event "
320 "(scancode 0xff)."); 323 "(scancode 0xff).\n");
321 } 324 }
322 } 325 }
323 } 326 }
@@ -344,6 +347,12 @@ adbhid_input_keycode(int id, int scancode, int repeat)
344 } 347 }
345 break; 348 break;
346 case ADB_KEY_POWER: 349 case ADB_KEY_POWER:
350 /* Keep track of the power key state */
351 if (up_flag)
352 ahid->flags &= ~FLAG_POWER_KEY_PRESSED;
353 else
354 ahid->flags |= FLAG_POWER_KEY_PRESSED;
355
347 /* Fn + Command will produce a bogus "power" keycode */ 356 /* Fn + Command will produce a bogus "power" keycode */
348 if (ahid->flags & FLAG_FN_KEY_PRESSED) { 357 if (ahid->flags & FLAG_FN_KEY_PRESSED) {
349 keycode = ADB_KEY_CMD; 358 keycode = ADB_KEY_CMD;