Commit 295c1fd5 authored by Marcel Holtmann's avatar Marcel Holtmann

[Bluetooth] Fix too many keys pressed error

This patch fixes the problem of keys repeating when too many keys
are pressed at the same time (e.g. when typing quickly). This
often results in "mount" becoming "mouount".

It seems that Bluetooth keyboards send a HID report with the keys
all set to 0x01 if too many keys were pressed at the same time.
This confuses the previous report handling logic and now these
reports are ignored.
Signed-off-by: default avatarJuha Yrjölä <juha.yrjola@iki.fi>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent e1869588
...@@ -75,6 +75,8 @@ static unsigned char hidp_keycode[256] = { ...@@ -75,6 +75,8 @@ static unsigned char hidp_keycode[256] = {
150,158,159,128,136,177,178,176,142,152,173,140 150,158,159,128,136,177,178,176,142,152,173,140
}; };
static unsigned char hidp_mkeyspat[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr) static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr)
{ {
struct hidp_session *session; struct hidp_session *session;
...@@ -176,6 +178,11 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb) ...@@ -176,6 +178,11 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
input_report_key(dev, hidp_keycode[i + 224], (udata[0] >> i) & 1); input_report_key(dev, hidp_keycode[i + 224], (udata[0] >> i) & 1);
/* If all the key codes have been set to 0x01, it means
* too many keys were pressed at the same time. */
if (!memcmp(udata + 2, hidp_mkeyspat, 6))
break;
for (i = 2; i < 8; i++) { for (i = 2; i < 8; i++) {
if (keys[i] > 3 && memscan(udata + 2, keys[i], 6) == udata + 8) { if (keys[i] > 3 && memscan(udata + 2, keys[i], 6) == udata + 8) {
if (hidp_keycode[keys[i]]) if (hidp_keycode[keys[i]])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment