config/udev: distinguish between real keyboards and other key devices

This patch introduces a new flag ATTR_KEY for hotplugged input devices,
so we can better distinguish between real keyboards (i.e. devices with
udev property ID_INPUT_KEYBOARD="1") and other key input devices like
lid switches, power buttons, etc.

All supported hotplug backends (udev, hal, and wscons) will set both
flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend
will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input
devices (hal and wscons will set both flags in any case). With this
distinction, kdrive input hotplugging mechanism will be allowed to only
grab real keyboards, as other key input devices are currently not
supported.

In order to don't break current behaviour, this patch will replace all
ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c.

[ajax: Just add ATTR_KEY, don't re-number the other attributes]

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Laércio de Sousa <laerciosousa@sme-mogidascruzes.sp.gov.br>
This commit is contained in:
Laércio de Sousa 2016-02-12 14:18:02 -02:00 committed by Adam Jackson
parent 851ff9ec04
commit daa6d2d58f
6 changed files with 11 additions and 4 deletions

View File

@ -170,7 +170,7 @@ device_added(LibHalContext * hal_ctx, const char *udi)
free(hal_tags);
if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL))
attrs.flags |= ATTR_KEYBOARD;
attrs.flags |= ATTR_KEY | ATTR_KEYBOARD;
if (libhal_device_query_capability(hal_ctx, udi, "input.mouse", NULL))
attrs.flags |= ATTR_POINTER;
if (libhal_device_query_capability(hal_ctx, udi, "input.joystick", NULL))

View File

@ -239,6 +239,10 @@ device_added(struct udev_device *udev_device)
attrs.vendor = strdup(value);
}
else if (!strcmp(key, "ID_INPUT_KEY")) {
LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_KEY;
}
else if (!strcmp(key, "ID_INPUT_KEYBOARD")) {
LOG_PROPERTY(path, key, value);
attrs.flags |= ATTR_KEYBOARD;
}

View File

@ -163,7 +163,7 @@ wscons_add_keyboard(void)
}
kbd_config_done:
attrs.flags |= ATTR_KEYBOARD;
attrs.flags |= ATTR_KEY | ATTR_KEYBOARD;
rc = NewInputDeviceRequest(input_options, &attrs, &dev);
if (rc != Success)
goto unwind;

View File

@ -2343,7 +2343,9 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
*pdev = ki->dixdev;
}
else {
ErrorF("unrecognised device identifier!\n");
ErrorF("unrecognised device identifier: %s\n",
input_option_get_value(input_option_find(optionsdup,
"device")));
input_option_free_list(&optionsdup);
return BadValue;
}

View File

@ -635,7 +635,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
/* MatchIs* booleans */
if (iclass->is_keyboard.set &&
iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEYBOARD))
iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEY))
return FALSE;
if (iclass->is_pointer.set &&
iclass->is_pointer.val != ! !(attrs->flags & ATTR_POINTER))

View File

@ -236,6 +236,7 @@ typedef struct _InputAttributes {
#define ATTR_TABLET (1<<3)
#define ATTR_TOUCHPAD (1<<4)
#define ATTR_TOUCHSCREEN (1<<5)
#define ATTR_KEY (1<<6)
/* Key/Button has been run through all input processing and events sent to clients. */
#define KEY_PROCESSED 1