summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@fido2.homeip.net>2008-10-23 21:54:44 -0700
committerPhilip Langdale <philipl@fido2.homeip.net>2008-10-23 21:54:44 -0700
commiteb03e96c1974a3fbe1c48c56974ff32bc886c8f7 (patch)
treea0a671aa85dc18d54dcda82ab738ac3e332888a0
parent223afd09500672a7fe8a1ab5fc221001863a8bec (diff)
Add HAL integration to support input hot plug.
* vmmouse_detect: A simple program that detects whether a vmmouse device is present. * hal-probe-vmmouse: A HAL callout script that uses vmmouse_detect and overrides input.x11_driver. * 11-x11-vmmouse.fdi: fdi descriptor that adds the callout for PS/2 mice. Additional 'configure' variables have been added to allow for overriding HAL paths, although this shouldn't usually be necessary.
-rw-r--r--Makefile.am2
-rw-r--r--README13
-rw-r--r--configure.ac28
-rw-r--r--fdi/11-x11-vmmouse.fdi10
-rw-r--r--fdi/Makefile.am25
-rw-r--r--man/Makefile.am4
-rw-r--r--man/vmmouse_detect.158
-rw-r--r--tools/Makefile.am39
-rwxr-xr-xtools/hal-probe-vmmouse.in10
-rw-r--r--tools/vmmouse_detect.c67
10 files changed, 253 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index de3a585..2e7b369 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,4 +19,4 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = shared src man
+SUBDIRS = shared src tools fdi man
diff --git a/README b/README
index 1e9e762..4205876 100644
--- a/README
+++ b/README
@@ -51,3 +51,16 @@ The driver is composed of three different layers:
are still transmitted on the PS/2 port so it is necessary
to be set up to receive those interrupts like a standard
PS/2 driver, but the actual data on the PS/2 port is ignored.
+
+vmmouse_detect
+--------------
+
+A simple program to detect whether the vmmouse device is present.
+It is used by the HAL callout script to automatically detect a
+vmmouse device.
+
+Returns 0 if we are running in a virtual machine where the vmmouse
+device is present.
+
+Returns 1 otherwise (either we are not in a VM or the vmmouse device
+was disabled).
diff --git a/configure.ac b/configure.ac
index a389f3a..90e3d22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,32 @@ AC_ARG_WITH(xorg-module-dir,
inputdir=${moduledir}/input
AC_SUBST(inputdir)
+AC_ARG_WITH(hal_bin_dir,
+ AC_HELP_STRING([--with-hal-bin-dir=DIR],
+ [Directory where HAL binaries where installed [[default=$bindir]]]),
+ [halbindir="$withval"],
+ [halbindir="$bindir"])
+HAL_BIN_DIR=${halbindir}
+AC_SUBST(HAL_BIN_DIR)
+
+AC_ARG_WITH(hal_callouts_dir,
+ AC_HELP_STRING([--with-hal-callouts-dir=DIR],
+ [Directory where HAL expects its callout scripts to be located
+ [[default=$libdir/hal]]]),
+ [halcalloutsdir="$withval"],
+ [halcalloutsdir="$libdir/hal"])
+HAL_CALLOUTS_DIR=${halcalloutsdir}
+AC_SUBST(HAL_CALLOUTS_DIR)
+
+AC_ARG_WITH(hal_fdi_dir,
+ AC_HELP_STRING([--with-hal-fdi-dir=DIR],
+ [Directory where HAL expects its fdi files to be located
+ [[default=$datadir/hal/fdi/policy/20thirdparty]]]),
+ [halfdidir="$withval"],
+ [halfdidir="$datadir/hal/fdi/policy/20thirdparty"])
+HAL_FDI_DIR=${halfdidir}
+AC_SUBST(HAL_FDI_DIR)
+
# Checks for extensions
XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
XORG_DRIVER_CHECK_EXT(XINPUT, inputproto)
@@ -101,4 +127,4 @@ AC_HEADER_STDC
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION
-AC_OUTPUT([Makefile shared/Makefile src/Makefile man/Makefile])
+AC_OUTPUT([Makefile shared/Makefile src/Makefile tools/Makefile fdi/Makefile man/Makefile])
diff --git a/fdi/11-x11-vmmouse.fdi b/fdi/11-x11-vmmouse.fdi
new file mode 100644
index 0000000..e725f9a
--- /dev/null
+++ b/fdi/11-x11-vmmouse.fdi
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<deviceinfo version="0.2">
+ <device>
+ <match key="info.capabilities" contains="input.mouse">
+ <match key="input.originating_device" contains="i8042_AUX_port">
+ <append key="info.callouts.add" type="strlist">hal-probe-vmmouse</append>
+ </match>
+ </match>
+ </device>
+</deviceinfo>
diff --git a/fdi/Makefile.am b/fdi/Makefile.am
new file mode 100644
index 0000000..4581f27
--- /dev/null
+++ b/fdi/Makefile.am
@@ -0,0 +1,25 @@
+# Copyright 2008 VMware, 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
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+# VMWARE, INC. 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.
+
+fdidir=$(HAL_FDI_DIR)
+fdi_DATA = 11-x11-vmmouse.fdi
+
+EXTRA_DIST = 11-x11-vmmouse.fdi
+
diff --git a/man/Makefile.am b/man/Makefile.am
index f0eb29b..1f31487 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -24,13 +24,15 @@
# from the copyright holders.
#
+man_MANS = @DRIVER_NAME@_detect.1
+
drivermandir = $(DRIVER_MAN_DIR)
driverman_PRE = @DRIVER_NAME@.man
driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
-EXTRA_DIST = @DRIVER_NAME@.man
+EXTRA_DIST = @DRIVER_NAME@.man @DRIVER_NAME@_detect.1
CLEANFILES = $(driverman_DATA)
diff --git a/man/vmmouse_detect.1 b/man/vmmouse_detect.1
new file mode 100644
index 0000000..ca1ec71
--- /dev/null
+++ b/man/vmmouse_detect.1
@@ -0,0 +1,58 @@
+.\" This manpage is copyright (C) 2007 Canonical, Ltd
+.\" Author: Bryce Harrington <bryce@ubuntu.com>
+.\"
+.\" This is free software; you may 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,
+.\" or (at your option) any later version.
+.\"
+.\" This 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 the Debian GNU/Linux system; if not, write to the Free
+.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+.\" 02111-1307 USA
+.\"
+.\" That's right, although mdetect itself is under the QPL, this manpage is
+.\" under the GPL. Enjoy!
+.TH vmmouse_detect 1 "2007-07-19" "Debian GNU/Linux"
+.SH NAME
+vmmouse_detect \- VMware mouse device autodetection tool
+.SH SYNOPSIS
+vmmouse_detect
+.SH OPTIONS
+vmmouse_detect has no options
+.SH DESCRIPTION
+.B vmmouse_detect
+is a tool for detecting if running in a VMware environment where vmmouse
+is used. It exits with a 0 return value if the vmmouse client is
+enabled, and 1 if not.
+.SH DIAGNOSTICS
+.BR vmmouse_detect 's
+exit status is used to communicate information.
+.IP 0
+.B vmmouse_detect
+found a mouse and exited normally.
+.IP 1
+Either the vmmouse client was not enabled, or it is not being run from
+within a VMware virtual machine.
+.SH BUGS
+Please report bugs in
+.B vmmouse_detect
+<https://bugs.launchpad.net/ubuntu/+source/mdetect/vmmouse_detect>.
+.SH AUTHORS
+.B vmmouse_detect
+is copyright 2007 VMware, Inc.
+.SH LICENSING
+The
+.B vmmouse_detect
+source code is licensed under a BSD-like license. See COPYING for
+details.
+.PP
+This manual page is licensed under the GNU General Public License.
+.SH SEE ALSO
+.IR mdetect (1),
+.IR XFree86 (1)
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..9236c5f
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,39 @@
+# Copyright 2008 VMware, 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
+# on the rights to use, copy, modify, merge, publish, distribute, sub
+# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+# VMWARE, INC. 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.
+
+bin_PROGRAMS = @DRIVER_NAME@_detect
+
+SHARED_PATH = $(top_srcdir)/shared
+INCLUDES = -I$(SHARED_PATH)
+
+@DRIVER_NAME@_detect_SOURCES = vmmouse_detect.c
+@DRIVER_NAME@_detect_LDADD = $(SHARED_PATH)/lib@DRIVER_NAME@.la
+
+calloutsdir=$(HAL_CALLOUTS_DIR)
+callouts_SCRIPTS = hal-probe-vmmouse
+
+hal-probe-vmmouse:
+ sed -e 's|__BIN_PREFIX__|$(bindir)|g' \
+ -e 's|__HAL_BIN_PREFIX__|$(HAL_BIN_DIR)|g' \
+ < $@.in > $@
+
+EXTRA_DIST = hal-probe-vmmouse.in
+
+CLEANFILES = hal-probe-vmmouse
diff --git a/tools/hal-probe-vmmouse.in b/tools/hal-probe-vmmouse.in
new file mode 100755
index 0000000..67e6149
--- /dev/null
+++ b/tools/hal-probe-vmmouse.in
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+[ -x __HAL_BIN_PREFIX__/hal-set-property ] || exit 0
+[ -x __BIN_PREFIX__/vmmouse_detect ] || exit 0
+
+__BIN_PREFIX__/vmmouse_detect
+if [ $? -eq 0 ]; then
+ __HAL_BIN_PREFIX__/hal-set-property --direct --udi "$UDI" --key input.x11_driver --string "vmmouse"
+fi
+
diff --git a/tools/vmmouse_detect.c b/tools/vmmouse_detect.c
new file mode 100644
index 0000000..e5f14a3
--- /dev/null
+++ b/tools/vmmouse_detect.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007 by VMware, 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+#include <stdlib.h>
+#include <signal.h>
+#include "vmmouse_client.h"
+
+void
+segvCB(int sig)
+{
+ exit(1);
+}
+
+
+int
+main(void)
+{
+ /*
+ * If the vmmouse test is not run in a VMware virtual machine, it
+ * will segfault instead of successfully accessing the port.
+ */
+ signal(SIGSEGV, segvCB);
+
+#if defined __i386__ || defined __x86_64__
+ /*
+ * To access i/o ports above 0x3ff, we need to be in iopl(3).
+ */
+
+ iopl(3);
+ if (VMMouseClient_Enable()) {
+ VMMouseClient_Disable();
+ return 0;
+ } else {
+ /*
+ * We get here if we are running in a VM and the vmmouse
+ * device is disabled.
+ */
+ return 1;
+ }
+#endif
+ return 1;
+}