Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b7c407b authored by Rodney Lorrimar's avatar Rodney Lorrimar Committed by Dmitry Torokhov
Browse files

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: default avatarRodney Lorrimar <rodney@rodney.id.au>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 2e75f044
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -225,6 +225,7 @@ struct adbhid {
#define FLAG_CAPSLOCK_TRANSLATE		0x00000008
#define FLAG_CAPSLOCK_TRANSLATE		0x00000008
#define FLAG_CAPSLOCK_DOWN		0x00000010
#define FLAG_CAPSLOCK_DOWN		0x00000010
#define FLAG_CAPSLOCK_IGNORE_NEXT	0x00000020
#define FLAG_CAPSLOCK_IGNORE_NEXT	0x00000020
#define FLAG_POWER_KEY_PRESSED		0x00000040


static struct adbhid *adbhid[16];
static struct adbhid *adbhid[16];


@@ -301,9 +302,11 @@ adbhid_input_keycode(int id, int scancode, int repeat)
				ahid->flags |= FLAG_CAPSLOCK_TRANSLATE
				ahid->flags |= FLAG_CAPSLOCK_TRANSLATE
					| FLAG_CAPSLOCK_DOWN;
					| FLAG_CAPSLOCK_DOWN;
			}
			}
		} else if (scancode == 0xff) {
		} else if (scancode == 0xff &&
			   !(ahid->flags & FLAG_POWER_KEY_PRESSED)) {
			/* Scancode 0xff usually signifies that the capslock
			/* Scancode 0xff usually signifies that the capslock
			 * key was either pressed or released. */
			 * key was either pressed or released, or that the
			 * power button was released. */
			if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) {
			if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) {
				keycode = ADB_KEY_CAPSLOCK;
				keycode = ADB_KEY_CAPSLOCK;
				if (ahid->flags & FLAG_CAPSLOCK_DOWN) {
				if (ahid->flags & FLAG_CAPSLOCK_DOWN) {
@@ -317,7 +320,7 @@ adbhid_input_keycode(int id, int scancode, int repeat)
				}
				}
			} else {
			} else {
				printk(KERN_INFO "Spurious caps lock event "
				printk(KERN_INFO "Spurious caps lock event "
						"(scancode 0xff).");
						 "(scancode 0xff).\n");
			}
			}
		}
		}
	}
	}
@@ -344,6 +347,12 @@ adbhid_input_keycode(int id, int scancode, int repeat)
		}
		}
		break;
		break;
	case ADB_KEY_POWER:
	case ADB_KEY_POWER:
		/* Keep track of the power key state */
		if (up_flag)
			ahid->flags &= ~FLAG_POWER_KEY_PRESSED;
		else
			ahid->flags |= FLAG_POWER_KEY_PRESSED;

		/* Fn + Command will produce a bogus "power" keycode */
		/* Fn + Command will produce a bogus "power" keycode */
		if (ahid->flags & FLAG_FN_KEY_PRESSED) {
		if (ahid->flags & FLAG_FN_KEY_PRESSED) {
			keycode = ADB_KEY_CMD;
			keycode = ADB_KEY_CMD;