2003-11-14 16:54:54 +01:00
|
|
|
/*
|
2003-11-14 17:49:22 +01:00
|
|
|
* Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org>
|
2003-11-14 16:54:54 +01:00
|
|
|
*
|
|
|
|
* 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 Frederic Lepied not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
* specific, written prior permission. Frederic Lepied makes no
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL FREDERIC LEPIED 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.
|
|
|
|
*
|
|
|
|
*/
|
2003-11-25 20:29:01 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000-2002 by The XFree86 Project, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of the copyright holder(s)
|
|
|
|
* and author(s) shall not be used in advertising or otherwise to promote
|
|
|
|
* the sale, use or other dealings in this Software without prior written
|
|
|
|
* authorization from the copyright holder(s) and author(s).
|
|
|
|
*/
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#include <X11/Xmd.h>
|
|
|
|
#include <X11/extensions/XI.h>
|
|
|
|
#include <X11/extensions/XIproto.h>
|
2008-11-25 05:12:02 +01:00
|
|
|
#include <X11/Xatom.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86Priv.h"
|
2009-10-02 15:29:28 +02:00
|
|
|
#include "xf86Config.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "xf86Xinput.h"
|
2006-07-21 21:23:37 +02:00
|
|
|
#include "xf86Optrec.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "mipointer.h"
|
2008-10-26 11:16:05 +01:00
|
|
|
#include "extinit.h"
|
2010-07-23 06:48:32 +02:00
|
|
|
#include "loaderProcs.h"
|
2014-01-14 15:37:33 +01:00
|
|
|
#include "systemd-logind.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#include "exevents.h" /* AddInputDevice */
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "exglobals.h"
|
2009-07-27 08:54:33 +02:00
|
|
|
#include "eventstr.h"
|
2010-10-19 05:37:46 +02:00
|
|
|
#include "inpututils.h"
|
2011-08-10 06:38:58 +02:00
|
|
|
#include "optionstr.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <string.h> /* InputClassMatches */
|
2009-10-02 15:29:28 +02:00
|
|
|
#ifdef HAVE_FNMATCH_H
|
|
|
|
#include <fnmatch.h>
|
|
|
|
#endif
|
2010-06-08 05:39:53 +02:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#endif
|
2009-10-02 15:29:28 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <stdarg.h>
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <stdint.h> /* for int64_t */
|
2014-03-22 22:30:04 +01:00
|
|
|
#include <sys/types.h>
|
2014-03-11 05:21:27 +01:00
|
|
|
#include <sys/stat.h>
|
2014-01-14 15:37:33 +01:00
|
|
|
#include <unistd.h>
|
2014-03-22 22:30:04 +01:00
|
|
|
#ifdef HAVE_SYS_MKDEV_H
|
|
|
|
#include <sys/mkdev.h> /* for major() & minor() on Solaris */
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-10-08 19:34:32 +02:00
|
|
|
#include "mi.h"
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <ptrveloc.h> /* dix pointer acceleration */
|
2008-11-25 05:12:02 +01:00
|
|
|
#include <xserver-properties.h>
|
2008-07-10 15:03:39 +02:00
|
|
|
|
2007-03-20 23:12:02 +01:00
|
|
|
#ifdef XFreeXDGA
|
|
|
|
#include "dgaproc.h"
|
|
|
|
#endif
|
|
|
|
|
2008-10-26 11:16:05 +01:00
|
|
|
#include "xkbsrv.h"
|
|
|
|
|
2010-09-02 07:08:01 +02:00
|
|
|
/* Valuator verification macro */
|
|
|
|
#define XI_VERIFY_VALUATORS(num_valuators) \
|
|
|
|
if (num_valuators > MAX_VALUATORS) { \
|
|
|
|
xf86Msg(X_ERROR, "%s: num_valuator %d is greater than" \
|
|
|
|
" MAX_VALUATORS\n", __FUNCTION__, num_valuators); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
2010-07-18 12:31:26 +02:00
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86InputDevicePostInit(DeviceIntPtr dev);
|
2010-07-18 12:31:26 +02:00
|
|
|
|
2014-01-31 15:21:38 +01:00
|
|
|
static InputInfoPtr *new_input_devices;
|
|
|
|
static int new_input_devices_count;
|
|
|
|
|
2008-07-10 15:03:39 +02:00
|
|
|
/**
|
|
|
|
* Eval config and modify DeviceVelocityRec accordingly
|
|
|
|
*/
|
|
|
|
static void
|
2013-12-15 10:05:51 +01:00
|
|
|
ProcessVelocityConfiguration(DeviceIntPtr pDev, const char *devname, void *list,
|
2008-11-25 05:12:02 +01:00
|
|
|
DeviceVelocityPtr s)
|
|
|
|
{
|
2009-02-28 22:17:47 +01:00
|
|
|
int tempi;
|
|
|
|
float tempf;
|
2008-11-25 05:12:02 +01:00
|
|
|
Atom float_prop = XIGetKnownProperty(XATOM_FLOAT);
|
|
|
|
Atom prop;
|
2008-07-10 15:03:39 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!s)
|
2008-07-10 15:03:39 +02:00
|
|
|
return;
|
|
|
|
|
2008-11-25 05:12:02 +01:00
|
|
|
/* common settings (available via device properties) */
|
2009-10-28 06:59:40 +01:00
|
|
|
tempf = xf86SetRealOption(list, "ConstantDeceleration", 1.0);
|
2010-01-06 19:13:36 +01:00
|
|
|
if (tempf > 1.0) {
|
2008-11-25 05:12:02 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
|
|
|
|
devname, tempf);
|
|
|
|
prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
|
|
|
|
XIChangeDeviceProperty(pDev, prop, float_prop, 32,
|
|
|
|
PropModeReplace, 1, &tempf, FALSE);
|
|
|
|
}
|
|
|
|
|
2009-10-28 06:59:40 +01:00
|
|
|
tempf = xf86SetRealOption(list, "AdaptiveDeceleration", 1.0);
|
2010-01-06 19:13:36 +01:00
|
|
|
if (tempf > 1.0) {
|
2008-11-25 05:12:02 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
|
|
|
|
devname, tempf);
|
|
|
|
prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
|
|
|
|
XIChangeDeviceProperty(pDev, prop, float_prop, 32,
|
|
|
|
PropModeReplace, 1, &tempf, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select profile by number */
|
|
|
|
tempi = xf86SetIntOption(list, "AccelerationProfile",
|
2012-03-21 20:55:09 +01:00
|
|
|
s->statistics.profile_number);
|
2008-11-25 05:12:02 +01:00
|
|
|
|
|
|
|
prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
|
|
|
|
if (XIChangeDeviceProperty(pDev, prop, XA_INTEGER, 32,
|
2010-01-06 19:13:36 +01:00
|
|
|
PropModeReplace, 1, &tempi, FALSE) == Success) {
|
2008-11-25 05:12:02 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i\n", devname,
|
|
|
|
tempi);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-11-25 05:12:02 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
|
|
|
|
devname, tempi);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set scaling */
|
|
|
|
tempf = xf86SetRealOption(list, "ExpectedRate", 0);
|
|
|
|
prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
|
2010-01-06 19:13:36 +01:00
|
|
|
if (tempf > 0) {
|
2008-11-25 05:12:02 +01:00
|
|
|
tempf = 1000.0 / tempf;
|
|
|
|
XIChangeDeviceProperty(pDev, prop, float_prop, 32,
|
|
|
|
PropModeReplace, 1, &tempf, FALSE);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2008-11-25 05:12:02 +01:00
|
|
|
tempf = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
|
|
|
|
XIChangeDeviceProperty(pDev, prop, float_prop, 32,
|
|
|
|
PropModeReplace, 1, &tempf, FALSE);
|
|
|
|
}
|
|
|
|
|
2009-02-28 22:17:47 +01:00
|
|
|
tempi = xf86SetIntOption(list, "VelocityTrackerCount", -1);
|
2010-01-06 19:13:36 +01:00
|
|
|
if (tempi > 1)
|
2012-03-21 20:55:09 +01:00
|
|
|
InitTrackers(s, tempi);
|
2008-07-31 00:39:03 +02:00
|
|
|
|
2009-02-28 22:17:47 +01:00
|
|
|
s->initial_range = xf86SetIntOption(list, "VelocityInitialRange",
|
|
|
|
s->initial_range);
|
2008-11-25 05:28:26 +01:00
|
|
|
|
2009-02-28 22:17:47 +01:00
|
|
|
s->max_diff = xf86SetRealOption(list, "VelocityAbsDiff", s->max_diff);
|
2008-07-10 15:03:39 +02:00
|
|
|
|
2009-02-28 22:17:47 +01:00
|
|
|
tempf = xf86SetRealOption(list, "VelocityRelDiff", -1);
|
2010-01-06 19:13:36 +01:00
|
|
|
if (tempf >= 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) max rel. velocity difference: %.1f%%\n",
|
|
|
|
devname, tempf * 100.0);
|
|
|
|
s->max_rel_diff = tempf;
|
2008-07-31 00:39:03 +02:00
|
|
|
}
|
2008-07-10 15:03:39 +02:00
|
|
|
|
|
|
|
/* Configure softening. If const deceleration is used, this is expected
|
|
|
|
* to provide better subpixel information so we enable
|
|
|
|
* softening by default only if ConstantDeceleration is not used
|
|
|
|
*/
|
|
|
|
s->use_softening = xf86SetBoolOption(list, "Softening",
|
|
|
|
s->const_acceleration == 1.0);
|
|
|
|
|
2008-07-31 00:39:03 +02:00
|
|
|
s->average_accel = xf86SetBoolOption(list, "AccelerationProfileAveraging",
|
|
|
|
s->average_accel);
|
2008-07-29 10:07:43 +02:00
|
|
|
|
2008-07-31 00:39:03 +02:00
|
|
|
s->reset_time = xf86SetIntOption(list, "VelocityReset", s->reset_time);
|
2008-07-10 15:03:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
ApplyAccelerationSettings(DeviceIntPtr dev)
|
|
|
|
{
|
2010-01-06 17:32:24 +01:00
|
|
|
int scheme, i;
|
2008-07-10 15:03:39 +02:00
|
|
|
DeviceVelocityPtr pVel;
|
2012-03-21 20:55:09 +01:00
|
|
|
InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
|
|
|
|
char *schemeStr;
|
2008-07-10 15:03:39 +02:00
|
|
|
|
2010-01-06 17:32:24 +01:00
|
|
|
if (dev->valuator && dev->ptrfeed) {
|
2012-03-21 20:55:09 +01:00
|
|
|
schemeStr = xf86SetStrOption(pInfo->options, "AccelerationScheme", "");
|
2008-07-23 12:06:34 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
scheme = dev->valuator->accelScheme.number;
|
2008-07-23 12:06:34 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!xf86NameCmp(schemeStr, "predictable"))
|
|
|
|
scheme = PtrAccelPredictable;
|
2008-07-23 12:06:34 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!xf86NameCmp(schemeStr, "lightweight"))
|
|
|
|
scheme = PtrAccelLightweight;
|
2008-07-23 12:06:34 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!xf86NameCmp(schemeStr, "none"))
|
|
|
|
scheme = PtrAccelNoOp;
|
2008-07-10 15:03:39 +02:00
|
|
|
|
|
|
|
/* reinit scheme if needed */
|
2010-01-06 19:13:36 +01:00
|
|
|
if (dev->valuator->accelScheme.number != scheme) {
|
|
|
|
if (dev->valuator->accelScheme.AccelCleanupProc) {
|
2008-07-10 15:03:39 +02:00
|
|
|
dev->valuator->accelScheme.AccelCleanupProc(dev);
|
|
|
|
}
|
|
|
|
|
2010-01-06 19:13:36 +01:00
|
|
|
if (InitPointerAccelerationScheme(dev, scheme)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
|
|
|
|
pInfo->name, schemeStr, scheme);
|
2008-07-23 12:06:34 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
|
|
|
|
pInfo->name, schemeStr);
|
|
|
|
scheme = dev->valuator->accelScheme.number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-07-23 12:06:34 +02:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
|
2010-07-23 06:16:38 +02:00
|
|
|
pInfo->name, scheme);
|
2008-07-10 15:03:39 +02:00
|
|
|
}
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(schemeStr);
|
2008-07-23 12:06:34 +02:00
|
|
|
|
2008-07-10 15:03:39 +02:00
|
|
|
/* process special configuration */
|
2010-01-06 19:13:36 +01:00
|
|
|
switch (scheme) {
|
2012-03-21 20:55:09 +01:00
|
|
|
case PtrAccelPredictable:
|
|
|
|
pVel = GetDevicePredictableAccelData(dev);
|
|
|
|
ProcessVelocityConfiguration(dev, pInfo->name, pInfo->options,
|
|
|
|
pVel);
|
|
|
|
break;
|
2008-07-10 15:03:39 +02:00
|
|
|
}
|
2010-01-06 17:32:24 +01:00
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
i = xf86SetIntOption(pInfo->options, "AccelerationNumerator",
|
2010-01-06 17:32:24 +01:00
|
|
|
dev->ptrfeed->ctrl.num);
|
|
|
|
if (i >= 0)
|
|
|
|
dev->ptrfeed->ctrl.num = i;
|
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
i = xf86SetIntOption(pInfo->options, "AccelerationDenominator",
|
2010-01-06 17:32:24 +01:00
|
|
|
dev->ptrfeed->ctrl.den);
|
|
|
|
if (i > 0)
|
|
|
|
dev->ptrfeed->ctrl.den = i;
|
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
i = xf86SetIntOption(pInfo->options, "AccelerationThreshold",
|
2010-01-06 17:32:24 +01:00
|
|
|
dev->ptrfeed->ctrl.threshold);
|
|
|
|
if (i >= 0)
|
|
|
|
dev->ptrfeed->ctrl.threshold = i;
|
|
|
|
|
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) acceleration factor: %.3f\n",
|
2012-03-21 20:55:09 +01:00
|
|
|
pInfo->name, ((float) dev->ptrfeed->ctrl.num) /
|
|
|
|
((float) dev->ptrfeed->ctrl.den));
|
2010-01-06 17:32:24 +01:00
|
|
|
xf86Msg(X_CONFIG, "%s: (accel) acceleration threshold: %i\n",
|
2010-07-23 06:16:38 +02:00
|
|
|
pInfo->name, dev->ptrfeed->ctrl.threshold);
|
2008-07-10 15:03:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-06 01:33:43 +02:00
|
|
|
static void
|
|
|
|
ApplyTransformationMatrix(DeviceIntPtr dev)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
|
2011-09-06 01:33:43 +02:00
|
|
|
char *str;
|
|
|
|
int rc;
|
2012-03-21 20:55:09 +01:00
|
|
|
float matrix[9] = { 0 };
|
2011-09-06 01:33:43 +02:00
|
|
|
|
|
|
|
if (!dev->valuator)
|
|
|
|
return;
|
|
|
|
|
|
|
|
str = xf86SetStrOption(pInfo->options, "TransformationMatrix", NULL);
|
|
|
|
if (!str)
|
|
|
|
return;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
rc = sscanf(str, "%f %f %f %f %f %f %f %f %f", &matrix[0], &matrix[1],
|
|
|
|
&matrix[2], &matrix[3], &matrix[4], &matrix[5], &matrix[6],
|
|
|
|
&matrix[7], &matrix[8]);
|
2011-09-06 01:33:43 +02:00
|
|
|
if (rc != 9) {
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86Msg(X_ERROR,
|
|
|
|
"%s: invalid format for transformation matrix. Ignoring configuration.\n",
|
2011-09-06 01:33:43 +02:00
|
|
|
pInfo->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
|
|
|
|
XIGetKnownProperty(XATOM_FLOAT), 32,
|
|
|
|
PropModeReplace, 9, matrix, FALSE);
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
2003-11-14 17:49:22 +01:00
|
|
|
* xf86ProcessCommonOptions --
|
|
|
|
*
|
|
|
|
* Process global options.
|
2003-11-14 16:54:54 +01:00
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr list)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-12-06 06:44:50 +01:00
|
|
|
if (xf86SetBoolOption(list, "Floating", 0) ||
|
|
|
|
!xf86SetBoolOption(list, "AlwaysCore", 1) ||
|
2007-05-28 12:54:16 +02:00
|
|
|
!xf86SetBoolOption(list, "SendCoreEvents", 1) ||
|
|
|
|
!xf86SetBoolOption(list, "CorePointer", 1) ||
|
|
|
|
!xf86SetBoolOption(list, "CoreKeyboard", 1)) {
|
2010-07-23 06:16:38 +02:00
|
|
|
xf86Msg(X_CONFIG, "%s: doesn't report core events\n", pInfo->name);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2010-07-23 06:16:38 +02:00
|
|
|
pInfo->flags |= XI86_ALWAYS_CORE;
|
|
|
|
xf86Msg(X_CONFIG, "%s: always reports core events\n", pInfo->name);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
2003-11-14 17:49:22 +01:00
|
|
|
* xf86ActivateDevice --
|
2008-11-26 05:15:04 +01:00
|
|
|
*
|
2003-11-14 17:49:22 +01:00
|
|
|
* Initialize an input device.
|
2003-11-14 16:54:54 +01:00
|
|
|
*
|
2008-11-26 05:15:04 +01:00
|
|
|
* Returns TRUE on success, or FALSE otherwise.
|
2003-11-14 16:54:54 +01:00
|
|
|
***********************************************************************
|
|
|
|
*/
|
2010-07-22 02:30:56 +02:00
|
|
|
static DeviceIntPtr
|
2010-07-23 06:16:38 +02:00
|
|
|
xf86ActivateDevice(InputInfoPtr pInfo)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
Atom atom;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
dev = AddInputDevice(serverClient, pInfo->device_control, TRUE);
|
2006-10-15 20:48:01 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (dev == NULL) {
|
|
|
|
xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n", pInfo->name);
|
2010-07-23 06:16:38 +02:00
|
|
|
pInfo->dev = NULL;
|
2010-07-22 02:30:56 +02:00
|
|
|
return NULL;
|
2010-07-22 02:16:15 +02:00
|
|
|
}
|
2008-11-26 05:15:04 +01:00
|
|
|
|
2010-09-01 07:42:44 +02:00
|
|
|
atom = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE);
|
|
|
|
AssignTypeAndName(dev, atom, pInfo->name);
|
2010-07-23 06:16:38 +02:00
|
|
|
dev->public.devicePrivate = pInfo;
|
|
|
|
pInfo->dev = dev;
|
2007-01-29 08:53:24 +01:00
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
dev->coreEvents = pInfo->flags & XI86_ALWAYS_CORE;
|
2010-07-22 02:16:15 +02:00
|
|
|
dev->type = SLAVE;
|
|
|
|
dev->spriteInfo->spriteOwner = FALSE;
|
2006-12-11 08:39:59 +01:00
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
|
2006-07-21 21:23:37 +02:00
|
|
|
|
2010-07-22 02:16:15 +02:00
|
|
|
if (serverGeneration == 1)
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86Msg(X_INFO,
|
|
|
|
"XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
|
2011-05-09 07:13:17 +02:00
|
|
|
pInfo->name, pInfo->type_name, dev->id);
|
2008-11-26 05:15:04 +01:00
|
|
|
|
2010-07-22 02:30:56 +02:00
|
|
|
return dev;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* Caller: ProcXSetDeviceMode
|
|
|
|
*
|
|
|
|
* Change the mode of an extension device.
|
|
|
|
* This function is used to change the mode of a device from reporting
|
|
|
|
* relative motion to reporting absolute positional information, and
|
|
|
|
* vice versa.
|
|
|
|
* The default implementation below is that no such devices are supported.
|
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pInfo->switch_mode) {
|
|
|
|
return (*pInfo->switch_mode) (client, dev, mode);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return BadMatch;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Caller: ProcXSetDeviceValuators
|
|
|
|
*
|
|
|
|
* Set the value of valuators on an extension input device.
|
|
|
|
* This function is used to set the initial value of valuators on
|
|
|
|
* those input devices that are capable of reporting either relative
|
|
|
|
* motion or an absolute position, and allow an initial position to be set.
|
|
|
|
* The default implementation below is that no such devices are supported.
|
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
SetDeviceValuators(ClientPtr client, DeviceIntPtr dev, int *valuators,
|
|
|
|
int first_valuator, int num_valuators)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-07-23 06:16:38 +02:00
|
|
|
InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
|
2006-10-18 10:57:22 +02:00
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
if (pInfo->set_device_valuators)
|
2012-03-21 20:55:09 +01:00
|
|
|
return (*pInfo->set_device_valuators) (pInfo, valuators, first_valuator,
|
|
|
|
num_valuators);
|
2006-10-18 10:57:22 +02:00
|
|
|
|
|
|
|
return BadMatch;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Caller: ProcXChangeDeviceControl
|
|
|
|
*
|
|
|
|
* Change the specified device controls on an extension input device.
|
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
|
|
|
|
|
|
|
|
if (!pInfo->control_proc) {
|
|
|
|
switch (control->control) {
|
|
|
|
case DEVICE_CORE:
|
|
|
|
case DEVICE_ABS_CALIB:
|
|
|
|
case DEVICE_ABS_AREA:
|
|
|
|
return BadMatch;
|
|
|
|
case DEVICE_RESOLUTION:
|
|
|
|
case DEVICE_ENABLE:
|
|
|
|
return Success;
|
|
|
|
default:
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return (*pInfo->control_proc) (pInfo, control);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2006-10-29 02:43:34 +02:00
|
|
|
|
2009-10-02 15:29:28 +02:00
|
|
|
/*
|
2010-06-08 05:39:53 +02:00
|
|
|
* Get the operating system name from uname and store it statically to avoid
|
|
|
|
* repeating the system call each time MatchOS is checked.
|
2009-10-02 15:29:28 +02:00
|
|
|
*/
|
2010-06-08 05:39:53 +02:00
|
|
|
static const char *
|
|
|
|
HostOS(void)
|
2009-10-02 15:29:28 +02:00
|
|
|
{
|
2010-06-08 05:39:53 +02:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
struct utsname name;
|
|
|
|
static char host_os[sizeof(name.sysname)] = "";
|
|
|
|
|
|
|
|
if (*host_os == '\0') {
|
|
|
|
if (uname(&name) >= 0)
|
2011-10-29 06:18:46 +02:00
|
|
|
strlcpy(host_os, name.sysname, sizeof(host_os));
|
2010-06-08 05:39:53 +02:00
|
|
|
else {
|
2011-10-29 06:18:46 +02:00
|
|
|
strlcpy(host_os, "unknown", sizeof(host_os));
|
2010-06-08 05:39:53 +02:00
|
|
|
}
|
2010-02-10 06:36:47 +01:00
|
|
|
}
|
2010-06-08 05:39:53 +02:00
|
|
|
return host_os;
|
|
|
|
#else
|
|
|
|
return "";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-06-08 05:39:52 +02:00
|
|
|
static int
|
|
|
|
match_substring(const char *attr, const char *pattern)
|
|
|
|
{
|
|
|
|
return (strstr(attr, pattern)) ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2010-06-10 15:11:10 +02:00
|
|
|
#ifdef HAVE_FNMATCH_H
|
|
|
|
static int
|
|
|
|
match_pattern(const char *attr, const char *pattern)
|
|
|
|
{
|
|
|
|
return fnmatch(pattern, attr, 0);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define match_pattern match_substring
|
|
|
|
#endif
|
|
|
|
|
2009-10-02 15:29:28 +02:00
|
|
|
#ifdef HAVE_FNMATCH_H
|
2010-06-08 05:39:52 +02:00
|
|
|
static int
|
|
|
|
match_path_pattern(const char *attr, const char *pattern)
|
|
|
|
{
|
|
|
|
return fnmatch(pattern, attr, FNM_PATHNAME);
|
|
|
|
}
|
2009-10-02 15:29:28 +02:00
|
|
|
#else
|
2010-06-08 05:39:52 +02:00
|
|
|
#define match_path_pattern match_substring
|
2009-10-02 15:29:28 +02:00
|
|
|
#endif
|
2010-06-08 05:39:52 +02:00
|
|
|
|
2011-05-19 08:39:52 +02:00
|
|
|
/*
|
|
|
|
* If no Layout section is found, xf86ServerLayout.id becomes "(implicit)"
|
|
|
|
* It is convenient that "" in patterns means "no explicit layout"
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
match_string_implicit(const char *attr, const char *pattern)
|
|
|
|
{
|
|
|
|
if (strlen(pattern)) {
|
|
|
|
return strcmp(attr, pattern);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return strcmp(attr, "(implicit)");
|
2011-05-19 08:39:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-08 05:39:52 +02:00
|
|
|
/*
|
2010-06-08 05:39:57 +02:00
|
|
|
* Match an attribute against a list of NULL terminated arrays of patterns.
|
|
|
|
* If a pattern in each list entry is matched, return TRUE.
|
2010-06-08 05:39:52 +02:00
|
|
|
*/
|
|
|
|
static Bool
|
2012-01-27 01:41:25 +01:00
|
|
|
MatchAttrToken(const char *attr, struct xorg_list *patterns,
|
2012-03-21 20:55:09 +01:00
|
|
|
int (*compare) (const char *attr, const char *pattern))
|
2010-06-08 05:39:52 +02:00
|
|
|
{
|
2010-06-08 05:39:57 +02:00
|
|
|
const xf86MatchGroup *group;
|
2010-06-08 05:39:52 +02:00
|
|
|
|
|
|
|
/* If there are no patterns, accept the match */
|
2012-01-27 01:41:25 +01:00
|
|
|
if (xorg_list_is_empty(patterns))
|
2010-06-08 05:39:52 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* If there are patterns but no attribute, reject the match */
|
|
|
|
if (!attr)
|
|
|
|
return FALSE;
|
|
|
|
|
2010-06-08 05:39:57 +02:00
|
|
|
/*
|
|
|
|
* Otherwise, iterate the list of patterns ensuring each entry has a
|
|
|
|
* match. Each list entry is a separate Match line of the same type.
|
|
|
|
*/
|
2012-01-27 01:41:25 +01:00
|
|
|
xorg_list_for_each_entry(group, patterns, entry) {
|
2014-01-30 00:16:23 +01:00
|
|
|
char *const *cur;
|
2010-06-08 05:39:57 +02:00
|
|
|
Bool match = FALSE;
|
|
|
|
|
|
|
|
for (cur = group->values; *cur; cur++)
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((*compare) (attr, *cur) == 0) {
|
2010-02-10 06:36:47 +01:00
|
|
|
match = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!match)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-06-08 05:39:52 +02:00
|
|
|
|
2010-06-08 05:39:57 +02:00
|
|
|
/* All the entries in the list matched the attribute */
|
|
|
|
return TRUE;
|
2010-06-08 05:39:52 +02:00
|
|
|
}
|
|
|
|
|
2009-10-02 15:29:28 +02:00
|
|
|
/*
|
|
|
|
* Classes without any Match statements match all devices. Otherwise, all
|
|
|
|
* statements must match.
|
|
|
|
*/
|
|
|
|
static Bool
|
2010-09-02 06:30:11 +02:00
|
|
|
InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
|
2012-03-21 20:55:09 +01:00
|
|
|
const InputAttributes * attrs)
|
2009-10-02 15:29:28 +02:00
|
|
|
{
|
2010-06-08 05:39:52 +02:00
|
|
|
/* MatchProduct substring */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!MatchAttrToken
|
|
|
|
(attrs->product, &iclass->match_product, match_substring))
|
2010-06-08 05:39:52 +02:00
|
|
|
return FALSE;
|
2010-02-10 06:36:47 +01:00
|
|
|
|
2010-06-08 05:39:52 +02:00
|
|
|
/* MatchVendor substring */
|
2010-06-08 05:39:57 +02:00
|
|
|
if (!MatchAttrToken(attrs->vendor, &iclass->match_vendor, match_substring))
|
2010-06-08 05:39:52 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* MatchDevicePath pattern */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!MatchAttrToken
|
|
|
|
(attrs->device, &iclass->match_device, match_path_pattern))
|
2010-06-08 05:39:52 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2010-06-08 05:39:53 +02:00
|
|
|
/* MatchOS case-insensitive string */
|
2010-06-08 05:39:57 +02:00
|
|
|
if (!MatchAttrToken(HostOS(), &iclass->match_os, strcasecmp))
|
2010-06-08 05:39:53 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2010-06-10 15:11:10 +02:00
|
|
|
/* MatchPnPID pattern */
|
2010-06-08 05:39:57 +02:00
|
|
|
if (!MatchAttrToken(attrs->pnp_id, &iclass->match_pnpid, match_pattern))
|
2010-06-10 15:11:10 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2010-06-10 15:15:41 +02:00
|
|
|
/* MatchUSBID pattern */
|
2010-06-08 05:39:57 +02:00
|
|
|
if (!MatchAttrToken(attrs->usb_id, &iclass->match_usbid, match_pattern))
|
2010-06-10 15:15:41 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2010-06-08 05:39:58 +02:00
|
|
|
/* MatchDriver string */
|
|
|
|
if (!MatchAttrToken(idev->driver, &iclass->match_driver, strcmp))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-06-08 05:39:52 +02:00
|
|
|
/*
|
|
|
|
* MatchTag string
|
|
|
|
* See if any of the device's tags match any of the MatchTag tokens.
|
|
|
|
*/
|
2012-01-27 01:41:25 +01:00
|
|
|
if (!xorg_list_is_empty(&iclass->match_tag)) {
|
2014-01-30 00:16:23 +01:00
|
|
|
char *const *tag;
|
2010-06-08 05:39:52 +02:00
|
|
|
Bool match;
|
|
|
|
|
2010-02-10 06:36:50 +01:00
|
|
|
if (!attrs->tags)
|
|
|
|
return FALSE;
|
2010-06-08 05:39:52 +02:00
|
|
|
for (tag = attrs->tags, match = FALSE; *tag; tag++) {
|
2010-06-08 05:39:57 +02:00
|
|
|
if (MatchAttrToken(*tag, &iclass->match_tag, strcmp)) {
|
2010-06-08 05:39:52 +02:00
|
|
|
match = TRUE;
|
|
|
|
break;
|
2010-02-10 06:36:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!match)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-05-19 08:39:52 +02:00
|
|
|
/* MatchLayout string */
|
2012-01-27 01:41:25 +01:00
|
|
|
if (!xorg_list_is_empty(&iclass->match_layout)) {
|
2011-05-19 08:39:52 +02:00
|
|
|
if (!MatchAttrToken(xf86ConfigLayout.id,
|
|
|
|
&iclass->match_layout, match_string_implicit))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-06-08 05:39:52 +02:00
|
|
|
/* MatchIs* booleans */
|
2009-10-02 15:29:28 +02:00
|
|
|
if (iclass->is_keyboard.set &&
|
2012-03-21 20:55:09 +01:00
|
|
|
iclass->is_keyboard.val != ! !(attrs->flags & ATTR_KEYBOARD))
|
2010-01-15 06:32:16 +01:00
|
|
|
return FALSE;
|
2009-10-02 15:29:28 +02:00
|
|
|
if (iclass->is_pointer.set &&
|
2012-03-21 20:55:09 +01:00
|
|
|
iclass->is_pointer.val != ! !(attrs->flags & ATTR_POINTER))
|
2010-01-15 06:32:16 +01:00
|
|
|
return FALSE;
|
2009-10-02 15:29:28 +02:00
|
|
|
if (iclass->is_joystick.set &&
|
2012-03-21 20:55:09 +01:00
|
|
|
iclass->is_joystick.val != ! !(attrs->flags & ATTR_JOYSTICK))
|
2010-01-15 06:32:16 +01:00
|
|
|
return FALSE;
|
2009-10-02 15:29:28 +02:00
|
|
|
if (iclass->is_tablet.set &&
|
2012-03-21 20:55:09 +01:00
|
|
|
iclass->is_tablet.val != ! !(attrs->flags & ATTR_TABLET))
|
2010-01-15 06:32:16 +01:00
|
|
|
return FALSE;
|
2009-10-02 15:29:28 +02:00
|
|
|
if (iclass->is_touchpad.set &&
|
2012-03-21 20:55:09 +01:00
|
|
|
iclass->is_touchpad.val != ! !(attrs->flags & ATTR_TOUCHPAD))
|
2010-01-15 06:32:16 +01:00
|
|
|
return FALSE;
|
2009-10-02 15:29:28 +02:00
|
|
|
if (iclass->is_touchscreen.set &&
|
2012-03-21 20:55:09 +01:00
|
|
|
iclass->is_touchscreen.val != ! !(attrs->flags & ATTR_TOUCHSCREEN))
|
2010-01-15 06:32:16 +01:00
|
|
|
return FALSE;
|
2010-06-08 05:39:52 +02:00
|
|
|
|
2010-01-15 06:32:16 +01:00
|
|
|
return TRUE;
|
2009-10-02 15:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-02-10 06:36:44 +01:00
|
|
|
* Merge in any InputClass configurations. Options in each InputClass
|
2010-02-13 19:40:40 +01:00
|
|
|
* section have more priority than the original device configuration as
|
2010-02-10 06:36:44 +01:00
|
|
|
* well as any previous InputClass sections.
|
2009-10-02 15:29:28 +02:00
|
|
|
*/
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
MergeInputClasses(const InputInfoPtr idev, const InputAttributes * attrs)
|
2009-10-02 15:29:28 +02:00
|
|
|
{
|
|
|
|
XF86ConfInputClassPtr cl;
|
2010-06-08 05:39:58 +02:00
|
|
|
XF86OptionPtr classopts;
|
2009-10-02 15:29:28 +02:00
|
|
|
|
|
|
|
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
|
2010-06-08 05:39:58 +02:00
|
|
|
if (!InputClassMatches(cl, idev, attrs))
|
2009-10-02 15:29:28 +02:00
|
|
|
continue;
|
|
|
|
|
2010-06-08 05:39:58 +02:00
|
|
|
/* Collect class options and driver settings */
|
|
|
|
classopts = xf86optionListDup(cl->option_lst);
|
|
|
|
if (cl->driver) {
|
2013-11-15 08:56:15 +01:00
|
|
|
free((void *) idev->driver);
|
2010-06-08 05:39:58 +02:00
|
|
|
idev->driver = xstrdup(cl->driver);
|
|
|
|
if (!idev->driver) {
|
|
|
|
xf86Msg(X_ERROR, "Failed to allocate memory while merging "
|
|
|
|
"InputClass configuration");
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
classopts = xf86ReplaceStrOption(classopts, "driver", idev->driver);
|
2010-06-08 05:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply options to device with InputClass settings preferred. */
|
2009-10-02 15:29:28 +02:00
|
|
|
xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
|
2010-09-02 06:30:11 +02:00
|
|
|
idev->name, cl->identifier);
|
|
|
|
idev->options = xf86optionListMerge(idev->options, classopts);
|
2010-02-13 19:40:40 +01:00
|
|
|
}
|
|
|
|
|
2009-10-02 15:29:28 +02:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2010-02-16 17:11:41 +01:00
|
|
|
/*
|
|
|
|
* Iterate the list of classes and look for Option "Ignore". Return the
|
|
|
|
* value of the last matching class and holler when returning TRUE.
|
|
|
|
*/
|
2010-02-10 06:36:46 +01:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
IgnoreInputClass(const InputInfoPtr idev, const InputAttributes * attrs)
|
2010-02-10 06:36:46 +01:00
|
|
|
{
|
|
|
|
XF86ConfInputClassPtr cl;
|
2010-02-16 17:11:41 +01:00
|
|
|
Bool ignore = FALSE;
|
|
|
|
const char *ignore_class;
|
2010-02-10 06:36:46 +01:00
|
|
|
|
|
|
|
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
|
2010-06-08 05:39:58 +02:00
|
|
|
if (!InputClassMatches(cl, idev, attrs))
|
2010-02-10 06:36:46 +01:00
|
|
|
continue;
|
|
|
|
if (xf86findOption(cl->option_lst, "Ignore")) {
|
|
|
|
ignore = xf86CheckBoolOption(cl->option_lst, "Ignore", FALSE);
|
2010-02-16 17:11:41 +01:00
|
|
|
ignore_class = cl->identifier;
|
2010-02-10 06:36:46 +01:00
|
|
|
}
|
|
|
|
}
|
2010-02-16 17:11:41 +01:00
|
|
|
|
|
|
|
if (ignore)
|
|
|
|
xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n",
|
2010-09-02 06:30:11 +02:00
|
|
|
idev->name, ignore_class);
|
2010-02-16 17:11:41 +01:00
|
|
|
return ignore;
|
2010-02-10 06:36:46 +01:00
|
|
|
}
|
|
|
|
|
2010-12-06 05:58:37 +01:00
|
|
|
InputInfoPtr
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86AllocateInput(void)
|
2010-07-22 04:00:07 +02:00
|
|
|
{
|
2010-09-02 06:30:11 +02:00
|
|
|
InputInfoPtr pInfo;
|
2010-07-22 04:00:07 +02:00
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
pInfo = calloc(sizeof(*pInfo), 1);
|
|
|
|
if (!pInfo)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pInfo->fd = -1;
|
|
|
|
pInfo->type_name = "UNKNOWN";
|
|
|
|
|
|
|
|
return pInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append InputInfoRec to the tail of xf86InputDevs. */
|
|
|
|
static void
|
|
|
|
xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
|
|
|
|
{
|
|
|
|
InputInfoPtr *prev = NULL;
|
2010-07-22 04:00:07 +02:00
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
pInfo->drv = drv;
|
|
|
|
pInfo->module = DuplicateModule(drv->module, NULL);
|
2010-07-22 04:00:07 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next);
|
2010-07-22 04:00:07 +02:00
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
*prev = pInfo;
|
|
|
|
pInfo->next = NULL;
|
2010-07-22 04:00:07 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86CollectInputOptions(pInfo, (const char **) drv->default_options);
|
2010-12-13 02:28:30 +01:00
|
|
|
xf86OptionListReport(pInfo->options);
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86ProcessCommonOptions(pInfo, pInfo->options);
|
2010-07-22 04:00:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-09-02 06:45:03 +02:00
|
|
|
* Remove an entry from xf86InputDevs and free all the device's information.
|
2010-07-22 04:00:07 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
xf86DeleteInput(InputInfoPtr pInp, int flags)
|
|
|
|
{
|
|
|
|
/* First check if the inputdev is valid. */
|
|
|
|
if (pInp == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2010-07-22 04:00:07 +02:00
|
|
|
|
|
|
|
if (pInp->module)
|
2012-03-21 20:55:09 +01:00
|
|
|
UnloadModule(pInp->module);
|
2010-07-22 04:00:07 +02:00
|
|
|
|
|
|
|
/* This should *really* be handled in drv->UnInit(dev) call instead, but
|
|
|
|
* if the driver forgets about it make sure we free it or at least crash
|
|
|
|
* with flying colors */
|
|
|
|
free(pInp->private);
|
|
|
|
|
|
|
|
FreeInputAttributes(pInp->attrs);
|
|
|
|
|
2014-05-02 06:14:58 +02:00
|
|
|
if (pInp->flags & XI86_SERVER_FD)
|
|
|
|
systemd_logind_release_fd(pInp->major, pInp->minor, pInp->fd);
|
2014-03-12 16:00:23 +01:00
|
|
|
|
2010-07-22 04:00:07 +02:00
|
|
|
/* Remove the entry from the list. */
|
|
|
|
if (pInp == xf86InputDevs)
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86InputDevs = pInp->next;
|
2010-07-22 04:00:07 +02:00
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
InputInfoPtr p = xf86InputDevs;
|
|
|
|
|
|
|
|
while (p && p->next != pInp)
|
|
|
|
p = p->next;
|
|
|
|
if (p)
|
|
|
|
p->next = pInp->next;
|
|
|
|
/* Else the entry wasn't in the xf86InputDevs list (ignore this). */
|
2010-07-22 04:00:07 +02:00
|
|
|
}
|
2010-09-02 06:30:11 +02:00
|
|
|
|
2013-11-15 08:56:15 +01:00
|
|
|
free((void *) pInp->driver);
|
|
|
|
free((void *) pInp->name);
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86optionListFree(pInp->options);
|
2010-07-22 04:00:07 +02:00
|
|
|
free(pInp);
|
|
|
|
}
|
|
|
|
|
2010-07-18 12:31:26 +02:00
|
|
|
/*
|
2011-09-05 07:43:14 +02:00
|
|
|
* Apply backend-specific initialization. Invoked after ActivateDevice(),
|
2010-07-18 12:31:26 +02:00
|
|
|
* i.e. after the driver successfully completed DEVICE_INIT and the device
|
|
|
|
* is advertised.
|
|
|
|
* @param dev the device
|
|
|
|
* @return Success or an error code
|
|
|
|
*/
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86InputDevicePostInit(DeviceIntPtr dev)
|
|
|
|
{
|
2010-07-18 12:31:26 +02:00
|
|
|
ApplyAccelerationSettings(dev);
|
2011-09-06 01:33:43 +02:00
|
|
|
ApplyTransformationMatrix(dev);
|
2010-07-18 12:31:26 +02:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2014-03-11 05:21:27 +01:00
|
|
|
static void
|
|
|
|
xf86stat(const char *path, int *maj, int *min)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (stat(path, &st) == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*maj = major(st.st_rdev);
|
|
|
|
*min = minor(st.st_rdev);
|
|
|
|
}
|
|
|
|
|
2008-11-21 03:02:02 +01:00
|
|
|
/**
|
|
|
|
* Create a new input device, activate and enable it.
|
|
|
|
*
|
2008-11-26 05:15:04 +01:00
|
|
|
* Possible return codes:
|
|
|
|
* BadName .. a bad driver name was supplied.
|
|
|
|
* BadImplementation ... The driver does not have a PreInit function. This
|
|
|
|
* is a driver bug.
|
|
|
|
* BadMatch .. device initialization failed.
|
|
|
|
* BadAlloc .. too many input devices
|
|
|
|
*
|
2008-11-21 03:02:02 +01:00
|
|
|
* @param idev The device, already set up with identifier, driver, and the
|
|
|
|
* options.
|
|
|
|
* @param pdev Pointer to the new device, if Success was reported.
|
|
|
|
* @param enable Enable the device after activating it.
|
|
|
|
*
|
|
|
|
* @return Success or an error code
|
|
|
|
*/
|
|
|
|
_X_INTERNAL int
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
|
2008-11-21 03:02:02 +01:00
|
|
|
{
|
|
|
|
InputDriverPtr drv = NULL;
|
|
|
|
DeviceIntPtr dev = NULL;
|
2014-01-14 15:37:33 +01:00
|
|
|
Bool paused;
|
2008-11-21 03:02:02 +01:00
|
|
|
int rval;
|
2014-03-11 05:21:27 +01:00
|
|
|
const char *path;
|
2008-11-21 03:02:02 +01:00
|
|
|
|
|
|
|
/* Memory leak for every attached device if we don't
|
|
|
|
* test if the module is already loaded first */
|
2010-09-02 06:30:11 +02:00
|
|
|
drv = xf86LookupInputDriver(pInfo->driver);
|
2008-11-21 03:02:02 +01:00
|
|
|
if (!drv)
|
2010-09-02 06:30:11 +02:00
|
|
|
if (xf86LoadOneModule(pInfo->driver, NULL))
|
|
|
|
drv = xf86LookupInputDriver(pInfo->driver);
|
2008-11-21 03:02:02 +01:00
|
|
|
if (!drv) {
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver);
|
2008-11-21 03:02:02 +01:00
|
|
|
rval = BadName;
|
|
|
|
goto unwind;
|
|
|
|
}
|
|
|
|
|
2014-03-11 05:21:27 +01:00
|
|
|
path = xf86CheckStrOption(pInfo->options, "Device", NULL);
|
|
|
|
if (path && pInfo->major == 0 && pInfo->minor == 0)
|
|
|
|
xf86stat(path, &pInfo->major, &pInfo->minor);
|
|
|
|
|
|
|
|
if (path && (drv->capabilities & XI86_DRV_CAP_SERVER_FD)){
|
2014-01-31 15:21:38 +01:00
|
|
|
int fd = systemd_logind_take_fd(pInfo->major, pInfo->minor,
|
2014-03-11 05:21:27 +01:00
|
|
|
path, &paused);
|
2014-01-31 15:21:38 +01:00
|
|
|
if (fd != -1) {
|
|
|
|
if (paused) {
|
|
|
|
/* Put on new_input_devices list for delayed probe */
|
|
|
|
new_input_devices = xnfrealloc(new_input_devices,
|
|
|
|
sizeof(pInfo) * (new_input_devices_count + 1));
|
|
|
|
new_input_devices[new_input_devices_count] = pInfo;
|
|
|
|
new_input_devices_count++;
|
2014-05-02 06:14:58 +02:00
|
|
|
systemd_logind_release_fd(pInfo->major, pInfo->minor, fd);
|
2014-01-31 15:21:38 +01:00
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
pInfo->fd = fd;
|
2014-01-14 15:37:33 +01:00
|
|
|
pInfo->flags |= XI86_SERVER_FD;
|
|
|
|
pInfo->options = xf86ReplaceIntOption(pInfo->options, "fd", fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86Msg(X_INFO, "Using input driver '%s' for '%s'\n", drv->driverName,
|
|
|
|
pInfo->name);
|
2011-03-18 02:06:57 +01:00
|
|
|
|
2008-11-21 03:02:02 +01:00
|
|
|
if (!drv->PreInit) {
|
|
|
|
xf86Msg(X_ERROR,
|
|
|
|
"Input driver `%s' has no PreInit function (ignoring)\n",
|
|
|
|
drv->driverName);
|
|
|
|
rval = BadImplementation;
|
|
|
|
goto unwind;
|
|
|
|
}
|
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86AddInput(drv, pInfo);
|
2008-11-21 03:02:02 +01:00
|
|
|
|
2010-07-21 08:00:26 +02:00
|
|
|
rval = drv->PreInit(drv, pInfo, 0);
|
|
|
|
|
|
|
|
if (rval != Success) {
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, pInfo->name);
|
2008-11-21 03:02:02 +01:00
|
|
|
goto unwind;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!(dev = xf86ActivateDevice(pInfo))) {
|
2008-11-26 05:15:04 +01:00
|
|
|
rval = BadAlloc;
|
|
|
|
goto unwind;
|
|
|
|
}
|
2008-11-21 03:02:02 +01:00
|
|
|
|
2009-05-12 08:09:35 +02:00
|
|
|
rval = ActivateDevice(dev, TRUE);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (rval != Success) {
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
|
2009-05-12 08:09:35 +02:00
|
|
|
RemoveDevice(dev, TRUE);
|
2008-12-23 00:59:28 +01:00
|
|
|
goto unwind;
|
2008-12-26 08:32:41 +01:00
|
|
|
}
|
2008-12-23 00:59:28 +01:00
|
|
|
|
2010-07-18 12:31:26 +02:00
|
|
|
rval = xf86InputDevicePostInit(dev);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (rval != Success) {
|
|
|
|
xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
|
|
|
|
RemoveDevice(dev, TRUE);
|
|
|
|
goto unwind;
|
2010-07-18 12:31:26 +02:00
|
|
|
}
|
|
|
|
|
2008-11-21 03:02:02 +01:00
|
|
|
/* Enable it if it's properly initialised and we're currently in the VT */
|
2013-04-10 08:32:11 +02:00
|
|
|
if (enable && dev->inited && dev->startup && xf86VTOwner()) {
|
2011-03-03 05:15:55 +01:00
|
|
|
OsBlockSignals();
|
2009-05-12 08:09:35 +02:00
|
|
|
EnableDevice(dev, TRUE);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!dev->enabled) {
|
2011-03-03 05:15:55 +01:00
|
|
|
OsReleaseSignals();
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
|
2011-06-27 08:30:28 +02:00
|
|
|
RemoveDevice(dev, TRUE);
|
2008-12-26 08:32:41 +01:00
|
|
|
rval = BadMatch;
|
|
|
|
goto unwind;
|
|
|
|
}
|
2008-12-23 01:00:34 +01:00
|
|
|
/* send enter/leave event, update sprite window */
|
|
|
|
CheckMotion(NULL, dev);
|
2011-03-03 05:15:55 +01:00
|
|
|
OsReleaseSignals();
|
2008-12-23 01:00:34 +01:00
|
|
|
}
|
2008-11-21 03:02:02 +01:00
|
|
|
|
|
|
|
*pdev = dev;
|
|
|
|
return Success;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
unwind:
|
|
|
|
if (pInfo) {
|
|
|
|
if (drv && drv->UnInit)
|
2008-11-21 03:02:02 +01:00
|
|
|
drv->UnInit(drv, pInfo, 0);
|
|
|
|
else
|
|
|
|
xf86DeleteInput(pInfo, 0);
|
|
|
|
}
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
|
|
|
|
DeviceIntPtr *pdev)
|
2006-07-19 17:41:16 +02:00
|
|
|
{
|
2010-09-02 06:30:11 +02:00
|
|
|
InputInfoPtr pInfo = NULL;
|
2006-07-19 17:41:16 +02:00
|
|
|
InputOption *option = NULL;
|
2007-04-10 22:52:08 +02:00
|
|
|
int rval = Success;
|
2007-08-01 02:30:07 +02:00
|
|
|
int is_auto = 0;
|
2006-07-19 17:41:16 +02:00
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
pInfo = xf86AllocateInput();
|
|
|
|
if (!pInfo)
|
2006-07-19 17:41:16 +02:00
|
|
|
return BadAlloc;
|
|
|
|
|
2011-08-10 06:38:58 +02:00
|
|
|
nt_list_for_each_entry(option, options, list.next) {
|
2011-10-25 03:49:26 +02:00
|
|
|
const char *key = input_option_get_key(option);
|
|
|
|
const char *value = input_option_get_value(option);
|
|
|
|
|
|
|
|
if (strcasecmp(key, "driver") == 0) {
|
2010-09-02 06:30:11 +02:00
|
|
|
if (pInfo->driver) {
|
2007-04-10 22:52:08 +02:00
|
|
|
rval = BadRequest;
|
|
|
|
goto unwind;
|
|
|
|
}
|
2011-10-25 03:49:26 +02:00
|
|
|
pInfo->driver = xstrdup(value);
|
2010-09-02 06:30:11 +02:00
|
|
|
if (!pInfo->driver) {
|
2007-04-10 22:52:08 +02:00
|
|
|
rval = BadAlloc;
|
|
|
|
goto unwind;
|
2006-07-19 17:41:16 +02:00
|
|
|
}
|
|
|
|
}
|
2007-08-01 02:30:07 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (strcasecmp(key, "name") == 0 || strcasecmp(key, "identifier") == 0) {
|
2010-09-02 06:30:11 +02:00
|
|
|
if (pInfo->name) {
|
2007-04-10 22:52:08 +02:00
|
|
|
rval = BadRequest;
|
|
|
|
goto unwind;
|
|
|
|
}
|
2011-10-25 03:49:26 +02:00
|
|
|
pInfo->name = xstrdup(value);
|
2010-09-02 06:30:11 +02:00
|
|
|
if (!pInfo->name) {
|
2007-04-10 22:52:08 +02:00
|
|
|
rval = BadAlloc;
|
|
|
|
goto unwind;
|
2006-07-19 17:41:16 +02:00
|
|
|
}
|
|
|
|
}
|
2007-08-01 02:30:07 +02:00
|
|
|
|
2011-10-25 03:49:26 +02:00
|
|
|
if (strcmp(key, "_source") == 0 &&
|
|
|
|
(strcmp(value, "server/hal") == 0 ||
|
|
|
|
strcmp(value, "server/udev") == 0 ||
|
|
|
|
strcmp(value, "server/wscons") == 0)) {
|
2009-04-30 03:39:50 +02:00
|
|
|
is_auto = 1;
|
2007-08-01 02:30:07 +02:00
|
|
|
if (!xf86Info.autoAddDevices) {
|
|
|
|
rval = BadMatch;
|
|
|
|
goto unwind;
|
|
|
|
}
|
|
|
|
}
|
2014-01-13 11:57:38 +01:00
|
|
|
|
|
|
|
if (strcmp(key, "major") == 0)
|
|
|
|
pInfo->major = atoi(value);
|
|
|
|
|
|
|
|
if (strcmp(key, "minor") == 0)
|
|
|
|
pInfo->minor = atoi(value);
|
2006-07-19 17:41:16 +02:00
|
|
|
}
|
2007-02-15 04:21:20 +01:00
|
|
|
|
2011-08-10 06:38:58 +02:00
|
|
|
nt_list_for_each_entry(option, options, list.next) {
|
2011-08-04 06:45:46 +02:00
|
|
|
/* Copy option key/value strings from the provided list */
|
|
|
|
pInfo->options = xf86AddNewOption(pInfo->options,
|
|
|
|
input_option_get_key(option),
|
|
|
|
input_option_get_value(option));
|
2007-04-10 22:52:08 +02:00
|
|
|
}
|
2006-07-19 17:41:16 +02:00
|
|
|
|
2009-10-02 15:29:28 +02:00
|
|
|
/* Apply InputClass settings */
|
|
|
|
if (attrs) {
|
2010-09-02 06:30:11 +02:00
|
|
|
if (IgnoreInputClass(pInfo, attrs)) {
|
2010-02-10 06:36:46 +01:00
|
|
|
rval = BadIDChoice;
|
|
|
|
goto unwind;
|
|
|
|
}
|
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
rval = MergeInputClasses(pInfo, attrs);
|
2009-10-02 15:29:28 +02:00
|
|
|
if (rval != Success)
|
|
|
|
goto unwind;
|
2010-05-25 09:15:32 +02:00
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
pInfo->attrs = DuplicateInputAttributes(attrs);
|
2009-10-02 15:29:28 +02:00
|
|
|
}
|
|
|
|
|
2012-01-03 01:45:45 +01:00
|
|
|
if (!pInfo->name) {
|
|
|
|
xf86Msg(X_INFO, "No identifier specified, ignoring this device.\n");
|
2009-12-23 07:05:16 +01:00
|
|
|
rval = BadRequest;
|
|
|
|
goto unwind;
|
|
|
|
}
|
|
|
|
|
2012-01-03 01:45:45 +01:00
|
|
|
if (!pInfo->driver) {
|
|
|
|
xf86Msg(X_INFO, "No input driver specified, ignoring this device.\n");
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86Msg(X_INFO,
|
|
|
|
"This device may have been added with another device file.\n");
|
2012-01-03 01:45:45 +01:00
|
|
|
rval = BadRequest;
|
2010-09-02 06:26:20 +02:00
|
|
|
goto unwind;
|
2009-12-23 07:05:16 +01:00
|
|
|
}
|
|
|
|
|
2010-09-02 06:30:11 +02:00
|
|
|
rval = xf86NewInputDevice(pInfo, pdev,
|
2012-03-21 20:55:09 +01:00
|
|
|
(!is_auto ||
|
|
|
|
(is_auto && xf86Info.autoEnableDevices)));
|
2010-09-02 06:30:11 +02:00
|
|
|
|
|
|
|
return rval;
|
2007-04-10 22:52:08 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
unwind:
|
2009-04-30 03:39:50 +02:00
|
|
|
if (is_auto && !xf86Info.autoAddDevices)
|
|
|
|
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
|
2010-09-02 06:30:11 +02:00
|
|
|
xf86DeleteInput(pInfo, 0);
|
2007-04-10 22:52:08 +02:00
|
|
|
return rval;
|
2006-07-19 17:41:16 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2010-05-26 16:54:35 +02:00
|
|
|
DeleteInputDeviceRequest(DeviceIntPtr pDev)
|
2007-04-10 22:54:32 +02:00
|
|
|
{
|
2010-07-23 06:16:38 +02:00
|
|
|
InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate;
|
2008-12-04 00:47:25 +01:00
|
|
|
InputDriverPtr drv = NULL;
|
2009-05-20 07:28:16 +02:00
|
|
|
Bool isMaster = IsMaster(pDev);
|
2007-04-10 22:54:32 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pInfo) /* need to get these before RemoveDevice */
|
2008-02-22 01:31:51 +01:00
|
|
|
drv = pInfo->drv;
|
2007-04-10 22:54:32 +02:00
|
|
|
|
2008-06-02 03:10:10 +02:00
|
|
|
OsBlockSignals();
|
2009-05-12 08:09:35 +02:00
|
|
|
RemoveDevice(pDev, TRUE);
|
2008-02-22 01:31:51 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!isMaster && pInfo != NULL) {
|
|
|
|
if (drv->UnInit)
|
2010-05-26 16:54:35 +02:00
|
|
|
drv->UnInit(drv, pInfo, 0);
|
2008-06-02 03:10:10 +02:00
|
|
|
else
|
2010-05-26 16:54:35 +02:00
|
|
|
xf86DeleteInput(pInfo, 0);
|
2008-04-23 04:08:08 +02:00
|
|
|
}
|
2008-06-02 03:10:10 +02:00
|
|
|
OsReleaseSignals();
|
2006-07-19 17:41:16 +02:00
|
|
|
}
|
|
|
|
|
2006-07-21 21:23:37 +02:00
|
|
|
/*
|
|
|
|
* convenient functions to post events
|
2003-11-14 16:54:54 +01:00
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostMotionEvent(DeviceIntPtr device,
|
|
|
|
int is_absolute, int first_valuator, int num_valuators, ...)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-07-21 21:23:37 +02:00
|
|
|
va_list var;
|
2007-06-04 12:48:06 +02:00
|
|
|
int i = 0;
|
2010-10-19 01:58:58 +02:00
|
|
|
ValuatorMask mask;
|
2007-06-04 12:59:42 +02:00
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
2007-06-04 12:48:06 +02:00
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_zero(&mask);
|
2007-06-04 12:48:06 +02:00
|
|
|
va_start(var, num_valuators);
|
|
|
|
for (i = 0; i < num_valuators; i++)
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-06-04 12:48:06 +02:00
|
|
|
va_end(var);
|
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
xf86PostMotionEventM(device, is_absolute, &mask);
|
2007-06-04 12:48:06 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostMotionEventP(DeviceIntPtr device,
|
|
|
|
int is_absolute,
|
|
|
|
int first_valuator,
|
|
|
|
int num_valuators, const int *valuators)
|
2010-10-19 05:37:46 +02:00
|
|
|
{
|
|
|
|
ValuatorMask mask;
|
|
|
|
|
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
|
|
|
|
|
|
|
valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
|
|
|
|
xf86PostMotionEventM(device, is_absolute, &mask);
|
|
|
|
}
|
|
|
|
|
2012-05-21 21:39:43 +02:00
|
|
|
static int
|
|
|
|
xf86CheckMotionEvent4DGA(DeviceIntPtr device, int is_absolute,
|
|
|
|
const ValuatorMask *mask)
|
2007-06-04 12:48:06 +02:00
|
|
|
{
|
2012-05-21 21:39:43 +02:00
|
|
|
int stolen = 0;
|
2006-11-16 03:21:08 +01:00
|
|
|
|
2007-03-20 23:12:02 +01:00
|
|
|
#if XFreeXDGA
|
2012-05-21 21:39:43 +02:00
|
|
|
ScreenPtr scr = NULL;
|
2013-11-15 08:56:15 +01:00
|
|
|
int idx = 0, i;
|
2012-05-21 21:39:43 +02:00
|
|
|
|
2007-10-02 05:49:07 +02:00
|
|
|
/* The evdev driver may not always send all axes across. */
|
2012-05-21 21:39:43 +02:00
|
|
|
if (valuator_mask_isset(mask, 0) || valuator_mask_isset(mask, 1)) {
|
|
|
|
scr = miPointerGetScreen(device);
|
|
|
|
if (scr) {
|
2011-01-24 00:06:47 +01:00
|
|
|
int dx = 0, dy = 0;
|
|
|
|
|
2012-05-21 21:39:43 +02:00
|
|
|
idx = scr->myNum;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (valuator_mask_isset(mask, 0)) {
|
2010-10-19 05:37:46 +02:00
|
|
|
dx = valuator_mask_get(mask, 0);
|
2007-10-02 05:49:07 +02:00
|
|
|
if (is_absolute)
|
2008-05-23 04:21:53 +02:00
|
|
|
dx -= device->last.valuators[0];
|
2007-10-02 05:49:07 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (valuator_mask_isset(mask, 1)) {
|
2010-10-19 05:37:46 +02:00
|
|
|
dy = valuator_mask_get(mask, 1);
|
2007-10-02 05:49:07 +02:00
|
|
|
if (is_absolute)
|
2008-05-23 04:21:53 +02:00
|
|
|
dy -= device->last.valuators[1];
|
2007-03-21 01:35:31 +01:00
|
|
|
}
|
2007-10-02 05:49:07 +02:00
|
|
|
|
2012-05-21 21:39:43 +02:00
|
|
|
if (DGAStealMotionEvent(device, idx, dx, dy))
|
|
|
|
stolen = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 2; i < valuator_mask_size(mask); i++) {
|
|
|
|
AxisInfoPtr ax;
|
|
|
|
double incr;
|
|
|
|
int val, button;
|
|
|
|
|
|
|
|
if (i >= device->valuator->numAxes)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!valuator_mask_isset(mask, i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ax = &device->valuator->axes[i];
|
|
|
|
|
|
|
|
if (ax->scroll.type == SCROLL_TYPE_NONE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!scr) {
|
|
|
|
scr = miPointerGetScreen(device);
|
|
|
|
if (!scr)
|
|
|
|
break;
|
|
|
|
idx = scr->myNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
incr = ax->scroll.increment;
|
|
|
|
val = valuator_mask_get(mask, i);
|
|
|
|
|
|
|
|
if (ax->scroll.type == SCROLL_TYPE_VERTICAL) {
|
|
|
|
if (incr * val < 0)
|
|
|
|
button = 4; /* up */
|
|
|
|
else
|
|
|
|
button = 5; /* down */
|
|
|
|
} else { /* SCROLL_TYPE_HORIZONTAL */
|
|
|
|
if (incr * val < 0)
|
|
|
|
button = 6; /* left */
|
|
|
|
else
|
|
|
|
button = 7; /* right */
|
2007-03-20 23:12:02 +01:00
|
|
|
}
|
2012-05-21 21:39:43 +02:00
|
|
|
|
|
|
|
if (DGAStealButtonEvent(device, idx, button, 1) &&
|
|
|
|
DGAStealButtonEvent(device, idx, button, 0))
|
|
|
|
stolen = 1;
|
|
|
|
}
|
|
|
|
|
2007-03-20 23:12:02 +01:00
|
|
|
#endif
|
|
|
|
|
2012-05-21 21:39:43 +02:00
|
|
|
return stolen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86PostMotionEventM(DeviceIntPtr device,
|
|
|
|
int is_absolute, const ValuatorMask *mask)
|
|
|
|
{
|
|
|
|
int flags = 0;
|
|
|
|
|
|
|
|
if (xf86CheckMotionEvent4DGA(device, is_absolute, mask))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (valuator_mask_num_valuators(mask) > 0) {
|
|
|
|
if (is_absolute)
|
|
|
|
flags = POINTER_ABSOLUTE;
|
|
|
|
else
|
|
|
|
flags = POINTER_RELATIVE | POINTER_ACCELERATE;
|
|
|
|
}
|
|
|
|
|
2011-04-15 02:07:10 +02:00
|
|
|
QueuePointerEvents(device, MotionNotify, 0, flags, mask);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostProximityEvent(DeviceIntPtr device,
|
|
|
|
int is_in, int first_valuator, int num_valuators, ...)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-10-23 05:56:07 +02:00
|
|
|
va_list var;
|
2009-07-28 07:20:37 +02:00
|
|
|
int i;
|
2010-10-19 01:58:58 +02:00
|
|
|
ValuatorMask mask;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_zero(&mask);
|
2006-10-23 05:56:07 +02:00
|
|
|
va_start(var, num_valuators);
|
|
|
|
for (i = 0; i < num_valuators; i++)
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2006-10-23 05:56:07 +02:00
|
|
|
va_end(var);
|
2006-07-21 21:23:37 +02:00
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
xf86PostProximityEventM(device, is_in, &mask);
|
2009-07-28 07:20:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostProximityEventP(DeviceIntPtr device,
|
|
|
|
int is_in,
|
|
|
|
int first_valuator,
|
|
|
|
int num_valuators, const int *valuators)
|
2009-07-28 07:20:37 +02:00
|
|
|
{
|
2010-10-19 05:37:46 +02:00
|
|
|
ValuatorMask mask;
|
2009-07-28 07:20:37 +02:00
|
|
|
|
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
|
|
|
|
2010-10-19 05:37:46 +02:00
|
|
|
valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
|
|
|
|
xf86PostProximityEventM(device, is_in, &mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostProximityEventM(DeviceIntPtr device,
|
|
|
|
int is_in, const ValuatorMask *mask)
|
2010-10-19 05:37:46 +02:00
|
|
|
{
|
2011-04-15 02:07:10 +02:00
|
|
|
QueueProximityEvents(device, is_in ? ProximityIn : ProximityOut, mask);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostButtonEvent(DeviceIntPtr device,
|
|
|
|
int is_absolute,
|
|
|
|
int button,
|
|
|
|
int is_down, int first_valuator, int num_valuators, ...)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-07-21 21:23:37 +02:00
|
|
|
va_list var;
|
2010-10-19 01:58:58 +02:00
|
|
|
ValuatorMask mask;
|
2009-07-28 07:20:37 +02:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_zero(&mask);
|
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
va_start(var, num_valuators);
|
|
|
|
for (i = 0; i < num_valuators; i++)
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
va_end(var);
|
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
|
2009-07-28 07:20:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostButtonEventP(DeviceIntPtr device,
|
|
|
|
int is_absolute,
|
|
|
|
int button,
|
|
|
|
int is_down,
|
|
|
|
int first_valuator,
|
|
|
|
int num_valuators, const int *valuators)
|
2010-10-19 05:37:46 +02:00
|
|
|
{
|
|
|
|
ValuatorMask mask;
|
|
|
|
|
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
|
|
|
|
|
|
|
valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
|
|
|
|
xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostButtonEventM(DeviceIntPtr device,
|
|
|
|
int is_absolute,
|
|
|
|
int button, int is_down, const ValuatorMask *mask)
|
2009-07-28 07:20:37 +02:00
|
|
|
{
|
2009-08-03 01:46:57 +02:00
|
|
|
int flags = 0;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (valuator_mask_num_valuators(mask) > 0) {
|
2010-12-08 05:43:51 +01:00
|
|
|
if (is_absolute)
|
|
|
|
flags = POINTER_ABSOLUTE;
|
|
|
|
else
|
|
|
|
flags = POINTER_RELATIVE | POINTER_ACCELERATE;
|
|
|
|
}
|
2006-11-16 03:21:08 +01:00
|
|
|
|
2007-03-20 23:12:02 +01:00
|
|
|
#if XFreeXDGA
|
2007-10-02 05:49:07 +02:00
|
|
|
if (miPointerGetScreen(device)) {
|
2011-01-24 00:06:47 +01:00
|
|
|
int index = miPointerGetScreen(device)->myNum;
|
|
|
|
|
2007-10-02 05:49:07 +02:00
|
|
|
if (DGAStealButtonEvent(device, index, button, is_down))
|
2007-03-21 01:35:31 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-03-20 23:12:02 +01:00
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2011-04-15 02:07:10 +02:00
|
|
|
QueuePointerEvents(device,
|
2011-04-11 07:48:15 +02:00
|
|
|
is_down ? ButtonPress : ButtonRelease, button,
|
|
|
|
flags, mask);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostKeyEvent(DeviceIntPtr device,
|
|
|
|
unsigned int key_code,
|
|
|
|
int is_down,
|
|
|
|
int is_absolute, int first_valuator, int num_valuators, ...)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-07-21 21:23:37 +02:00
|
|
|
va_list var;
|
2009-07-28 07:20:37 +02:00
|
|
|
int i = 0;
|
2010-10-19 01:58:58 +02:00
|
|
|
ValuatorMask mask;
|
2006-07-21 21:23:37 +02:00
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
2008-02-01 04:54:04 +01:00
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_zero(&mask);
|
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
va_start(var, num_valuators);
|
|
|
|
for (i = 0; i < num_valuators; i++)
|
2010-10-19 01:58:58 +02:00
|
|
|
valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2009-07-28 07:20:37 +02:00
|
|
|
va_end(var);
|
|
|
|
|
2010-10-19 01:58:58 +02:00
|
|
|
xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
|
2009-07-28 07:20:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostKeyEventP(DeviceIntPtr device,
|
|
|
|
unsigned int key_code,
|
|
|
|
int is_down,
|
|
|
|
int is_absolute,
|
|
|
|
int first_valuator, int num_valuators, const int *valuators)
|
2009-07-28 07:20:37 +02:00
|
|
|
{
|
2010-10-19 05:37:46 +02:00
|
|
|
ValuatorMask mask;
|
2009-07-28 07:20:37 +02:00
|
|
|
|
|
|
|
XI_VERIFY_VALUATORS(num_valuators);
|
2006-08-10 13:00:14 +02:00
|
|
|
|
2010-10-19 05:37:46 +02:00
|
|
|
valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
|
|
|
|
xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostKeyEventM(DeviceIntPtr device,
|
|
|
|
unsigned int key_code,
|
|
|
|
int is_down, int is_absolute, const ValuatorMask *mask)
|
2010-10-19 05:37:46 +02:00
|
|
|
{
|
2011-01-24 00:06:40 +01:00
|
|
|
#if XFreeXDGA
|
|
|
|
DeviceIntPtr pointer;
|
|
|
|
|
|
|
|
/* Some pointers send key events, paired device is wrong then. */
|
2011-08-01 06:14:02 +02:00
|
|
|
pointer = GetMaster(device, POINTER_OR_FLOAT);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2011-01-24 00:06:40 +01:00
|
|
|
if (miPointerGetScreen(pointer)) {
|
2011-01-24 00:06:47 +01:00
|
|
|
int index = miPointerGetScreen(pointer)->myNum;
|
|
|
|
|
2011-01-24 00:06:40 +01:00
|
|
|
if (DGAStealKeyEvent(device, index, key_code, is_down))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-15 02:07:10 +02:00
|
|
|
QueueKeyboardEvents(device,
|
2012-03-21 20:55:09 +01:00
|
|
|
is_down ? KeyPress : KeyRelease, key_code, mask);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code, int is_down)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2010-10-19 05:37:46 +02:00
|
|
|
ValuatorMask mask;
|
|
|
|
|
|
|
|
valuator_mask_zero(&mask);
|
|
|
|
xf86PostKeyEventM(device, key_code, is_down, 0, &mask);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2010-07-23 06:16:38 +02:00
|
|
|
InputInfoPtr
|
2009-01-11 08:33:18 +01:00
|
|
|
xf86FirstLocalDevice(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
return xf86InputDevs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cx - raw data from touch screen
|
2010-10-13 07:53:59 +02:00
|
|
|
* to_max - scaled highest dimension
|
2003-11-14 17:49:22 +01:00
|
|
|
* (remember, this is of rows - 1 because of 0 origin)
|
2010-10-13 07:53:59 +02:00
|
|
|
* to_min - scaled lowest dimension
|
|
|
|
* from_max - highest raw value from touch screen calibration
|
|
|
|
* from_min - lowest raw value from touch screen calibration
|
2003-11-14 17:49:22 +01:00
|
|
|
*
|
|
|
|
* This function is the same for X or Y coordinates.
|
|
|
|
* You may have to reverse the high and low values to compensate for
|
|
|
|
* different orgins on the touch screen vs X.
|
2010-10-13 07:53:59 +02:00
|
|
|
*
|
|
|
|
* e.g. to scale from device coordinates into screen coordinates, call
|
|
|
|
* xf86ScaleAxis(x, 0, screen_width, dev_min, dev_max);
|
2003-11-14 17:49:22 +01:00
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
int X;
|
2010-10-13 07:53:59 +02:00
|
|
|
int64_t to_width = to_max - to_min;
|
|
|
|
int64_t from_width = from_max - from_min;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2010-10-13 07:53:59 +02:00
|
|
|
if (from_width) {
|
2012-03-21 20:55:09 +01:00
|
|
|
X = (int) (((to_width * (Cx - from_min)) / from_width) + to_min);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
X = 0;
|
|
|
|
ErrorF("Divide by Zero in xf86ScaleAxis\n");
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-10-13 07:53:59 +02:00
|
|
|
if (X > to_max)
|
2012-03-21 20:55:09 +01:00
|
|
|
X = to_max;
|
2010-10-13 07:53:59 +02:00
|
|
|
if (X < to_min)
|
2012-03-21 20:55:09 +01:00
|
|
|
X = to_min;
|
|
|
|
|
2010-06-06 16:18:40 +02:00
|
|
|
return X;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2011-09-23 04:03:48 +02:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
|
|
|
|
int maxval, int resolution, int min_res, int max_res,
|
|
|
|
int mode)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2006-07-21 21:23:37 +02:00
|
|
|
if (!dev || !dev->valuator)
|
2011-09-23 04:03:48 +02:00
|
|
|
return FALSE;
|
2006-07-21 21:23:37 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution,
|
|
|
|
min_res, max_res, mode);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-08-12 07:55:48 +02:00
|
|
|
* Set the valuator values to be in sync with dix/event.c
|
2003-11-14 17:49:22 +01:00
|
|
|
* DefineInitialRootWindow().
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:49:22 +01:00
|
|
|
xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
|
|
|
|
{
|
2006-07-21 21:23:37 +02:00
|
|
|
if (axnum == 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
|
2008-05-23 04:21:53 +02:00
|
|
|
dev->last.valuators[0] = dev->valuator->axisVal[0];
|
2006-07-21 21:23:37 +02:00
|
|
|
}
|
|
|
|
else if (axnum == 1) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
|
2008-05-23 04:21:53 +02:00
|
|
|
dev->last.valuators[1] = dev->valuator->axisVal[1];
|
2006-07-21 21:23:37 +02:00
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2007-04-24 14:04:47 +02:00
|
|
|
/**
|
|
|
|
* Deactivate a device. Call this function from the driver if you receive a
|
|
|
|
* read error or something else that spoils your day.
|
|
|
|
* Device will be moved to the off_devices list, but it will still be there
|
|
|
|
* until you really clean up after it.
|
|
|
|
* Notifies the client about an inactive device.
|
2007-04-24 15:22:33 +02:00
|
|
|
*
|
|
|
|
* @param panic True if device is unrecoverable and needs to be removed.
|
2007-04-24 14:04:47 +02:00
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-04-24 15:22:33 +02:00
|
|
|
xf86DisableDevice(DeviceIntPtr dev, Bool panic)
|
2007-04-24 14:04:47 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!panic) {
|
2009-05-12 08:09:35 +02:00
|
|
|
DisableDevice(dev, TRUE);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2009-09-17 08:01:29 +02:00
|
|
|
SendDevicePresenceEvent(dev->id, DeviceUnrecoverable);
|
2010-05-26 16:54:35 +02:00
|
|
|
DeleteInputDeviceRequest(dev);
|
2007-04-24 15:22:33 +02:00
|
|
|
}
|
2007-04-24 14:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reactivate a device. Call this function from the driver if you just found
|
|
|
|
* out that the read error wasn't quite that bad after all.
|
|
|
|
* Device will be re-activated, and an event sent to the client.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-04-24 14:04:47 +02:00
|
|
|
xf86EnableDevice(DeviceIntPtr dev)
|
|
|
|
{
|
2009-05-12 08:09:35 +02:00
|
|
|
EnableDevice(dev, TRUE);
|
2007-04-24 14:04:47 +02:00
|
|
|
}
|
|
|
|
|
2011-12-14 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* Post a touch event with optional valuators. If this is the first touch in
|
|
|
|
* the sequence, at least x & y valuators must be provided. The driver is
|
|
|
|
* responsible for maintaining the correct event sequence (TouchBegin, TouchUpdate,
|
|
|
|
* TouchEnd). Submitting an update or end event for a unregistered touchid will
|
|
|
|
* result in errors.
|
|
|
|
* Touch IDs may be reused by the driver but only after a TouchEnd has been
|
|
|
|
* submitted for that touch ID.
|
|
|
|
*
|
|
|
|
* @param dev The device to post the event for
|
|
|
|
* @param touchid The touchid of the current touch event. Must be an
|
|
|
|
* existing ID for TouchUpdate or TouchEnd events
|
|
|
|
* @param type One of XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd
|
|
|
|
* @param flags Flags for this event
|
|
|
|
* @param The valuator mask with all valuators set for this event.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid, uint16_t type,
|
|
|
|
uint32_t flags, const ValuatorMask *mask)
|
|
|
|
{
|
|
|
|
|
|
|
|
QueueTouchEvents(dev, type, touchid, flags, mask);
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:21:38 +01:00
|
|
|
void
|
|
|
|
xf86InputEnableVTProbe(void)
|
|
|
|
{
|
|
|
|
int i, is_auto = 0;
|
|
|
|
InputOption *option = NULL;
|
|
|
|
DeviceIntPtr pdev;
|
|
|
|
|
|
|
|
for (i = 0; i < new_input_devices_count; i++) {
|
|
|
|
InputInfoPtr pInfo = new_input_devices[i];
|
|
|
|
|
|
|
|
is_auto = 0;
|
|
|
|
nt_list_for_each_entry(option, pInfo->options, list.next) {
|
|
|
|
const char *key = input_option_get_key(option);
|
|
|
|
const char *value = input_option_get_value(option);
|
|
|
|
|
|
|
|
if (strcmp(key, "_source") == 0 &&
|
|
|
|
(strcmp(value, "server/hal") == 0 ||
|
|
|
|
strcmp(value, "server/udev") == 0 ||
|
|
|
|
strcmp(value, "server/wscons") == 0))
|
|
|
|
is_auto = 1;
|
|
|
|
}
|
|
|
|
xf86NewInputDevice(pInfo, &pdev,
|
|
|
|
(!is_auto ||
|
|
|
|
(is_auto && xf86Info.autoEnableDevices)));
|
|
|
|
}
|
|
|
|
new_input_devices_count = 0;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* end of xf86Xinput.c */
|