Skip to content

Commit

Permalink
Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes
Browse files Browse the repository at this point in the history
This allows for debugging non-functional keys easily from
userspace.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Seth Forshee authored and Dmitry Torokhov committed Mar 29, 2011
1 parent f3cf5c4 commit 170531b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/input/sparse-keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ int sparse_keymap_setup(struct input_dev *dev,
}

if (test_bit(EV_KEY, dev->evbit)) {
__set_bit(KEY_UNKNOWN, dev->keybit);
__set_bit(EV_MSC, dev->evbit);
__set_bit(MSC_SCAN, dev->mscbit);
}
Expand Down Expand Up @@ -311,12 +312,19 @@ bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
{
const struct key_entry *ke =
sparse_keymap_entry_from_scancode(dev, code);
struct key_entry unknown_ke;

if (ke) {
sparse_keymap_report_entry(dev, ke, value, autorelease);
return true;
}

/* Report an unknown key event as a debugging aid */
unknown_ke.type = KE_KEY;
unknown_ke.code = code;
unknown_ke.keycode = KEY_UNKNOWN;
sparse_keymap_report_entry(dev, &unknown_ke, value, true);

return false;
}
EXPORT_SYMBOL(sparse_keymap_report_event);
Expand Down

0 comments on commit 170531b

Please sign in to comment.