diff options
-rw-r--r-- | include/evdev-properties.h | 53 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/draglock.c | 5 | ||||
-rw-r--r-- | src/emuMB.c | 11 | ||||
-rw-r--r-- | src/emuWheel.c | 67 |
5 files changed, 83 insertions, 55 deletions
diff --git a/include/evdev-properties.h b/include/evdev-properties.h new file mode 100644 index 0000000..27e2bda --- /dev/null +++ b/include/evdev-properties.h @@ -0,0 +1,53 @@ +/* + * Copyright © 2008 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Red Hat + * not be used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. Red + * Hat makes no representations about the suitability of this software + * for any purpose. It is provided "as is" without express or implied + * 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) + */ + + +#ifndef _EVDEV_PROPERTIES_H_ +#define _EVDEV_PROPERTIES_H_ + +/* Middle mouse button emulation */ +/* BOOL */ +#define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation" +/* CARD16 */ +#define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout" + +/* Wheel emulation */ +/* BOOL */ +#define EVDEV_PROP_WHEEL "Evdev Wheel Emulation" +/* CARD8, 4 values [x up, x down, y up, y down], 0 to disable a value*/ +#define EVDEV_PROP_WHEEL_AXES "Evdev Wheel Emulation Axes" +/* CARD16 */ +#define EVDEV_PROP_WHEEL_INERTIA "Evdev Wheel Emulation Inertia" +/* CARD16 */ +#define EVDEV_PROP_WHEEL_TIMEOUT "Evdev Wheel Emulation Timeout" +/* CARD8, value range 0-32, 0 to disable a value */ +#define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button" + +/* Drag lock */ +/* CARD8, either 1 value or pairs, value range 0-32, 0 to disable a value*/ +#define EVDEV_PROP_DRAGLOCK "Drag Lock Buttons" + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index a3b256f..16cec14 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,6 +28,8 @@ @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version @DRIVER_NAME@_drv_ladir = @inputdir@ +INCLUDES=-I$(top_srcdir)/include/ + @DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c \ @DRIVER_NAME@.h \ emuMB.c \ diff --git a/src/draglock.c b/src/draglock.c index 03b4345..68fe5c0 100644 --- a/src/draglock.c +++ b/src/draglock.c @@ -41,11 +41,10 @@ #include <X11/Xatom.h> #include <exevents.h> +#include <evdev-properties.h> #include "evdev.h" #ifdef HAVE_PROPERTIES -static const char *propname_dlock = "Drag Lock Buttons"; - static Atom prop_dlock = 0; /* Drag lock buttons. */ void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button); @@ -223,7 +222,7 @@ EvdevDragLockInitProperty(DeviceIntPtr dev) if (!dev->button) /* don't init prop for keyboards */ return; - prop_dlock = MakeAtom((char*)propname_dlock, strlen(propname_dlock), TRUE); + prop_dlock = MakeAtom(EVDEV_PROP_DRAGLOCK, strlen(EVDEV_PROP_DRAGLOCK), TRUE); if (pEvdev->dragLock.meta) { XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, diff --git a/src/emuMB.c b/src/emuMB.c index 7456117..3235be4 100644 --- a/src/emuMB.c +++ b/src/emuMB.c @@ -39,6 +39,7 @@ #include <xf86Xinput.h> #include <exevents.h> +#include <evdev-properties.h> #include "evdev.h" enum { @@ -48,12 +49,8 @@ enum { }; #ifdef HAVE_PROPERTIES -static const char *propname_mbemu = "Middle Button Emulation"; -static const char *propname_mbtimeout = "Middle Button Timeout"; - 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: @@ -367,7 +364,7 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev) if (!dev->button) /* don't init prop for keyboards */ return; - prop_mbemu = MakeAtom((char*)propname_mbemu, strlen(propname_mbemu), TRUE); + prop_mbemu = MakeAtom(EVDEV_PROP_MIDBUTTON, strlen(EVDEV_PROP_MIDBUTTON), TRUE); rc = XIChangeDeviceProperty(dev, prop_mbemu, XA_INTEGER, 8, PropModeReplace, 1, &pEvdev->emulateMB.enabled, @@ -376,8 +373,8 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev) return; XISetDevicePropertyDeletable(dev, prop_mbemu, FALSE); - prop_mbtimeout = MakeAtom((char*)propname_mbtimeout, - strlen(propname_mbtimeout), + prop_mbtimeout = MakeAtom(EVDEV_PROP_MIDBUTTON_TIMEOUT, + strlen(EVDEV_PROP_MIDBUTTON_TIMEOUT), TRUE); rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 16, PropModeReplace, 1, &pEvdev->emulateMB.timeout, FALSE); diff --git a/src/emuWheel.c b/src/emuWheel.c index 568913f..a053720 100644 --- a/src/emuWheel.c +++ b/src/emuWheel.c @@ -39,21 +39,14 @@ #include <xf86Xinput.h> #include <exevents.h> +#include <evdev-properties.h> #include "evdev.h" #define WHEEL_NOT_CONFIGURED 0 #ifdef HAVE_PROPERTIES -static const char *propname_wheel_emu = "Wheel Emulation"; -static const char *propname_wheel_xmap = "Wheel Emulation X Axis"; -static const char *propname_wheel_ymap = "Wheel Emulation Y Axis"; -static const char *propname_wheel_inertia = "Wheel Emulation Inertia"; -static const char *propname_wheel_timeout = "Wheel Emulation Timeout"; -static const char *propname_wheel_button = "Wheel Emulation Button"; - static Atom prop_wheel_emu = 0; -static Atom prop_wheel_xmap = 0; -static Atom prop_wheel_ymap = 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; @@ -232,7 +225,7 @@ void EvdevWheelEmuPreInit(InputInfoPtr pInfo) { EvdevPtr pEvdev = (EvdevPtr)pInfo->private; - char val[2]; + char val[4]; int wheelButton; int inertia; int timeout; @@ -328,13 +321,10 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo) val[0] = pEvdev->emulateWheel.X.up_button; val[1] = pEvdev->emulateWheel.X.down_button; - XIChangeDeviceProperty(pInfo->dev, prop_wheel_xmap, XA_INTEGER, 8, - PropModeReplace, 2, val, TRUE); - - val[0] = pEvdev->emulateWheel.Y.up_button; - val[1] = pEvdev->emulateWheel.Y.down_button; - XIChangeDeviceProperty(pInfo->dev, prop_wheel_ymap, XA_INTEGER, 8, - PropModeReplace, 2, val, TRUE); + val[2] = pEvdev->emulateWheel.Y.up_button; + val[3] = pEvdev->emulateWheel.Y.down_button; + XIChangeDeviceProperty(pInfo->dev, prop_wheel_axismap, XA_INTEGER, 8, + PropModeReplace, 4, val, TRUE); #endif } @@ -346,12 +336,12 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev) InputInfoPtr pInfo = dev->public.devicePrivate; EvdevPtr pEvdev = pInfo->private; int rc = TRUE; - INT32 valid_vals[] = { TRUE, FALSE}; + INT32 valid_vals[4] = { TRUE, FALSE}; if (!dev->button) /* don't init prop for keyboards */ return; - prop_wheel_emu = MakeAtom((char*)propname_wheel_emu, strlen(propname_wheel_emu), TRUE); + prop_wheel_emu = MakeAtom(EVDEV_PROP_WHEEL, strlen(EVDEV_PROP_WHEEL), TRUE); rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8, PropModeReplace, 1, &pEvdev->emulateWheel.enabled, FALSE); @@ -362,27 +352,19 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev) valid_vals[0] = pEvdev->emulateWheel.X.up_button; valid_vals[1] = pEvdev->emulateWheel.X.down_button; + valid_vals[2] = pEvdev->emulateWheel.Y.up_button; + valid_vals[3] = pEvdev->emulateWheel.Y.down_button; - prop_wheel_xmap = MakeAtom((char*)propname_wheel_xmap, strlen(propname_wheel_xmap), TRUE); - rc = XIChangeDeviceProperty(dev, prop_wheel_xmap, XA_INTEGER, 8, - PropModeReplace, 2, valid_vals, FALSE); - if (rc != Success) - return; - - XISetDevicePropertyDeletable(dev, prop_wheel_xmap, FALSE); + prop_wheel_axismap = MakeAtom(EVDEV_PROP_WHEEL_AXES, strlen(EVDEV_PROP_WHEEL_AXES), TRUE); + rc = XIChangeDeviceProperty(dev, prop_wheel_axismap, XA_INTEGER, 8, + PropModeReplace, 4, valid_vals, FALSE); - valid_vals[0] = pEvdev->emulateWheel.Y.up_button; - valid_vals[1] = pEvdev->emulateWheel.Y.down_button; - - prop_wheel_ymap = MakeAtom((char*)propname_wheel_ymap, strlen(propname_wheel_ymap), TRUE); - rc = XIChangeDeviceProperty(dev, prop_wheel_ymap, XA_INTEGER, 8, - PropModeReplace, 2, valid_vals, FALSE); if (rc != Success) return; - XISetDevicePropertyDeletable(dev, prop_wheel_ymap, FALSE); + XISetDevicePropertyDeletable(dev, prop_wheel_axismap, FALSE); - prop_wheel_inertia = MakeAtom((char*)propname_wheel_inertia, strlen(propname_wheel_inertia), TRUE); + prop_wheel_inertia = MakeAtom(EVDEV_PROP_WHEEL_INERTIA, strlen(EVDEV_PROP_WHEEL_INERTIA), TRUE); rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16, PropModeReplace, 1, &pEvdev->emulateWheel.inertia, FALSE); @@ -391,7 +373,7 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE); - prop_wheel_timeout = MakeAtom((char*)propname_wheel_timeout, strlen(propname_wheel_timeout), TRUE); + prop_wheel_timeout = MakeAtom(EVDEV_PROP_WHEEL_TIMEOUT, strlen(EVDEV_PROP_WHEEL_TIMEOUT), TRUE); rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16, PropModeReplace, 1, &pEvdev->emulateWheel.timeout, FALSE); @@ -400,7 +382,7 @@ EvdevWheelEmuInitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE); - prop_wheel_button = MakeAtom((char*)propname_wheel_button, strlen(propname_wheel_button), TRUE); + prop_wheel_button = MakeAtom(EVDEV_PROP_WHEEL_BUTTON, strlen(EVDEV_PROP_WHEEL_BUTTON), TRUE); rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8, PropModeReplace, 1, &pEvdev->emulateWheel.button, FALSE); @@ -448,20 +430,15 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (bt < 0 || bt >= EVDEV_MAXBUTTONS) return BadValue; pEvdev->emulateWheel.button = bt; - } else if (atom == prop_wheel_xmap) + } else if (atom == prop_wheel_axismap) { - if (val->size != 2) + if (val->size != 4) return BadValue; pEvdev->emulateWheel.X.up_button = *((CARD8*)val->data); pEvdev->emulateWheel.X.down_button = *(((CARD8*)val->data) + 1); - } else if (atom == prop_wheel_ymap) - { - if (val->size != 2) - return BadValue; - - pEvdev->emulateWheel.Y.up_button = *((CARD8*)val->data); - pEvdev->emulateWheel.Y.down_button = *(((CARD8*)val->data) + 1); + pEvdev->emulateWheel.Y.up_button = *(((CARD8*)val->data) + 2); + pEvdev->emulateWheel.Y.down_button = *(((CARD8*)val->data) + 3); } else if (atom == prop_wheel_inertia) { int inertia = *((CARD16*)val->data); |