mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
13 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1ee12b9a3 | ||
|
|
74690817fc | ||
|
|
b2cbbb178e | ||
|
|
7d91fc7bfc | ||
|
|
09987eab9a | ||
|
|
8af0e6f1eb | ||
|
|
56e9a7a248 | ||
|
|
7df6523774 | ||
|
|
f4e76a4c53 | ||
|
|
ac772cde94 | ||
|
|
7749159241 | ||
|
|
833fc517d7 | ||
|
|
4d698d8ece |
@@ -23,7 +23,7 @@
|
|||||||
# Initialize Autoconf
|
# Initialize Autoconf
|
||||||
AC_PREREQ([2.60])
|
AC_PREREQ([2.60])
|
||||||
AC_INIT([xf86-input-evdev],
|
AC_INIT([xf86-input-evdev],
|
||||||
[2.7.0],
|
[2.7.2],
|
||||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||||
[xf86-input-evdev])
|
[xf86-input-evdev])
|
||||||
AC_CONFIG_SRCDIR([Makefile.am])
|
AC_CONFIG_SRCDIR([Makefile.am])
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ static Atom prop_wheel_timeout = 0;
|
|||||||
static Atom prop_wheel_button = 0;
|
static Atom prop_wheel_button = 0;
|
||||||
|
|
||||||
/* Local Funciton Prototypes */
|
/* Local Funciton Prototypes */
|
||||||
static BOOL EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char *axis_name);
|
|
||||||
static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
|
static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
|
||||||
|
|
||||||
/* Filter mouse button events */
|
/* Filter mouse button events */
|
||||||
@@ -197,7 +196,8 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
|
|||||||
/* Handle button mapping here to avoid code duplication,
|
/* Handle button mapping here to avoid code duplication,
|
||||||
returns true if a button mapping was found. */
|
returns true if a button mapping was found. */
|
||||||
static BOOL
|
static BOOL
|
||||||
EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_name)
|
EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis,
|
||||||
|
const char *axis_name)
|
||||||
{
|
{
|
||||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||||
char *option_string;
|
char *option_string;
|
||||||
|
|||||||
89
src/evdev.c
89
src/evdev.c
@@ -93,7 +93,7 @@
|
|||||||
#define ABS_MT_TRACKING_ID 0x39
|
#define ABS_MT_TRACKING_ID 0x39
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *evdevDefaults[] = {
|
static const char *evdevDefaults[] = {
|
||||||
"XkbRules", "evdev",
|
"XkbRules", "evdev",
|
||||||
"XkbModel", "evdev",
|
"XkbModel", "evdev",
|
||||||
"XkbLayout", "us",
|
"XkbLayout", "us",
|
||||||
@@ -119,6 +119,7 @@ static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode);
|
|||||||
static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab);
|
static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab);
|
||||||
static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
|
static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
|
||||||
static int EvdevOpenDevice(InputInfoPtr pInfo);
|
static int EvdevOpenDevice(InputInfoPtr pInfo);
|
||||||
|
static void EvdevCloseDevice(InputInfoPtr pInfo);
|
||||||
|
|
||||||
static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
|
static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
|
||||||
static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
|
static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
|
||||||
@@ -277,7 +278,7 @@ EvdevRemoveDevice(InputInfoPtr pInfo)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
|
SetXkbOption(InputInfoPtr pInfo, const char *name, char **option)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
@@ -1061,7 +1062,9 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
|
|||||||
static void
|
static void
|
||||||
EvdevFreeMasks(EvdevPtr pEvdev)
|
EvdevFreeMasks(EvdevPtr pEvdev)
|
||||||
{
|
{
|
||||||
|
#ifdef MULTITOUCH
|
||||||
int i;
|
int i;
|
||||||
|
#endif
|
||||||
|
|
||||||
valuator_mask_free(&pEvdev->vals);
|
valuator_mask_free(&pEvdev->vals);
|
||||||
valuator_mask_free(&pEvdev->old_vals);
|
valuator_mask_free(&pEvdev->old_vals);
|
||||||
@@ -1108,8 +1111,7 @@ EvdevReadInput(InputInfoPtr pInfo)
|
|||||||
EvdevMBEmuFinalize(pInfo);
|
EvdevMBEmuFinalize(pInfo);
|
||||||
Evdev3BEmuFinalize(pInfo);
|
Evdev3BEmuFinalize(pInfo);
|
||||||
xf86RemoveEnabledDevice(pInfo);
|
xf86RemoveEnabledDevice(pInfo);
|
||||||
close(pInfo->fd);
|
EvdevCloseDevice(pInfo);
|
||||||
pInfo->fd = -1;
|
|
||||||
} else if (errno != EAGAIN)
|
} else if (errno != EAGAIN)
|
||||||
{
|
{
|
||||||
/* We use X_NONE here because it doesn't alloc */
|
/* We use X_NONE here because it doesn't alloc */
|
||||||
@@ -1304,6 +1306,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
|
|||||||
}
|
}
|
||||||
#ifdef MULTITOUCH
|
#ifdef MULTITOUCH
|
||||||
if (num_mt_axes_total > 0) {
|
if (num_mt_axes_total > 0) {
|
||||||
|
pEvdev->num_mt_vals = num_mt_axes_total;
|
||||||
pEvdev->mt_mask = valuator_mask_new(num_mt_axes_total);
|
pEvdev->mt_mask = valuator_mask_new(num_mt_axes_total);
|
||||||
if (!pEvdev->mt_mask) {
|
if (!pEvdev->mt_mask) {
|
||||||
xf86Msg(X_ERROR, "%s: failed to allocate MT valuator mask.\n",
|
xf86Msg(X_ERROR, "%s: failed to allocate MT valuator mask.\n",
|
||||||
@@ -1344,7 +1347,9 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MAX; axis++) {
|
for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MAX; axis++) {
|
||||||
|
#ifdef MULTITOUCH
|
||||||
int j;
|
int j;
|
||||||
|
#endif
|
||||||
int mapping;
|
int mapping;
|
||||||
pEvdev->axis_map[axis] = -1;
|
pEvdev->axis_map[axis] = -1;
|
||||||
if (!EvdevBitIsSet(pEvdev->abs_bitmask, axis) ||
|
if (!EvdevBitIsSet(pEvdev->abs_bitmask, axis) ||
|
||||||
@@ -1384,7 +1389,8 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
|
|||||||
XIDependentTouch : XIDirectTouch;
|
XIDependentTouch : XIDirectTouch;
|
||||||
|
|
||||||
if (pEvdev->mtdev->caps.slot.maximum > 0)
|
if (pEvdev->mtdev->caps.slot.maximum > 0)
|
||||||
num_touches = pEvdev->mtdev->caps.slot.maximum;
|
num_touches = pEvdev->mtdev->caps.slot.maximum -
|
||||||
|
pEvdev->mtdev->caps.slot.minimum + 1;
|
||||||
|
|
||||||
if (!InitTouchClassDeviceStruct(device, num_touches, mode,
|
if (!InitTouchClassDeviceStruct(device, num_touches, mode,
|
||||||
num_mt_axes_total)) {
|
num_mt_axes_total)) {
|
||||||
@@ -1600,7 +1606,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
|
|||||||
else if (axis == REL_DIAL)
|
else if (axis == REL_DIAL)
|
||||||
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_NONE);
|
SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_NONE);
|
||||||
else if (axis == REL_HWHEEL)
|
else if (axis == REL_HWHEEL)
|
||||||
SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, -1.0, SCROLL_FLAG_NONE);
|
SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1658,7 +1664,7 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
|
|||||||
/* Check for user-defined button mapping */
|
/* Check for user-defined button mapping */
|
||||||
if ((mapping = xf86CheckStrOption(pInfo->options, "ButtonMapping", NULL)))
|
if ((mapping = xf86CheckStrOption(pInfo->options, "ButtonMapping", NULL)))
|
||||||
{
|
{
|
||||||
char *map, *s = " ";
|
char *map, *s = NULL;
|
||||||
int btn = 0;
|
int btn = 0;
|
||||||
|
|
||||||
xf86IDrvMsg(pInfo, X_CONFIG, "ButtonMapping '%s'\n", mapping);
|
xf86IDrvMsg(pInfo, X_CONFIG, "ButtonMapping '%s'\n", mapping);
|
||||||
@@ -1864,8 +1870,7 @@ EvdevProc(DeviceIntPtr device, int what)
|
|||||||
{
|
{
|
||||||
EvdevGrabDevice(pInfo, 0, 1);
|
EvdevGrabDevice(pInfo, 0, 1);
|
||||||
xf86RemoveEnabledDevice(pInfo);
|
xf86RemoveEnabledDevice(pInfo);
|
||||||
close(pInfo->fd);
|
EvdevCloseDevice(pInfo);
|
||||||
pInfo->fd = -1;
|
|
||||||
}
|
}
|
||||||
pEvdev->min_maj = 0;
|
pEvdev->min_maj = 0;
|
||||||
pEvdev->flags &= ~EVDEV_INITIALIZED;
|
pEvdev->flags &= ~EVDEV_INITIALIZED;
|
||||||
@@ -1874,10 +1879,7 @@ EvdevProc(DeviceIntPtr device, int what)
|
|||||||
|
|
||||||
case DEVICE_CLOSE:
|
case DEVICE_CLOSE:
|
||||||
xf86IDrvMsg(pInfo, X_INFO, "Close\n");
|
xf86IDrvMsg(pInfo, X_INFO, "Close\n");
|
||||||
if (pInfo->fd != -1) {
|
EvdevCloseDevice(pInfo);
|
||||||
close(pInfo->fd);
|
|
||||||
pInfo->fd = -1;
|
|
||||||
}
|
|
||||||
EvdevFreeMasks(pEvdev);
|
EvdevFreeMasks(pEvdev);
|
||||||
EvdevRemoveDevice(pInfo);
|
EvdevRemoveDevice(pInfo);
|
||||||
pEvdev->min_maj = 0;
|
pEvdev->min_maj = 0;
|
||||||
@@ -2271,6 +2273,9 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
xf86IDrvMsg(pInfo, X_INFO, "Configuring as touchscreen\n");
|
xf86IDrvMsg(pInfo, X_INFO, "Configuring as touchscreen\n");
|
||||||
pInfo->type_name = XI_TOUCHSCREEN;
|
pInfo->type_name = XI_TOUCHSCREEN;
|
||||||
} else {
|
} else {
|
||||||
|
if (!EvdevBitIsSet(pEvdev->rel_bitmask, REL_X) ||
|
||||||
|
!EvdevBitIsSet(pEvdev->rel_bitmask, REL_Y))
|
||||||
|
EvdevForceXY(pInfo, Relative);
|
||||||
xf86IDrvMsg(pInfo, X_INFO, "Configuring as mouse\n");
|
xf86IDrvMsg(pInfo, X_INFO, "Configuring as mouse\n");
|
||||||
pInfo->type_name = XI_MOUSE;
|
pInfo->type_name = XI_MOUSE;
|
||||||
}
|
}
|
||||||
@@ -2349,13 +2354,16 @@ EvdevOpenDevice(InputInfoPtr pInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MULTITOUCH
|
#ifdef MULTITOUCH
|
||||||
pEvdev->mtdev = mtdev_new_open(pInfo->fd);
|
if (!pEvdev->mtdev) { /* after PreInit mtdev is still valid */
|
||||||
|
pEvdev->mtdev = mtdev_new_open(pInfo->fd);
|
||||||
|
if (!pEvdev->mtdev) {
|
||||||
|
xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
|
||||||
|
EvdevCloseDevice(pInfo);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (pEvdev->mtdev)
|
if (pEvdev->mtdev)
|
||||||
pEvdev->cur_slot = pEvdev->mtdev->caps.slot.value;
|
pEvdev->cur_slot = pEvdev->mtdev->caps.slot.value;
|
||||||
else {
|
|
||||||
xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check major/minor of device node to avoid adding duplicate devices. */
|
/* Check major/minor of device node to avoid adding duplicate devices. */
|
||||||
@@ -2363,17 +2371,34 @@ EvdevOpenDevice(InputInfoPtr pInfo)
|
|||||||
if (EvdevIsDuplicate(pInfo))
|
if (EvdevIsDuplicate(pInfo))
|
||||||
{
|
{
|
||||||
xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
|
xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
|
||||||
close(pInfo->fd);
|
EvdevCloseDevice(pInfo);
|
||||||
#ifdef MULTITOUCH
|
|
||||||
mtdev_close_delete(pEvdev->mtdev);
|
|
||||||
pEvdev->mtdev = NULL;
|
|
||||||
#endif
|
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
EvdevCloseDevice(InputInfoPtr pInfo)
|
||||||
|
{
|
||||||
|
EvdevPtr pEvdev = pInfo->private;
|
||||||
|
if (pInfo->fd >= 0)
|
||||||
|
{
|
||||||
|
close(pInfo->fd);
|
||||||
|
pInfo->fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MULTITOUCH
|
||||||
|
if (pEvdev->mtdev)
|
||||||
|
{
|
||||||
|
mtdev_close_delete(pEvdev->mtdev);
|
||||||
|
pEvdev->mtdev = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
|
EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
|
||||||
{
|
{
|
||||||
@@ -2454,8 +2479,7 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
|
|||||||
return Success;
|
return Success;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (pInfo->fd >= 0)
|
EvdevCloseDevice(pInfo);
|
||||||
close(pInfo->fd);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2544,7 +2568,7 @@ EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code)
|
|||||||
/* Aligned with linux/input.h.
|
/* Aligned with linux/input.h.
|
||||||
Note that there are holes in the ABS_ range, these are simply replaced with
|
Note that there are holes in the ABS_ range, these are simply replaced with
|
||||||
MISC here */
|
MISC here */
|
||||||
static char* abs_labels[] = {
|
static const char *abs_labels[] = {
|
||||||
AXIS_LABEL_PROP_ABS_X, /* 0x00 */
|
AXIS_LABEL_PROP_ABS_X, /* 0x00 */
|
||||||
AXIS_LABEL_PROP_ABS_Y, /* 0x01 */
|
AXIS_LABEL_PROP_ABS_Y, /* 0x01 */
|
||||||
AXIS_LABEL_PROP_ABS_Z, /* 0x02 */
|
AXIS_LABEL_PROP_ABS_Z, /* 0x02 */
|
||||||
@@ -2607,7 +2631,7 @@ static char* abs_labels[] = {
|
|||||||
AXIS_LABEL_PROP_ABS_MT_PRESSURE, /* 0x3a */
|
AXIS_LABEL_PROP_ABS_MT_PRESSURE, /* 0x3a */
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* rel_labels[] = {
|
static const char *rel_labels[] = {
|
||||||
AXIS_LABEL_PROP_REL_X,
|
AXIS_LABEL_PROP_REL_X,
|
||||||
AXIS_LABEL_PROP_REL_Y,
|
AXIS_LABEL_PROP_REL_Y,
|
||||||
AXIS_LABEL_PROP_REL_Z,
|
AXIS_LABEL_PROP_REL_Z,
|
||||||
@@ -2620,7 +2644,7 @@ static char* rel_labels[] = {
|
|||||||
AXIS_LABEL_PROP_REL_MISC
|
AXIS_LABEL_PROP_REL_MISC
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* btn_labels[][16] = {
|
static const char *btn_labels[][16] = {
|
||||||
{ /* BTN_MISC group offset 0x100*/
|
{ /* BTN_MISC group offset 0x100*/
|
||||||
BTN_LABEL_PROP_BTN_0, /* 0x00 */
|
BTN_LABEL_PROP_BTN_0, /* 0x00 */
|
||||||
BTN_LABEL_PROP_BTN_1, /* 0x01 */
|
BTN_LABEL_PROP_BTN_1, /* 0x01 */
|
||||||
@@ -2705,7 +2729,7 @@ static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *ato
|
|||||||
{
|
{
|
||||||
Atom atom;
|
Atom atom;
|
||||||
int axis;
|
int axis;
|
||||||
char **labels;
|
const char **labels;
|
||||||
int labels_len = 0;
|
int labels_len = 0;
|
||||||
|
|
||||||
if (mode == Absolute)
|
if (mode == Absolute)
|
||||||
@@ -2875,7 +2899,8 @@ EvdevInitProperty(DeviceIntPtr dev)
|
|||||||
if ((pEvdev->num_vals > 0) && (prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP)))
|
if ((pEvdev->num_vals > 0) && (prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP)))
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
Atom atoms[pEvdev->num_vals];
|
int num_axes = pEvdev->num_vals + pEvdev->num_mt_vals;
|
||||||
|
Atom atoms[num_axes];
|
||||||
|
|
||||||
if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
|
if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
|
||||||
mode = Absolute;
|
mode = Absolute;
|
||||||
@@ -2886,9 +2911,9 @@ EvdevInitProperty(DeviceIntPtr dev)
|
|||||||
mode = Absolute;
|
mode = Absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
EvdevInitAxesLabels(pEvdev, mode, pEvdev->num_vals, atoms);
|
EvdevInitAxesLabels(pEvdev, mode, num_axes, atoms);
|
||||||
XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
|
XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
|
||||||
PropModeReplace, pEvdev->num_vals, atoms, FALSE);
|
PropModeReplace, num_axes, atoms, FALSE);
|
||||||
XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
|
XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
|
||||||
}
|
}
|
||||||
/* Button labelling */
|
/* Button labelling */
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ typedef struct {
|
|||||||
int grabDevice; /* grab the event device? */
|
int grabDevice; /* grab the event device? */
|
||||||
|
|
||||||
int num_vals; /* number of valuators */
|
int num_vals; /* number of valuators */
|
||||||
|
int num_mt_vals; /* number of multitouch valuators */
|
||||||
int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
|
int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
|
||||||
ValuatorMask *vals; /* new values coming in */
|
ValuatorMask *vals; /* new values coming in */
|
||||||
ValuatorMask *old_vals; /* old values for calculating relative motion */
|
ValuatorMask *old_vals; /* old values for calculating relative motion */
|
||||||
|
|||||||
Reference in New Issue
Block a user