Compare commits

...

43 Commits

Author SHA1 Message Date
Peter Hutterer
990540fa19 evdev 2.5.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-23 10:34:36 +10:00
Peter Hutterer
b8945e61eb man: don't reference README.mouse
No real reason to refer to the mouse driver's readme.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-23 10:27:45 +10:00
Peter Hutterer
97dc45b769 evdev 2.4.99.901
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-19 12:50:25 +10:00
Bartosz Brachaczek
ec6cb31cc4 evdev: Initialize valuators array. (#24737)
The array needs to be filled with zeros, otherwise we may end up sending
it with random values if non-zero values aren't in one row (which is the
case for A4Tech X-750F which sends REL_MISC events without a reason).

X.Org Bug 24737 <http://bugs.freedesktop.org/show_bug.cgi?id=24737>

Signed-off-by: Bartosz Brachaczek <b.brachaczek@gmail.com>
Tested-by: Bartek Iwaniec <hash87@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-16 10:45:26 +10:00
Bartosz Brachaczek
ed47c7f33e evdev: Revert "Set all valuators for relative motion events (#24737)"
It isn't necessary to post zero-deltas to X Server. In order not to post
uninitialized "v" array we should rather simply initialize it.

This reverts commit c1f16a4f59.

Signed-off-by: Bartosz Brachaczek <b.brachaczek@gmail.com>
Tested-by: Bartek Iwaniec <hash87@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-16 10:45:07 +10:00
Peter Hutterer
899218e181 Don't count BTN_TOUCH as tool. (#29428)
Devices that don't have a tool but BTN_TOUCH simply have the tool always on.
Devices that have a tool other than BTN_TOUCH set this tool before BTN_TOUCH
is emitted anyway.

X.Org Bug 29428 <http://bugs.freedesktop.org/show_bug.cgi?id=29428>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-08-16 10:04:08 +10:00
Alex Warg
421585fda6 Fix out-of-bounds access if more than MAX_VALUATORS are present. (#28809)
The functions EvdevAddRelClass and EvdevAddAbsClass do out of bounds
accesses to vals and old_vals arrays in the EvdevRec structure if there are
more than MAX_VALUATORS axes reported by the kernel.

X.Org Bug 28809 <http://bugs.freedesktop.org/show_bug.cgi?id=28809>

Signed-off-by: Alex Warg <alexander.warg@os.inf.tu-dresden.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-07-01 08:16:07 +10:00
Peter Hutterer
8697811f56 man: some minor fixes to man page.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-28 10:49:56 +10:00
Peter Hutterer
b06bffdc97 Add myself to Authors in man page.
git blames me for about half the driver now, I guess that's enough
justification ;)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-28 10:49:56 +10:00
Gaetan Nadon
9410e452d2 config: use AC_PROG_INSTALL now supplied by XORG_DEFAULT_OPTIONS
It depends on util-macros 1.8
The existing statement can now be removed from the configuration file.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-06-16 15:19:39 -04:00
Gaetan Nadon
516e538da4 config: upgrade to util-macros 1.8 for additional man page support
Use MAN_SUBST now supplied in XORG_MANPAGE_SECTIONS
The value of MAN_SUBST is the same for all X.Org packages.

Use AC_PROG_SED now supplied by XORG_DEFAULT_OPTIONS
The existing statement can now be removed from the configuration file.

Use Automake $() for variables in Makefile.am

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-06-16 15:19:38 -04:00
Gaetan Nadon
1f38e1bc11 COPYING: update and refactor the Copyright notices
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-06-16 15:17:06 -04:00
Peter Hutterer
456579ba30 Bump to 2.4.99
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-06-01 10:20:25 +10:00
Peter Hutterer
21a2ac818e Disable middle mouse button emulation by default.
The AUTO feature was the default, MB emulation was on until a middle mouse
button was pressed. MB emulation however results in a delay of the first
press, causing minor annoyances to the users and being generally confusing
when the behaviour before a button press is different to after a button
pres.

Disable the feature by default instead. There's not a lot of two-button mice
around anymore though and the inability to detect two-button mice makes for
non-deterministic detection of when the emulation should be on.

Middle button emulation can be enabled with a configuration snippet:

Section "InputClass"
        Identifier "middle button emulation"
        MatchIsPointer "on"
        Option "Emulate3Buttons" "on"
EndSection

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
2010-05-31 11:01:26 +10:00
Peter Hutterer
4c21624240 Remove libc wrappers for malloc, calloc and free.
Evdev is Linux-only, and we've had the above calls for quite a while now.
Plus, now that the server has removed them they generate _a lot_ of warnings
otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
6e244b1098 Move mode declaration, it's not const either.
What we're getting back from xf86SetStrOption is a strdup'd string, not
const, especially given that we free it a few lines down.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
e7c301563a Move opening the device into a separate function.
Re-use from EvdevOn and PreInit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
ffc2c9961f Move checks for calibration, inversion and axis swap to EvdevProbe.
Keyboard devices don't need these checks.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
7c01cff1fa Move EVIOCGRAB into a static func.
This is in preparation of some major rework, there are no functional
changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
e6e20c1b3e Move error handling in PreInit down to the end.
Just have one exit path instead of different ones. Guards are in place to
avoid freeing/deleting something that shouldn't be.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
b27d03b248 Comment odd EVIOCGRAB behaviour and reshuffle conditions a bit.
The reason for this rather weird approach is to ungrab immediately after
getting a successful grab. Evdev shouldn't be hogging the device if nothing
is done with it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-28 09:24:28 +10:00
Peter Hutterer
ba78428ed5 Remove support for kernel 2.4.
It's been 6 years since 2.6, I doubt evdev would even work on 2.4 right now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-05-28 09:24:28 +10:00
Gaetan Nadon
041a1f246a config: AC_PROG_SED is required explicitly.
It sets the SED env variable with an appropriate sed program path
It still works on some platform when not explicity called.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-05-10 21:44:43 -04:00
Peter Hutterer
44b80d177f Update a stale comment about the use of pEvdev->tool.
Including some typo fixes in the same comment.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-06 11:11:30 +10:00
Peter Hutterer
7bbbce9a83 Read the device resolution from the kernel.
For earlier kernels, use the previous hardcoded resolution in place.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-04-29 22:05:23 +10:00
Peter Hutterer
35b6085bf8 config: remove AH_TOP autoheader statement.
Include it in evdev.h instead.
xorg-server.h is required to define the right datatype sizes on 64 bit,
hence ensure that evdev.h is the first included in each file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-29 09:07:03 +10:00
Gaetan Nadon
539d67505c Revert "config: remove AH_TOP autoheader statement"
The changed location of xorg-server.h had some side-effects.
See Bug 27768 <https://bugs.freedesktop.org/show_bug.cgi?id=27768>

