aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common/xf86Xinput.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-11-14 21:29:32 +0000
committermarha <marha@users.sourceforge.net>2010-11-14 21:29:32 +0000
commit3425b16d521b8846b95df2b7d32a548d93341f3b (patch)
treefa430e95285d90f990b2d5574dad1e409ba5980c /xorg-server/hw/xfree86/common/xf86Xinput.c
parent41c64098a90b4e974d5005a1619472f2e8a64ea1 (diff)
downloadvcxsrv-3425b16d521b8846b95df2b7d32a548d93341f3b.tar.gz
vcxsrv-3425b16d521b8846b95df2b7d32a548d93341f3b.tar.bz2
vcxsrv-3425b16d521b8846b95df2b7d32a548d93341f3b.zip
xserver pixman libX11 libXext 14/11/2010
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86Xinput.c')
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c553
1 files changed, 289 insertions, 264 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index 3542abd4a..e90268a06 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -59,23 +59,15 @@
#include "xf86Priv.h"
#include "xf86Config.h"
#include "xf86Xinput.h"
-#include "XIstubs.h"
#include "xf86Optrec.h"
-#include "xf86Parser.h"
#include "mipointer.h"
-#include "xf86InPriv.h"
-#include "compiler.h"
#include "extinit.h"
#include "loaderProcs.h"
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-
#include "exevents.h" /* AddInputDevice */
#include "exglobals.h"
#include "eventstr.h"
+#include "inpututils.h"
#include <string.h> /* InputClassMatches */
#ifdef HAVE_FNMATCH_H
@@ -85,15 +77,9 @@
#include <sys/utsname.h>
#endif
-#include "extnsionst.h"
-
-#include "windowstr.h" /* screenIsSaved */
-
#include <stdarg.h>
#include <stdint.h> /* for int64_t */
-#include <X11/Xpoll.h>
-
#include "mi.h"
#include <ptrveloc.h> /* dix pointer acceleration */
@@ -105,10 +91,19 @@
#include "xkbsrv.h"
-#include "os.h"
+/* 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; \
+ }
EventListPtr xf86Events = NULL;
+static int
+xf86InputDevicePostInit(DeviceIntPtr dev);
+
/**
* Eval config and modify DeviceVelocityRec accordingly
*/
@@ -203,11 +198,11 @@ static void
ApplyAccelerationSettings(DeviceIntPtr dev){
int scheme, i;
DeviceVelocityPtr pVel;
- LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
char* schemeStr;
if (dev->valuator && dev->ptrfeed) {
- schemeStr = xf86SetStrOption(local->options, "AccelerationScheme", "");
+ schemeStr = xf86SetStrOption(pInfo->options, "AccelerationScheme", "");
scheme = dev->valuator->accelScheme.number;
@@ -228,15 +223,15 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
if (InitPointerAccelerationScheme(dev, scheme)) {
xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
- local->name, schemeStr, scheme);
+ pInfo->name, schemeStr, scheme);
} else {
xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
- local->name, schemeStr);
+ pInfo->name, schemeStr);
scheme = dev->valuator->accelScheme.number;
}
} else {
xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
- local->name, scheme);
+ pInfo->name, scheme);
}
free(schemeStr);
@@ -245,45 +240,34 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
switch (scheme) {
case PtrAccelPredictable:
pVel = GetDevicePredictableAccelData(dev);
- ProcessVelocityConfiguration (dev, local->name, local->options,
+ ProcessVelocityConfiguration (dev, pInfo->name, pInfo->options,
pVel);
break;
}
- i = xf86SetIntOption(local->options, "AccelerationNumerator",
+ i = xf86SetIntOption(pInfo->options, "AccelerationNumerator",
dev->ptrfeed->ctrl.num);
if (i >= 0)
dev->ptrfeed->ctrl.num = i;
- i = xf86SetIntOption(local->options, "AccelerationDenominator",
+ i = xf86SetIntOption(pInfo->options, "AccelerationDenominator",
dev->ptrfeed->ctrl.den);
if (i > 0)
dev->ptrfeed->ctrl.den = i;
- i = xf86SetIntOption(local->options, "AccelerationThreshold",
+ i = xf86SetIntOption(pInfo->options, "AccelerationThreshold",
dev->ptrfeed->ctrl.threshold);
if (i >= 0)
dev->ptrfeed->ctrl.threshold = i;
xf86Msg(X_CONFIG, "%s: (accel) acceleration factor: %.3f\n",
- local->name, ((float)dev->ptrfeed->ctrl.num)/
+ pInfo->name, ((float)dev->ptrfeed->ctrl.num)/
((float)dev->ptrfeed->ctrl.den));
xf86Msg(X_CONFIG, "%s: (accel) acceleration threshold: %i\n",
- local->name, dev->ptrfeed->ctrl.threshold);
+ pInfo->name, dev->ptrfeed->ctrl.threshold);
}
}
-static Bool
-xf86SendDragEvents(DeviceIntPtr device)
-{
- LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
-
- if (device->button && device->button->buttonsDown > 0)
- return local->flags & XI86_SEND_DRAG_EVENTS;
- else
- return TRUE;
-}
-
/***********************************************************************
*
* xf86ProcessCommonOptions --
@@ -293,27 +277,18 @@ xf86SendDragEvents(DeviceIntPtr device)
***********************************************************************
*/
void
-xf86ProcessCommonOptions(LocalDevicePtr local,
+xf86ProcessCommonOptions(InputInfoPtr pInfo,
pointer list)
{
if (!xf86SetBoolOption(list, "AlwaysCore", 1) ||
!xf86SetBoolOption(list, "SendCoreEvents", 1) ||
!xf86SetBoolOption(list, "CorePointer", 1) ||
!xf86SetBoolOption(list, "CoreKeyboard", 1)) {
- xf86Msg(X_CONFIG, "%s: doesn't report core events\n", local->name);
- } else {
- local->flags |= XI86_ALWAYS_CORE;
- xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
- }
-
- if (xf86SetBoolOption(list, "SendDragEvents", 1)) {
- local->flags |= XI86_SEND_DRAG_EVENTS;
+ xf86Msg(X_CONFIG, "%s: doesn't report core events\n", pInfo->name);
} else {
- xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
+ pInfo->flags |= XI86_ALWAYS_CORE;
+ xf86Msg(X_CONFIG, "%s: always reports core events\n", pInfo->name);
}
-
- /* Backwards compatibility. */
- local->history_size = GetMotionHistorySize();
}
/***********************************************************************
@@ -325,86 +300,38 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
* Returns TRUE on success, or FALSE otherwise.
***********************************************************************
*/
-int
-xf86ActivateDevice(LocalDevicePtr local)
+static DeviceIntPtr
+xf86ActivateDevice(InputInfoPtr pInfo)
{
DeviceIntPtr dev;
+ Atom atom;
- if (local->flags & XI86_CONFIGURED) {
- dev = AddInputDevice(serverClient, local->device_control, TRUE);
+ dev = AddInputDevice(serverClient, pInfo->device_control, TRUE);
- if (dev == NULL)
- {
- xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
- local->name);
- local->dev = NULL;
- return FALSE;
- }
-
- local->atom = MakeAtom(local->type_name,
- strlen(local->type_name),
- TRUE);
- AssignTypeAndName(dev, local->atom, local->name);
- dev->public.devicePrivate = (pointer) local;
- local->dev = dev;
-
- dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
- dev->type = SLAVE;
- dev->spriteInfo->spriteOwner = FALSE;
-
- dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
- dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
-
- RegisterOtherDevice(dev);
- XkbSetExtension(dev, ProcessKeyboardEvent);
-
- if (serverGeneration == 1)
- xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
- local->name, local->type_name);
+ if (dev == NULL)
+ {
+ xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
+ pInfo->name);
+ pInfo->dev = NULL;
+ return NULL;
}
- return TRUE;
-}
+ atom = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE);
+ AssignTypeAndName(dev, atom, pInfo->name);
+ dev->public.devicePrivate = pInfo;
+ pInfo->dev = dev;
+ dev->coreEvents = pInfo->flags & XI86_ALWAYS_CORE;
+ dev->type = SLAVE;
+ dev->spriteInfo->spriteOwner = FALSE;
-/***********************************************************************
- *
- * Caller: ProcXOpenDevice
- *
- * This is the implementation-dependent routine to open an input device.
- * Some implementations open all input devices when the server is first
- * initialized, and never close them. Other implementations open only
- * the X pointer and keyboard devices during server initialization,
- * and only open other input devices when some client makes an
- * XOpenDevice request. This entry point is for the latter type of
- * implementation.
- *
- * If the physical device is not already open, do it here. In this case,
- * you need to keep track of the fact that one or more clients has the
- * device open, and physically close it when the last client that has
- * it open does an XCloseDevice.
- *
- * The default implementation is to do nothing (assume all input devices
- * are opened during X server initialization and kept open).
- *
- ***********************************************************************
- */
+ dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
-void
-OpenInputDevice(DeviceIntPtr dev,
- ClientPtr client,
- int *status)
-{
- if (!dev->inited)
- ActivateDevice(dev, TRUE);
+ if (serverGeneration == 1)
+ xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
+ pInfo->name, pInfo->type_name);
- *status = Success;
-}
-
-void
-CloseInputDevice(DeviceIntPtr dev,
- ClientPtr client)
-{
+ return dev;
}
/****************************************************************************
@@ -423,10 +350,10 @@ CloseInputDevice(DeviceIntPtr dev,
int
SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
{
- LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
- if (local->switch_mode) {
- return (*local->switch_mode)(client, dev, mode);
+ if (pInfo->switch_mode) {
+ return (*pInfo->switch_mode)(client, dev, mode);
}
else
return BadMatch;
@@ -450,10 +377,10 @@ int
SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
int first_valuator, int num_valuators)
{
- LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
- if (local->set_device_valuators)
- return (*local->set_device_valuators)(local, valuators, first_valuator,
+ if (pInfo->set_device_valuators)
+ return (*pInfo->set_device_valuators)(pInfo, valuators, first_valuator,
num_valuators);
return BadMatch;
@@ -472,9 +399,9 @@ SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
int
ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
{
- LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
- if (!local->control_proc) {
+ if (!pInfo->control_proc) {
switch (control->control) {
case DEVICE_CORE:
return BadMatch;
@@ -488,15 +415,10 @@ ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
}
}
else {
- return (*local->control_proc)(local, control);
+ return (*pInfo->control_proc)(pInfo, control);
}
}
-void
-AddOtherInputDevices(void)
-{
-}
-
/*
* Get the operating system name from uname and store it statically to avoid
* repeating the system call each time MatchOS is checked.
@@ -592,7 +514,7 @@ MatchAttrToken(const char *attr, struct list *patterns,
* statements must match.
*/
static Bool
-InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
+InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
const InputAttributes *attrs)
{
/* MatchProduct substring */
@@ -672,7 +594,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
* well as any previous InputClass sections.
*/
static int
-MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
+MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
XF86OptionPtr classopts;
@@ -697,9 +619,8 @@ MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
/* Apply options to device with InputClass settings preferred. */
xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
- idev->identifier, cl->identifier);
- idev->commonOptions = xf86optionListMerge(idev->commonOptions,
- classopts);
+ idev->name, cl->identifier);
+ idev->options = xf86optionListMerge(idev->options, classopts);
}
return Success;
@@ -710,7 +631,7 @@ MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
* value of the last matching class and holler when returning TRUE.
*/
static Bool
-IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
+IgnoreInputClass(const InputInfoPtr idev, const InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
Bool ignore = FALSE;
@@ -727,10 +648,95 @@ IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
if (ignore)
xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n",
- idev->identifier, ignore_class);
+ idev->name, ignore_class);
return ignore;
}
+static InputInfoPtr
+xf86AllocateInput(void)
+{
+ InputInfoPtr pInfo;
+
+ 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;
+
+ pInfo->drv = drv;
+ pInfo->module = DuplicateModule(drv->module, NULL);
+
+ for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
+ ;
+
+ *prev = pInfo;
+ pInfo->next = NULL;
+
+ xf86CollectInputOptions(pInfo, (const char**)drv->default_options);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+}
+
+/*
+ * Remove an entry from xf86InputDevs and free all the device's information.
+ */
+void
+xf86DeleteInput(InputInfoPtr pInp, int flags)
+{
+ /* First check if the inputdev is valid. */
+ if (pInp == NULL)
+ return;
+
+ if (pInp->module)
+ UnloadModule(pInp->module);
+
+ /* 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);
+
+ /* Remove the entry from the list. */
+ if (pInp == xf86InputDevs)
+ xf86InputDevs = pInp->next;
+ else {
+ 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). */
+ }
+
+ free(pInp->driver);
+ free(pInp->name);
+ xf86optionListFree(pInp->options);
+ free(pInp);
+}
+
+/*
+ * Apply backend-specific initialization. Invoked after ActiveteDevice(),
+ * 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
+xf86InputDevicePostInit(DeviceIntPtr dev) {
+ ApplyAccelerationSettings(dev);
+ return Success;
+}
+
/**
* Create a new input device, activate and enable it.
*
@@ -749,21 +755,20 @@ IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
* @return Success or an error code
*/
_X_INTERNAL int
-xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
+xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
{
InputDriverPtr drv = NULL;
- InputInfoPtr pInfo = NULL;
DeviceIntPtr dev = NULL;
int rval;
/* Memory leak for every attached device if we don't
* test if the module is already loaded first */
- drv = xf86LookupInputDriver(idev->driver);
+ drv = xf86LookupInputDriver(pInfo->driver);
if (!drv)
- if (xf86LoadOneModule(idev->driver, NULL))
- drv = xf86LookupInputDriver(idev->driver);
+ if (xf86LoadOneModule(pInfo->driver, NULL))
+ drv = xf86LookupInputDriver(pInfo->driver);
if (!drv) {
- xf86Msg(X_ERROR, "No input driver matching `%s'\n", idev->driver);
+ xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver);
rval = BadName;
goto unwind;
}
@@ -776,42 +781,44 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
goto unwind;
}
- pInfo = drv->PreInit(drv, idev, 0);
+ xf86AddInput(drv, pInfo);
- if (!pInfo) {
- xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
- rval = BadMatch;
- goto unwind;
- }
- else if (!(pInfo->flags & XI86_CONFIGURED)) {
- xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
- idev->identifier);
- rval = BadMatch;
+ rval = drv->PreInit(drv, pInfo, 0);
+
+ if (rval != Success) {
+ xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, pInfo->name);
goto unwind;
}
- if (!xf86ActivateDevice(pInfo))
+ if (!(dev = xf86ActivateDevice(pInfo)))
{
rval = BadAlloc;
goto unwind;
}
- dev = pInfo->dev;
rval = ActivateDevice(dev, TRUE);
if (rval != Success)
{
- xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
+ xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
RemoveDevice(dev, TRUE);
goto unwind;
}
+ rval = xf86InputDevicePostInit(dev);
+ if (rval != Success)
+ {
+ xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
+ RemoveDevice(dev, TRUE);
+ goto unwind;
+ }
+
/* Enable it if it's properly initialised and we're currently in the VT */
if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
{
EnableDevice(dev, TRUE);
if (!dev->enabled)
{
- xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
+ xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
rval = BadMatch;
goto unwind;
}
@@ -824,7 +831,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
unwind:
if(pInfo) {
- if(drv->UnInit)
+ if(drv && drv->UnInit)
drv->UnInit(drv, pInfo, 0);
else
xf86DeleteInput(pInfo, 0);
@@ -836,23 +843,23 @@ int
NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
DeviceIntPtr *pdev)
{
- IDevRec *idev = NULL;
+ InputInfoPtr pInfo = NULL;
InputOption *option = NULL;
int rval = Success;
int is_auto = 0;
- idev = calloc(sizeof(*idev), 1);
- if (!idev)
+ pInfo = xf86AllocateInput();
+ if (!pInfo)
return BadAlloc;
for (option = options; option; option = option->next) {
if (strcasecmp(option->key, "driver") == 0) {
- if (idev->driver) {
+ if (pInfo->driver) {
rval = BadRequest;
goto unwind;
}
- idev->driver = xstrdup(option->value);
- if (!idev->driver) {
+ pInfo->driver = xstrdup(option->value);
+ if (!pInfo->driver) {
rval = BadAlloc;
goto unwind;
}
@@ -860,12 +867,12 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
if (strcasecmp(option->key, "name") == 0 ||
strcasecmp(option->key, "identifier") == 0) {
- if (idev->identifier) {
+ if (pInfo->name) {
rval = BadRequest;
goto unwind;
}
- idev->identifier = xstrdup(option->value);
- if (!idev->identifier) {
+ pInfo->name = xstrdup(option->value);
+ if (!pInfo->name) {
rval = BadAlloc;
goto unwind;
}
@@ -885,7 +892,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
for (option = options; option; option = option->next) {
/* Steal option key/value strings from the provided list.
* We need those strings, the InputOption list doesn't. */
- idev->commonOptions = xf86addNewOption(idev->commonOptions,
+ pInfo->options = xf86addNewOption(pInfo->options,
option->key, option->value);
option->key = NULL;
option->value = NULL;
@@ -893,58 +900,51 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
/* Apply InputClass settings */
if (attrs) {
- if (IgnoreInputClass(idev, attrs)) {
+ if (IgnoreInputClass(pInfo, attrs)) {
rval = BadIDChoice;
goto unwind;
}
- rval = MergeInputClasses(idev, attrs);
+ rval = MergeInputClasses(pInfo, attrs);
if (rval != Success)
goto unwind;
- idev->attrs = DuplicateInputAttributes(attrs);
+ pInfo->attrs = DuplicateInputAttributes(attrs);
}
- if (!idev->driver || !idev->identifier) {
+ if (!pInfo->driver || !pInfo->name) {
xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n");
rval = BadRequest;
goto unwind;
}
- if (!idev->identifier) {
+ if (!pInfo->name) {
xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
- return BadMatch;
+ rval = BadMatch;
+ goto unwind;
}
- rval = xf86NewInputDevice(idev, pdev,
+ rval = xf86NewInputDevice(pInfo, pdev,
(!is_auto || (is_auto && xf86Info.autoEnableDevices)));
- if (rval == Success)
- return Success;
+
+ return rval;
unwind:
if (is_auto && !xf86Info.autoAddDevices)
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
- free(idev->driver);
- free(idev->identifier);
- xf86optionListFree(idev->commonOptions);
- free(idev);
+ xf86DeleteInput(pInfo, 0);
return rval;
}
void
DeleteInputDeviceRequest(DeviceIntPtr pDev)
{
- LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
+ InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate;
InputDriverPtr drv = NULL;
- IDevRec *idev = NULL;
- IDevPtr *it;
Bool isMaster = IsMaster(pDev);
if (pInfo) /* need to get these before RemoveDevice */
- {
drv = pInfo->drv;
- idev = pInfo->conf_idev;
- }
OsBlockSignals();
RemoveDevice(pDev, TRUE);
@@ -955,19 +955,6 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
drv->UnInit(drv, pInfo, 0);
else
xf86DeleteInput(pInfo, 0);
-
- /* devices added through HAL aren't in the config layout */
- it = xf86ConfigLayout.inputs;
- while(*it && *it != idev)
- it++;
-
- if (!(*it)) /* end of list, not in the layout */
- {
- free(idev->driver);
- free(idev->identifier);
- xf86optionListFree(idev->commonOptions);
- free(idev);
- }
}
OsReleaseSignals();
}
@@ -985,16 +972,17 @@ xf86PostMotionEvent(DeviceIntPtr device,
{
va_list var;
int i = 0;
- static int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
XI_VERIFY_VALUATORS(num_valuators);
+ valuator_mask_zero(&mask);
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
- valuators[i] = va_arg(var, int);
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
va_end(var);
- xf86PostMotionEventP(device, is_absolute, first_valuator, num_valuators, valuators);
+ xf86PostMotionEventM(device, is_absolute, &mask);
}
void
@@ -1002,10 +990,22 @@ xf86PostMotionEventP(DeviceIntPtr device,
int is_absolute,
int first_valuator,
int num_valuators,
- int *valuators)
+ const int *valuators)
+{
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostMotionEventM(device, is_absolute, &mask);
+}
+
+void
+xf86PostMotionEventM(DeviceIntPtr device,
+ int is_absolute,
+ const ValuatorMask *mask)
{
int i = 0, nevents = 0;
- Bool drag = xf86SendDragEvents(device);
DeviceEvent *event;
int flags = 0;
@@ -1014,8 +1014,6 @@ xf86PostMotionEventP(DeviceIntPtr device,
int dx = 0, dy = 0;
#endif
- XI_VERIFY_VALUATORS(num_valuators);
-
if (is_absolute)
flags = POINTER_ABSOLUTE;
else
@@ -1023,19 +1021,20 @@ xf86PostMotionEventP(DeviceIntPtr device,
#if XFreeXDGA
/* The evdev driver may not always send all axes across. */
- if (num_valuators >= 1 && first_valuator <= 1) {
+ if (valuator_mask_isset(mask, 0) ||
+ valuator_mask_isset(mask, 1))
if (miPointerGetScreen(device)) {
index = miPointerGetScreen(device)->myNum;
- if (first_valuator == 0)
+ if (valuator_mask_isset(mask, 0))
{
- dx = valuators[0];
+ dx = valuator_mask_get(mask, 0);
if (is_absolute)
dx -= device->last.valuators[0];
}
- if (first_valuator == 1 || num_valuators >= 2)
+ if (valuator_mask_isset(mask, 1))
{
- dy = valuators[1 - first_valuator];
+ dy = valuator_mask_get(mask, 1);
if (is_absolute)
dy -= device->last.valuators[1];
}
@@ -1043,21 +1042,13 @@ xf86PostMotionEventP(DeviceIntPtr device,
if (DGAStealMotionEvent(device, index, dx, dy))
return;
}
- }
#endif
- nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
- flags, first_valuator, num_valuators,
- valuators);
+ nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
for (i = 0; i < nevents; i++) {
event = (DeviceEvent*)((xf86Events + i)->event);
- /* Don't post core motion events for devices not registered to send
- * drag events. */
- if (event->header == ET_Internal &&
- (event->type != ET_Motion || drag)) {
- mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
- }
+ mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
}
}
@@ -1070,18 +1061,17 @@ xf86PostProximityEvent(DeviceIntPtr device,
{
va_list var;
int i;
- int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
XI_VERIFY_VALUATORS(num_valuators);
+ valuator_mask_zero(&mask);
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
- valuators[i] = va_arg(var, int);
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
va_end(var);
- xf86PostProximityEventP(device, is_in, first_valuator, num_valuators,
- valuators);
-
+ xf86PostProximityEventM(device, is_in, &mask);
}
void
@@ -1089,15 +1079,25 @@ xf86PostProximityEventP(DeviceIntPtr device,
int is_in,
int first_valuator,
int num_valuators,
- int *valuators)
+ const int *valuators)
{
- int i, nevents;
+ ValuatorMask mask;
XI_VERIFY_VALUATORS(num_valuators);
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostProximityEventM(device, is_in, &mask);
+}
+
+void
+xf86PostProximityEventM(DeviceIntPtr device,
+ int is_in,
+ const ValuatorMask *mask)
+{
+ int i, nevents;
+
nevents = GetProximityEvents(xf86Events, device,
- is_in ? ProximityIn : ProximityOut,
- first_valuator, num_valuators, valuators);
+ is_in ? ProximityIn : ProximityOut, mask);
for (i = 0; i < nevents; i++)
mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
@@ -1113,19 +1113,19 @@ xf86PostButtonEvent(DeviceIntPtr device,
...)
{
va_list var;
- int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
int i = 0;
XI_VERIFY_VALUATORS(num_valuators);
+ valuator_mask_zero(&mask);
+
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
- valuators[i] = va_arg(var, int);
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
va_end(var);
- xf86PostButtonEventP(device, is_absolute, button, is_down, first_valuator,
- num_valuators, valuators);
-
+ xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
}
void
@@ -1135,7 +1135,22 @@ xf86PostButtonEventP(DeviceIntPtr device,
int is_down,
int first_valuator,
int num_valuators,
- int *valuators)
+ const int *valuators)
+{
+ 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
+xf86PostButtonEventM(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down,
+ const ValuatorMask *mask)
{
int i = 0, nevents = 0;
int flags = 0;
@@ -1144,8 +1159,6 @@ xf86PostButtonEventP(DeviceIntPtr device,
int index;
#endif
- XI_VERIFY_VALUATORS(num_valuators);
-
if (is_absolute)
flags = POINTER_ABSOLUTE;
else
@@ -1161,7 +1174,7 @@ xf86PostButtonEventP(DeviceIntPtr device,
nevents = GetPointerEvents(xf86Events, device,
is_down ? ButtonPress : ButtonRelease, button,
- flags, first_valuator, num_valuators, valuators);
+ flags, mask);
for (i = 0; i < nevents; i++)
mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
@@ -1179,18 +1192,18 @@ xf86PostKeyEvent(DeviceIntPtr device,
{
va_list var;
int i = 0;
- static int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
XI_VERIFY_VALUATORS(num_valuators);
+ valuator_mask_zero(&mask);
+
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
- valuators[i] = va_arg(var, int);
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
va_end(var);
- xf86PostKeyEventP(device, key_code, is_down, is_absolute, first_valuator,
- num_valuators, valuators);
-
+ xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
}
void
@@ -1200,17 +1213,29 @@ xf86PostKeyEventP(DeviceIntPtr device,
int is_absolute,
int first_valuator,
int num_valuators,
- int *valuators)
+ const int *valuators)
{
- int i = 0, nevents = 0;
+ ValuatorMask mask;
XI_VERIFY_VALUATORS(num_valuators);
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
+}
+
+void
+xf86PostKeyEventM(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute,
+ const ValuatorMask *mask)
+{
+ int i = 0, nevents = 0;
+
if (is_absolute) {
nevents = GetKeyboardValuatorEvents(xf86Events, device,
is_down ? KeyPress : KeyRelease,
- key_code, first_valuator,
- num_valuators, valuators);
+ key_code, mask);
}
else {
nevents = GetKeyboardEvents(xf86Events, device,
@@ -1227,10 +1252,13 @@ xf86PostKeyboardEvent(DeviceIntPtr device,
unsigned int key_code,
int is_down)
{
- xf86PostKeyEventP(device, key_code, is_down, 0, 0, 0, NULL);
+ ValuatorMask mask;
+
+ valuator_mask_zero(&mask);
+ xf86PostKeyEventM(device, key_code, is_down, 0, &mask);
}
-LocalDevicePtr
+InputInfoPtr
xf86FirstLocalDevice(void)
{
return xf86InputDevs;
@@ -1286,27 +1314,27 @@ xf86ScaleAxis(int Cx,
* specific like a touch screen.
*/
void
-xf86XInputSetScreen(LocalDevicePtr local,
+xf86XInputSetScreen(InputInfoPtr pInfo,
int screen_number,
int x,
int y)
{
- if (miPointerGetScreen(local->dev) !=
+ if (miPointerGetScreen(pInfo->dev) !=
screenInfo.screens[screen_number]) {
- miPointerSetScreen(local->dev, screen_number, x, y);
+ miPointerSetScreen(pInfo->dev, screen_number, x, y);
}
}
void
xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
- int resolution, int min_res, int max_res)
+ int resolution, int min_res, int max_res, int mode)
{
if (!dev || !dev->valuator)
return;
InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
- max_res);
+ max_res, mode);
}
/*
@@ -1324,9 +1352,6 @@ xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
dev->last.valuators[1] = dev->valuator->axisVal[1];
}
-
- if(axnum == 0) /* to prevent double invocation */
- ApplyAccelerationSettings(dev);
}