mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 04:30:06 +01:00
plugin: register plugins for the plugin-specific usages
The debounce, wheel/wheel-low-res, double-tool and eraser-button plugins can limit themselves to a specific usage. The mtdev plugin needs to pass each each event to mtdev and the proximity timer plugin needs to get each event's timestamp so they cannot be restricted. The forced-tool could be restricted but effectively any event on the devices it works on will have one of those usages set so there's no point. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1271>
This commit is contained in:
parent
3a86b6ea58
commit
d1dbbb7328
5 changed files with 30 additions and 0 deletions
|
|
@ -743,6 +743,15 @@ debounce_plugin_device_added(struct libinput_plugin *libinput_plugin,
|
|||
|
||||
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
|
||||
|
||||
/* We don't care about BTN_TRIGGER_HAPPY_* */
|
||||
for (unsigned int code = BTN_0; code <= KEY_OK; code++) {
|
||||
evdev_usage_t usage = evdev_usage_from_code(EV_KEY, code);
|
||||
if (evdev_usage_is_button(usage)) {
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin,
|
||||
evdev_usage_enum(usage));
|
||||
}
|
||||
}
|
||||
|
||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||
struct plugin_device *pd = zalloc(sizeof(*pd));
|
||||
pd->device = libinput_device_ref(device);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,13 @@ wheel_plugin_device_new(struct libinput_plugin *libinput_plugin,
|
|||
libevdev_enable_event_code(libevdev, EV_REL, REL_HWHEEL_HI_RES, NULL);
|
||||
|
||||
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_WHEEL);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_HWHEEL);
|
||||
|
||||
/* A device may have those disabled via a quirk but we just re-enabled it
|
||||
* above. Make sure we get those events too to filter them out */
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_WHEEL_HI_RES);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_HWHEEL_HI_RES);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -506,6 +506,11 @@ wheel_plugin_device_new(struct libinput_plugin *libinput_plugin,
|
|||
|
||||
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
|
||||
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_WHEEL);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_WHEEL_HI_RES);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_HWHEEL);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_REL_HWHEEL_HI_RES);
|
||||
|
||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||
struct plugin_device *pd =
|
||||
wheel_plugin_device_create(libinput_plugin, plugin, device);
|
||||
|
|
|
|||
|
|
@ -339,6 +339,8 @@ double_tool_plugin_device_added(struct libinput_plugin *libinput_plugin,
|
|||
return;
|
||||
|
||||
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_TOOL_PEN);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_TOOL_RUBBER);
|
||||
|
||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||
struct plugin_device *pd = zalloc(sizeof(*pd));
|
||||
|
|
|
|||
|
|
@ -541,6 +541,13 @@ eraser_button_plugin_device_added(struct libinput_plugin *libinput_plugin,
|
|||
return;
|
||||
|
||||
libinput_plugin_enable_device_event_frame(libinput_plugin, device, true);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_TOOL_PEN);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_TOOL_RUBBER);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_TOUCH);
|
||||
/* These are the only ones we allow setting the eraser button to */
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_STYLUS);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_STYLUS2);
|
||||
libinput_plugin_enable_evdev_usage(libinput_plugin, EVDEV_BTN_STYLUS3);
|
||||
|
||||
struct plugin_data *plugin = libinput_plugin_get_user_data(libinput_plugin);
|
||||
struct plugin_device *pd = zalloc(sizeof(*pd));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue