pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
libopeninput: enumerate devices with udev
Module Name: pkgsrc-wip
Committed By: kikadf <kikadf.01%gmail.com@localhost>
Pushed By: kikadf
Date: Wed Sep 9 20:11:55 2026 +0200
Changeset: 5f4301b2a9ee5d71aa54a6001858cc58afcbdf0d
Modified Files:
libopeninput/distinfo
libopeninput/patches/patch-src_wscons.c
libopeninput/patches/patch-src_wscons.h
Log Message:
libopeninput: enumerate devices with udev
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=5f4301b2a9ee5d71aa54a6001858cc58afcbdf0d
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
libopeninput/distinfo | 4 +-
libopeninput/patches/patch-src_wscons.c | 198 +++++++++++++++++++-------------
libopeninput/patches/patch-src_wscons.h | 14 ++-
3 files changed, 135 insertions(+), 81 deletions(-)
diffs:
diff --git a/libopeninput/distinfo b/libopeninput/distinfo
index 030d79f82e..a1c94e20bb 100644
--- a/libopeninput/distinfo
+++ b/libopeninput/distinfo
@@ -3,5 +3,5 @@ $NetBSD: distinfo,v 1.2 2026/05/27 17:14:19 kikadf Exp $
BLAKE2s (libopeninput-1.31.3-10995219206280da0f1a3ba124abe4c8ef89e021.tar.gz) = 1bb9295eb9bf288dd512d09e94d318241a820f5fb8d1d39f094df2c3794e0ece
SHA512 (libopeninput-1.31.3-10995219206280da0f1a3ba124abe4c8ef89e021.tar.gz) = 4957ef42cfc6868546225d0b690acf51bc2a2fb799161a603fd3560c3d2b13af298161f4682f11e909aeaf443106b65cc4625a0afbc2b3fbd7fa27f61d34ef47
Size (libopeninput-1.31.3-10995219206280da0f1a3ba124abe4c8ef89e021.tar.gz) = 1203451 bytes
-SHA1 (patch-src_wscons.c) = 1c4d0301a5361ecaff32d5bb0b7a2264ee15deff
-SHA1 (patch-src_wscons.h) = 20c749ef79352094e1b646fdbe9566f95d7e0a41
+SHA1 (patch-src_wscons.c) = f4cee7cd0145ecd8e90cc85a7aac80d5a9fc0b48
+SHA1 (patch-src_wscons.h) = d4ce816f3e1b33e4f6dc4dc9d15f41400bccf2a4
diff --git a/libopeninput/patches/patch-src_wscons.c b/libopeninput/patches/patch-src_wscons.c
index cac3cc8b77..b74e743847 100644
--- a/libopeninput/patches/patch-src_wscons.c
+++ b/libopeninput/patches/patch-src_wscons.c
@@ -2,34 +2,25 @@ $NetBSD: patch-src_wscons.c,v 1.1 2026/04/13 15:19:37 kikadf Exp $
* Handle attached-detached devices with udev monitor
---- src/wscons.c.orig 2026-03-08 12:38:09.000000000 +0000
+--- src/wscons.c.orig 2026-08-29 17:19:47.000000000 +0000
+++ src/wscons.c
-@@ -46,51 +46,121 @@ static void
+@@ -47,6 +47,126 @@ static void
wscons_device_init_pointer_acceleration(struct wscons_device *device,
struct motion_filter *filter);
--static int
--udev_input_enable(struct libinput *libinput)
++#if defined(__NetBSD__)
+static void
+wscons_udev_handler(void *data)
- {
++{
+ struct udev_input *input = data;
+ struct udev_device *udev_device;
- struct libinput_seat *seat;
- struct libinput_device *device;
++ struct libinput_seat *seat;
++ struct libinput_device *device;
+ usec_t time;
+ struct timespec ts;
+ struct libinput_event *event;
+ const char *action, *devnode, *sysname;
-
-- seat = wscons_seat_get(libinput, default_seat, default_seat_name);
-- list_for_each(device, &seat->devices_list, link) {
-- device->fd = open_restricted(libinput, device->devname, O_RDWR);
-- device->source =
-- libinput_add_fd(libinput, device->fd,
-- wscons_device_dispatch, device);
-- if (!device->source) {
-- return -ENOMEM;
++
+ udev_device = udev_monitor_receive_device(input->udev_monitor);
+ if (!udev_device)
+ return;
@@ -63,9 +54,8 @@ $NetBSD: patch-src_wscons.c,v 1.1 2026/04/13 15:19:37 kikadf Exp $
+ libinput_path_remove_device(device);
+ break;
+ }
- }
- }
-- return 0;
++ }
++ }
+
+out:
+ udev_device_unref(udev_device);
@@ -109,22 +99,13 @@ $NetBSD: patch-src_wscons.c,v 1.1 2026/04/13 15:19:37 kikadf Exp $
+ input->udev_monitor = NULL;
+ }
+ return -1;
- }
-
- static void
- udev_input_disable(struct libinput *libinput)
- {
-- struct libinput_seat *seat;
-- struct libinput_device *device;
++}
++
++static void
++udev_input_disable(struct libinput *libinput)
++{
+ struct udev_input *input = (struct udev_input*)libinput;
-
-- seat = wscons_seat_get(libinput, default_seat, default_seat_name);
-- list_for_each(device, &seat->devices_list, link) {
-- if (device->source) {
-- libinput_remove_source(libinput, device->source);
-- device->source = NULL;
-- }
-- close_restricted(libinput, device->fd);
++
+ if (input->udev_monitor_source) {
+ libinput_remove_source(&input->base, input->udev_monitor_source);
+ input->udev_monitor_source = NULL;
@@ -132,77 +113,140 @@ $NetBSD: patch-src_wscons.c,v 1.1 2026/04/13 15:19:37 kikadf Exp $
+ if (input->udev_monitor) {
+ udev_monitor_unref(input->udev_monitor);
+ input->udev_monitor = NULL;
- }
- }
-
- static void
- udev_input_destroy(struct libinput *libinput)
- {
-- struct libinput_seat *seat;
-- struct libinput_device *device;
++ }
++}
++
++static void
++udev_input_destroy(struct libinput *libinput)
++{
+ struct udev_input *input = (struct udev_input*)libinput;
-
-- fprintf(stderr, "%s", __func__);
-- seat = wscons_seat_get(libinput, default_seat, default_seat_name);
-- list_for_each(device, &seat->devices_list, link) {
-- close_restricted(libinput, device->fd);
++
+ if (input->udev) {
+ udev_unref(input->udev);
+ input->udev = NULL;
++ }
++}
++
++#else // OpenBSD
+ static int
+ udev_input_enable(struct libinput *libinput)
+ {
+@@ -94,6 +214,7 @@ udev_input_destroy(struct libinput *libi
+ close_restricted(libinput, device->fd);
}
}
++#endif // if NetBSD else OpenBSD
-@@ -295,17 +365,24 @@ libinput_udev_create_context(const struc
- void *user_data,
- struct udev *udev)
- {
-- struct libinput *libinput;
-+ struct udev_input *input;
+ static int
+ udev_device_change_seat(struct libinput_device *device,
+@@ -303,6 +424,83 @@ wscons_seat_get(struct libinput *libinpu
+ return seat;
+ }
-- libinput = calloc(1, sizeof(*libinput));
-- if (libinput == NULL)
++#if defined(__NetBSD__)
++LIBINPUT_EXPORT struct libinput *
++libinput_udev_create_context(const struct libinput_interface *interface,
++ void *user_data,
++ struct udev *udev)
++{
++ struct udev_input *input;
++
+ if (!interface || !udev)
+ return NULL;
+
+ input = calloc(1, sizeof(*input));
+ if (!input)
- return NULL;
-
-- if (libinput_init(libinput, interface, &interface_backend, user_data) != 0) {
-- free(libinput);
++ return NULL;
++
+ if (libinput_init(&input->base, interface, &interface_backend, user_data) != 0) {
+ libinput_unref(&input->base);
+ free(input);
- return NULL;
- }
-- return libinput;
++ return NULL;
++ }
+
+ input->udev = udev_ref(udev);
+
+ return &input->base;
- }
-
- LIBINPUT_EXPORT int
-@@ -317,6 +394,7 @@ libinput_udev_assign_seat(struct libinpu
- usec_t time;
- struct timespec ts;
- struct libinput_event *event;
++}
++
++LIBINPUT_EXPORT int
++libinput_udev_assign_seat(struct libinput *libinput, const char *seat_id)
++{
++ struct libinput_seat *seat;
++ struct libinput_device *device;
++ usec_t time;
++ struct timespec ts;
++ struct libinput_event *event;
++ struct udev_list_entry *entry;
+ struct udev_input *input = (struct udev_input*)libinput;
-
- /* Add standard devices */
- for (int i = 0; i < 10; i++) {
-@@ -342,6 +420,10 @@ libinput_udev_assign_seat(struct libinpu
- post_device_event(device, time, LIBINPUT_EVENT_DEVICE_ADDED,
- event);
- }
++ struct udev *udev = input->udev;
++
++ /* Add standard devices */
++ _unref_(udev_enumerate) *e = udev_enumerate_new(udev);
++ udev_enumerate_add_match_subsystem(e, "input");
++ udev_enumerate_scan_devices(e);
++ udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
++ const char *path = udev_list_entry_get_name(entry);
++ _unref_(udev_device) *device = udev_device_new_from_syspath(udev, path);
++ if (!device)
++ continue;
++
++ const char *sysname = udev_device_get_sysname(device);
++ if (!sysname ||
++ (!strstartswith(sysname, "wskbd") &&
++ !strstartswith(sysname, "wsmouse"))) {
++ continue;
++ }
++
++ const char *devnode = udev_device_get_devnode(device);
++ if (!devnode)
++ continue;
++ libinput_path_add_device(libinput, devnode);
++ }
++
++ seat = wscons_seat_get(libinput, default_seat, default_seat_name);
++ list_for_each(device, &seat->devices_list, link) {
++ clock_gettime(CLOCK_REALTIME, &ts);
++ time = usec_from_timespec(&ts);
++ event = calloc(1, sizeof(*event));
++ post_device_event(device, time, LIBINPUT_EVENT_DEVICE_ADDED,
++ event);
++ }
+
+ if (udev_input_enable(&input->base) < 0)
+ return -1;
+
++ return 0;
++}
++
++#else // OpenBSD
+ LIBINPUT_EXPORT struct libinput *
+ libinput_udev_create_context(const struct libinput_interface *interface,
+ void *user_data,
+@@ -357,6 +555,7 @@ libinput_udev_assign_seat(struct libinpu
+ }
return 0;
}
++#endif // if NetBSD else OpenBSD
-@@ -609,6 +691,7 @@ libinput_path_remove_device(struct libin
+ LIBINPUT_EXPORT struct libinput *
+ libinput_path_create_context(const struct libinput_interface *interface,
+@@ -554,6 +753,14 @@ wscons_device_init(struct wscons_device
+ return 0;
+ }
+
++void
++wscons_device_destroy(struct wscons_device *wscons_device)
++{
++ filter_destroy(wscons_device->pointer.filter);
++ free(wscons_device->base.devname);
++ free(wscons_device);
++}
++
+ LIBINPUT_EXPORT struct libinput_device *
+ libinput_path_add_device(struct libinput *libinput,
+ const char *path)
+@@ -622,6 +829,7 @@ libinput_path_remove_device(struct libin
{
struct libinput *libinput = device->seat->libinput;
diff --git a/libopeninput/patches/patch-src_wscons.h b/libopeninput/patches/patch-src_wscons.h
index f7fcac0310..e0735e7388 100644
--- a/libopeninput/patches/patch-src_wscons.h
+++ b/libopeninput/patches/patch-src_wscons.h
@@ -2,18 +2,28 @@ $NetBSD: patch-src_wscons.h,v 1.1 2026/04/13 15:19:37 kikadf Exp $
* Handle attached-detached devices with udev monitor
---- src/wscons.h.orig 2026-03-08 12:38:09.000000000 +0000
+--- src/wscons.h.orig 2026-08-29 17:19:47.000000000 +0000
+++ src/wscons.h
-@@ -25,6 +25,12 @@ struct wscons_device {
+@@ -25,6 +25,14 @@ struct wscons_device {
} pointer;
};
++#if defined(__NetBSD__)
+struct udev_input {
+ struct libinput base;
+ struct udev *udev;
+ struct udev_monitor *udev_monitor;
+ struct libinput_source *udev_monitor_source;
+};
++#endif
static inline struct wscons_device *
wscons_device(struct libinput_device *device)
+@@ -32,6 +40,7 @@ wscons_device(struct libinput_device *de
+ return container_of(device, struct wscons_device, base);
+ }
+ extern int wscons_keyboard_init(struct wscons_device *);
++extern void wscons_device_destroy(struct wscons_device *);
+ extern uint32_t wskey_transcode(struct TransMapRec *, int);
+ extern void post_device_event(struct libinput_device *, usec_t ,
+ enum libinput_event_type , struct libinput_event *);
Home |
Main Index |
Thread Index |
Old Index