├── .gitignore ├── 10-evdev.conf ├── COPYING ├── Makefile.am ├── README ├── autogen.sh ├── configure.ac ├── include ├── Makefile.am └── evdev-properties.h ├── man ├── Makefile.am └── evdev.man ├── src ├── Makefile.am ├── apple.c ├── axis_labels.h ├── draglock.c ├── emuMB.c ├── emuThird.c ├── emuWheel.c ├── evdev.c └── evdev.h └── xorg-evdev.pc.in /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # X.Org module default exclusion patterns 3 | # The next section if for module specific patterns 4 | # 5 | # Do not edit the following section 6 | # GNU Build System (Autotools) 7 | aclocal.m4 8 | autom4te.cache/ 9 | autoscan.log 10 | ChangeLog 11 | compile 12 | config.guess 13 | config.h 14 | config.h.in 15 | config.log 16 | config-ml.in 17 | config.py 18 | config.status 19 | config.status.lineno 20 | config.sub 21 | configure 22 | configure.scan 23 | depcomp 24 | .deps/ 25 | INSTALL 26 | install-sh 27 | .libs/ 28 | libtool 29 | libtool.m4 30 | ltmain.sh 31 | lt~obsolete.m4 32 | ltoptions.m4 33 | ltsugar.m4 34 | ltversion.m4 35 | Makefile 36 | Makefile.in 37 | mdate-sh 38 | missing 39 | mkinstalldirs 40 | *.pc 41 | py-compile 42 | stamp-h? 43 | symlink-tree 44 | texinfo.tex 45 | ylwrap 46 | 47 | # Do not edit the following section 48 | # Edit Compile Debug Document Distribute 49 | *~ 50 | *.[0-9] 51 | *.[0-9]x 52 | *.bak 53 | *.bin 54 | core 55 | *.dll 56 | *.exe 57 | *-ISO*.bdf 58 | *-JIS*.bdf 59 | *-KOI8*.bdf 60 | *.kld 61 | *.ko 62 | *.ko.cmd 63 | *.lai 64 | *.l[oa] 65 | *.[oa] 66 | *.obj 67 | *.patch 68 | *.so 69 | *.pcf.gz 70 | *.pdb 71 | *.tar.bz2 72 | *.tar.gz 73 | # 74 | # Add & Override patterns for xf86-input-evdev 75 | # 76 | # Edit the following section as needed 77 | # For example, !report.pc overrides *.pc. See 'man gitignore' 78 | # 79 | -------------------------------------------------------------------------------- /10-evdev.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Catch-all evdev loader for udev-based systems 3 | # We don't simply match on any device since that also adds accelerometers 4 | # and other devices that we don't really want to use. The list below 5 | # matches everything but joysticks. 6 | 7 | Section "InputClass" 8 | Identifier "evdev pointer catchall" 9 | MatchIsPointer "on" 10 | MatchDevicePath "/dev/input/event*" 11 | Driver "evdev" 12 | EndSection 13 | 14 | Section "InputClass" 15 | Identifier "evdev keyboard catchall" 16 | MatchIsKeyboard "on" 17 | MatchDevicePath "/dev/input/event*" 18 | Driver "evdev" 19 | EndSection 20 | 21 | Section "InputClass" 22 | Identifier "evdev touchpad catchall" 23 | MatchIsTouchpad "on" 24 | MatchDevicePath "/dev/input/event*" 25 | Driver "evdev" 26 | EndSection 27 | 28 | Section "InputClass" 29 | Identifier "evdev tablet catchall" 30 | MatchIsTablet "on" 31 | MatchDevicePath "/dev/input/event*" 32 | Driver "evdev" 33 | EndSection 34 | 35 | Section "InputClass" 36 | Identifier "evdev touchscreen catchall" 37 | MatchIsTouchscreen "on" 38 | MatchDevicePath "/dev/input/event*" 39 | Driver "evdev" 40 | EndSection 41 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. 2 | Copyright 1993 by David Dawes 3 | Copyright 2002 by SuSE Linux AG, Author: Egbert Eich 4 | Copyright 1994-2002 by The XFree86 Project, Inc. 5 | Copyright 2002 by Paul Elliott 6 | Copyright © 2008 University of South Australia 7 | Copyright 2008 by Chris Salch 8 | Copyright © 2008 Red Hat, Inc. 9 | 10 | Permission to use, copy, modify, distribute, and sell this software 11 | and its documentation for any purpose is hereby granted without 12 | fee, provided that the above copyright notice appear in all copies 13 | and that both that copyright notice and this permission notice 14 | appear in supporting documentation, and that the name of the authors 15 | not be used in advertising or publicity pertaining to distribution of the 16 | software without specific, written prior permission. The authors make no 17 | representations about the suitability of this software for any 18 | purpose. It is provided "as is" without express or implied 19 | warranty. 20 | 21 | THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 22 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 23 | NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 24 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 25 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 26 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 27 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 28 | 29 | Copyright 2005 Sun Microsystems, Inc. All rights reserved. 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a 32 | copy of this software and associated documentation files (the "Software"), 33 | to deal in the Software without restriction, including without limitation 34 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 35 | and/or sell copies of the Software, and to permit persons to whom the 36 | Software is furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice (including the next 39 | paragraph) shall be included in all copies or substantial portions of the 40 | Software. 41 | 42 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 43 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 44 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 45 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 46 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 47 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 48 | DEALINGS IN THE SOFTWARE. 49 | 50 | Copyright 2005 Adam Jackson. 51 | 52 | Permission is hereby granted, free of charge, to any person obtaining a 53 | copy of this software and associated documentation files (the "Software"), 54 | to deal in the Software without restriction, including without limitation 55 | on the rights to use, copy, modify, merge, publish, distribute, sub 56 | license, and/or sell copies of the Software, and to permit persons to whom 57 | the Software is furnished to do so, subject to the following conditions: 58 | 59 | The above copyright notice and this permission notice (including the next 60 | paragraph) shall be included in all copies or substantial portions of the 61 | Software. 62 | 63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 64 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 65 | FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 66 | ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 67 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 68 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 69 | 70 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright 2005 Adam Jackson. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the "Software"), 5 | # to deal in the Software without restriction, including without limitation 6 | # on the rights to use, copy, modify, merge, publish, distribute, sub 7 | # license, and/or sell copies of the Software, and to permit persons to whom 8 | # the Software is furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice (including the next 11 | # paragraph) shall be included in all copies or substantial portions of the 12 | # Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17 | # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | 21 | 22 | # Provide an sdk location that is writable by the evdev module 23 | DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg' 24 | 25 | SUBDIRS = src man include 26 | MAINTAINERCLEANFILES = ChangeLog INSTALL 27 | 28 | pkgconfigdir = $(libdir)/pkgconfig 29 | pkgconfig_DATA = xorg-evdev.pc 30 | 31 | dist_xorgconf_DATA = 10-evdev.conf 32 | 33 | .PHONY: ChangeLog INSTALL 34 | 35 | INSTALL: 36 | $(INSTALL_CMD) 37 | 38 | ChangeLog: 39 | $(CHANGELOG_CMD) 40 | 41 | dist-hook: ChangeLog INSTALL 42 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This fork provides an implementation of SpaceFn in xf86-input-evdev. 2 | 3 | "The SpaceFN layout: trying to end keyboard inflation" 4 | https://geekhack.org/index.php?topic=51069.0 5 | 6 | The idea of SpaceFn is to let the space key work as both a regular 7 | space and a modifier. For more information about the implementation 8 | and how to build, install, and configure it, see 9 | http://www.ljosa.com/~ljosa/software/spacefn-xorg/. 10 | 11 | ------------------------------------------------------------------------ 12 | 13 | xf86-input-evdev - Generic Linux input driver for the Xorg X server 14 | 15 | Please submit bugs & patches to the Xorg bugzilla: 16 | 17 | https://bugs.freedesktop.org/enter_bug.cgi?product=xorg 18 | 19 | All questions regarding this software should be directed at the 20 | Xorg mailing list: 21 | 22 | http://lists.freedesktop.org/mailman/listinfo/xorg 23 | 24 | The master development code repository can be found at: 25 | 26 | git://anongit.freedesktop.org/git/xorg/driver/xf86-input-evdev 27 | 28 | http://cgit.freedesktop.org/xorg/driver/xf86-input-evdev 29 | 30 | For more information on the git code manager, see: 31 | 32 | http://wiki.x.org/wiki/GitPage 33 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | srcdir=`dirname "$0"` 4 | test -z "$srcdir" && srcdir=. 5 | 6 | ORIGDIR=`pwd` 7 | cd "$srcdir" 8 | 9 | autoreconf -v --install || exit 1 10 | cd "$ORIGDIR" || exit $? 11 | 12 | git config --local --get format.subjectPrefix >/dev/null 2>&1 || 13 | git config --local format.subjectPrefix "PATCH xf86-input-evdev" 14 | 15 | if test -z "$NOCONFIGURE"; then 16 | exec "$srcdir"/configure "$@" 17 | fi 18 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Copyright 2005 Adam Jackson. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the "Software"), 5 | # to deal in the Software without restriction, including without limitation 6 | # on the rights to use, copy, modify, merge, publish, distribute, sub 7 | # license, and/or sell copies of the Software, and to permit persons to whom 8 | # the Software is furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice (including the next 11 | # paragraph) shall be included in all copies or substantial portions of the 12 | # Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17 | # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | # 21 | # Process this file with autoconf to produce a configure script 22 | 23 | # Initialize Autoconf 24 | AC_PREREQ([2.60]) 25 | AC_INIT([xf86-input-evdev], 26 | [2.10.5], 27 | [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], 28 | [xf86-input-evdev]) 29 | AC_CONFIG_SRCDIR([Makefile.am]) 30 | AC_CONFIG_HEADERS([config.h]) 31 | AC_CONFIG_AUX_DIR(.) 32 | 33 | # Initialize Automake 34 | AM_INIT_AUTOMAKE([foreign dist-bzip2]) 35 | 36 | # Initialize libtool 37 | AC_DISABLE_STATIC 38 | AC_PROG_LIBTOOL 39 | 40 | # Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS 41 | m4_ifndef([XORG_MACROS_VERSION], 42 | [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) 43 | XORG_MACROS_VERSION(1.8) 44 | XORG_DEFAULT_OPTIONS 45 | 46 | # Obtain compiler/linker options from server and required extensions 47 | PKG_CHECK_MODULES(XORG, [xorg-server >= 1.12] xproto [inputproto >= 2.1.99.3]) 48 | PKG_CHECK_MODULES(UDEV, libudev) 49 | 50 | PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4]) 51 | PKG_CHECK_MODULES(MTDEV, mtdev) 52 | 53 | # Define a configure option for an alternate input module directory 54 | AC_ARG_WITH(xorg-module-dir, 55 | AC_HELP_STRING([--with-xorg-module-dir=DIR], 56 | [Default xorg module directory [[default=$libdir/xorg/modules]]]), 57 | [moduledir="$withval"], 58 | [moduledir="$libdir/xorg/modules"]) 59 | inputdir=${moduledir}/input 60 | AC_SUBST(inputdir) 61 | 62 | AC_ARG_WITH(xorg-conf-dir, 63 | AC_HELP_STRING([--with-xorg-conf-dir=DIR], 64 | [Default xorg.conf.d directory [[default=$prefix/share/X11/xorg.conf.d/]]]), 65 | [xorgconfdir="$withval"], 66 | [xorgconfdir="$prefix/share/X11/xorg.conf.d"]) 67 | AC_SUBST(xorgconfdir) 68 | 69 | # X Server SDK location is required to install evdev header files 70 | # This location is also relayed in the xorg-evdev.pc file 71 | sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server` 72 | 73 | # Workaround overriding sdkdir to be able to create a tarball when user has no 74 | # write permission in sdkdir. See DISTCHECK_CONFIGURE_FLAGS in Makefile.am 75 | AC_ARG_WITH([sdkdir], [], [sdkdir="$withval"]) 76 | AC_SUBST([sdkdir]) 77 | 78 | DRIVER_NAME=evdev 79 | AC_SUBST([DRIVER_NAME]) 80 | 81 | AC_CONFIG_FILES([Makefile 82 | src/Makefile 83 | man/Makefile 84 | include/Makefile 85 | xorg-evdev.pc]) 86 | AC_OUTPUT 87 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | sdk_HEADERS = evdev-properties.h 2 | -------------------------------------------------------------------------------- /include/evdev-properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2008 Red Hat, Inc. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software 5 | * and its documentation for any purpose is hereby granted without 6 | * fee, provided that the above copyright notice appear in all copies 7 | * and that both that copyright notice and this permission notice 8 | * appear in supporting documentation, and that the name of Red Hat 9 | * not be used in advertising or publicity pertaining to distribution 10 | * of the software without specific, written prior permission. Red 11 | * Hat makes no representations about the suitability of this software 12 | * for any purpose. It is provided "as is" without express or implied 13 | * warranty. 14 | * 15 | * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 17 | * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | * 23 | * Authors: 24 | * Peter Hutterer (peter.hutterer@redhat.com) 25 | */ 26 | 27 | 28 | #ifndef _EVDEV_PROPERTIES_H_ 29 | #define _EVDEV_PROPERTIES_H_ 30 | 31 | /* Middle mouse button emulation */ 32 | /* BOOL */ 33 | #define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation" 34 | /* CARD32 */ 35 | #define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout" 36 | /* CARD8 */ 37 | #define EVDEV_PROP_MIDBUTTON_BUTTON "Evdev Middle Button Button" 38 | 39 | /* Wheel emulation */ 40 | /* BOOL */ 41 | #define EVDEV_PROP_WHEEL "Evdev Wheel Emulation" 42 | /* CARD8, 4 values [x up, x down, y up, y down], 0 to disable a value*/ 43 | #define EVDEV_PROP_WHEEL_AXES "Evdev Wheel Emulation Axes" 44 | /* CARD16 */ 45 | #define EVDEV_PROP_WHEEL_INERTIA "Evdev Wheel Emulation Inertia" 46 | /* CARD16 */ 47 | #define EVDEV_PROP_WHEEL_TIMEOUT "Evdev Wheel Emulation Timeout" 48 | /* CARD8, value range 0-32, 0 to always scroll */ 49 | #define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button" 50 | 51 | /* Drag lock */ 52 | /* CARD8, either 1 value or pairs, value range 0-32, 0 to disable a value*/ 53 | #define EVDEV_PROP_DRAGLOCK "Evdev Drag Lock Buttons" 54 | 55 | /* Axis inversion */ 56 | /* BOOL, 2 values [x, y], 1 inverts axis */ 57 | #define EVDEV_PROP_INVERT_AXES "Evdev Axis Inversion" 58 | 59 | /* Reopen attempts. */ 60 | /* CARD8 */ 61 | #define EVDEV_PROP_REOPEN "Evdev Reopen Attempts" /* OBSOLETE */ 62 | 63 | /* Run-time calibration */ 64 | /* CARD32, 4 values [minx, maxx, miny, maxy], or no values for unset */ 65 | #define EVDEV_PROP_CALIBRATION "Evdev Axis Calibration" 66 | 67 | /* Swap x and y axis. */ 68 | /* BOOL */ 69 | #define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap" 70 | 71 | /* BOOL */ 72 | #define EVDEV_PROP_THIRDBUTTON "Evdev Third Button Emulation" 73 | /* CARD32 */ 74 | #define EVDEV_PROP_THIRDBUTTON_TIMEOUT "Evdev Third Button Emulation Timeout" 75 | /* CARD8 */ 76 | #define EVDEV_PROP_THIRDBUTTON_BUTTON "Evdev Third Button Emulation Button" 77 | /* CARD32 */ 78 | #define EVDEV_PROP_THIRDBUTTON_THRESHOLD "Evdev Third Button Emulation Threshold" 79 | 80 | /* CARD8, 1 value, 81 | This property is initialized on devices that have multimedia keys on the 82 | function keys. The value of the property selects the default behaviour 83 | for the function keys. The behaviour of the fn key (if any exists) is 84 | hardware specific. On some hardware, fn may toggle the other set of 85 | functions available on the keys. 86 | 87 | 0 send functions keys by default, fn may toggle to multimedia keys 88 | 1 send multimedia keys by default, fn may toggle to function keys 89 | */ 90 | #define EVDEV_PROP_FUNCTION_KEYS "Evdev Function Keys" 91 | 92 | /* Smooth scroll */ 93 | /* INT32, 3 values (vertical, horizontal, dial) */ 94 | #define EVDEV_PROP_SCROLL_DISTANCE "Evdev Scrolling Distance" 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright 2005 Sun Microsystems, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the "Software"), 5 | # to deal in the Software without restriction, including without limitation 6 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | # and/or sell copies of the Software, and to permit persons to whom the 8 | # Software is furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice (including the next 11 | # paragraph) shall be included in all copies or substantial portions of the 12 | # Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | # DEALINGS IN THE SOFTWARE. 21 | # 22 | 23 | drivermandir = $(DRIVER_MAN_DIR) 24 | 25 | driverman_PRE = $(DRIVER_NAME).man 26 | 27 | driverman_DATA = $(driverman_PRE:man=$(DRIVER_MAN_SUFFIX)) 28 | 29 | EXTRA_DIST = $(DRIVER_NAME).man 30 | 31 | CLEANFILES = $(driverman_DATA) 32 | 33 | SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man 34 | 35 | # String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure 36 | .man.$(DRIVER_MAN_SUFFIX): 37 | $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@ 38 | -------------------------------------------------------------------------------- /man/evdev.man: -------------------------------------------------------------------------------- 1 | .\" shorthand for double quote that works everywhere. 2 | .ds q \N'34' 3 | .TH EVDEV __drivermansuffix__ __vendorversion__ 4 | .SH NAME 5 | evdev \- Generic Linux input driver 6 | .SH SYNOPSIS 7 | .nf 8 | .B "Section \*qInputDevice\*q" 9 | .BI " Identifier \*q" devname \*q 10 | .B " Driver \*qevdev\*q" 11 | .BI " Option \*qDevice\*q \*q" devpath \*q 12 | .BI " Option \*qEmulate3Buttons\*q \*q" True \*q 13 | .BI " Option \*qEmulate3Timeout\*q \*q" 50 \*q 14 | .BI " Option \*qGrabDevice\*q \*q" False \*q 15 | \ \ ... 16 | .B EndSection 17 | .fi 18 | .SH DESCRIPTION 19 | .B evdev 20 | is an __xservername__ input driver for Linux\'s generic event devices. It 21 | therefore supports all input devices that the kernel knows about, including 22 | most mice, keyboards, tablets and touchscreens. 23 | .B evdev 24 | is the default driver on the major Linux distributions. 25 | .PP 26 | The 27 | .B evdev 28 | driver can serve as both a pointer and a keyboard input device. Multiple 29 | input devices are supported by multiple instances of this driver, with one 30 | InputDevice section of your __xconfigfile__ for each input device that will 31 | use this driver. 32 | .PP 33 | It is recommended that 34 | .B evdev 35 | devices are configured through the 36 | .B InputClass 37 | directive (refer to __xconfigfile__(__filemansuffix__)) instead of manual 38 | per-device configuration. Devices configured in the 39 | __xconfigfile__(__filemansuffix__) are not hot-plug capable. 40 | .PP 41 | .SH SUPPORTED HARDWARE 42 | In general, any input device that the kernel has a driver for can be accessed 43 | through the 44 | .B evdev 45 | driver. See the Linux kernel documentation for a complete list. 46 | .PP 47 | .SH CONFIGURATION DETAILS 48 | Please refer to __xconfigfile__(__filemansuffix__) for general configuration 49 | details and for options that can be used with all input drivers. This 50 | section only covers configuration details specific to this driver. 51 | .PP 52 | The following driver 53 | .B Options 54 | are supported: 55 | .TP 7 56 | .BI "Option \*qButtonMapping\*q \*q" string \*q 57 | Sets the button mapping for this device. The mapping is a space-separated list 58 | of button mappings that correspond in order to the physical buttons on the 59 | device (i.e. the first number is the mapping for button 1, etc.). The default 60 | mapping is "1 2 3 ... 32". A mapping of 0 deactivates the button. Multiple 61 | buttons can have the same mapping. 62 | For example, a left-handed mouse with deactivated scroll-wheel would use a 63 | mapping of "3 2 1 0 0". Invalid mappings are ignored and the default mapping 64 | is used. Buttons not specified in the user's mapping use the default mapping. 65 | .TP 7 66 | .BI "Option \*qDevice\*q \*q" string \*q 67 | Specifies the device through which the device can be accessed. This will 68 | generally be of the form \*q/dev/input/eventX\*q, where X is some integer. 69 | The mapping from device node to hardware is system-dependent. Property: 70 | "Device Node" (read-only). 71 | .TP 7 72 | .BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q 73 | Sets \*qdrag lock buttons\*q that simulate holding a button down, so 74 | that low dexterity people do not have to hold a button down at the 75 | same time they move a mouse cursor. Button numbers occur in pairs, 76 | with the lock button number occurring first, followed by the button 77 | number that is the target of the lock button. Property: "Evdev 78 | Drag Lock Buttons". 79 | .TP 7 80 | .BI "Option \*qDragLockButtons\*q \*q" "M1" \*q 81 | Sets a \*qmaster drag lock button\*q that acts as a \*qMeta Key\*q 82 | indicating that the next button pressed is to be 83 | \*qdrag locked\*q. Property: "Evdev Drag Lock Buttons". 84 | .TP 7 85 | .TP 7 86 | .BI "Option \*qEmulate3Buttons\*q \*q" boolean \*q 87 | Enable/disable the emulation of the third (middle) mouse button for mice 88 | which only have two physical buttons. The third button is emulated by 89 | pressing both buttons simultaneously. Default: off. Property: "Evdev Middle 90 | Button Emulation". 91 | .TP 7 92 | .BI "Option \*qEmulate3Timeout\*q \*q" integer \*q 93 | Sets the timeout (in milliseconds) that the driver waits before deciding 94 | if two buttons where pressed "simultaneously" when 3 button emulation is 95 | enabled. Default: 50. Property: "Evdev Middle Button Timeout". 96 | .TP 7 97 | .BI "Option \*qEmulate3Button\*q \*q" integer \*q 98 | Specifies the physical button number to be emitted if middle button emulation 99 | is triggered. 100 | Default: 2. Property: "Evdev Middle Button Button". 101 | .TP 7 102 | .BI "Option \*qEmulateWheel\*q \*q" boolean \*q 103 | Enable/disable "wheel" emulation. Wheel emulation means emulating button 104 | press/release events when the mouse is moved while a specific real button 105 | is pressed. Wheel button events (typically buttons 4 and 5) are 106 | usually used for scrolling. Wheel emulation is useful for getting wheel-like 107 | behaviour with trackballs. It can also be useful for mice with 4 or 108 | more buttons but no wheel. See the description of the 109 | .BR EmulateWheelButton , 110 | .BR EmulateWheelInertia , 111 | .BR EmulateWheelTimeout , 112 | .BR XAxisMapping , 113 | and 114 | .B YAxisMapping 115 | options. Default: off. Property "Evdev Wheel Emulation". 116 | .TP 7 117 | .BI "Option \*qEmulateWheelButton\*q \*q" integer \*q 118 | Specifies which button must be held down to enable wheel emulation mode. 119 | While this button is down, X and/or Y pointer movement will generate button 120 | press/release events as specified for the 121 | .B XAxisMapping 122 | and 123 | .B YAxisMapping 124 | settings. If the button is 0 and 125 | .BR EmulateWheel 126 | is on, any motion of the device is converted into wheel events. Default: 4. 127 | Property: "Evdev Wheel Emulation Button". 128 | .TP 7 129 | .BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q 130 | Specifies how far (in pixels) the pointer must move to generate button 131 | press/release events in wheel emulation mode. Default: 10. Property: "Evdev 132 | Wheel Emulation Inertia". 133 | .IP 134 | This value must be set for any device does not resemble a standard mouse. 135 | Specifically, on absolute devices such as tablets the value should be set to 136 | a reasonable fraction of the expected movement to avoid excess scroll events. 137 | .IP 138 | .B WARNING: 139 | the name \*qinertia\*q is a misnomer. This option defines the distance 140 | required to generate one scroll event similar to the 141 | .B VertScrollDelta 142 | and 143 | .B HorizScrollDelta 144 | options. It does not enable inertia in the 145 | physical sense, scrolling stops immediately once the movement has stopped. 146 | .TP 7 147 | .BI "Option \*qEmulateWheelTimeout\*q \*q" integer \*q 148 | Specifies the time in milliseconds the 149 | .BR EmulateWheelButton 150 | must be pressed before wheel emulation is started. If the 151 | .BR EmulateWheelButton 152 | is released before this timeout, the original button press/release event 153 | is sent. Default: 200. Property: "Evdev Wheel Emulation Timeout". 154 | .TP 7 155 | .BI "Option \*qEmulateThirdButton\*q \*q" boolean \*q 156 | Enable third button emulation. Third button emulation emits a right button 157 | event (by default) by pressing and holding the first button. The first 158 | button must be held down for the configured timeout and must not move more 159 | than the configured threshold for the emulation to activate. Otherwise, the 160 | first button event is posted as normal. Default: off. Property: "Evdev 161 | Third Button Emulation". 162 | .TP 7 163 | .BI "Option \*qEmulateThirdButtonTimeout\*q \*q" integer \*q 164 | Specifies the timeout in milliseconds between the initial button press and 165 | the generation of the emulated button event. 166 | Default: 1000. Property: "Evdev Third Button Emulation Timeout". 167 | .TP 7 168 | .BI "Option \*qEmulateThirdButtonButton\*q \*q" integer \*q 169 | Specifies the physical button number to be emitted if third button emulation 170 | is triggered. 171 | Default: 3. Property: "Evdev Third Button Button". 172 | .TP 7 173 | .BI "Option \*qEmulateThirdButtonMoveThreshold\*q \*q" integer \*q 174 | Specifies the maximum move fuzz in device coordinates for third button 175 | emulation. If the device moves by more than this threshold before the third 176 | button emulation is triggered, the emulation is cancelled and a first button 177 | event is generated as normal. 178 | Default: 20. Property: "Evdev Third Button Emulation Threshold". 179 | .TP 7 180 | .BI "Option \*qGrabDevice\*q \*q" boolean \*q 181 | Force a grab on the event device. Doing so will ensure that no other driver 182 | can initialise the same device and it will also stop the device from sending 183 | events to /dev/kbd or /dev/input/mice. Events from this device will not be 184 | sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation). 185 | Default: disabled. 186 | .TP 7 187 | .BI "Option \*qInvertX\*q \*q" Bool \*q 188 | .TP 7 189 | .BI "Option \*qInvertY\*q \*q" Bool \*q 190 | Invert the given axis. Default: off. Property: "Evdev Axis Inversion". 191 | .TP 7 192 | .BI "Option \*qIgnoreRelativeAxes\*q \*q" Bool \*q 193 | .TP 7 194 | .BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q 195 | Ignore the specified type of axis. Default: unset. The X server cannot deal 196 | with devices that have both relative and absolute axes. Evdev tries to guess 197 | wich axes to ignore given the device type and disables absolute axes for 198 | mice and relative axes for tablets, touchscreens and touchpad. These options 199 | allow to forcibly disable an axis type. Mouse wheel axes are exempt and will 200 | work even if relative axes are ignored. No property, this configuration must 201 | be set in the configuration. 202 | .br 203 | If either option is set to False, the driver will not ignore the specified 204 | axes regardless of the presence of other axes. This may trigger buggy 205 | behavior and events from this axis are always forwarded. Users are 206 | discouraged from setting this option. 207 | .TP 7 208 | .BI "Option \*qCalibration\*q \*q" "min-x max-x min-y max-y" \*q 209 | Calibrates the X and Y axes for devices that need to scale to a different 210 | coordinate system than reported to the X server. This feature is required 211 | for devices that need to scale to a different coordinate system than 212 | originally reported by the kernel (e.g. touchscreens). The scaling to the 213 | custom coordinate system is done in-driver and the X server is unaware of 214 | the transformation. Property: "Evdev Axis Calibration". 215 | .TP 7 216 | .B Option \*qMode\*q \*qRelative\*q\fP|\fP\*qAbsolute\*q 217 | Sets the mode of the device if device has absolute axes. 218 | The default value for touchpads is relative, for other absolute. 219 | This option has no effect on devices without absolute axes. 220 | .TP 7 221 | .BI "Option \*qSwapAxes\*q \*q" Bool \*q 222 | Swap x/y axes. Default: off. Property: "Evdev Axes Swap". 223 | .TP 7 224 | .BI "Option \*qXAxisMapping\*q \*q" "N1 N2" \*q 225 | Specifies which buttons are mapped to motion in the X direction in wheel 226 | emulation mode. Button number 227 | .I N1 228 | is mapped to the negative X axis motion and button number 229 | .I N2 230 | is mapped to the positive X axis motion. Default: no mapping. Property: 231 | "Evdev Wheel Emulation Axes". 232 | .TP 7 233 | .BI "Option \*qYAxisMapping\*q \*q" "N1 N2" \*q 234 | Specifies which buttons are mapped to motion in the Y direction in wheel 235 | emulation mode. Button number 236 | .I N1 237 | is mapped to the negative Y axis motion and button number 238 | .I N2 239 | is mapped to the positive Y axis motion. Default: "4 5". Property: 240 | "Evdev Wheel Emulation Axes". 241 | .TP 7 242 | .BI "Option \*qTypeName\*q \*q"type"\*q 243 | Specify the X Input 1.x type (see XListInputDevices(__libmansuffix__)). 244 | There is rarely a need to use this option, evdev will guess the device type 245 | based on the device's capabilities. This option is provided for devices that 246 | need quirks. 247 | .TP 7 248 | .BI "Option \*qVertScrollDelta\*q \*q" integer \*q 249 | The amount of motion considered one unit of scrolling vertically. 250 | Default: "1". Property: "Evdev Scrolling Distance". 251 | .TP 7 252 | .BI "Option \*qHorizScrollDelta\*q \*q" integer \*q 253 | The amount of motion considered one unit of scrolling horizontally. 254 | Default: "1". Property: "Evdev Scrolling Distance". 255 | .TP 7 256 | .BI "Option \*qDialDelta\*q \*q" integer \*q 257 | The amount of motion considered one unit of turning the dial. Default: "1". 258 | Property: "Evdev Scrolling Distance". 259 | .TP 7 260 | .BI "Option \*qResolution\*q \*q" integer \*q 261 | Sets the resolution of the device in dots per inch. The resolution is used 262 | to scale relative motion events from mouse devices to 1000 DPI resolution. This 263 | can be used to make high resolution mice less sensitive without turning off 264 | acceleration. If set to 0 no scaling will be performed. Default: "0". 265 | 266 | .SH SUPPORTED PROPERTIES 267 | The following properties are provided by the 268 | .B evdev 269 | driver. 270 | .TP 7 271 | .BI "Evdev Axis Calibration" 272 | 4 32-bit values, order min-x, max-x, min-y, max-y or 0 values to disable 273 | in-driver axis calibration. 274 | .TP 7 275 | .BI "Evdev Axis Inversion" 276 | 2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis. 277 | .TP 7 278 | .BI "Evdev Axes Swap" 279 | 1 boolean value (8 bit, 0 or 1). 1 swaps x/y axes. 280 | .TP 7 281 | .BI "Evdev Drag Lock Buttons" 282 | 8-bit. Either 1 value or pairs of values. Value range 0-32, 0 disables a 283 | value. 284 | .TP 7 285 | .BI "Evdev Middle Button Emulation" 286 | 1 boolean value (8 bit, 0 or 1). 287 | .TP 7 288 | .BI "Evdev Middle Button Timeout" 289 | 1 16-bit positive value. 290 | .TP 7 291 | .BI "Evdev Middle Button Button" 292 | 1 8-bit value, allowed range 0-32, 0 disables the button. 293 | .TP 7 294 | .BI "Evdev Wheel Emulation" 295 | 1 boolean value (8 bit, 0 or 1). 296 | .TP 7 297 | .BI "Evdev Wheel Emulation Axes" 298 | 4 8-bit values, order X up, X down, Y up, Y down. 0 disables a value. 299 | .TP 7 300 | .BI "Evdev Wheel Emulation Button" 301 | 1 8-bit value, allowed range 0-32, 0 disables the button. 302 | .TP 7 303 | .BI "Evdev Wheel Emulation Inertia" 304 | 1 16-bit positive value. 305 | .TP 7 306 | .BI "Evdev Wheel Emulation Timeout" 307 | 1 16-bit positive value. 308 | .TP 7 309 | .BI "Evdev Scrolling Distance" 310 | 3 32-bit values: vertical, horizontal and dial. 311 | 312 | .SH AUTHORS 313 | Kristian Høgsberg, Peter Hutterer 314 | .SH "SEE ALSO" 315 | __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) 316 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright 2005 Adam Jackson. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a 4 | # copy of this software and associated documentation files (the "Software"), 5 | # to deal in the Software without restriction, including without limitation 6 | # on the rights to use, copy, modify, merge, publish, distribute, sub 7 | # license, and/or sell copies of the Software, and to permit persons to whom 8 | # the Software is furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice (including the next 11 | # paragraph) shall be included in all copies or substantial portions of the 12 | # Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17 | # ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | 21 | 22 | # this is obnoxious: 23 | # -module lets us name the module exactly how we want 24 | # -avoid-version prevents gratuitous .0.0.0 version numbers on the end 25 | # _ladir passes a dummy rpath to libtool so the thing will actually link 26 | # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. 27 | 28 | AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) 29 | AM_CPPFLAGS =-I$(top_srcdir)/include $(LIBEVDEV_CFLAGS) 30 | 31 | @DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la 32 | @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version 33 | @DRIVER_NAME@_drv_la_LIBADD = $(MTDEV_LIBS) $(UDEV_LIBS) $(LIBEVDEV_LIBS) 34 | @DRIVER_NAME@_drv_ladir = @inputdir@ 35 | 36 | @DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \ 37 | @DRIVER_NAME@.h \ 38 | emuMB.c \ 39 | emuThird.c \ 40 | emuWheel.c \ 41 | draglock.c \ 42 | apple.c \ 43 | axis_labels.h 44 | 45 | -------------------------------------------------------------------------------- /src/apple.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2011 Red Hat, Inc. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software 5 | * and its documentation for any purpose is hereby granted without 6 | * fee, provided that the above copyright notice appear in all copies 7 | * and that both that copyright notice and this permission notice 8 | * appear in supporting documentation, and that the name of Red Hat 9 | * not be used in advertising or publicity pertaining to distribution 10 | * of the software without specific, written prior permission. Red 11 | * Hat makes no representations about the suitability of this software 12 | * for any purpose. It is provided "as is" without express or implied 13 | * warranty. 14 | * 15 | * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 17 | * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | * 23 | * Authors: 24 | * Peter Hutterer (peter.hutterer@redhat.com) 25 | */ 26 | 27 | #ifdef HAVE_CONFIG_H 28 | #include "config.h" 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | /* Apple-specific controls. 45 | * 46 | * On Apple keyboards, the multimedia function keys are overlaid with the F 47 | * keys. F1 is also BrightnessDown, F10 is Mute, etc. The kernel provides a 48 | * tweak to enable/disable this. 49 | * 50 | * /sys/module/hid_apple/parameters/fnmode 51 | * 0 .. keyboard sends Fx keys, fn is disabled 52 | * 1 .. keyboard sends multimedia keys, fn sends Fx keys 53 | * 2 .. keyboard sends Fx keys, fn sends multimedia keys 54 | * 55 | * We only handle 1 and 2, don't care about 0. If fnmode is found to be on 56 | * 0, we force it to 2 instead. 57 | */ 58 | 59 | /* In this file: fkeymode refers to the evdev-specific enums and parameters, 60 | * fnmode refers to the fnmode parameter exposed by the kernel. fnmode is 61 | * apple-specific */ 62 | #define FNMODE_PATH "/sys/module/hid_apple/parameters/fnmode" 63 | 64 | /* Taken from the kernel */ 65 | #define USB_VENDOR_ID_APPLE 0x05ac 66 | #define USB_DEVICE_ID_APPLE_ALU_MINI_ANSI 0x021d 67 | #define USB_DEVICE_ID_APPLE_ALU_MINI_ISO 0x021e 68 | #define USB_DEVICE_ID_APPLE_ALU_MINI_JIS 0x021f 69 | #define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220 70 | #define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221 71 | #define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222 72 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c 73 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d 74 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e 75 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 76 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a 77 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b 78 | 79 | static int EvdevAppleGetProperty (DeviceIntPtr dev, Atom property); 80 | static int EvdevAppleSetProperty(DeviceIntPtr dev, Atom atom, 81 | XIPropertyValuePtr val, BOOL checkonly); 82 | 83 | static Atom prop_fkeymode; 84 | static Bool fnmode_readonly; /* set if we can only read fnmode */ 85 | 86 | struct product_table 87 | { 88 | unsigned int vendor; 89 | unsigned int product; 90 | } apple_keyboard_table[] = { 91 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI}, 92 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO}, 93 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS}, 94 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI}, 95 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO}, 96 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS}, 97 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI}, 98 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO}, 99 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS}, 100 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI}, 101 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO}, 102 | { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS}, 103 | { 0, 0} 104 | }; 105 | 106 | /** 107 | * @return TRUE if the device matches a product in the given product table, 108 | * FALSE otherwise 109 | */ 110 | static Bool product_check(const struct product_table *t, int vendor, int product) 111 | { 112 | while (t->vendor) 113 | { 114 | if (vendor == t->vendor && product == t->product) 115 | return TRUE; 116 | t++; 117 | } 118 | 119 | return FALSE; 120 | } 121 | 122 | /** 123 | * @return 0 on success, -1 otherwise (check errno) 124 | */ 125 | static int 126 | set_fnmode(enum fkeymode fkeymode) 127 | { 128 | int fd; 129 | char mode; 130 | int bytes_written; 131 | 132 | if (fkeymode == FKEYMODE_UNKNOWN) 133 | { 134 | errno = EINVAL; /* silly you */ 135 | return -1; 136 | } 137 | 138 | fd = open(FNMODE_PATH, O_WRONLY); 139 | if (fd < 0) 140 | return -1; 141 | 142 | mode = (fkeymode == FKEYMODE_FKEYS) ? '2' : '1'; 143 | 144 | bytes_written = write(fd, &mode, 1); 145 | close(fd); 146 | 147 | return (bytes_written == 1) ? 0 : -1; 148 | } 149 | 150 | /** 151 | * Get the current value of fnmode. If fnmode is found to be on 0, we set it 152 | * to 2 in the process. Yes, quite daring, I know. I live on the edge. 153 | * 154 | * @return The current setting of fnmode or FKEYMODE_UNKNOWN on error (check 155 | * errno) 156 | */ 157 | static enum fkeymode 158 | get_fnmode(void) 159 | { 160 | int fd; 161 | char retvalue; 162 | 163 | fd = open(FNMODE_PATH, O_RDWR); 164 | if (fd < 0 && errno == EACCES) 165 | { 166 | fnmode_readonly = TRUE; 167 | fd = open(FNMODE_PATH, O_RDONLY); 168 | } 169 | 170 | if (fd < 0) 171 | goto err; 172 | 173 | if (read(fd, &retvalue, 1) != 1) 174 | goto err; 175 | 176 | if (retvalue != '0' && retvalue != '1' && retvalue != '2') 177 | { 178 | xf86Msg(X_ERROR, "Invalid fnmode value: %c\n", retvalue); 179 | errno = EINVAL; 180 | goto err; 181 | } 182 | 183 | close(fd); 184 | 185 | /* we don't want 0, switch to 2 */ 186 | if (retvalue == '0') 187 | { 188 | if (fnmode_readonly) 189 | xf86Msg(X_WARNING, "fnmode is disabled and read-only. Fn key will" 190 | "not toggle to multimedia keys.\n"); 191 | else 192 | set_fnmode(FKEYMODE_FKEYS); 193 | } 194 | 195 | 196 | return retvalue == '1' ? FKEYMODE_MMKEYS : FKEYMODE_FKEYS; 197 | 198 | err: 199 | if (fd >= 0) 200 | close(fd); 201 | return FKEYMODE_UNKNOWN; 202 | } 203 | 204 | /** 205 | * Set the property value to fkeymode. If the property doesn't exist, 206 | * initialize it. 207 | */ 208 | static void set_fkeymode_property(InputInfoPtr pInfo, enum fkeymode fkeymode) 209 | { 210 | DeviceIntPtr dev = pInfo->dev; 211 | BOOL init = FALSE; 212 | char data; 213 | 214 | switch(fkeymode) 215 | { 216 | case FKEYMODE_FKEYS: data = 0; break; 217 | case FKEYMODE_MMKEYS: data = 1; break; 218 | case FKEYMODE_UNKNOWN: 219 | xf86IDrvMsg(pInfo, X_ERROR, "Failed to get fnmode (%s)\n", strerror(errno)); 220 | return; 221 | } 222 | 223 | if (!prop_fkeymode) { 224 | init = TRUE; 225 | prop_fkeymode = MakeAtom(EVDEV_PROP_FUNCTION_KEYS, strlen(EVDEV_PROP_FUNCTION_KEYS), TRUE); 226 | } 227 | 228 | /* Don't send an event if we're initializing the property */ 229 | XIChangeDeviceProperty(dev, prop_fkeymode, XA_INTEGER, 8, 230 | PropModeReplace, 1, &data, !init); 231 | 232 | if (init) 233 | { 234 | XISetDevicePropertyDeletable(dev, prop_fkeymode, FALSE); 235 | XIRegisterPropertyHandler(dev, EvdevAppleSetProperty, EvdevAppleGetProperty, NULL); 236 | } 237 | } 238 | 239 | 240 | /** 241 | * Called when a client reads the property state. 242 | * Update with current kernel state, it may have changed behind our back. 243 | */ 244 | static int 245 | EvdevAppleGetProperty (DeviceIntPtr dev, Atom property) 246 | { 247 | if (property == prop_fkeymode) 248 | { 249 | InputInfoPtr pInfo = dev->public.devicePrivate; 250 | EvdevPtr pEvdev = pInfo->private; 251 | enum fkeymode fkeymode; 252 | 253 | fkeymode = get_fnmode(); 254 | if (fkeymode != pEvdev->fkeymode) { 255 | /* set internal copy first, so we don't write to the file in 256 | * SetProperty handler */ 257 | pEvdev->fkeymode = fkeymode; 258 | set_fkeymode_property(pInfo, fkeymode); 259 | } 260 | } 261 | return Success; 262 | } 263 | 264 | static int 265 | EvdevAppleSetProperty(DeviceIntPtr dev, Atom atom, 266 | XIPropertyValuePtr val, BOOL checkonly) 267 | { 268 | InputInfoPtr pInfo = dev->public.devicePrivate; 269 | EvdevPtr pEvdev = pInfo->private; 270 | 271 | if (atom == prop_fkeymode) 272 | { 273 | CARD8 v = *(CARD8*)val->data; 274 | 275 | if (val->format != 8 || val->type != XA_INTEGER) 276 | return BadMatch; 277 | 278 | if (fnmode_readonly) 279 | return BadAccess; 280 | 281 | if (v > 1) 282 | return BadValue; 283 | 284 | if (!checkonly) 285 | { 286 | if ((!v && pEvdev->fkeymode != FKEYMODE_FKEYS) || 287 | (v && pEvdev->fkeymode != FKEYMODE_MMKEYS)) 288 | { 289 | pEvdev->fkeymode = v ? FKEYMODE_MMKEYS : FKEYMODE_FKEYS; 290 | set_fnmode(pEvdev->fkeymode); 291 | } 292 | } 293 | } 294 | 295 | return Success; 296 | } 297 | 298 | void 299 | EvdevAppleInitProperty(DeviceIntPtr dev) 300 | { 301 | InputInfoPtr pInfo = dev->public.devicePrivate; 302 | EvdevPtr pEvdev = pInfo->private; 303 | enum fkeymode fkeymode; 304 | 305 | if (!product_check(apple_keyboard_table, 306 | libevdev_get_id_vendor(pEvdev->dev), 307 | libevdev_get_id_product(pEvdev->dev))) 308 | return; 309 | 310 | fkeymode = get_fnmode(); 311 | pEvdev->fkeymode = fkeymode; 312 | set_fkeymode_property(pInfo, fkeymode); 313 | } 314 | -------------------------------------------------------------------------------- /src/axis_labels.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2004-2008 Red Hat, Inc. 3 | * 4 | * Permission to use, copy, modify, distribute, and sell this software 5 | * and its documentation for any purpose is hereby granted without 6 | * fee, provided that the above copyright notice appear in all copies 7 | * and that both that copyright notice and this permission notice 8 | * appear in supporting documentation, and that the name of Red Hat 9 | * not be used in advertising or publicity pertaining to distribution 10 | * of the software without specific, written prior permission. Red 11 | * Hat makes no representations about the suitability of this software 12 | * for any purpose. It is provided "as is" without express or implied 13 | * warranty. 14 | * 15 | * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 17 | * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | */ 23 | 24 | #ifdef HAVE_CONFIG_H 25 | #include "config.h" 26 | #endif 27 | 28 | #include 29 | 30 | #ifndef AXIS_LABELS 31 | #define AXIS_LABELS 32 | 33 | /* Aligned with linux/input.h. 34 | Note that there are holes in the ABS_ range, these are simply replaced with 35 | MISC here */ 36 | static const char* abs_labels[] = { 37 | AXIS_LABEL_PROP_ABS_X, /* 0x00 */ 38 | AXIS_LABEL_PROP_ABS_Y, /* 0x01 */ 39 | AXIS_LABEL_PROP_ABS_Z, /* 0x02 */ 40 | AXIS_LABEL_PROP_ABS_RX, /* 0x03 */ 41 | AXIS_LABEL_PROP_ABS_RY, /* 0x04 */ 42 | AXIS_LABEL_PROP_ABS_RZ, /* 0x05 */ 43 | AXIS_LABEL_PROP_ABS_THROTTLE, /* 0x06 */ 44 | AXIS_LABEL_PROP_ABS_RUDDER, /* 0x07 */ 45 | AXIS_LABEL_PROP_ABS_WHEEL, /* 0x08 */ 46 | AXIS_LABEL_PROP_ABS_GAS, /* 0x09 */ 47 | AXIS_LABEL_PROP_ABS_BRAKE, /* 0x0a */ 48 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 49 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 50 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 51 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 52 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 53 | AXIS_LABEL_PROP_ABS_HAT0X, /* 0x10 */ 54 | AXIS_LABEL_PROP_ABS_HAT0Y, /* 0x11 */ 55 | AXIS_LABEL_PROP_ABS_HAT1X, /* 0x12 */ 56 | AXIS_LABEL_PROP_ABS_HAT1Y, /* 0x13 */ 57 | AXIS_LABEL_PROP_ABS_HAT2X, /* 0x14 */ 58 | AXIS_LABEL_PROP_ABS_HAT2Y, /* 0x15 */ 59 | AXIS_LABEL_PROP_ABS_HAT3X, /* 0x16 */ 60 | AXIS_LABEL_PROP_ABS_HAT3Y, /* 0x17 */ 61 | AXIS_LABEL_PROP_ABS_PRESSURE, /* 0x18 */ 62 | AXIS_LABEL_PROP_ABS_DISTANCE, /* 0x19 */ 63 | AXIS_LABEL_PROP_ABS_TILT_X, /* 0x1a */ 64 | AXIS_LABEL_PROP_ABS_TILT_Y, /* 0x1b */ 65 | AXIS_LABEL_PROP_ABS_TOOL_WIDTH, /* 0x1c */ 66 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 67 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 68 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 69 | AXIS_LABEL_PROP_ABS_VOLUME /* 0x20 */ 70 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 71 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 72 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 73 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 74 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 75 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 76 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 77 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 78 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 79 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 80 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 81 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 82 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 83 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 84 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 85 | AXIS_LABEL_PROP_ABS_MISC, /* undefined */ 86 | AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR, /* 0x30 */ 87 | AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR, /* 0x31 */ 88 | AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR, /* 0x32 */ 89 | AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR, /* 0x33 */ 90 | AXIS_LABEL_PROP_ABS_MT_ORIENTATION, /* 0x34 */ 91 | AXIS_LABEL_PROP_ABS_MT_POSITION_X, /* 0x35 */ 92 | AXIS_LABEL_PROP_ABS_MT_POSITION_Y, /* 0x36 */ 93 | AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE, /* 0x37 */ 94 | AXIS_LABEL_PROP_ABS_MT_BLOB_ID, /* 0x38 */ 95 | AXIS_LABEL_PROP_ABS_MT_TRACKING_ID, /* 0x39 */ 96 | AXIS_LABEL_PROP_ABS_MT_PRESSURE, /* 0x3a */ 97 | #ifdef AXIS_LABEL_PROP_ABS_MT_DISTANCE 98 | AXIS_LABEL_PROP_ABS_MT_DISTANCE, /* 0x3b */ 99 | AXIS_LABEL_PROP_ABS_MT_TOOL_X, /* 0x3c */ 100 | AXIS_LABEL_PROP_ABS_MT_TOOL_Y, /* 0x3d */ 101 | #endif /* AXIS_LABEL_PROP_ABS_MT_DISTANCE */ 102 | }; 103 | 104 | static const char* rel_labels[] = { 105 | AXIS_LABEL_PROP_REL_X, 106 | AXIS_LABEL_PROP_REL_Y, 107 | AXIS_LABEL_PROP_REL_Z, 108 | AXIS_LABEL_PROP_REL_RX, 109 | AXIS_LABEL_PROP_REL_RY, 110 | AXIS_LABEL_PROP_REL_RZ, 111 | AXIS_LABEL_PROP_REL_HWHEEL, 112 | AXIS_LABEL_PROP_REL_DIAL, 113 | AXIS_LABEL_PROP_REL_WHEEL, 114 | AXIS_LABEL_PROP_REL_MISC 115 | }; 116 | 117 | static const char* btn_labels[][16] = { 118 | { /* BTN_MISC group offset 0x100*/ 119 | BTN_LABEL_PROP_BTN_0, /* 0x00 */ 120 | BTN_LABEL_PROP_BTN_1, /* 0x01 */ 121 | BTN_LABEL_PROP_BTN_2, /* 0x02 */ 122 | BTN_LABEL_PROP_BTN_3, /* 0x03 */ 123 | BTN_LABEL_PROP_BTN_4, /* 0x04 */ 124 | BTN_LABEL_PROP_BTN_5, /* 0x05 */ 125 | BTN_LABEL_PROP_BTN_6, /* 0x06 */ 126 | BTN_LABEL_PROP_BTN_7, /* 0x07 */ 127 | BTN_LABEL_PROP_BTN_8, /* 0x08 */ 128 | BTN_LABEL_PROP_BTN_9 /* 0x09 */ 129 | }, 130 | { /* BTN_MOUSE group offset 0x110 */ 131 | BTN_LABEL_PROP_BTN_LEFT, /* 0x00 */ 132 | BTN_LABEL_PROP_BTN_RIGHT, /* 0x01 */ 133 | BTN_LABEL_PROP_BTN_MIDDLE, /* 0x02 */ 134 | BTN_LABEL_PROP_BTN_SIDE, /* 0x03 */ 135 | BTN_LABEL_PROP_BTN_EXTRA, /* 0x04 */ 136 | BTN_LABEL_PROP_BTN_FORWARD, /* 0x05 */ 137 | BTN_LABEL_PROP_BTN_BACK, /* 0x06 */ 138 | BTN_LABEL_PROP_BTN_TASK /* 0x07 */ 139 | }, 140 | { /* BTN_JOYSTICK group offset 0x120 */ 141 | BTN_LABEL_PROP_BTN_TRIGGER, /* 0x00 */ 142 | BTN_LABEL_PROP_BTN_THUMB, /* 0x01 */ 143 | BTN_LABEL_PROP_BTN_THUMB2, /* 0x02 */ 144 | BTN_LABEL_PROP_BTN_TOP, /* 0x03 */ 145 | BTN_LABEL_PROP_BTN_TOP2, /* 0x04 */ 146 | BTN_LABEL_PROP_BTN_PINKIE, /* 0x05 */ 147 | BTN_LABEL_PROP_BTN_BASE, /* 0x06 */ 148 | BTN_LABEL_PROP_BTN_BASE2, /* 0x07 */ 149 | BTN_LABEL_PROP_BTN_BASE3, /* 0x08 */ 150 | BTN_LABEL_PROP_BTN_BASE4, /* 0x09 */ 151 | BTN_LABEL_PROP_BTN_BASE5, /* 0x0a */ 152 | BTN_LABEL_PROP_BTN_BASE6, /* 0x0b */ 153 | NULL, 154 | NULL, 155 | NULL, 156 | BTN_LABEL_PROP_BTN_DEAD /* 0x0f */ 157 | }, 158 | { /* BTN_GAMEPAD group offset 0x130 */ 159 | BTN_LABEL_PROP_BTN_A, /* 0x00 */ 160 | BTN_LABEL_PROP_BTN_B, /* 0x01 */ 161 | BTN_LABEL_PROP_BTN_C, /* 0x02 */ 162 | BTN_LABEL_PROP_BTN_X, /* 0x03 */ 163 | BTN_LABEL_PROP_BTN_Y, /* 0x04 */ 164 | BTN_LABEL_PROP_BTN_Z, /* 0x05 */ 165 | BTN_LABEL_PROP_BTN_TL, /* 0x06 */ 166 | BTN_LABEL_PROP_BTN_TR, /* 0x07 */ 167 | BTN_LABEL_PROP_BTN_TL2, /* 0x08 */ 168 | BTN_LABEL_PROP_BTN_TR2, /* 0x09 */ 169 | BTN_LABEL_PROP_BTN_SELECT, /* 0x0a */ 170 | BTN_LABEL_PROP_BTN_START, /* 0x0b */ 171 | BTN_LABEL_PROP_BTN_MODE, /* 0x0c */ 172 | BTN_LABEL_PROP_BTN_THUMBL, /* 0x0d */ 173 | BTN_LABEL_PROP_BTN_THUMBR /* 0x0e */ 174 | }, 175 | { /* BTN_DIGI group offset 0x140 */ 176 | BTN_LABEL_PROP_BTN_TOOL_PEN, /* 0x00 */ 177 | BTN_LABEL_PROP_BTN_TOOL_RUBBER, /* 0x01 */ 178 | BTN_LABEL_PROP_BTN_TOOL_BRUSH, /* 0x02 */ 179 | BTN_LABEL_PROP_BTN_TOOL_PENCIL, /* 0x03 */ 180 | BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH, /* 0x04 */ 181 | BTN_LABEL_PROP_BTN_TOOL_FINGER, /* 0x05 */ 182 | BTN_LABEL_PROP_BTN_TOOL_MOUSE, /* 0x06 */ 183 | BTN_LABEL_PROP_BTN_TOOL_LENS, /* 0x07 */ 184 | NULL, 185 | NULL, 186 | BTN_LABEL_PROP_BTN_TOUCH, /* 0x0a */ 187 | BTN_LABEL_PROP_BTN_STYLUS, /* 0x0b */ 188 | BTN_LABEL_PROP_BTN_STYLUS2, /* 0x0c */ 189 | BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP, /* 0x0d */ 190 | BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP /* 0x0e */ 191 | }, 192 | { /* BTN_WHEEL group offset 0x150 */ 193 | BTN_LABEL_PROP_BTN_GEAR_DOWN, /* 0x00 */ 194 | BTN_LABEL_PROP_BTN_GEAR_UP /* 0x01 */ 195 | } 196 | }; 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /src/draglock.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljosa/xf86-input-evdev-spacefn/4944298acb81b03cc4571e668d9cd2ea0b3c8568/src/draglock.c -------------------------------------------------------------------------------- /src/emuMB.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. 3 | * Copyright 1993 by David Dawes 4 | * Copyright 2002 by SuSE Linux AG, Author: Egbert Eich 5 | * Copyright 1994-2002 by The XFree86 Project, Inc. 6 | * Copyright 2002 by Paul Elliott 7 | * (Ported from xf86-input-mouse, above copyrights taken from there) 8 | * Copyright © 2008 University of South Australia 9 | * 10 | * Permission to use, copy, modify, distribute, and sell this software 11 | * and its documentation for any purpose is hereby granted without 12 | * fee, provided that the above copyright notice appear in all copies 13 | * and that both that copyright notice and this permission notice 14 | * appear in supporting documentation, and that the name of the authors 15 | * not be used in advertising or publicity pertaining to distribution of the 16 | * software without specific, written prior permission. The authors make no 17 | * representations about the suitability of this software for any 18 | * purpose. It is provided "as is" without express or implied 19 | * warranty. 20 | * 21 | * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 22 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 23 | * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 24 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 25 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 26 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 27 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 28 | * 29 | */ 30 | 31 | /* Middle mouse button emulation code. */ 32 | 33 | #ifdef HAVE_CONFIG_H 34 | #include "config.h" 35 | #endif 36 | 37 | #include "evdev.h" 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include 45 | 46 | static Atom prop_mbemu = 0; /* Middle button emulation on/off property */ 47 | static Atom prop_mbtimeout = 0; /* Middle button timeout property */ 48 | static Atom prop_mbbuton = 0; /* Middle button target button property */ 49 | /* 50 | * Lets create a simple finite-state machine for 3 button emulation: 51 | * 52 | * We track buttons 1 and 3 (left and right). There are 11 states: 53 | * 0 ground - initial state 54 | * 1 delayed left - left pressed, waiting for right 55 | * 2 delayed right - right pressed, waiting for left 56 | * 3 pressed middle - right and left pressed, emulated middle sent 57 | * 4 pressed left - left pressed and sent 58 | * 5 pressed right - right pressed and sent 59 | * 6 released left - left released after emulated middle 60 | * 7 released right - right released after emulated middle 61 | * 8 repressed left - left pressed after released left 62 | * 9 repressed right - right pressed after released right 63 | * 10 pressed both - both pressed, not emulating middle 64 | * 65 | * At each state, we need handlers for the following events 66 | * 0: no buttons down 67 | * 1: left button down 68 | * 2: right button down 69 | * 3: both buttons down 70 | * 4: emulate3Timeout passed without a button change 71 | * Note that button events are not deltas, they are the set of buttons being 72 | * pressed now. It's possible (ie, mouse hardware does it) to go from (eg) 73 | * left down to right down without anything in between, so all cases must be 74 | * handled. 75 | * 76 | * a handler consists of three values: 77 | * 0: action1 78 | * 1: action2 79 | * 2: new emulation state 80 | * 81 | * action > 0: ButtonPress 82 | * action = 0: nothing 83 | * action < 0: ButtonRelease 84 | * 85 | * The comment preceeding each section is the current emulation state. 86 | * The comments to the right are of the form 87 | *