This reverts commit 9dbace89be.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-22 11:42:49 +10:00
Peter Hutterer
a77dea1caa Merge branch 'master' of git://gitorious.org/omcfadde/xf86-input-evdev 2010-04-20 16:31:09 +10:00
Oliver McFadden
5fb1e841eb evdev: EvdevProbe: check ioctl() return value and warn on failure.
Called function "ioctl" whose return value should be checked (checked 10
out of 11 times)

Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-20 09:12:43 +03:00
Oliver McFadden
a4f2d12cd8 evdev: ioctl() may return a negative value therefor use a signed integer.
Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-20 09:12:38 +03:00
Oliver McFadden
6b5c0401e2 evdev: leaked_storage: free memory allocated from the xf86Option code.
Signed-off-by: Oliver McFadden <oliver.mcfadden@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-20 09:12:30 +03:00
Gaetan Nadon
993e011b91 man: Use Autoconf provided $(AM_V_GEN)$(SED)
Enables silent rule and use platform appropriate version of sed.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
2d5e922a6d include: EXTRA_DIST is not required for header files.
The sdk_HEADERS is sufficient as the "sdk" prefix
matches the "dir" suffix in the "sdkdir" variable.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
41a38ec886 config: require macros 1.4, fix warnings, m4 quotings and layout
Fix some m4 quoting
Fix some autoconf warnings
remove AC_PROG_CC as it overrides AC_PROG_C_C99 from XORG_DEFAULT_OPTIONS
Regroup statements per section
Add comments
Upgrade X.Org macros to 1.4 for INSTALL file copying

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
b31c00efea config: optional extension check for inputproto not required
The check should be in PKG_CHECK_MODULES permanently.

The XORG_DRIVER_CHECK_EXT will add inputproto to PKG_CHECK_MODULES
only if the extension is available. By definition, this extension
is always available and the evdev driver cannot function without it.

This is evidenced by the absence of XINPUT conditional code.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:07 -04:00
Gaetan Nadon
b48dcfa3f2 config: replace deprecated INCLUDES with AM_CPPFLAGS
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
44baa36b99 config: refactor and comment the sdkdir distcheck workaround
Seperate legitimate sdkdir usage from distcheck workaround.
Comment this non obvious workaround.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
7fa5982d47 config: remove unrequired AC_HEADER_STDC
Autoconf says:
"This macro is obsolescent, as current systems have conforming
header files. New programs need not use this macro".

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
fe8d0fa11a replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS
Regroup AC statements at the top.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
09b918db86 config: update AC_PREREQ statement to 2.60
Unrelated to the previous patches, the new value simply reflects
the reality that the minimum level for autoconf to configure
all x.org modules is 2.60 dated June 2006.

ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Gaetan Nadon
9dbace89be config: remove AH_TOP autoheader statement
The generated config.h does not need to include xorg-server.h
for the content it provides.
Add #include <xorg-server.h> in .[hc] files as needed.

Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2010-04-19 08:52:06 -04:00
Paulo Ricardo Zanoni
aaf65e7bfa Don't set pEvdev->rel for mouse wheel events
This way we won't get empty MotionNotify events when the mouse wheel is
used.

Signed-off-by: Paulo Ricardo Zanoni <pzanoni@mandriva.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-17 15:17:27 +10:00
Peter Hutterer
8eede7ea8d Use X_PROBED instead of X_INFO for probed values.
No functional changes, only the log output differs now.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
2010-04-09 14:32:18 +10:00
12 changed files with 264 additions and 305 deletions

49
COPYING
View File

@@ -1,16 +1,21 @@
Various copyright notices found in this driver:
Copyright © 2004-2008 Red Hat, Inc.
Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
Copyright 1993 by David Dawes <dawes@xfree86.org>
Copyright 2002 by SuSE Linux AG, Author: Egbert Eich
Copyright 1994-2002 by The XFree86 Project, Inc.
Copyright 2002 by Paul Elliott
Copyright © 2008 University of South Australia
Copyright 2008 by Chris Salch
Copyright © 2008 Red Hat, Inc.
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without
fee, provided that the above copyright notice appear in all copies
and that both that copyright notice and this permission notice
appear in supporting documentation, and that the name of Red Hat
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission. Red
Hat makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied
appear in supporting documentation, and that the name of the authors
not be used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. The authors make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
@@ -42,34 +47,6 @@ 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.
Copyright © 2008 University of South Australia
copyrights taken from xf86-input-mouse, partly valid for this driver.
Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
Copyright 1993 by David Dawes <dawes@xfree86.org>
Copyright 2002 by SuSE Linux AG, Author: Egbert Eich
Copyright 1994-2002 by The XFree86 Project, Inc.
Copyright 2002 by Paul Elliott
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without
fee, provided that the above copyright notice appear in all copies
and that both that copyright notice and this permission notice
appear in supporting documentation, and that the name of the authors
not be used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. The authors make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Copyright 2005 Adam Jackson.
Permission is hereby granted, free of charge, to any person obtaining a

