2025-06-06 13:51:22 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2025 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2025-06-23 15:06:36 +10:00
|
|
|
#include "util-macros.h"
|
2025-06-06 13:51:22 +10:00
|
|
|
#include "util-mem.h"
|
2025-07-01 16:30:11 +10:00
|
|
|
|
2025-06-06 13:51:22 +10:00
|
|
|
#include "evdev-plugin.h"
|
|
|
|
|
#include "evdev.h"
|
|
|
|
|
|
|
|
|
|
static inline void
|
2025-12-01 09:17:37 +10:00
|
|
|
evdev_process_frame(struct evdev_device *device, struct evdev_frame *frame, usec_t time)
|
2025-06-06 13:51:22 +10:00
|
|
|
{
|
|
|
|
|
struct evdev_dispatch *dispatch = device->dispatch;
|
|
|
|
|
|
|
|
|
|
libinput_timer_flush(evdev_libinput_context(device), time);
|
|
|
|
|
|
2025-06-23 15:06:36 +10:00
|
|
|
dispatch->interface->process(dispatch, device, frame, time);
|
2025-06-06 13:51:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
2025-06-23 14:32:16 +10:00
|
|
|
evdev_device_dispatch_frame(struct libinput_plugin *plugin,
|
2025-06-06 13:51:22 +10:00
|
|
|
struct libinput_device *libinput_device,
|
|
|
|
|
struct evdev_frame *frame)
|
|
|
|
|
{
|
|
|
|
|
struct evdev_device *device = evdev_device(libinput_device);
|
2025-12-01 09:17:37 +10:00
|
|
|
usec_t time = evdev_frame_get_time(frame);
|
2025-06-23 15:55:02 +10:00
|
|
|
evdev_process_frame(device, frame, time);
|
2025-06-06 13:51:22 +10:00
|
|
|
|
|
|
|
|
/* Discard event to make the plugin system aware we're done */
|
|
|
|
|
evdev_frame_reset(frame);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-17 16:01:09 +10:00
|
|
|
static void
|
|
|
|
|
evdev_plugin_device_added(struct libinput_plugin *plugin,
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
libinput_plugin_enable_device_event_frame(plugin, device, true);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-06 13:51:22 +10:00
|
|
|
static const struct libinput_plugin_interface interface = {
|
|
|
|
|
.run = NULL,
|
|
|
|
|
.destroy = NULL,
|
|
|
|
|
.device_new = NULL,
|
|
|
|
|
.device_ignored = NULL,
|
2025-06-17 16:01:09 +10:00
|
|
|
.device_added = evdev_plugin_device_added,
|
2025-06-06 13:51:22 +10:00
|
|
|
.device_removed = NULL,
|
2025-06-23 14:32:16 +10:00
|
|
|
.evdev_frame = evdev_device_dispatch_frame,
|
2025-06-06 13:51:22 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_evdev_dispatch_plugin(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
_unref_(libinput_plugin) *p =
|
|
|
|
|
libinput_plugin_new(libinput, "evdev", &interface, NULL);
|
|
|
|
|
}
|