mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-03-24 09:44:28 +00:00
Add property support for axis inversion.
This commit is contained in:
@@ -50,4 +50,8 @@
|
||||
/* CARD8, either 1 value or pairs, value range 0-32, 0 to disable a value*/
|
||||
#define EVDEV_PROP_DRAGLOCK "Evdev Drag Lock Buttons"
|
||||
|
||||
/* Axis inversion */
|
||||
/* BOOL, 2 values [x, y], 1 inverts axis */
|
||||
#define EVDEV_PROP_INVERT_AXES "Evdev Axis Inversion"
|
||||
|
||||
#endif
|
||||
|
||||
59
src/evdev.c
59
src/evdev.c
@@ -52,6 +52,11 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
#include <X11/Xatom.h>
|
||||
#include <evdev-properties.h>
|
||||
#endif
|
||||
|
||||
/* 2.4 compatibility */
|
||||
#ifndef EVIOCGRAB
|
||||
#define EVIOCGRAB _IOW('E', 0x90, int)
|
||||
@@ -100,6 +105,15 @@ static const char *evdevDefaults[] = {
|
||||
static int EvdevOn(DeviceIntPtr);
|
||||
static int EvdevCacheCompare(InputInfoPtr pInfo, Bool compare);
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static void EvdevInitProperty(DeviceIntPtr dev);
|
||||
static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
|
||||
XIPropertyValuePtr val);
|
||||
static Atom prop_invert = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
|
||||
{
|
||||
@@ -944,6 +958,8 @@ EvdevInit(DeviceIntPtr device)
|
||||
XIRegisterPropertyHandler(device, EvdevMBEmuSetProperty, NULL, NULL);
|
||||
XIRegisterPropertyHandler(device, EvdevWheelEmuSetProperty, NULL, NULL);
|
||||
XIRegisterPropertyHandler(device, EvdevDragLockSetProperty, NULL, NULL);
|
||||
XIRegisterPropertyHandler(device, EvdevSetProperty, NULL, NULL);
|
||||
EvdevInitProperty(device);
|
||||
EvdevMBEmuInitProperty(device);
|
||||
EvdevWheelEmuInitProperty(device);
|
||||
EvdevDragLockInitProperty(device);
|
||||
@@ -1451,3 +1467,46 @@ EvdevUtilButtonEventToButtonNumber(int code)
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROPERTIES
|
||||
static void
|
||||
EvdevInitProperty(DeviceIntPtr dev)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int rc;
|
||||
BOOL invert[2];
|
||||
|
||||
invert[0] = pEvdev->invert_x;
|
||||
invert[1] = pEvdev->invert_y;
|
||||
|
||||
prop_invert = MakeAtom(EVDEV_PROP_INVERT_AXES, strlen(EVDEV_PROP_INVERT_AXES), TRUE);
|
||||
|
||||
rc = XIChangeDeviceProperty(dev, prop_invert, XA_INTEGER, 8,
|
||||
PropModeReplace, 2,
|
||||
invert, FALSE);
|
||||
if (rc != Success)
|
||||
return;
|
||||
|
||||
XISetDevicePropertyDeletable(dev, prop_invert, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (atom == prop_invert)
|
||||
{
|
||||
BOOL* data;
|
||||
if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
data = (BOOL*)val->data;
|
||||
pEvdev->invert_x = data[0];
|
||||
pEvdev->invert_y = data[1];
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user