View File

@@ -19,7 +19,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Ensure headers are installed below $(prefix) for distcheck
# Provide an sdk location that is writable by the evdev module
DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg'
SUBDIRS = src man include

View File

@@ -20,33 +20,34 @@
#
# Process this file with autoconf to produce a configure script
AC_PREREQ(2.57)
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xf86-input-evdev],
2.4.0,
[2.5.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
xf86-input-evdev)
[xf86-input-evdev])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE([foreign dist-bzip2])
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
# Require xorg-macros: XORG_DEFAULT_OPTIONS
m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.3)
XORG_DEFAULT_OPTIONS
AM_CONFIG_HEADER([config.h])
# Checks for programs.
# Initialize libtool
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_CC
AH_TOP([#include "xorg-server.h"])
# Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
# Obtain compiler/linker options from server and required extensions
PKG_CHECK_MODULES(XORG, xorg-server xproto inputproto)
# Define a configure option for an alternate input module directory
AC_ARG_WITH(xorg-module-dir,
AC_HELP_STRING([--with-xorg-module-dir=DIR],
[Default xorg module directory [[default=$libdir/xorg/modules]]]),
@@ -55,28 +56,21 @@ AC_ARG_WITH(xorg-module-dir,
inputdir=${moduledir}/input
AC_SUBST(inputdir)
# Checks for extensions
XORG_DRIVER_CHECK_EXT(XINPUT, inputproto)
# X Server SDK location is required to install evdev header files
# This location is also relayed in the xorg-evdev.pc file
sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
# Checks for pkg-config packages. We need to be able to override sdkdir
# to satisfy silly distcheck requirements.
PKG_CHECK_MODULES(XORG, xorg-server xproto $REQUIRED_MODULES)
AC_ARG_WITH([sdkdir], [],
[sdkdir="$withval"],
[sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`])
# Workaround overriding sdkdir to be able to create a tarball when user has no
# write permission in sdkdir. See DISTCHECK_CONFIGURE_FLAGS in Makefile.am
AC_ARG_WITH([sdkdir], [], [sdkdir="$withval"])
AC_SUBST([sdkdir])
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
DRIVER_NAME=evdev
AC_SUBST([DRIVER_NAME])
AC_OUTPUT([Makefile
src/Makefile
man/Makefile
include/Makefile
xorg-evdev.pc])
AC_CONFIG_FILES([Makefile
src/Makefile
man/Makefile
include/Makefile
xorg-evdev.pc])
AC_OUTPUT

View File

@@ -1,2 +1 @@
EXTRA_DIST = evdev-properties.h
sdk_HEADERS = evdev-properties.h

View File

@@ -22,33 +22,16 @@
drivermandir = $(DRIVER_MAN_DIR)
driverman_PRE = @DRIVER_NAME@.man
driverman_PRE = $(DRIVER_NAME).man
driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
driverman_DATA = $(driverman_PRE:man=$(DRIVER_MAN_SUFFIX))
EXTRA_DIST = @DRIVER_NAME@.man
EXTRA_DIST = $(DRIVER_NAME).man
CLEANFILES = $(driverman_DATA)
SED = sed
# Strings to replace in man pages
XORGRELSTRING = @PACKAGE_STRING@
XORGMANNAME = X Version 11
MAN_SUBSTS = \
-e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
-e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
-e 's|__xservername__|Xorg|g' \
-e 's|__xconfigfile__|xorg.conf|g' \
-e 's|__projectroot__|$(prefix)|g' \
-e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \
-e 's|__drivermansuffix__|$(DRIVER_MAN_SUFFIX)|g' \
-e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \
-e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \
-e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g'
SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
.man.$(DRIVER_MAN_SUFFIX):
sed $(MAN_SUBSTS) < $< > $@
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@

View File

@@ -19,15 +19,24 @@ evdev \- Generic Linux input driver
.B evdev
is an __xservername__ input driver for Linux\'s generic event devices. It
therefore supports all input devices that the kernel knows about, including
most mice and keyboards.
most mice, keyboards, tablets and touchscreens.
.B evdev
is the default driver on the major Linux distributions.
.PP
The
.B evdev
driver can serve as both a pointer and a keyboard input device, and may be
used as both the core keyboard and the core pointer. Multiple input devices
are supported by multiple instances of this driver, with one Load
directive for evdev in the Module section of your __xconfigfile__ for each
input device that will use this driver.
driver can serve as both a pointer and a keyboard input device. Multiple
input devices are supported by multiple instances of this driver, with one
InputDevice section of your __xconfigfile__ for each input device that will
use this driver.
.PP
It is recommended that
.B evdev
devices are configured through the
.B InputClass
directive (refer to __xconfigfile__(__filemansuffix__)) instead of manual
per-device configuration. Devices configured in the
__xconfigfile__(__filemansuffix__) are not hot-plug capable.
.PP
.SH SUPPORTED HARDWARE
In general, any input device that the kernel has a driver for can be accessed
@@ -76,8 +85,7 @@ indicating that the next button pressed is to be
.BI "Option \*qEmulate3Buttons\*q \*q" boolean \*q
Enable/disable the emulation of the third (middle) mouse button for mice
which only have two physical buttons. The third button is emulated by
pressing both buttons simultaneously. Default: off for touchscreens, otherwise
on until a middle mouse button event is registered. Property: "Evdev Middle
pressing both buttons simultaneously. Default: off. Property: "Evdev Middle
Button Emulation".
.TP 7
.BI "Option \*qEmulate3Timeout\*q \*q" integer \*q
@@ -228,7 +236,6 @@ value.
1 16-bit positive value.
.SH AUTHORS
Kristian Høgsberg.
Kristian Høgsberg, Peter Hutterer
.SH "SEE ALSO"
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__),
README.mouse.
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)

View File

@@ -26,13 +26,12 @@
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
AM_CPPFLAGS =-I$(top_srcdir)/include
@DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
@DRIVER_NAME@_drv_ladir = @inputdir@
INCLUDES=-I$(top_srcdir)/include/
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \
@DRIVER_NAME@.h \
emuMB.c \

View File

@@ -35,6 +35,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "evdev.h"
#include <xf86.h>
#include <xf86Xinput.h>
@@ -42,7 +43,6 @@
#include <exevents.h>
#include <evdev-properties.h>
#include "evdev.h"
#ifdef HAVE_PROPERTIES
static Atom prop_dlock = 0; /* Drag lock buttons. */
@@ -145,6 +145,8 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
if (next_num != NULL && *next_num == '\0')
next_num = NULL;
}
free(option_string);
}
/* Updates DragLock button state and fires button event messges */

View File

@@ -34,19 +34,14 @@
#include "config.h"
#endif
#include "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
#include <xf86Xinput.h>
#include <exevents.h>
#include <evdev-properties.h>
#include "evdev.h"
enum {
MBEMU_DISABLED = 0,
MBEMU_ENABLED,
MBEMU_AUTO
};
#ifdef HAVE_PROPERTIES
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
@@ -231,11 +226,6 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
if (!pEvdev->emulateMB.enabled)
return ret;
if (button == 2) {
EvdevMBEmuEnable(pInfo, FALSE);
return ret;
}
/* don't care about other buttons */
if (button != 1 && button != 3)
return ret;
@@ -310,20 +300,9 @@ EvdevMBEmuPreInit(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
if (pEvdev->flags & EVDEV_TOUCHSCREEN)
pEvdev->emulateMB.enabled = MBEMU_DISABLED;
else
pEvdev->emulateMB.enabled = MBEMU_AUTO;
if (xf86FindOption(pInfo->options, "Emulate3Buttons"))
{
pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
"Emulate3Buttons",
MBEMU_ENABLED);
xf86Msg(X_INFO, "%s: Forcing middle mouse button emulation %s.\n",
pInfo->name, (pEvdev->emulateMB.enabled) ? "on" : "off");
}
pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
"Emulate3Buttons",
FALSE);
pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
"Emulate3Timeout", 50);
}
@@ -351,16 +330,6 @@ EvdevMBEmuFinalize(InputInfoPtr pInfo)
}
/* Enable/disable middle mouse button emulation. */
void
EvdevMBEmuEnable(InputInfoPtr pInfo, BOOL enable)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
if (pEvdev->emulateMB.enabled == MBEMU_AUTO)
pEvdev->emulateMB.enabled = enable;
}
#ifdef HAVE_PROPERTIES
static int
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,

View File

@@ -33,6 +33,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "evdev.h"
#include <X11/Xatom.h>
#include <xf86.h>
@@ -40,7 +41,6 @@
#include <exevents.h>
#include <evdev-properties.h>
#include "evdev.h"
#define WHEEL_NOT_CONFIGURED 0
@@ -232,13 +232,13 @@ EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_
} else {
xf86Msg(X_WARNING, "%s: Invalid %s value:\"%s\"\n",
pInfo->name, axis_name, option_string);
}
free(option_string);
/* Clean up and log what happened */
if (msg) {
xf86Msg(X_CONFIG, "%s: %s: %s\n",pInfo->name, axis_name, msg);
xfree(msg);
free(msg);
return TRUE;
}
}

View File

@@ -31,9 +31,12 @@
#include "config.h"
#endif
#include "evdev.h"
#include <X11/keysym.h>
#include <X11/extensions/XI.h>
#include <linux/version.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
@@ -45,8 +48,6 @@
#include <xorgVersion.h>
#include <xkbsrv.h>
#include "evdev.h"
#ifdef HAVE_PROPERTIES
#include <X11/Xatom.h>
#include <evdev-properties.h>
@@ -65,20 +66,6 @@
#define MAXDEVICES MAX_DEVICES
#endif
/* 2.4 compatibility */
#ifndef EVIOCGRAB
#define EVIOCGRAB _IOW('E', 0x90, int)
#endif
#ifndef BTN_TASK
#define BTN_TASK 0x117
#endif
#ifndef EV_SYN
#define EV_SYN EV_RST
#endif
/* end compat */
#define ArrayLength(a) (sizeof(a) / (sizeof((a)[0])))
#define MIN_KEYCODE 8
@@ -106,6 +93,9 @@ static int EvdevOn(DeviceIntPtr);
static int EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare);
static void EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl);
static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode);
static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab);
static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
static BOOL EvdevOpenDevice(InputInfoPtr pInfo);
#ifdef HAVE_PROPERTIES
static void EvdevInitAxesLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
@@ -259,7 +249,7 @@ SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
if ((s = xf86SetStrOption(pInfo->options, name, NULL))) {
if (!s[0]) {
xfree(s);
free(s);
*option = NULL;
} else {
*option = s;
@@ -396,7 +386,7 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
for (i = 0; i < REL_CNT; i++)
{
int map = pEvdev->axis_map[i];
if (map != -1)
if (pEvdev->delta[i] && map != -1)
{
v[map] = pEvdev->delta[i];
if (map < first)
@@ -494,8 +484,6 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
/* Get the signed value, earlier kernels had this as unsigned */
value = ev->value;
pEvdev->rel = 1;
switch (ev->code) {
case REL_WHEEL:
if (value > 0)
@@ -522,6 +510,7 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
if (EvdevWheelEmuFilterMotion(pInfo, ev))
return;
pEvdev->rel = 1;
pEvdev->delta[ev->code] += value;
break;
}
@@ -588,7 +577,6 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
break;
case BTN_TOUCH:
pEvdev->tool = value ? ev->code : 0;
if (!(pEvdev->flags & (EVDEV_TOUCHSCREEN | EVDEV_TABLET)))
break;
/* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
@@ -630,9 +618,9 @@ EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v,
* pressed. On wacom tablets, this means that the pen is in
* proximity of the tablet. After the pen is removed, BTN_DIGI is
* released, and a (0, 0) absolute event is generated. Checking
* pEvdev->digi here, lets us ignore that event. pEvdev is
* initialized to 1 so devices that doesn't use this scheme still
* just works.
* pEvdev->tool here, lets us ignore that event. pEvdev->tool is
* initialized to 1 so devices that don't use this scheme still
* just work.
*/
if (pEvdev->abs && pEvdev->tool) {
xf86PostMotionEventP(pInfo->dev, TRUE, *first_v, *num_v, v);
@@ -673,7 +661,7 @@ static void
EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
{
int num_v = 0, first_v = 0;
int v[MAX_VALUATORS];
int v[MAX_VALUATORS] = {};
EvdevPtr pEvdev = pInfo->private;
EvdevProcessValuators(pInfo, v, &num_v, &first_v);
@@ -1150,7 +1138,6 @@ EvdevAddAbsClass(DeviceIntPtr device)
EvdevPtr pEvdev;
int num_axes, axis, i = 0;
Atom *atoms;
const char *mode;
pInfo = device->public.devicePrivate;
pEvdev = pInfo->private;
@@ -1161,12 +1148,18 @@ EvdevAddAbsClass(DeviceIntPtr device)
num_axes = CountBits(pEvdev->abs_bitmask, NLONGS(ABS_MAX));
if (num_axes < 1)
return !Success;
if (num_axes > MAX_VALUATORS) {
xf86Msg(X_WARNING, "%s: found %d axes, limiting to %d.\n", device->name, num_axes, MAX_VALUATORS);
num_axes = MAX_VALUATORS;
}
pEvdev->num_vals = num_axes;
memset(pEvdev->vals, 0, num_axes * sizeof(int));
memset(pEvdev->old_vals, -1, num_axes * sizeof(int));
atoms = xalloc(pEvdev->num_vals * sizeof(Atom));
atoms = malloc(pEvdev->num_vals * sizeof(Atom));
for (axis = ABS_X; axis <= ABS_MAX; axis++) {
for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MAX; axis++) {
pEvdev->axis_map[axis] = -1;
if (!TestBit(axis, pEvdev->abs_bitmask))
continue;
@@ -1188,20 +1181,29 @@ EvdevAddAbsClass(DeviceIntPtr device)
for (axis = ABS_X; axis <= ABS_MAX; axis++) {
int axnum = pEvdev->axis_map[axis];
int resolution = 10000;
if (axnum == -1)
continue;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 30)
/* Kernel provides units/mm, X wants units/m */
if (pEvdev->absinfo[axis].resolution)
resolution = pEvdev->absinfo[axis].resolution * 1000;
#endif
xf86InitValuatorAxisStruct(device, axnum,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
atoms[axnum],
#endif
pEvdev->absinfo[axis].minimum,
pEvdev->absinfo[axis].maximum,
10000, 0, 10000);
resolution, 0, resolution);
xf86InitValuatorDefaults(device, axnum);
pEvdev->old_vals[axnum] = -1;
}
xfree(atoms);
free(atoms);
if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc))
return !Success;
@@ -1229,6 +1231,7 @@ EvdevAddAbsClass(DeviceIntPtr device)
if (xf86FindOption(pInfo->options, "Mode"))
{
char *mode;
mode = xf86SetStrOption(pInfo->options, "Mode", NULL);
if (!strcasecmp("absolute", mode))
pEvdev->flags &= ~EVDEV_RELATIVE_MODE;
@@ -1236,6 +1239,7 @@ EvdevAddAbsClass(DeviceIntPtr device)
pEvdev->flags |= EVDEV_RELATIVE_MODE;
else
xf86Msg(X_INFO, "%s: unknown mode, use default\n", pInfo->name);
free(mode);
}
return Success;
@@ -1271,11 +1275,16 @@ EvdevAddRelClass(DeviceIntPtr device)
if (num_axes <= 0)
return !Success;
if (num_axes > MAX_VALUATORS) {
xf86Msg(X_WARNING, "%s: found %d axes, limiting to %d.\n", device->name, num_axes, MAX_VALUATORS);
num_axes = MAX_VALUATORS;
}
pEvdev->num_vals = num_axes;
memset(pEvdev->vals, 0, num_axes * sizeof(int));
atoms = xalloc(pEvdev->num_vals * sizeof(Atom));
atoms = malloc(pEvdev->num_vals * sizeof(Atom));
for (axis = REL_X; axis <= REL_MAX; axis++)
for (axis = REL_X; i < MAX_VALUATORS && axis <= REL_MAX; axis++)
{
pEvdev->axis_map[axis] = -1;
/* We don't post wheel events, so ignore them here too */
@@ -1316,7 +1325,7 @@ EvdevAddRelClass(DeviceIntPtr device)
xf86InitValuatorDefaults(device, axnum);
}
xfree(atoms);
free(atoms);
pInfo->flags |= XI86_POINTER_CAPABLE;
@@ -1333,7 +1342,7 @@ EvdevAddButtonClass(DeviceIntPtr device)
pInfo = device->public.devicePrivate;
pEvdev = pInfo->private;
labels = xalloc(pEvdev->num_buttons * sizeof(Atom));
labels = malloc(pEvdev->num_buttons * sizeof(Atom));
EvdevInitButtonLabels(pEvdev, pEvdev->num_buttons, labels);
if (!InitButtonClassDeviceStruct(device, pEvdev->num_buttons,
@@ -1343,7 +1352,7 @@ EvdevAddButtonClass(DeviceIntPtr device)
pEvdev->btnmap))
return !Success;
xfree(labels);
free(labels);
return Success;
}
@@ -1371,15 +1380,16 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
/* Check for user-defined button mapping */
if ((mapping = xf86CheckStrOption(pInfo->options, "ButtonMapping", NULL)))
{
char *s = " ";
char *map, *s = " ";
int btn = 0;
xf86Msg(X_CONFIG, "%s: ButtonMapping '%s'\n", pInfo->name, mapping);
map = mapping;
while (s && *s != '\0' && nbuttons < EVDEV_MAXBUTTONS)
{
btn = strtol(mapping, &s, 10);
btn = strtol(map, &s, 10);
if (s == mapping || btn < 0 || btn > EVDEV_MAXBUTTONS)
if (s == map || btn < 0 || btn > EVDEV_MAXBUTTONS)
{
xf86Msg(X_ERROR,
"%s: ... Invalid button mapping. Using defaults\n",
@@ -1389,8 +1399,9 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
}
pEvdev->btnmap[nbuttons++] = btn;
mapping = s;
map = s;
}
free(mapping);
}
for (i = nbuttons; i < ArrayLength(pEvdev->btnmap); i++)
@@ -1531,35 +1542,14 @@ EvdevOn(DeviceIntPtr device)
{
InputInfoPtr pInfo;
EvdevPtr pEvdev;
int rc = 0;
pInfo = device->public.devicePrivate;
pEvdev = pInfo->private;
if (pInfo->fd == -1) /* after PreInit fd is still open */
{
do {
pInfo->fd = open(pEvdev->device, O_RDWR | O_NONBLOCK, 0);
} while (pInfo->fd < 0 && errno == EINTR);
if (pInfo->fd < 0) {
xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n",
pEvdev->device);
return !Success;
}
}
if (pEvdev->grabDevice && (rc = ioctl(pInfo->fd, EVIOCGRAB, (void *)1)))
xf86Msg(X_WARNING, "%s: Grab failed (%s)\n", pInfo->name,
strerror(errno));
pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
if (EvdevIsDuplicate(pInfo))
{
xf86Msg(X_WARNING, "%s: Refusing to enable duplicate device.\n",
pInfo->name);
/* after PreInit fd is still open */
if (!EvdevOpenDevice(pInfo))
return !Success;
}
EvdevGrabDevice(pInfo, 1, 0);
xf86FlushInput(pInfo->fd);
xf86AddEnabledDevice(pInfo);
@@ -1593,9 +1583,7 @@ EvdevProc(DeviceIntPtr device, int what)
EvdevMBEmuFinalize(pInfo);
if (pInfo->fd != -1)
{
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
strerror(errno));
EvdevGrabDevice(pInfo, 0, 1);
xf86RemoveEnabledDevice(pInfo);
close(pInfo->fd);
pInfo->fd = -1;
@@ -1631,8 +1619,7 @@ static int
EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare)
{
EvdevPtr pEvdev = pInfo->private;
size_t len;
int i;
int i, len;
char name[1024] = {0};
unsigned long bitmask[NLONGS(EV_CNT)] = {0};
@@ -1763,28 +1750,39 @@ error:
}
/**
* Issue an EVIOCGRAB on the device file, either as a grab or to ungrab, or
* both. Return TRUE on success, otherwise FALSE. Failing the release is a
* still considered a success, because it's not as if you could do anything
* about it.
*/
static BOOL
EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab)
{
EvdevPtr pEvdev = pInfo->private;
if (pEvdev->grabDevice)
{
if (grab && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
xf86Msg(X_WARNING, "%s: Grab failed (%s)\n", pInfo->name,
strerror(errno));
return FALSE;
} else if (ungrab && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
strerror(errno));
}
return TRUE;
}
static int
EvdevProbe(InputInfoPtr pInfo)
{
int i, has_rel_axes, has_abs_axes, has_keys, num_buttons, has_scroll;
int has_lmr; /* left middle right */
int kernel24 = 0;
int ignore_abs = 0, ignore_rel = 0;
EvdevPtr pEvdev = pInfo->private;
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
if (errno == EINVAL) {
/* keyboards are unsafe in 2.4 */
kernel24 = 1;
pEvdev->grabDevice = 0;
} else {
xf86Msg(X_ERROR, "Grab failed. Device already configured?\n");
return 1;
}
} else if (pEvdev->grabDevice) {
ioctl(pInfo->fd, EVIOCGRAB, (void *)0);
}
/* Trinary state for ignoring axes:
- unset: do the normal thing.
- TRUE: explicitly ignore them.
@@ -1833,7 +1831,7 @@ EvdevProbe(InputInfoPtr pInfo)
{
pEvdev->flags |= EVDEV_BUTTON_EVENTS;
pEvdev->num_buttons = num_buttons;
xf86Msg(X_INFO, "%s: Found %d mouse buttons\n", pInfo->name,
xf86Msg(X_PROBED, "%s: Found %d mouse buttons\n", pInfo->name,
num_buttons);
}
@@ -1848,7 +1846,7 @@ EvdevProbe(InputInfoPtr pInfo)
if (TestBit(REL_WHEEL, pEvdev->rel_bitmask) ||
TestBit(REL_HWHEEL, pEvdev->rel_bitmask) ||
TestBit(REL_DIAL, pEvdev->rel_bitmask)) {
xf86Msg(X_INFO, "%s: Found scroll wheel(s)\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found scroll wheel(s)\n", pInfo->name);
has_scroll = TRUE;
if (!num_buttons)
xf86Msg(X_INFO, "%s: Forcing buttons for scroll wheel(s)\n",
@@ -1859,12 +1857,12 @@ EvdevProbe(InputInfoPtr pInfo)
if (!ignore_rel)
{
xf86Msg(X_INFO, "%s: Found relative axes\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found relative axes\n", pInfo->name);
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
if (TestBit(REL_X, pEvdev->rel_bitmask) &&
TestBit(REL_Y, pEvdev->rel_bitmask)) {
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found x and y relative axes\n", pInfo->name);
}
} else {
xf86Msg(X_INFO, "%s: Relative axes present but ignored.\n", pInfo->name);
@@ -1884,15 +1882,15 @@ EvdevProbe(InputInfoPtr pInfo)
xf86Msg(X_INFO, "%s: Absolute axes present but ignored.\n", pInfo->name);
has_abs_axes = FALSE;
} else if (has_abs_axes) {
xf86Msg(X_INFO, "%s: Found absolute axes\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found absolute axes\n", pInfo->name);
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
if ((TestBit(ABS_X, pEvdev->abs_bitmask) &&
TestBit(ABS_Y, pEvdev->abs_bitmask))) {
xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found x and y absolute axes\n", pInfo->name);
if (TestBit(BTN_TOOL_PEN, pEvdev->key_bitmask))
{
xf86Msg(X_INFO, "%s: Found absolute tablet.\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found absolute tablet.\n", pInfo->name);
pEvdev->flags |= EVDEV_TABLET;
if (!pEvdev->num_buttons)
{
@@ -1902,11 +1900,11 @@ EvdevProbe(InputInfoPtr pInfo)
} else if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask) ||
TestBit(BTN_TOUCH, pEvdev->key_bitmask)) {
if (has_lmr || TestBit(BTN_TOOL_FINGER, pEvdev->key_bitmask)) {
xf86Msg(X_INFO, "%s: Found absolute touchpad.\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found absolute touchpad.\n", pInfo->name);
pEvdev->flags |= EVDEV_TOUCHPAD;
memset(pEvdev->old_vals, -1, sizeof(int) * pEvdev->num_vals);
} else {
xf86Msg(X_INFO, "%s: Found absolute touchscreen\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found absolute touchscreen\n", pInfo->name);
pEvdev->flags |= EVDEV_TOUCHSCREEN;
pEvdev->flags |= EVDEV_BUTTON_EVENTS;
}
@@ -1916,13 +1914,37 @@ EvdevProbe(InputInfoPtr pInfo)
for (i = 0; i < BTN_MISC; i++) {
if (TestBit(i, pEvdev->key_bitmask)) {
xf86Msg(X_INFO, "%s: Found keys\n", pInfo->name);
xf86Msg(X_PROBED, "%s: Found keys\n", pInfo->name);
pEvdev->flags |= EVDEV_KEYBOARD_EVENTS;
has_keys = TRUE;
break;
}
}
if (has_rel_axes || has_abs_axes)
{
char *str;
int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 };
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
if (str) {
num_calibration = sscanf(str, "%d %d %d %d",
&calibration[0], &calibration[1],
&calibration[2], &calibration[3]);
free(str);
if (num_calibration == 4)
EvdevSetCalibration(pInfo, num_calibration, calibration);
else
xf86Msg(X_ERROR,
"%s: Insufficient calibration factors (%d). Ignoring calibration\n",
pInfo->name, num_calibration);
}
}
if (has_rel_axes || has_abs_axes || num_buttons) {
pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
XI86_CONFIGURED;
@@ -1942,14 +1964,9 @@ EvdevProbe(InputInfoPtr pInfo)
}
if (has_keys) {
if (kernel24) {
xf86Msg(X_INFO, "%s: Kernel < 2.6 is too old, ignoring keyboard\n",
pInfo->name);
} else {
xf86Msg(X_INFO, "%s: Configuring as keyboard\n", pInfo->name);
pInfo->flags |= XI86_KEYBOARD_CAPABLE | XI86_CONFIGURED;
pInfo->type_name = XI_KEYBOARD;
}
xf86Msg(X_INFO, "%s: Configuring as keyboard\n", pInfo->name);
pInfo->flags |= XI86_KEYBOARD_CAPABLE | XI86_CONFIGURED;
pInfo->type_name = XI_KEYBOARD;
}
if (has_scroll && (pInfo->flags & XI86_CONFIGURED) &&
@@ -1990,18 +2007,60 @@ EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4])
}
}
static BOOL
EvdevOpenDevice(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
char *device = (char*)pEvdev->device;
if (!device)
{
device = xf86CheckStrOption(pInfo->options, "Device", NULL);
if (!device) {
xf86Msg(X_ERROR, "%s: No device specified.\n", pInfo->name);
return FALSE;
}
pEvdev->device = device;
xf86Msg(X_CONFIG, "%s: Device: \"%s\"\n", pInfo->name, device);
}
if (pInfo->fd < 0)
{
do {
pInfo->fd = open(device, O_RDWR | O_NONBLOCK, 0);
} while (pInfo->fd < 0 && errno == EINTR);
if (pInfo->fd < 0) {
xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n", device);
return FALSE;
}
}
/* Check major/minor of device node to avoid adding duplicate devices. */
pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
if (EvdevIsDuplicate(pInfo))
{
xf86Msg(X_WARNING, "%s: device file is duplicate. Ignoring.\n",
pInfo->name);
close(pInfo->fd);
return FALSE;
}
return TRUE;
}
static InputInfoPtr
EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
{
InputInfoPtr pInfo;
const char *device, *str;
int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 };
EvdevPtr pEvdev;
if (!(pInfo = xf86AllocateInput(drv, 0)))
return NULL;
/* Initialise the InputInfoRec. */
pInfo->fd = -1;
pInfo->name = dev->identifier;
pInfo->flags = 0;
pInfo->type_name = "UNKNOWN";
@@ -2017,81 +2076,45 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pInfo->private_flags = 0;
pInfo->always_core_feedback = NULL;
pInfo->conf_idev = dev;
pInfo->private = NULL;
if (!(pEvdev = xcalloc(sizeof(EvdevRec), 1)))
return pInfo;
if (!(pEvdev = calloc(sizeof(EvdevRec), 1)))
goto error;
pInfo->private = pEvdev;
xf86CollectInputOptions(pInfo, evdevDefaults, NULL);
xf86ProcessCommonOptions(pInfo, pInfo->options);
if (!EvdevOpenDevice(pInfo))
goto error;
/*
* We initialize pEvdev->tool to 1 so that device that doesn't use
* proximity will still report events.
*/
pEvdev->tool = 1;
device = xf86CheckStrOption(dev->commonOptions, "Device", NULL);
if (!device) {
xf86Msg(X_ERROR, "%s: No device specified.\n", pInfo->name);
xf86DeleteInput(pInfo, 0);
return NULL;
}
pEvdev->device = device;
xf86Msg(X_CONFIG, "%s: Device: \"%s\"\n", pInfo->name, device);
do {
pInfo->fd = open(device, O_RDWR | O_NONBLOCK, 0);
} while (pInfo->fd < 0 && errno == EINTR);
if (pInfo->fd < 0) {
xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n", device);
xf86DeleteInput(pInfo, 0);
return NULL;
}
/* Check major/minor of device node to avoid adding duplicate devices. */
pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
if (EvdevIsDuplicate(pInfo))
{
xf86Msg(X_WARNING, "%s: device file already in use. Ignoring.\n",
pInfo->name);
close(pInfo->fd);
xf86DeleteInput(pInfo, 0);
return NULL;
}
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
if (str) {
num_calibration = sscanf(str, "%d %d %d %d",
&calibration[0], &calibration[1],
&calibration[2], &calibration[3]);
if (num_calibration == 4)
EvdevSetCalibration(pInfo, num_calibration, calibration);
else
xf86Msg(X_ERROR,
"%s: Insufficient calibration factors (%d). Ignoring calibration\n",
pInfo->name, num_calibration);
}
/* Grabbing the event device stops in-kernel event forwarding. In other
words, it disables rfkill and the "Macintosh mouse button emulation".
Note that this needs a server that sets the console to RAW mode. */
pEvdev->grabDevice = xf86CheckBoolOption(dev->commonOptions, "GrabDevice", 0);
/* If grabDevice is set, ungrab immediately since we only want to grab
* between DEVICE_ON and DEVICE_OFF. If we never get DEVICE_ON, don't
* hold a grab. */
if (!EvdevGrabDevice(pInfo, 1, 1))
{
xf86Msg(X_WARNING, "%s: Device may already be configured.\n",
pInfo->name);
goto error;
}
EvdevInitButtonMapping(pInfo);
if (EvdevCacheCompare(pInfo, FALSE) ||
EvdevProbe(pInfo)) {
close(pInfo->fd);
xf86DeleteInput(pInfo, 0);
return NULL;
goto error;
}
EvdevAddDevice(pInfo);
@@ -2104,6 +2127,12 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
}
return pInfo;
error:
if (pInfo->fd >= 0)
close(pInfo->fd);
xf86DeleteInput(pInfo, 0);
return NULL;
}
_X_EXPORT InputDriverRec EVDEV = {

View File

@@ -34,6 +34,7 @@
#include <linux/input.h>
#include <linux/types.h>
#include <xorg-server.h>
#include <xf86Xinput.h>
#include <xf86_OSproc.h>
#include <xkbstr.h>
@@ -213,7 +214,6 @@ void EvdevMBEmuBlockHandler(pointer, struct timeval**, pointer);
void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuOn(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr);
void EvdevMBEmuEnable(InputInfoPtr, BOOL);
/* Mouse Wheel emulation */
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);