aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/hal
diff options
context:
space:
mode:
authormarcus <marcus@FreeBSD.org>2009-01-27 01:55:44 +0800
committermarcus <marcus@FreeBSD.org>2009-01-27 01:55:44 +0800
commitf1b81cca1a3fd0a8a55fd368a7cc61dd543dc2e2 (patch)
treeef21914ab361cefa767a2a84887fda9059a0fa2d /sysutils/hal
parent00cfb421096c29d79764a0fe1b31baa86afa1e7e (diff)
downloadfreebsd-ports-gnome-f1b81cca1a3fd0a8a55fd368a7cc61dd543dc2e2.tar.gz
freebsd-ports-gnome-f1b81cca1a3fd0a8a55fd368a7cc61dd543dc2e2.tar.zst
freebsd-ports-gnome-f1b81cca1a3fd0a8a55fd368a7cc61dd543dc2e2.zip
Take another stab at fixing mouse support in X. This approach eliminates
the constant polling to find a mouse device owner, and instead uses a kevent/polling model. Testing has shown this to work in all cases. Tested by: rnoland
Diffstat (limited to 'sysutils/hal')
-rw-r--r--sysutils/hal/Makefile2
-rw-r--r--sysutils/hal/files/hald.in2
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c96
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-devtree.c43
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_hf-usb.c11
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am24
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in97
-rw-r--r--sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c304
-rw-r--r--sysutils/hal/pkg-plist1
9 files changed, 556 insertions, 24 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile
index a5716f331744..e6f240d29b0d 100644
--- a/sysutils/hal/Makefile
+++ b/sysutils/hal/Makefile
@@ -8,7 +8,7 @@
PORTNAME= hal
DISTVERSION= 0.5.11
-PORTREVISION= 13
+PORTREVISION= 14
CATEGORIES= sysutils
MASTER_SITES= http://hal.freedesktop.org/releases/
diff --git a/sysutils/hal/files/hald.in b/sysutils/hal/files/hald.in
index 04e784e6ce6f..4e8b7e7e66e1 100644
--- a/sysutils/hal/files/hald.in
+++ b/sysutils/hal/files/hald.in
@@ -4,7 +4,7 @@
# $MCom: ports/sysutils/hal/files/hald.in,v 1.14 2008/08/21 16:04:48 mezz Exp $
#
# PROVIDE: hald
-# REQUIRE: DAEMON usbd devd dbus
+# REQUIRE: DAEMON usbd devd dbus moused
#
# Add the following line to /etc/rc.conf to enable the HAL daemon:
#
diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
index 2503e946c4ca..f3a14ac70051 100644
--- a/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
+++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c
@@ -1,6 +1,6 @@
---- hald/freebsd/addons/addon-mouse.c.orig 2009-01-24 02:12:21.000000000 -0500
-+++ hald/freebsd/addons/addon-mouse.c 2009-01-24 02:14:11.000000000 -0500
-@@ -0,0 +1,319 @@
+--- hald/freebsd/addons/addon-mouse.c.orig 2009-01-25 16:54:29.000000000 -0500
++++ hald/freebsd/addons/addon-mouse.c 2009-01-25 23:00:48.000000000 -0500
+@@ -0,0 +1,371 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
@@ -29,6 +29,10 @@
+#endif
+
+#include <sys/param.h>
++#include <sys/types.h>
++#include <sys/event.h>
++#include <sys/time.h>
++#include <sys/proc.h>
+#if __FreeBSD_version >= 800058
+#include <sys/types.h>
+#include <sys/user.h>
@@ -49,9 +53,10 @@
+#define CMD "/usr/bin/fstat %s"
+#endif
+
-+#define MOUSE_DRIVER "mouse"
+#define MOUSED_DEVICE "/dev/sysmouse"
+#define MOUSED_PROC_NAME "moused"
++#define XORG_PROC_NAME "Xorg"
++#define NO_PID -1
+
+static struct
+{
@@ -60,6 +65,8 @@
+ struct timespec next_update;
+} addon = { { 2, 0 } };
+
++static int kd = -1;
++
+#if __FreeBSD_version >= 800058
+static struct kinfo_proc *
+hfp_kinfo_getproc (int *cntp)
@@ -129,11 +136,13 @@
+}
+
+static gboolean
-+device_opened_by_proc (const char *device, const char *proc)
++device_opened_by_proc (const char *device, const char *proc, pid_t *pid)
+{
+ struct kinfo_proc *kip, *pfreep;
+ int cnt, i;
+
++ *pid = NO_PID;
++
+ pfreep = hfp_kinfo_getproc(&cnt);
+ if (pfreep == NULL)
+ return FALSE;
@@ -157,6 +166,7 @@
+ if (kif->kf_type == KF_TYPE_VNODE &&
+ ! strcmp(kif->kf_path, device))
+ {
++ *pid = kip->ki_pid;
+ g_free(ffreep);
+ g_free(pfreep);
+ return TRUE;
@@ -171,7 +181,7 @@
+}
+#else
+static gboolean
-+device_opened_by_proc (const char *device, const char *proc)
++device_opened_by_proc (const char *device, const char *proc, pid_t *pid)
+{
+ char **lines;
+ char *output = NULL;
@@ -180,8 +190,9 @@
+ gboolean found = FALSE;
+
+ cmd = g_strdup_printf(CMD, device);
++ *pid = NO_PID;
+
-+ if (! g_spawn_command_line_sync (cmd, &output, NULL, NULL, NULL))
++ if (! g_spawn_command_line_sync(cmd, &output, NULL, NULL, NULL))
+ {
+ g_free(cmd);
+ goto done;
@@ -206,7 +217,7 @@
+
+ fields = g_strsplit_set(lines[i], " ", 0);
+ len = g_strv_length(fields);
-+ if (len < 2)
++ if (len < 3)
+ {
+ g_strfreev(fields);
+ continue;
@@ -216,6 +227,10 @@
+ if (j < len && fields[j] && ! strcmp(fields[j], proc))
+ {
+ found = TRUE;
++ for (++j; j < len && fields[j] && *fields[j] == '\0'; j++)
++ ;
++ if (j < len && fields[j])
++ *pid = atoi(fields[j]);
+ g_strfreev(fields);
+ break;
+ }
@@ -232,9 +247,9 @@
+#endif
+
+static const char *
-+get_mouse_device (const char *device)
++get_mouse_device (const char *device, pid_t *pid)
+{
-+ if (device_opened_by_proc(device, MOUSED_PROC_NAME))
++ if (device_opened_by_proc(device, MOUSED_PROC_NAME, pid))
+ return MOUSED_DEVICE;
+
+ return device;
@@ -243,25 +258,59 @@
+static void
+poll_for_moused (void)
+{
-+ char *old_device;
++ struct kevent ev;
+ const char *device;
+ gboolean found;
++ pid_t pid;
++ char *owner = NULL;
++ char *prev_owner = NULL;
+
-+ old_device = libhal_device_get_property_string(hfp_ctx, hfp_udi, "input.device", &hfp_error);
-+ dbus_error_free(&hfp_error);
++again:
++ device = get_mouse_device(addon.device_file, &pid);
++ if (pid != NO_PID)
++ {
++ EV_SET(&ev, pid, EVFILT_PROC, EV_ADD | EV_ENABLE, NOTE_EXIT, 0, NULL);
++ if (kevent(kd, &ev, 1, NULL, 0, NULL) < 0)
++ return;
++ g_free(owner);
++ owner = g_strdup(MOUSED_PROC_NAME);
++ }
++ else
++ {
++ found = device_opened_by_proc(device, XORG_PROC_NAME, &pid);
++ if (found && pid != NO_PID)
++ {
++ EV_SET(&ev, pid, EVFILT_PROC, EV_ADD | EV_ENABLE, NOTE_EXIT, 0, NULL);
++ if (kevent(kd, &ev, 1, NULL, 0, NULL) < 0)
++ return;
++ g_free(owner);
++ owner = g_strdup(XORG_PROC_NAME);
++ }
++ else
++ goto out;
++ }
++
++ if (owner && prev_owner && strcmp(owner, prev_owner))
++ goto out;
++
++ if (kevent(kd, NULL, 0, &ev, 1, NULL) < 0)
++ return;
++
++ sleep(3);
++ g_free(prev_owner);
++ prev_owner = NULL;
++ if (owner)
++ prev_owner = g_strdup(owner);
++ goto again;
+
-+ device = get_mouse_device(addon.device_file);
-+ if (strcmp(old_device, device))
++out:
++ if (owner)
+ {
-+ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.device", &hfp_error);
-+ dbus_error_free(&hfp_error);
-+ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device", device, &hfp_error);
++ libhal_device_reprobe(hfp_ctx, hfp_udi, &hfp_error);
+ dbus_error_free(&hfp_error);
+ }
-+ g_free(old_device);
-+
-+ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.x11_driver", MOUSE_DRIVER, &hfp_error);
-+ dbus_error_free(&hfp_error);
++ g_free(owner);
++ g_free(prev_owner);
+}
+
+int
@@ -285,6 +334,9 @@
+ connection = libhal_ctx_get_dbus_connection(hfp_ctx);
+ assert(connection != NULL);
+
++ kd = kqueue();
++ assert(kd > -1);
++
+ while (TRUE)
+ {
+ /* process dbus traffic until update interval has elapsed */
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-devtree.c b/sysutils/hal/files/patch-hald_freebsd_hf-devtree.c
new file mode 100644
index 000000000000..ff41705faf6a
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-devtree.c
@@ -0,0 +1,43 @@
+--- hald/freebsd/hf-devtree.c.orig 2008-05-07 19:24:03.000000000 -0400
++++ hald/freebsd/hf-devtree.c 2009-01-25 17:17:02.000000000 -0500
+@@ -426,7 +426,13 @@ hf_devtree_probe (void)
+ HalDevice *device;
+
+ device = hf_devtree_device_new(parent, info->handler, info->unit);
+- hf_device_preprobe_and_add(device);
++ if (hf_device_preprobe(device))
++ {
++ if (hal_device_has_capability(device, "input.mouse"))
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
++
++ hf_device_add(device);
++ }
+ }
+
+ devices = g_slist_delete_link(devices, root);
+@@ -434,6 +440,17 @@ hf_devtree_probe (void)
+ }
+ }
+
++static gboolean
++hf_devtree_rescan (HalDevice *device)
++{
++ if (hal_device_has_capability(device, "input.mouse"))
++ {
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
++ return TRUE;
++ }
++ return FALSE;
++}
++
+ HalDevice *
+ hf_devtree_find_from_name (HalDeviceStore *store, const char *name)
+ {
+@@ -597,5 +614,6 @@ hf_devtree_is_driver (const char *name,
+ }
+
+ HFHandler hf_devtree_handler = {
+- .probe = hf_devtree_probe
++ .probe = hf_devtree_probe,
++ .device_rescan = hf_devtree_rescan
+ };
diff --git a/sysutils/hal/files/patch-hald_freebsd_hf-usb.c b/sysutils/hal/files/patch-hald_freebsd_hf-usb.c
new file mode 100644
index 000000000000..c3a129ef8149
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_hf-usb.c
@@ -0,0 +1,11 @@
+--- hald/freebsd/hf-usb.c.orig 2009-01-25 16:34:49.000000000 -0500
++++ hald/freebsd/hf-usb.c 2009-01-25 16:36:42.000000000 -0500
+@@ -575,6 +575,8 @@ hf_usb_probe_device (HalDevice *parent,
+ {
+ if (hal_device_has_capability(device, "hiddev"))
+ hf_runner_run_sync(device, 0, "hald-probe-hiddev", NULL);
++ if (hal_device_has_capability(device, "input.mouse"))
++ hf_runner_run_sync(device, 0, "hald-probe-mouse", NULL);
+
+ hf_device_add(device);
+ }
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am
new file mode 100644
index 000000000000..3c9004ea8d6e
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.am
@@ -0,0 +1,24 @@
+--- hald/freebsd/probing/Makefile.am.orig 2008-05-07 19:24:08.000000000 -0400
++++ hald/freebsd/probing/Makefile.am 2009-01-25 18:13:33.000000000 -0500
+@@ -10,6 +10,7 @@ AM_CPPFLAGS = \
+ if HALD_COMPILE_FREEBSD
+ libexec_PROGRAMS = \
+ hald-probe-hiddev \
++ hald-probe-mouse \
+ hald-probe-scsi \
+ hald-probe-smbios \
+ hald-probe-storage \
+@@ -21,6 +22,13 @@ hald_probe_hiddev_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
+ -lusbhid
+
++hald_probe_mouse_SOURCES = probe-mouse.c
++hald_probe_mouse_CPPFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@
++hald_probe_mouse_LDADD = \
++ @GLIB_LIBS@ \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++ -lutil
++
+ hald_probe_smbios_SOURCES = probe-smbios.c
+ hald_probe_smbios_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in
new file mode 100644
index 000000000000..328ae7e8b2fc
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_Makefile.in
@@ -0,0 +1,97 @@
+--- hald/freebsd/probing/Makefile.in.orig 2009-01-25 16:54:29.000000000 -0500
++++ hald/freebsd/probing/Makefile.in 2009-01-25 18:14:20.000000000 -0500
+@@ -34,6 +34,7 @@ build_triplet = @build@
+ host_triplet = @host@
+ @HALD_COMPILE_FREEBSD_TRUE@libexec_PROGRAMS = \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-hiddev$(EXEEXT) \
++@HALD_COMPILE_FREEBSD_TRUE@ hald-probe-mouse$(EXEEXT) \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-scsi$(EXEEXT) \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-smbios$(EXEEXT) \
+ @HALD_COMPILE_FREEBSD_TRUE@ hald-probe-storage$(EXEEXT) \
+@@ -54,6 +55,9 @@ PROGRAMS = $(libexec_PROGRAMS)
+ am_hald_probe_hiddev_OBJECTS = probe-hiddev.$(OBJEXT)
+ hald_probe_hiddev_OBJECTS = $(am_hald_probe_hiddev_OBJECTS)
+ hald_probe_hiddev_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
++am_hald_probe_mouse_OBJECTS = hald_probe_mouse-probe-mouse.$(OBJEXT)
++hald_probe_mouse_OBJECTS = $(am_hald_probe_mouse_OBJECTS)
++hald_probe_mouse_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+ am_hald_probe_scsi_OBJECTS = probe-scsi.$(OBJEXT)
+ hald_probe_scsi_OBJECTS = $(am_hald_probe_scsi_OBJECTS)
+ hald_probe_scsi_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+@@ -82,10 +86,11 @@ CCLD = $(CC)
+ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+-SOURCES = $(hald_probe_hiddev_SOURCES) $(hald_probe_scsi_SOURCES) \
+- $(hald_probe_smbios_SOURCES) $(hald_probe_storage_SOURCES) \
+- $(hald_probe_volume_SOURCES)
+-DIST_SOURCES = $(hald_probe_hiddev_SOURCES) $(hald_probe_scsi_SOURCES) \
++SOURCES = $(hald_probe_hiddev_SOURCES) $(hald_probe_mouse_SOURCES) \
++ $(hald_probe_scsi_SOURCES) $(hald_probe_smbios_SOURCES) \
++ $(hald_probe_storage_SOURCES) $(hald_probe_volume_SOURCES)
++DIST_SOURCES = $(hald_probe_hiddev_SOURCES) \
++ $(hald_probe_mouse_SOURCES) $(hald_probe_scsi_SOURCES) \
+ $(hald_probe_smbios_SOURCES) $(hald_probe_storage_SOURCES) \
+ $(hald_probe_volume_SOURCES)
+ ETAGS = etags
+@@ -238,6 +243,7 @@ sharedstatedir = @sharedstatedir@
+ srcdir = @srcdir@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
++top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ AM_CPPFLAGS = \
+@@ -254,6 +260,13 @@ hald_probe_hiddev_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
+ -lusbhid
+
++hald_probe_mouse_SOURCES = probe-mouse.c
++hald_probe_mouse_CPPFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@
++hald_probe_mouse_LDADD = \
++ @GLIB_LIBS@ \
++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la \
++ -lutil
++
+ hald_probe_smbios_SOURCES = probe-smbios.c
+ hald_probe_smbios_LDADD = \
+ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la
+@@ -340,6 +353,9 @@ clean-libexecPROGRAMS:
+ hald-probe-hiddev$(EXEEXT): $(hald_probe_hiddev_OBJECTS) $(hald_probe_hiddev_DEPENDENCIES)
+ @rm -f hald-probe-hiddev$(EXEEXT)
+ $(LINK) $(hald_probe_hiddev_OBJECTS) $(hald_probe_hiddev_LDADD) $(LIBS)
++hald-probe-mouse$(EXEEXT): $(hald_probe_mouse_OBJECTS) $(hald_probe_mouse_DEPENDENCIES)
++ @rm -f hald-probe-mouse$(EXEEXT)
++ $(LINK) $(hald_probe_mouse_OBJECTS) $(hald_probe_mouse_LDADD) $(LIBS)
+ hald-probe-scsi$(EXEEXT): $(hald_probe_scsi_OBJECTS) $(hald_probe_scsi_DEPENDENCIES)
+ @rm -f hald-probe-scsi$(EXEEXT)
+ $(LINK) $(hald_probe_scsi_OBJECTS) $(hald_probe_scsi_LDADD) $(LIBS)
+@@ -359,6 +375,7 @@ mostlyclean-compile:
+ distclean-compile:
+ -rm -f *.tab.c
+
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_mouse-probe-mouse.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_storage-probe-storage.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_probe_volume-freebsd_dvd_rw_utils.Po@am__quote@
+@@ -388,6 +405,20 @@ distclean-compile:
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
++hald_probe_mouse-probe-mouse.o: probe-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hald_probe_mouse-probe-mouse.o -MD -MP -MF $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo -c -o hald_probe_mouse-probe-mouse.o `test -f 'probe-mouse.c' || echo '$(srcdir)/'`probe-mouse.c
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo $(DEPDIR)/hald_probe_mouse-probe-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='probe-mouse.c' object='hald_probe_mouse-probe-mouse.o' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hald_probe_mouse-probe-mouse.o `test -f 'probe-mouse.c' || echo '$(srcdir)/'`probe-mouse.c
++
++hald_probe_mouse-probe-mouse.obj: probe-mouse.c
++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hald_probe_mouse-probe-mouse.obj -MD -MP -MF $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo -c -o hald_probe_mouse-probe-mouse.obj `if test -f 'probe-mouse.c'; then $(CYGPATH_W) 'probe-mouse.c'; else $(CYGPATH_W) '$(srcdir)/probe-mouse.c'; fi`
++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_probe_mouse-probe-mouse.Tpo $(DEPDIR)/hald_probe_mouse-probe-mouse.Po
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='probe-mouse.c' object='hald_probe_mouse-probe-mouse.obj' libtool=no @AMDEPBACKSLASH@
++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_mouse_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hald_probe_mouse-probe-mouse.obj `if test -f 'probe-mouse.c'; then $(CYGPATH_W) 'probe-mouse.c'; else $(CYGPATH_W) '$(srcdir)/probe-mouse.c'; fi`
++
+ hald_probe_storage-freebsd_dvd_rw_utils.o: freebsd_dvd_rw_utils.c
+ @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hald_probe_storage_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hald_probe_storage-freebsd_dvd_rw_utils.o -MD -MP -MF $(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Tpo -c -o hald_probe_storage-freebsd_dvd_rw_utils.o `test -f 'freebsd_dvd_rw_utils.c' || echo '$(srcdir)/'`freebsd_dvd_rw_utils.c
+ @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Tpo $(DEPDIR)/hald_probe_storage-freebsd_dvd_rw_utils.Po
diff --git a/sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c b/sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c
new file mode 100644
index 000000000000..516c5773b87f
--- /dev/null
+++ b/sysutils/hal/files/patch-hald_freebsd_probing_probe-mouse.c
@@ -0,0 +1,304 @@
+--- hald/freebsd/probing/probe-mouse.c.orig 2009-01-25 16:54:29.000000000 -0500
++++ hald/freebsd/probing/probe-mouse.c 2009-01-25 18:40:04.000000000 -0500
+@@ -0,0 +1,301 @@
++/***************************************************************************
++ * CVSID: $Id$
++ *
++ * probe-hiddev.c : Mouse prober
++ *
++ * Copyright (C) 2008 Joe Marcus Clarke <marcus@FreeBSD.org>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ *
++ **************************************************************************/
++
++#ifdef HAVE_CONFIG_H
++# include <config.h>
++#endif
++
++#include <sys/param.h>
++#if __FreeBSD_version >= 800058
++#include <sys/types.h>
++#include <sys/user.h>
++#include <sys/sysctl.h>
++#include <libutil.h>
++#endif
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <fcntl.h>
++#include <glib.h>
++
++#include "../libprobe/hfp.h"
++
++#if __FreeBSD_version < 800058
++#define CMD "/usr/bin/fstat %s"
++#endif
++
++#define MOUSE_DRIVER "mouse"
++#define MOUSED_DEVICE "/dev/sysmouse"
++#define MOUSED_PROC_NAME "moused"
++#define XORG_PROC_NAME "Xorg"
++
++#if __FreeBSD_version >= 800058
++static struct kinfo_proc *
++hfp_kinfo_getproc (int *cntp)
++{
++ int mib[3];
++ int error;
++ int cnt;
++ size_t len;
++ char *buf, *bp, *eb;
++ struct kinfo_proc *kip, *kp, *ki;
++
++ *cntp = 0;
++
++ len = 0;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC;
++ mib[2] = KERN_PROC_PROC;
++
++ error = sysctl(mib, 3, NULL, &len, NULL, 0);
++ if (error)
++ return NULL;
++
++ len = len * 4 / 3;
++ buf = (char *) g_malloc(len);
++ if (buf == NULL)
++ return NULL;
++
++ error = sysctl(mib, 3, buf, &len, NULL, 0);
++ if (error)
++ {
++ g_free(buf);
++ return NULL;
++ }
++
++ cnt = 0;
++ bp = buf;
++ eb = buf + len;
++ while (bp < eb)
++ {
++ ki = (struct kinfo_proc *) (uintptr_t) bp;
++ bp += ki->ki_structsize;
++ cnt++;
++ }
++
++ kip = calloc(cnt, sizeof (*kip));
++ if (kip == NULL)
++ {
++ g_free(buf);
++ return NULL;
++ }
++
++ bp = buf;
++ eb = buf + len;
++ kp = kip;
++ while (bp < eb)
++ {
++ ki = (struct kinfo_proc *) (uintptr_t) bp;
++ memcpy(kp, ki, ki->ki_structsize);
++ bp += ki->ki_structsize;
++ kp->ki_structsize = sizeof(*kp);
++ kp++;
++ }
++
++ g_free(buf);
++ *cntp = cnt;
++ return kip;
++}
++
++static gboolean
++device_opened_by_proc (const char *device, const char *proc)
++{
++ struct kinfo_proc *kip, *pfreep;
++ int cnt, i;
++
++ pfreep = hfp_kinfo_getproc(&cnt);
++ if (pfreep == NULL)
++ return FALSE;
++
++ for (i = 0; i < cnt; i++)
++ {
++ kip = &pfreep[i];
++
++ if (! strcmp(kip->ki_comm, proc))
++ {
++ struct kinfo_file *kif, *ffreep;
++ int fcnt, j;
++
++ ffreep = kinfo_getfile(kip->ki_pid, &fcnt);
++ if (ffreep == NULL)
++ continue;
++ for (j = 0; j < fcnt; j++)
++ {
++ kif = &ffreep[j];
++
++ if (kif->kf_type == KF_TYPE_VNODE &&
++ ! strcmp(kif->kf_path, device))
++ {
++ g_free(ffreep);
++ g_free(pfreep);
++ return TRUE;
++ }
++ }
++ g_free(ffreep);
++ }
++ }
++ g_free(pfreep);
++
++ return FALSE;
++}
++#else
++static gboolean
++device_opened_by_proc (const char *device, const char *proc)
++{
++ char **lines;
++ char *output = NULL;
++ char *cmd;
++ int i;
++ gboolean found = FALSE;
++
++ cmd = g_strdup_printf(CMD, device);
++
++ if (! g_spawn_command_line_sync(cmd, &output, NULL, NULL, NULL))
++ {
++ g_free(cmd);
++ goto done;
++ }
++ g_free(cmd);
++
++ if (! output || strlen(output) == 0)
++ goto done;
++
++ lines = g_strsplit(output, "\n", 0);
++ if (g_strv_length(lines) < 2)
++ {
++ g_strfreev(lines);
++ goto done;
++ }
++
++ for (i = 1; lines[i]; i++)
++ {
++ char **fields;
++ guint len;
++ guint j;
++
++ fields = g_strsplit_set(lines[i], " ", 0);
++ len = g_strv_length(fields);
++ if (len < 3)
++ {
++ g_strfreev(fields);
++ continue;
++ }
++ for (j = 1; j < len && fields[j] && *fields[j] == '\0'; j++)
++ ;
++ if (j < len && fields[j] && ! strcmp(fields[j], proc))
++ {
++ found = TRUE;
++ g_strfreev(fields);
++ break;
++ }
++ g_strfreev(fields);
++ }
++
++ g_strfreev(lines);
++
++done:
++ g_free(output);
++
++ return found;
++}
++#endif
++
++static void
++probe_mouse (const char *device_file)
++{
++ gboolean found;
++ char *driver;
++
++ driver = libhal_device_get_property_string(hfp_ctx, hfp_udi,
++ "input.x11_driver", &hfp_error);
++ dbus_error_free(&hfp_error);
++
++ found = device_opened_by_proc(device_file, XORG_PROC_NAME);
++ if (found)
++ {
++ if (driver)
++ {
++ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.x11_driver",
++ &hfp_error);
++ dbus_error_free(&hfp_error);
++ g_free(driver);
++ }
++ return;
++ }
++
++ found = device_opened_by_proc(device_file, MOUSED_PROC_NAME);
++ if (found)
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device",
++ MOUSED_DEVICE, &hfp_error);
++ dbus_error_free(&hfp_error);
++ found = device_opened_by_proc(MOUSED_DEVICE, XORG_PROC_NAME);
++ if (! found)
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi,
++ "input.x11_driver",
++ MOUSE_DRIVER, &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++ else if (driver)
++ {
++ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.x11_driver",
++ &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++ }
++ else
++ {
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device",
++ device_file, &hfp_error);
++ dbus_error_free(&hfp_error);
++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.x11_driver",
++ MOUSE_DRIVER, &hfp_error);
++ dbus_error_free(&hfp_error);
++ }
++
++ g_free(driver);
++}
++
++int
++main (int argc, char **argv)
++{
++ char *device_file;
++
++ if (! hfp_init(argc, argv))
++ goto end;
++
++ device_file = getenv("HAL_PROP_FREEBSD_DEVICE_FILE");
++ if (! device_file)
++ goto end;
++
++ /* give a meaningful process title for ps(1) */
++ setproctitle("%s", device_file);
++
++ /* Sleep for a second to give moused a chance to connect. */
++ sleep(1);
++ probe_mouse(device_file);
++
++ end:
++ return 0;
++}
diff --git a/sysutils/hal/pkg-plist b/sysutils/hal/pkg-plist
index f42809179477..04b41b3765b9 100644
--- a/sysutils/hal/pkg-plist
+++ b/sysutils/hal/pkg-plist
@@ -65,6 +65,7 @@ libexec/hald-addon-mouse-sysmouse
libexec/hald-addon-storage
libexec/hald-generate-fdi-cache
libexec/hald-probe-hiddev
+libexec/hald-probe-mouse
libexec/hald-probe-scsi
libexec/hald-probe-smbios
libexec/hald-probe-storage