mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
74 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76b1d58a97 | ||
|
|
224a28de25 | ||
|
|
bc2f01ab83 | ||
|
|
9d9c9870c8 | ||
|
|
5c5b2c8db8 | ||
|
|
854df75f49 | ||
|
|
8c55e94a6a | ||
|
|
965338e9d0 | ||
|
|
0075da20d6 | ||
|
|
009ac94a8e | ||
|
|
4b76d80e93 | ||
|
|
6dd6f2d3c6 | ||
|
|
0c7c087f77 | ||
|
|
ba9377c6d9 | ||
|
|
7f7606fc46 | ||
|
|
0ba58f483e | ||
|
|
5fb4875747 | ||
|
|
e99ab2314f | ||
|
|
191660189a | ||
|
|
a1c3f8efbb | ||
|
|
f3c628acc4 | ||
|
|
7909975b0b | ||
|
|
8d6dfd13b0 | ||
|
|
fed454192d | ||
|
|
cf93a21df1 | ||
|
|
fac1a41c75 | ||
|
|
3175a2a96d | ||
|
|
5e9b027807 | ||
|
|
2ce305129c | ||
|
|
9411749f76 | ||
|
|
239e972be1 | ||
|
|
6127923fe0 | ||
|
|
fc4f98153c | ||
|
|
fabee66bcc | ||
|
|
91d90a7959 | ||
|
|
c1b89bda12 | ||
|
|
907b7cad3f | ||
|
|
c9a2b4e9ce | ||
|
|
e18abd0049 | ||
|
|
683a55e504 | ||
|
|
a9cdb6590c | ||
|
|
dd000dd4fa | ||
|
|
745fca03a2 | ||
|
|
b450efdf95 | ||
|
|
eede8ccffc | ||
|
|
2aba790ed3 | ||
|
|
49693892ce | ||
|
|
070f30e089 | ||
|
|
ffe35b6c25 | ||
|
|
5069e05335 | ||
|
|
0b9fad23a3 | ||
|
|
b79776cf8c | ||
|
|
a52cd1cab2 | ||
|
|
eaf202531f | ||
|
|
74151b3c52 | ||
|
|
e9d96e87ac | ||
|
|
bb15bac149 | ||
|
|
7611d2fc73 | ||
|
|
ebe41bfba7 | ||
|
|
68a6a18fc2 | ||
|
|
eeacd3e5a8 | ||
|
|
5708e38494 | ||
|
|
41111ce1ef | ||
|
|
b4c47d5f94 | ||
|
|
50193a0dd3 | ||
|
|
0049cce4d0 | ||
|
|
d9001a6be9 | ||
|
|
22db196815 | ||
|
|
54ac2306b8 | ||
|
|
768c25a99b | ||
|
|
b5c9f41b2b | ||
|
|
8bc4be3048 | ||
|
|
30c3645e20 | ||
|
|
3b52fe2ea4 |
15
configure.ac
15
configure.ac
@@ -23,7 +23,7 @@
|
||||
# Initialize Autoconf
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT([xf86-input-evdev],
|
||||
[2.5.99.903],
|
||||
[2.7.0],
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||
[xf86-input-evdev])
|
||||
AC_CONFIG_SRCDIR([Makefile.am])
|
||||
@@ -45,7 +45,18 @@ 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)
|
||||
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto inputproto)
|
||||
PKG_CHECK_MODULES(UDEV, libudev)
|
||||
|
||||
PKG_CHECK_MODULES(XI22, [inputproto >= 2.1.99.3] [xorg-server >= 1.11.99.901], HAVE_XI22="yes", HAVE_XI22="no")
|
||||
|
||||
if test "x$HAVE_XI22" = xyes; then
|
||||
# Obtain compiler/linker options for mtdev
|
||||
PKG_CHECK_MODULES(MTDEV, mtdev, HAVE_MTDEV="yes", HAVE_MTDEV="no")
|
||||
fi
|
||||
if test "x$HAVE_XI22" = xyes && test "x$HAVE_MTDEV" = xyes; then
|
||||
AC_DEFINE(MULTITOUCH, 1, [XI2.2 available])
|
||||
fi
|
||||
|
||||
# Define a configure option for an alternate input module directory
|
||||
AC_ARG_WITH(xorg-module-dir,
|
||||
|
||||
@@ -66,4 +66,25 @@
|
||||
/* BOOL */
|
||||
#define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap"
|
||||
|
||||
/* BOOL */
|
||||
#define EVDEV_PROP_THIRDBUTTON "Evdev Third Button Emulation"
|
||||
/* CARD32 */
|
||||
#define EVDEV_PROP_THIRDBUTTON_TIMEOUT "Evdev Third Button Emulation Timeout"
|
||||
/* CARD8 */
|
||||
#define EVDEV_PROP_THIRDBUTTON_BUTTON "Evdev Third Button Emulation Button"
|
||||
/* CARD32 */
|
||||
#define EVDEV_PROP_THIRDBUTTON_THRESHOLD "Evdev Third Button Emulation Threshold"
|
||||
|
||||
/* CARD8, 1 value,
|
||||
This property is initialized on devices that have multimedia keys on the
|
||||
function keys. The value of the property selects the default behaviour
|
||||
for the function keys. The behaviour of the fn key (if any exists) is
|
||||
hardware specific. On some hardware, fn may toggle the other set of
|
||||
functions available on the keys.
|
||||
|
||||
0 send functions keys by default, fn may toggle to multimedia keys
|
||||
1 send multimedia keys by default, fn may toggle to function keys
|
||||
*/
|
||||
#define EVDEV_PROP_FUNCTION_KEYS "Evdev Function Keys"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -66,7 +66,8 @@ is used. Buttons not specified in the user's mapping use the default mapping.
|
||||
.BI "Option \*qDevice\*q \*q" string \*q
|
||||
Specifies the device through which the device can be accessed. This will
|
||||
generally be of the form \*q/dev/input/eventX\*q, where X is some integer.
|
||||
The mapping from device node to hardware is system-dependent.
|
||||
The mapping from device node to hardware is system-dependent. Property:
|
||||
"Device Node" (read-only).
|
||||
.TP 7
|
||||
.BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q
|
||||
Sets \*qdrag lock buttons\*q that simulate holding a button down, so
|
||||
@@ -133,6 +134,31 @@ must be pressed before wheel emulation is started. If the
|
||||
is released before this timeout, the original button press/release event
|
||||
is sent. Default: 200. Property: "Evdev Wheel Emulation Timeout".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulateThirdButton\*q \*q" boolean \*q
|
||||
Enable third button emulation. Third button emulation emits a right button
|
||||
event (by default) by pressing and holding the first button. The first
|
||||
button must be held down for the configured timeout and must not move more
|
||||
than the configured threshold for the emulation to activate. Otherwise, the
|
||||
first button event is posted as normal. Default: off. Property: "Evdev
|
||||
Third Button Emulation".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulateThirdButtonTimeout\*q \*q" integer \*q
|
||||
Specifies the timeout in milliseconds between the initial button press and
|
||||
the generation of the emulated button event.
|
||||
Default: 1000. Property: "Evdev Third Button Emulation Timeout".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulateThirdButtonButton\*q \*q" integer \*q
|
||||
Specifies the physical button number to be emitted if third button emulation
|
||||
is triggered.
|
||||
Default: 3. Property: "Evdev Third Button Button".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulateThirdButtonMoveThreshold\*q \*q" integer \*q
|
||||
Specifies the maximum move fuzz in device coordinates for third button
|
||||
emulation. If the device moves by more than this threshold before the third
|
||||
button emulation is triggered, the emulation is cancelled and a first button
|
||||
event is generated as normal.
|
||||
Default: 20. Property: "Evdev Third Button Emulation Threshold".
|
||||
.TP 7
|
||||
.BI "Option \*qGrabDevice\*q \*q" boolean \*q
|
||||
Force a grab on the event device. Doing so will ensure that no other driver
|
||||
can initialise the same device and it will also stop the device from sending
|
||||
|
||||
@@ -30,11 +30,14 @@ 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_la_LIBADD = $(MTDEV_LIBS)
|
||||
@DRIVER_NAME@_drv_ladir = @inputdir@
|
||||
|
||||
@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \
|
||||
@DRIVER_NAME@.h \
|
||||
emuMB.c \
|
||||
emuThird.c \
|
||||
emuWheel.c \
|
||||
draglock.c
|
||||
draglock.c \
|
||||
apple.c
|
||||
|
||||
|
||||
312
src/apple.c
Normal file
312
src/apple.c
Normal file
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright © 2011 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
|
||||
* 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.
|
||||
*
|
||||
* Authors:
|
||||
* Peter Hutterer (peter.hutterer@redhat.com)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <evdev.h>
|
||||
#include <evdev-properties.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <exevents.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86Xinput.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
/* Apple-specific controls.
|
||||
*
|
||||
* On Apple keyboards, the multimedia function keys are overlaid with the F
|
||||
* keys. F1 is also BrightnessDown, F10 is Mute, etc. The kernel provides a
|
||||
* tweak to enable/disable this.
|
||||
*
|
||||
* /sys/module/hid_apple/parameters/fnmode
|
||||
* 0 .. keyboard sends Fx keys, fn is disabled
|
||||
* 1 .. keyboard sends multimedia keys, fn sends Fx keys
|
||||
* 2 .. keyboard sends Fx keys, fn sends multimedia keys
|
||||
*
|
||||
* We only handle 1 and 2, don't care about 0. If fnmode is found to be on
|
||||
* 0, we force it to 2 instead.
|
||||
*/
|
||||
|
||||
/* In this file: fkeymode refers to the evdev-specific enums and parameters,
|
||||
* fnmode refers to the fnmode parameter exposed by the kernel. fnmode is
|
||||
* apple-specific */
|
||||
#define FNMODE_PATH "/sys/module/hid_apple/parameters/fnmode"
|
||||
|
||||
/* Taken from the kernel */
|
||||
#define USB_VENDOR_ID_APPLE 0x05ac
|
||||
#define USB_DEVICE_ID_APPLE_ALU_MINI_ANSI 0x021d
|
||||
#define USB_DEVICE_ID_APPLE_ALU_MINI_ISO 0x021e
|
||||
#define USB_DEVICE_ID_APPLE_ALU_MINI_JIS 0x021f
|
||||
#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
|
||||
#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
|
||||
#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
|
||||
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
|
||||
|
||||
static int EvdevAppleGetProperty (DeviceIntPtr dev, Atom property);
|
||||
static int EvdevAppleSetProperty(DeviceIntPtr dev, Atom atom,
|
||||
XIPropertyValuePtr val, BOOL checkonly);
|
||||
|
||||
static Atom prop_fkeymode;
|
||||
static Bool fnmode_readonly; /* set if we can only read fnmode */
|
||||
|
||||
struct product_table
|
||||
{
|
||||
unsigned int vendor;
|
||||
unsigned int product;
|
||||
} apple_keyboard_table[] = {
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO},
|
||||
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS},
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return TRUE if the device matches a product in the given product table,
|
||||
* FALSE otherwise
|
||||
*/
|
||||
static Bool product_check(const struct product_table *t, int vendor, int product)
|
||||
{
|
||||
while (t->vendor)
|
||||
{
|
||||
if (vendor == t->vendor && product == t->product)
|
||||
return TRUE;
|
||||
t++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 0 on success, -1 otherwise (check errno)
|
||||
*/
|
||||
static int
|
||||
set_fnmode(enum fkeymode fkeymode)
|
||||
{
|
||||
int fd;
|
||||
char mode;
|
||||
int bytes_written;
|
||||
|
||||
if (fkeymode == FKEYMODE_UNKNOWN)
|
||||
{
|
||||
errno = EINVAL; /* silly you */
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = open(FNMODE_PATH, O_WRONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
mode = (fkeymode == FKEYMODE_FKEYS) ? '2' : '1';
|
||||
|
||||
bytes_written = write(fd, &mode, 1);
|
||||
close(fd);
|
||||
|
||||
return (bytes_written == 1) ? 0 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of fnmode. If fnmode is found to be on 0, we set it
|
||||
* to 2 in the process. Yes, quite daring, I know. I live on the edge.
|
||||
*
|
||||
* @return The current setting of fnmode or FKEYMODE_UNKNOWN on error (check
|
||||
* errno)
|
||||
*/
|
||||
static enum fkeymode
|
||||
get_fnmode(void)
|
||||
{
|
||||
int fd;
|
||||
char retvalue;
|
||||
|
||||
fd = open(FNMODE_PATH, O_RDWR);
|
||||
if (fd < 0 && errno == EACCES)
|
||||
{
|
||||
fnmode_readonly = TRUE;
|
||||
fd = open(FNMODE_PATH, O_RDONLY);
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
goto err;
|
||||
|
||||
if (read(fd, &retvalue, 1) != 1)
|
||||
goto err;
|
||||
|
||||
if (retvalue != '0' && retvalue != '1' && retvalue != '2')
|
||||
{
|
||||
xf86Msg(X_ERROR, "Invalid fnmode value: %c\n", retvalue);
|
||||
errno = EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
/* we don't want 0, switch to 2 */
|
||||
if (retvalue == '0')
|
||||
{
|
||||
if (fnmode_readonly)
|
||||
xf86Msg(X_WARNING, "fnmode is disabled and read-only. Fn key will"
|
||||
"not toggle to multimedia keys.\n");
|
||||
else
|
||||
set_fnmode(FKEYMODE_FKEYS);
|
||||
}
|
||||
|
||||
|
||||
return retvalue == '1' ? FKEYMODE_MMKEYS : FKEYMODE_FKEYS;
|
||||
|
||||
err:
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
return FKEYMODE_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the property value to fkeymode. If the property doesn't exist,
|
||||
* initialize it.
|
||||
*/
|
||||
static void set_fkeymode_property(InputInfoPtr pInfo, enum fkeymode fkeymode)
|
||||
{
|
||||
DeviceIntPtr dev = pInfo->dev;
|
||||
BOOL init = FALSE;
|
||||
char data;
|
||||
|
||||
switch(fkeymode)
|
||||
{
|
||||
case FKEYMODE_FKEYS: data = 0; break;
|
||||
case FKEYMODE_MMKEYS: data = 1; break;
|
||||
case FKEYMODE_UNKNOWN:
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "Failed to get fnmode (%s)\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!prop_fkeymode) {
|
||||
init = TRUE;
|
||||
prop_fkeymode = MakeAtom(EVDEV_PROP_FUNCTION_KEYS, strlen(EVDEV_PROP_FUNCTION_KEYS), TRUE);
|
||||
}
|
||||
|
||||
/* Don't send an event if we're initializing the property */
|
||||
XIChangeDeviceProperty(dev, prop_fkeymode, XA_INTEGER, 8,
|
||||
PropModeReplace, 1, &data, !init);
|
||||
|
||||
if (init)
|
||||
{
|
||||
XISetDevicePropertyDeletable(dev, prop_fkeymode, FALSE);
|
||||
XIRegisterPropertyHandler(dev, EvdevAppleSetProperty, EvdevAppleGetProperty, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a client reads the property state.
|
||||
* Update with current kernel state, it may have changed behind our back.
|
||||
*/
|
||||
static int
|
||||
EvdevAppleGetProperty (DeviceIntPtr dev, Atom property)
|
||||
{
|
||||
if (property == prop_fkeymode)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
enum fkeymode fkeymode;
|
||||
|
||||
fkeymode = get_fnmode();
|
||||
if (fkeymode != pEvdev->fkeymode) {
|
||||
/* set internal copy first, so we don't write to the file in
|
||||
* SetProperty handler */
|
||||
pEvdev->fkeymode = fkeymode;
|
||||
set_fkeymode_property(pInfo, fkeymode);
|
||||
}
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
EvdevAppleSetProperty(DeviceIntPtr dev, Atom atom,
|
||||
XIPropertyValuePtr val, BOOL checkonly)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (atom == prop_fkeymode)
|
||||
{
|
||||
CARD8 v = *(CARD8*)val->data;
|
||||
|
||||
if (val->format != 8 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (fnmode_readonly)
|
||||
return BadAccess;
|
||||
|
||||
if (v > 1)
|
||||
return BadValue;
|
||||
|
||||
if (!checkonly)
|
||||
{
|
||||
if ((!v && pEvdev->fkeymode != FKEYMODE_FKEYS) ||
|
||||
(v && pEvdev->fkeymode != FKEYMODE_MMKEYS))
|
||||
{
|
||||
pEvdev->fkeymode = v ? FKEYMODE_MMKEYS : FKEYMODE_FKEYS;
|
||||
set_fnmode(pEvdev->fkeymode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
EvdevAppleInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
enum fkeymode fkeymode;
|
||||
|
||||
if (!product_check(apple_keyboard_table,
|
||||
pEvdev->id_vendor, pEvdev->id_product))
|
||||
return;
|
||||
|
||||
fkeymode = get_fnmode();
|
||||
pEvdev->fkeymode = fkeymode;
|
||||
set_fkeymode_property(pInfo, fkeymode);
|
||||
}
|
||||
@@ -44,9 +44,7 @@
|
||||
|
||||
#include <evdev-properties.h>
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static Atom prop_dlock = 0; /* Drag lock buttons. */
|
||||
#endif
|
||||
|
||||
void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button);
|
||||
|
||||
@@ -105,13 +103,12 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
|
||||
/* We only have a meta button */
|
||||
pEvdev->dragLock.meta = meta_button;
|
||||
|
||||
xf86Msg(X_CONFIG, "%s: DragLockButtons : "
|
||||
"%i as meta\n",
|
||||
pInfo->name, meta_button);
|
||||
xf86IDrvMsg(pInfo, X_CONFIG, "DragLockButtons : "
|
||||
"%i as meta\n", meta_button);
|
||||
} else {
|
||||
xf86Msg(X_ERROR, "%s: DragLockButtons : "
|
||||
"Incomplete pair specifying button pairs %s\n",
|
||||
pInfo->name, option_string);
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "DragLockButtons : "
|
||||
"Incomplete pair specifying button pairs %s\n",
|
||||
option_string);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -119,23 +116,24 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
|
||||
if ((meta_button <= EVDEV_MAXBUTTONS) && (meta_button >= 0 ) &&
|
||||
(lock_button <= EVDEV_MAXBUTTONS) && (lock_button >= 0)) {
|
||||
|
||||
xf86Msg(X_CONFIG, "%s: DragLockButtons : %i -> %i\n",
|
||||
pInfo->name, meta_button, lock_button);
|
||||
xf86IDrvMsg(pInfo, X_CONFIG,
|
||||
"DragLockButtons : %i -> %i\n",
|
||||
meta_button, lock_button);
|
||||
|
||||
pEvdev->dragLock.lock_pair[meta_button - 1] = lock_button;
|
||||
pairs=TRUE;
|
||||
} else {
|
||||
/* Let the user know something was wrong
|
||||
with this pair of buttons */
|
||||
xf86Msg(X_CONFIG, "%s: DragLockButtons : "
|
||||
"Invalid button pair %i -> %i\n",
|
||||
pInfo->name, meta_button, lock_button);
|
||||
xf86IDrvMsg(pInfo, X_CONFIG,"DragLockButtons : "
|
||||
"Invalid button pair %i -> %i\n",
|
||||
meta_button, lock_button);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xf86Msg(X_ERROR, "%s: Found DragLockButtons "
|
||||
"with invalid lock button string : '%s'\n",
|
||||
pInfo->name, option_string);
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "Found DragLockButtons "
|
||||
"with invalid lock button string : '%s'\n",
|
||||
option_string);
|
||||
|
||||
/* This should be the case anyhow, just make sure */
|
||||
next_num = NULL;
|
||||
@@ -211,7 +209,6 @@ EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
/**
|
||||
* Set the drag lock property.
|
||||
* If only one value is supplied, then this is used as the meta button.
|
||||
@@ -319,5 +316,3 @@ EvdevDragLockInitProperty(DeviceIntPtr dev)
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,10 +43,8 @@
|
||||
|
||||
#include <evdev-properties.h>
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
|
||||
static Atom prop_mbtimeout = 0; /* Middle button timeout property */
|
||||
#endif
|
||||
/*
|
||||
* Lets create a simple finite-state machine for 3 button emulation:
|
||||
*
|
||||
@@ -193,7 +191,8 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
|
||||
|
||||
pEvdev->emulateMB.pending = FALSE;
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
|
||||
EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
|
||||
EvdevPostButtonEvent(pInfo, abs(id),
|
||||
(id >= 0) ? BUTTON_PRESS : BUTTON_RELEASE);
|
||||
pEvdev->emulateMB.state =
|
||||
stateTab[pEvdev->emulateMB.state][4][2];
|
||||
} else {
|
||||
@@ -330,7 +329,6 @@ EvdevMBEmuFinalize(InputInfoPtr pInfo)
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static int
|
||||
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
BOOL checkonly)
|
||||
@@ -391,4 +389,3 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
416
src/emuThird.c
Normal file
416
src/emuThird.c
Normal file
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
* Copyright © 2011 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 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Right mouse button emulation code.
|
||||
* Emulates a right button event if the first button is held down for a
|
||||
* timeout. If the device moves more than a certain amount before the
|
||||
* timeout is over, the emulation is cancelled and a normal button event is
|
||||
* generated.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evdev.h"
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86Xinput.h>
|
||||
#include <exevents.h>
|
||||
|
||||
#include <evdev-properties.h>
|
||||
|
||||
/* Threshold (in device coordinates) for devices to cancel emulation */
|
||||
#define DEFAULT_MOVE_THRESHOLD 20
|
||||
|
||||
static Atom prop_3bemu; /* Right button emulation on/off property */
|
||||
static Atom prop_3btimeout; /* Right button timeout property */
|
||||
static Atom prop_3bbutton; /* Right button target physical button */
|
||||
static Atom prop_3bthreshold; /* Right button move cancellation threshold */
|
||||
|
||||
/* State machine for 3rd button emulation */
|
||||
enum EmulationState {
|
||||
EM3B_OFF, /* no event */
|
||||
EM3B_PENDING, /* timer pending */
|
||||
EM3B_EMULATING /* in emulation */
|
||||
};
|
||||
|
||||
static void
|
||||
Evdev3BEmuPostButtonEvent(InputInfoPtr pInfo, int button, enum ButtonAction act)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
int absolute = Relative;
|
||||
|
||||
/* if we cancel, emit the button down event at our start position,
|
||||
* not at the current position. Only for absolute devices though. For
|
||||
* relative events, this may be a bit iffy since pointer accel may shoot
|
||||
* us back more than we moved and confuse the user.
|
||||
*/
|
||||
if (emu3B->flags & EVDEV_ABSOLUTE_EVENTS)
|
||||
absolute = Absolute;
|
||||
|
||||
xf86PostButtonEventP(pInfo->dev, absolute, button,
|
||||
(act == BUTTON_PRESS) ? 1 : 0, 0,
|
||||
(absolute ? 2 : 0), emu3B->startpos);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Timer function. Post a button down event to the server.
|
||||
*
|
||||
* @param arg The InputInfoPtr for this device.
|
||||
*/
|
||||
CARD32
|
||||
Evdev3BEmuTimer(OsTimerPtr timer, CARD32 time, pointer arg)
|
||||
{
|
||||
InputInfoPtr pInfo = (InputInfoPtr)arg;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
int sigstate = 0;
|
||||
|
||||
sigstate = xf86BlockSIGIO ();
|
||||
emu3B->state = EM3B_EMULATING;
|
||||
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_PRESS);
|
||||
xf86UnblockSIGIO (sigstate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cancel all emulation, reset the timer and reset deltas.
|
||||
*/
|
||||
static void
|
||||
Evdev3BCancel(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
|
||||
if (emu3B->state != EM3B_OFF)
|
||||
{
|
||||
TimerCancel(emu3B->timer);
|
||||
emu3B->state = EM3B_OFF;
|
||||
memset(emu3B->delta, 0, sizeof(emu3B->delta));
|
||||
}
|
||||
|
||||
emu3B->flags = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emulate a third button on button press. Note that emulation only triggers
|
||||
* on button 1.
|
||||
*
|
||||
* Return TRUE if event was swallowed by middle mouse button emulation,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
BOOL
|
||||
Evdev3BEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
int ret = FALSE;
|
||||
|
||||
if (!emu3B->enabled)
|
||||
goto out;
|
||||
|
||||
if (press)
|
||||
emu3B->buttonstate |= button;
|
||||
else
|
||||
emu3B->buttonstate &= ~button;
|
||||
|
||||
/* Any other button pressed? Cancel timer */
|
||||
if (button != 1)
|
||||
{
|
||||
switch (emu3B->state)
|
||||
{
|
||||
case EM3B_PENDING:
|
||||
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
|
||||
Evdev3BCancel(pInfo);
|
||||
break;
|
||||
case EM3B_EMULATING:
|
||||
/* We're emulating and now the user pressed a different
|
||||
* button. Just release the emulating one, tell the user to
|
||||
* not do that and get on with life */
|
||||
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_RELEASE);
|
||||
Evdev3BCancel(pInfo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Don't emulate if any other button is down */
|
||||
if ((emu3B->buttonstate & ~0x1) != 0)
|
||||
goto out;
|
||||
|
||||
/* Release event → cancel, send press and release now. */
|
||||
if (!press)
|
||||
{
|
||||
switch(emu3B->state)
|
||||
{
|
||||
case EM3B_PENDING:
|
||||
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
|
||||
Evdev3BCancel(pInfo);
|
||||
break;
|
||||
case EM3B_EMULATING:
|
||||
Evdev3BEmuPostButtonEvent(pInfo, emu3B->button, BUTTON_RELEASE);
|
||||
Evdev3BCancel(pInfo);
|
||||
ret = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (press && emu3B->state == EM3B_OFF)
|
||||
{
|
||||
emu3B->state = EM3B_PENDING;
|
||||
emu3B->timer = TimerSet(emu3B->timer, 0, emu3B->timeout,
|
||||
Evdev3BEmuTimer, pInfo);
|
||||
ret = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle absolute x/y motion. If the motion is above the threshold, cancel
|
||||
* emulation.
|
||||
*/
|
||||
void
|
||||
Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
int cancel = FALSE;
|
||||
int axis = 0;
|
||||
|
||||
if (emu3B->state != EM3B_PENDING)
|
||||
{
|
||||
if (valuator_mask_isset(vals, 0))
|
||||
emu3B->startpos[0] = valuator_mask_get(vals, 0);
|
||||
if (valuator_mask_isset(vals, 1))
|
||||
emu3B->startpos[1] = valuator_mask_get(vals, 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((emu3B->flags & EVDEV_ABSOLUTE_EVENTS) == 0)
|
||||
emu3B->flags |= EVDEV_ABSOLUTE_EVENTS;
|
||||
|
||||
while (axis <= 1 && !cancel)
|
||||
{
|
||||
if (valuator_mask_isset(vals, axis))
|
||||
{
|
||||
int delta = valuator_mask_get(vals, axis) - emu3B->startpos[axis];
|
||||
if (abs(delta) > emu3B->threshold)
|
||||
cancel = TRUE;
|
||||
}
|
||||
axis++;
|
||||
}
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
|
||||
Evdev3BCancel(pInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle relative x/y motion. If the motion is above the threshold, cancel
|
||||
* emulation.
|
||||
*/
|
||||
void
|
||||
Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
|
||||
if (emu3B->state != EM3B_PENDING)
|
||||
return;
|
||||
|
||||
emu3B->delta[0] += dx;
|
||||
emu3B->delta[1] += dy;
|
||||
emu3B->flags |= EVDEV_RELATIVE_EVENTS;
|
||||
|
||||
if (abs(emu3B->delta[0]) > emu3B->threshold ||
|
||||
abs(emu3B->delta[1]) > emu3B->threshold)
|
||||
{
|
||||
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
|
||||
Evdev3BCancel(pInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Evdev3BEmuPreInit(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
|
||||
emu3B->enabled = xf86SetBoolOption(pInfo->options,
|
||||
"EmulateThirdButton",
|
||||
FALSE);
|
||||
emu3B->timeout = xf86SetIntOption(pInfo->options,
|
||||
"EmulateThirdButtonTimeout",
|
||||
1000);
|
||||
emu3B->button = xf86SetIntOption(pInfo->options,
|
||||
"EmulateThirdButtonButton",
|
||||
3);
|
||||
/* FIXME: this should be auto-configured based on axis ranges */
|
||||
emu3B->threshold = xf86SetIntOption(pInfo->options,
|
||||
"EmulateThirdButtonMoveThreshold",
|
||||
DEFAULT_MOVE_THRESHOLD);
|
||||
/* allocate now so we don't allocate in the signal handler */
|
||||
emu3B->timer = TimerSet(NULL, 0, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
Evdev3BEmuOn(InputInfoPtr pInfo)
|
||||
{
|
||||
/* This function just exists for symmetry in evdev.c */
|
||||
}
|
||||
|
||||
void
|
||||
Evdev3BEmuFinalize(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
|
||||
TimerFree(emu3B->timer);
|
||||
emu3B->timer = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
Evdev3BEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
BOOL checkonly)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
|
||||
if (atom == prop_3bemu)
|
||||
{
|
||||
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
emu3B->enabled = *((BOOL*)val->data);
|
||||
|
||||
} else if (atom == prop_3btimeout)
|
||||
{
|
||||
if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
emu3B->timeout = *((CARD32*)val->data);
|
||||
|
||||
} else if (atom == prop_3bbutton)
|
||||
{
|
||||
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
emu3B->button = *((CARD8*)val->data);
|
||||
} else if (atom == prop_3bthreshold)
|
||||
{
|
||||
if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
emu3B->threshold = *((CARD32*)val->data);
|
||||
}
|
||||
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise properties for third button emulation
|
||||
*/
|
||||
void
|
||||
Evdev3BEmuInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
struct emulate3B *emu3B = &pEvdev->emulate3B;
|
||||
int rc;
|
||||
|
||||
if (!dev->button) /* don't init prop for keyboards */
|
||||
return;
|
||||
|
||||
/* third button emulation on/off */
|
||||
prop_3bemu = MakeAtom(EVDEV_PROP_THIRDBUTTON, strlen(EVDEV_PROP_THIRDBUTTON), TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_3bemu, XA_INTEGER, 8,
|
||||
PropModeReplace, 1,
|
||||
&emu3B->enabled,
|
||||
FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_3bemu, FALSE);
|
||||
|
||||
/* third button emulation timeout */
|
||||
prop_3btimeout = MakeAtom(EVDEV_PROP_THIRDBUTTON_TIMEOUT,
|
||||
strlen(EVDEV_PROP_THIRDBUTTON_TIMEOUT),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_3btimeout, XA_INTEGER, 32, PropModeReplace, 1,
|
||||
&emu3B->timeout, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_3btimeout, FALSE);
|
||||
|
||||
/* third button emulation button to be triggered */
|
||||
prop_3bbutton = MakeAtom(EVDEV_PROP_THIRDBUTTON_BUTTON,
|
||||
strlen(EVDEV_PROP_THIRDBUTTON_BUTTON),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_3bbutton, XA_INTEGER, 8, PropModeReplace, 1,
|
||||
&emu3B->button, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_3bbutton, FALSE);
|
||||
|
||||
/* third button emulation movement threshold */
|
||||
prop_3bthreshold = MakeAtom(EVDEV_PROP_THIRDBUTTON_THRESHOLD,
|
||||
strlen(EVDEV_PROP_THIRDBUTTON_THRESHOLD),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_3bthreshold, XA_INTEGER, 32, PropModeReplace, 1,
|
||||
&emu3B->threshold, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_3bthreshold, FALSE);
|
||||
|
||||
XIRegisterPropertyHandler(dev, Evdev3BEmuSetProperty, NULL, NULL);
|
||||
}
|
||||
@@ -44,13 +44,11 @@
|
||||
|
||||
#define WHEEL_NOT_CONFIGURED 0
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static Atom prop_wheel_emu = 0;
|
||||
static Atom prop_wheel_axismap = 0;
|
||||
static Atom prop_wheel_inertia = 0;
|
||||
static Atom prop_wheel_timeout = 0;
|
||||
static Atom prop_wheel_button = 0;
|
||||
#endif
|
||||
|
||||
/* Local Funciton Prototypes */
|
||||
static BOOL EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char *axis_name);
|
||||
@@ -120,8 +118,9 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
|
||||
|
||||
/* We don't want to intercept real mouse wheel events */
|
||||
if(pEv->type == EV_ABS) {
|
||||
oldValue = pEvdev->vals[pEvdev->axis_map[pEv->code]];
|
||||
pEvdev->vals[pEvdev->axis_map[pEv->code]] = value;
|
||||
int axis = pEvdev->axis_map[pEv->code];
|
||||
oldValue = valuator_mask_get(pEvdev->vals, axis);
|
||||
valuator_mask_set(pEvdev->vals, axis, value);
|
||||
value -= oldValue; /* make value into a differential measurement */
|
||||
}
|
||||
|
||||
@@ -230,14 +229,14 @@ EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_
|
||||
if (down_button > pEvdev->num_buttons) pEvdev->num_buttons = down_button;
|
||||
|
||||
} else {
|
||||
xf86Msg(X_WARNING, "%s: Invalid %s value:\"%s\"\n",
|
||||
pInfo->name, axis_name, option_string);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Invalid %s value:\"%s\"\n",
|
||||
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);
|
||||
xf86IDrvMsg(pInfo, X_CONFIG, "%s: %s\n", axis_name, msg);
|
||||
free(msg);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -250,14 +249,10 @@ void
|
||||
EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
char val[4];
|
||||
int wheelButton;
|
||||
int inertia;
|
||||
int timeout;
|
||||
|
||||
val[0] = 0;
|
||||
val[1] = 0;
|
||||
|
||||
if (xf86SetBoolOption(pInfo->options, "EmulateWheel", FALSE)) {
|
||||
pEvdev->emulateWheel.enabled = TRUE;
|
||||
} else
|
||||
@@ -266,9 +261,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
wheelButton = xf86SetIntOption(pInfo->options, "EmulateWheelButton", 4);
|
||||
|
||||
if ((wheelButton < 0) || (wheelButton > EVDEV_MAXBUTTONS)) {
|
||||
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelButton value: %d\n",
|
||||
pInfo->name, wheelButton);
|
||||
xf86Msg(X_WARNING, "%s: Wheel emulation disabled.\n", pInfo->name);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Invalid EmulateWheelButton value: %d\n",
|
||||
wheelButton);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Wheel emulation disabled.\n");
|
||||
|
||||
pEvdev->emulateWheel.enabled = FALSE;
|
||||
}
|
||||
@@ -278,10 +273,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
inertia = xf86SetIntOption(pInfo->options, "EmulateWheelInertia", 10);
|
||||
|
||||
if (inertia <= 0) {
|
||||
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelInertia value: %d\n",
|
||||
pInfo->name, inertia);
|
||||
xf86Msg(X_WARNING, "%s: Using built-in inertia value.\n",
|
||||
pInfo->name);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Invalid EmulateWheelInertia value: %d\n",
|
||||
inertia);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Using built-in inertia value.\n");
|
||||
|
||||
inertia = 10;
|
||||
}
|
||||
@@ -291,10 +285,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
timeout = xf86SetIntOption(pInfo->options, "EmulateWheelTimeout", 200);
|
||||
|
||||
if (timeout < 0) {
|
||||
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelTimeout value: %d\n",
|
||||
pInfo->name, timeout);
|
||||
xf86Msg(X_WARNING, "%s: Using built-in timeout value.\n",
|
||||
pInfo->name);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Invalid EmulateWheelTimeout value: %d\n",
|
||||
timeout);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Using built-in timeout value.\n");
|
||||
|
||||
timeout = 200;
|
||||
}
|
||||
@@ -314,9 +307,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
pEvdev->num_buttons = 5;
|
||||
|
||||
/* Display default Configuration */
|
||||
xf86Msg(X_CONFIG, "%s: YAxisMapping: buttons %d and %d\n",
|
||||
pInfo->name, pEvdev->emulateWheel.Y.up_button,
|
||||
pEvdev->emulateWheel.Y.down_button);
|
||||
xf86IDrvMsg(pInfo, X_CONFIG, "YAxisMapping: buttons %d and %d\n",
|
||||
pEvdev->emulateWheel.Y.up_button,
|
||||
pEvdev->emulateWheel.Y.down_button);
|
||||
}
|
||||
|
||||
|
||||
@@ -329,13 +322,13 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
pEvdev->emulateWheel.X.traveled_distance = 0;
|
||||
pEvdev->emulateWheel.Y.traveled_distance = 0;
|
||||
|
||||
xf86Msg(X_CONFIG, "%s: EmulateWheelButton: %d, "
|
||||
"EmulateWheelInertia: %d, "
|
||||
"EmulateWheelTimeout: %d\n",
|
||||
pInfo->name, pEvdev->emulateWheel.button, inertia, timeout);
|
||||
xf86IDrvMsg(pInfo, X_CONFIG,
|
||||
"EmulateWheelButton: %d, "
|
||||
"EmulateWheelInertia: %d, "
|
||||
"EmulateWheelTimeout: %d\n",
|
||||
pEvdev->emulateWheel.button, inertia, timeout);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static int
|
||||
EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
BOOL checkonly)
|
||||
@@ -485,4 +478,3 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev)
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
1628
src/evdev.c
1628
src/evdev.c
File diff suppressed because it is too large
Load Diff
117
src/evdev.h
117
src/evdev.h
@@ -28,6 +28,10 @@
|
||||
* Oliver McFadden (oliver.mcfadden@nokia.com)
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef EVDEV_H
|
||||
#define EVDEV_H
|
||||
|
||||
@@ -39,6 +43,10 @@
|
||||
#include <xf86_OSproc.h>
|
||||
#include <xkbstr.h>
|
||||
|
||||
#ifdef MULTITOUCH
|
||||
#include <mtdev.h>
|
||||
#endif
|
||||
|
||||
#ifndef EV_CNT /* linux 2.6.23 kernels and earlier lack _CNT defines */
|
||||
#define EV_CNT (EV_MAX+1)
|
||||
#endif
|
||||
@@ -55,6 +63,10 @@
|
||||
#define LED_CNT (LED_MAX+1)
|
||||
#endif
|
||||
|
||||
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 14
|
||||
#define HAVE_SMOOTH_SCROLLING 1
|
||||
#endif
|
||||
|
||||
#define EVDEV_MAXBUTTONS 32
|
||||
#define EVDEV_MAXQUEUE 32
|
||||
|
||||
@@ -72,31 +84,38 @@
|
||||
#define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */
|
||||
#define EVDEV_RELATIVE_MODE (1 << 11) /* Force relative events for devices with absolute axes */
|
||||
|
||||
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
|
||||
#define HAVE_PROPERTIES 1
|
||||
#endif
|
||||
|
||||
#ifndef MAX_VALUATORS
|
||||
#define MAX_VALUATORS 36
|
||||
#endif
|
||||
|
||||
|
||||
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
|
||||
typedef struct {
|
||||
char *rules;
|
||||
char *model;
|
||||
char *layout;
|
||||
char *variant;
|
||||
char *options;
|
||||
} XkbRMLVOSet;
|
||||
#ifndef XI_PROP_DEVICE_NODE
|
||||
#define XI_PROP_DEVICE_NODE "Device Node"
|
||||
#endif
|
||||
|
||||
|
||||
#define LONG_BITS (sizeof(long) * 8)
|
||||
|
||||
/* Number of longs needed to hold the given number of bits */
|
||||
#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
|
||||
|
||||
/* Function key mode */
|
||||
enum fkeymode {
|
||||
FKEYMODE_UNKNOWN = 0,
|
||||
FKEYMODE_FKEYS, /* function keys send function keys */
|
||||
FKEYMODE_MMKEYS, /* function keys send multimedia keys */
|
||||
};
|
||||
|
||||
enum SlotState {
|
||||
SLOTSTATE_OPEN = 8,
|
||||
SLOTSTATE_CLOSE,
|
||||
SLOTSTATE_UPDATE,
|
||||
SLOTSTATE_EMPTY,
|
||||
};
|
||||
|
||||
enum ButtonAction {
|
||||
BUTTON_RELEASE = 0,
|
||||
BUTTON_PRESS = 1
|
||||
};
|
||||
|
||||
/* axis specific data for wheel emulation */
|
||||
typedef struct {
|
||||
int up_button;
|
||||
@@ -110,19 +129,41 @@ typedef struct {
|
||||
EV_QUEUE_KEY, /* xf86PostKeyboardEvent() */
|
||||
EV_QUEUE_BTN, /* xf86PostButtonEvent() */
|
||||
EV_QUEUE_PROXIMITY, /* xf86PostProximityEvent() */
|
||||
#ifdef MULTITOUCH
|
||||
EV_QUEUE_TOUCH, /*xf86PostTouchEvent() */
|
||||
#endif
|
||||
} type;
|
||||
int key; /* May be either a key code or button number. */
|
||||
int val; /* State of the key/button; pressed or released. */
|
||||
union {
|
||||
int key; /* May be either a key code or button number. */
|
||||
#ifdef MULTITOUCH
|
||||
unsigned int touch; /* Touch ID */
|
||||
#endif
|
||||
} detail;
|
||||
int val; /* State of the key/button/touch; pressed or released. */
|
||||
#ifdef MULTITOUCH
|
||||
ValuatorMask *touchMask;
|
||||
#endif
|
||||
} EventQueueRec, *EventQueuePtr;
|
||||
|
||||
typedef struct {
|
||||
const char *device;
|
||||
unsigned short id_vendor;
|
||||
unsigned short id_product;
|
||||
|
||||
char *device;
|
||||
int grabDevice; /* grab the event device? */
|
||||
|
||||
int num_vals; /* number of valuators */
|
||||
int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
|
||||
int vals[MAX_VALUATORS];
|
||||
int old_vals[MAX_VALUATORS]; /* Translate absolute inputs to relative */
|
||||
ValuatorMask *vals; /* new values coming in */
|
||||
ValuatorMask *old_vals; /* old values for calculating relative motion */
|
||||
ValuatorMask *prox; /* last values set while not in proximity */
|
||||
ValuatorMask *mt_mask;
|
||||
ValuatorMask **last_mt_vals;
|
||||
int cur_slot;
|
||||
enum SlotState slot_state;
|
||||
#ifdef MULTITOUCH
|
||||
struct mtdev *mtdev;
|
||||
#endif
|
||||
|
||||
int flags;
|
||||
int in_proximity; /* device in proximity */
|
||||
@@ -134,12 +175,8 @@ typedef struct {
|
||||
|
||||
int delta[REL_CNT];
|
||||
unsigned int abs_queued, rel_queued, prox_queued;
|
||||
unsigned int abs_prox; /* valuators posted while out of prox? */
|
||||
|
||||
/* XKB stuff has to be per-device rather than per-driver */
|
||||
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
|
||||
XkbComponentNamesRec xkbnames;
|
||||
#endif
|
||||
XkbRMLVOSet rmlvo;
|
||||
|
||||
/* Middle mouse button emulation */
|
||||
@@ -151,6 +188,19 @@ typedef struct {
|
||||
Time expires; /* time of expiry */
|
||||
Time timeout;
|
||||
} emulateMB;
|
||||
/* Third mouse button emulation */
|
||||
struct emulate3B {
|
||||
BOOL enabled;
|
||||
BOOL state; /* current state */
|
||||
Time timeout; /* timeout until third button press */
|
||||
int buttonstate; /* phys. button state */
|
||||
int button; /* phys button to emit */
|
||||
int threshold; /* move threshold in dev coords */
|
||||
OsTimerPtr timer;
|
||||
int delta[2]; /* delta x/y, accumulating */
|
||||
int startpos[2]; /* starting pos for abs devices */
|
||||
int flags; /* remember if we had rel or abs movement */
|
||||
} emulate3B;
|
||||
struct {
|
||||
int meta; /* meta key to lock any button */
|
||||
BOOL meta_state; /* meta_button state */
|
||||
@@ -196,13 +246,19 @@ typedef struct {
|
||||
/* Event queue used to defer keyboard/button events until EV_SYN time. */
|
||||
int num_queue;
|
||||
EventQueueRec queue[EVDEV_MAXQUEUE];
|
||||
|
||||
enum fkeymode fkeymode;
|
||||
} EvdevRec, *EvdevPtr;
|
||||
|
||||
/* Event posting functions */
|
||||
void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
|
||||
void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
|
||||
void EvdevQueueProximityEvent(InputInfoPtr pInfo, int value);
|
||||
void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value);
|
||||
#ifdef MULTITOUCH
|
||||
void EvdevQueueTouchEvent(InputInfoPtr pInfo, unsigned int touch,
|
||||
ValuatorMask *mask, uint16_t type);
|
||||
#endif
|
||||
void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, enum ButtonAction act);
|
||||
void EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count);
|
||||
void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
|
||||
int v[MAX_VALUATORS]);
|
||||
@@ -219,6 +275,15 @@ void EvdevMBEmuPreInit(InputInfoPtr);
|
||||
void EvdevMBEmuOn(InputInfoPtr);
|
||||
void EvdevMBEmuFinalize(InputInfoPtr);
|
||||
|
||||
/* Third button emulation */
|
||||
CARD32 Evdev3BEmuTimer(OsTimerPtr timer, CARD32 time, pointer arg);
|
||||
BOOL Evdev3BEmuFilterEvent(InputInfoPtr, int, BOOL);
|
||||
void Evdev3BEmuPreInit(InputInfoPtr pInfo);
|
||||
void Evdev3BEmuOn(InputInfoPtr);
|
||||
void Evdev3BEmuFinalize(InputInfoPtr);
|
||||
void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy);
|
||||
void Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals);
|
||||
|
||||
/* Mouse Wheel emulation */
|
||||
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
|
||||
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
|
||||
@@ -228,9 +293,9 @@ BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
|
||||
void EvdevDragLockPreInit(InputInfoPtr pInfo);
|
||||
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
void EvdevMBEmuInitProperty(DeviceIntPtr);
|
||||
void Evdev3BEmuInitProperty(DeviceIntPtr);
|
||||
void EvdevWheelEmuInitProperty(DeviceIntPtr);
|
||||
void EvdevDragLockInitProperty(DeviceIntPtr);
|
||||
#endif
|
||||
void EvdevAppleInitProperty(DeviceIntPtr);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user