aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common/xf86Xinput.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86Xinput.c')
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c516
1 files changed, 367 insertions, 149 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index 710e787fd..1f412349c 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -52,19 +52,17 @@
#include <X11/Xfuncproto.h>
#include <X11/Xmd.h>
-#ifdef XINPUT
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#endif
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Xinput.h"
-#ifdef XINPUT
#include "XIstubs.h"
#include "xf86Optrec.h"
-#endif
#include "mipointer.h"
#include "xf86InPriv.h"
+#include "compiler.h"
+#include "extinit.h"
#ifdef DPMSExtension
#define DPMS_SERVER
@@ -86,11 +84,157 @@
#include "mi.h"
+#include <ptrveloc.h> /* dix pointer acceleration */
+
#ifdef XFreeXDGA
#include "dgaproc.h"
#endif
-xEvent *xf86Events = NULL;
+#ifdef XKB
+#include "xkbsrv.h"
+#endif
+
+#include "os.h"
+
+EventListPtr xf86Events = NULL;
+
+/**
+ * Eval config and modify DeviceVelocityRec accordingly
+ */
+static void
+ProcessVelocityConfiguration(char* devname, pointer list, DeviceVelocityPtr s){
+ int tempi, i;
+ float tempf, tempf2;
+
+ if(!s)
+ return;
+
+ tempf = xf86SetRealOption(list, "FilterHalflife", -1);
+ if(tempf > 0)
+ tempf = 1.0 / tempf; /* set reciprocal if possible */
+
+ tempf2 = xf86SetRealOption(list, "FilterChainProgression", 2.0);
+ xf86Msg(X_CONFIG, "%s: (accel) filter chain progression: %.2f\n",
+ devname, tempf2);
+ if(tempf2 < 1)
+ tempf2 = 2;
+
+ tempi = xf86SetIntOption(list, "FilterChainLength", 1);
+ if(tempi < 1 || tempi > MAX_VELOCITY_FILTERS)
+ tempi = 1;
+
+ if(tempf > 0.0f && tempi >= 1 && tempf2 >= 1.0f)
+ InitFilterChain(s, tempf, tempf2, tempi, 40);
+
+ for(i = 0; i < tempi; i++)
+ xf86Msg(X_CONFIG, "%s: (accel) filter stage %i: %.2f ms\n",
+ devname, i, 1.0f / (s->filters[i].rdecay));
+
+ tempf = xf86SetRealOption(list, "ConstantDeceleration", 1.0);
+ if(tempf > 1.0){
+ xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
+ devname, tempf);
+ s->const_acceleration = 1.0 / tempf; /* set reciprocal deceleration
+ alias acceleration */
+ }
+
+ tempf = xf86SetRealOption(list, "AdaptiveDeceleration", 1.0);
+ if(tempf > 1.0){
+ xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
+ devname, tempf);
+ s->min_acceleration = 1.0 / tempf; /* set minimum acceleration */
+ }
+
+ tempf = xf86SetRealOption(list, "VelocityCoupling", -1);
+ if(tempf >= 0){
+ xf86Msg(X_CONFIG, "%s: (accel) velocity coupling is %.1f%%\n", devname,
+ tempf*100.0);
+ s->coupling = tempf;
+ }
+
+ /* 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);
+
+ s->average_accel = xf86SetBoolOption(list, "AccelerationProfileAveraging",
+ s->average_accel);
+
+ s->reset_time = xf86SetIntOption(list, "VelocityReset", s->reset_time);
+
+ tempf = xf86SetRealOption(list, "ExpectedRate", 0);
+ if(tempf > 0){
+ s->corr_mul = 1000.0 / tempf;
+ }else{
+ s->corr_mul = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
+ }
+
+ /* select profile by number */
+ tempi= xf86SetIntOption(list, "AccelerationProfile",
+ s->statistics.profile_number);
+
+ if(SetAccelerationProfile(s, tempi)){
+ xf86Msg(X_CONFIG, "%s: (accel) set acceleration profile %i\n", devname, tempi);
+ }else{
+ xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
+ devname, tempi);
+ }
+}
+
+static void
+ApplyAccelerationSettings(DeviceIntPtr dev){
+ int scheme;
+ DeviceVelocityPtr pVel;
+ LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+ char* schemeStr;
+
+ if(dev->valuator){
+ schemeStr = xf86SetStrOption(local->options, "AccelerationScheme", "");
+
+ scheme = dev->valuator->accelScheme.number;
+
+ if(!xf86NameCmp(schemeStr, "predictable"))
+ scheme = PtrAccelPredictable;
+
+ if(!xf86NameCmp(schemeStr, "lightweight"))
+ scheme = PtrAccelLightweight;
+
+ if(!xf86NameCmp(schemeStr, "none"))
+ scheme = PtrAccelNoOp;
+
+ /* reinit scheme if needed */
+ if(dev->valuator->accelScheme.number != scheme){
+ if(dev->valuator->accelScheme.AccelCleanupProc){
+ dev->valuator->accelScheme.AccelCleanupProc(dev);
+ }
+
+ if(InitPointerAccelerationScheme(dev, scheme)){
+ xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
+ local->name, schemeStr, scheme);
+ }else{
+ xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
+ local->name, schemeStr);
+ scheme = dev->valuator->accelScheme.number;
+ }
+ }else{
+ xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
+ local->name, scheme);
+ }
+
+ xfree(schemeStr);
+
+ /* process special configuration */
+ switch(scheme){
+ case PtrAccelPredictable:
+ pVel = GetDevicePredictableAccelData(dev);
+ ProcessVelocityConfiguration (local->name, local->options,
+ pVel);
+ break;
+ }
+ }
+}
static Bool
xf86SendDragEvents(DeviceIntPtr device)
@@ -135,7 +279,7 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
local->history_size = GetMotionHistorySize();
/* Preallocate xEvent store */
if (!xf86Events)
- xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ GetEventList(&xf86Events);
if (!xf86Events)
FatalError("Couldn't allocate event store\n");
}
@@ -143,22 +287,28 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
/***********************************************************************
*
* xf86ActivateDevice --
- *
+ *
* Initialize an input device.
*
+ * Returns TRUE on success, or FALSE otherwise.
***********************************************************************
*/
-_X_EXPORT void
+_X_EXPORT int
xf86ActivateDevice(LocalDevicePtr local)
{
DeviceIntPtr dev;
if (local->flags & XI86_CONFIGURED) {
- dev = AddInputDevice(local->device_control, TRUE);
+ dev = AddInputDevice(serverClient, local->device_control, TRUE);
if (dev == NULL)
- FatalError("Too many input devices");
-
+ {
+ 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);
@@ -166,9 +316,21 @@ xf86ActivateDevice(LocalDevicePtr local)
dev->public.devicePrivate = (pointer) local;
local->dev = dev;
- dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
- RegisterOtherDevice(dev);
+ dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
+ dev->isMaster = FALSE;
+ dev->spriteInfo->spriteOwner = FALSE;
+
+ if (DeviceIsPointerType(dev))
+ {
+ dev->deviceGrab.ActivateGrab = ActivatePointerGrab;
+ dev->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
+ } else
+ {
+ dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
+ dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+ }
+ RegisterOtherDevice(dev);
#ifdef XKB
if (!noXkbExtension)
XkbSetExtension(dev, ProcessKeyboardEvent);
@@ -178,10 +340,11 @@ xf86ActivateDevice(LocalDevicePtr local)
xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
local->name, local->type_name);
}
+
+ return TRUE;
}
-#ifdef XINPUT
/***********************************************************************
*
* Caller: ProcXOpenDevice
@@ -292,6 +455,7 @@ ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
if (!local->control_proc) {
switch (control->control) {
case DEVICE_CORE:
+ return BadMatch;
case DEVICE_RESOLUTION:
case DEVICE_ABS_CALIB:
case DEVICE_ABS_AREA:
@@ -310,16 +474,107 @@ void
AddOtherInputDevices()
{
}
-#endif
-int
-NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
+/**
+ * Create a new input device, activate and enable it.
+ *
+ * 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
+ *
+ * @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
+xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
{
- IDevRec *idev = NULL;
InputDriverPtr drv = NULL;
InputInfoPtr pInfo = NULL;
- InputOption *option = 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);
+ if (!drv)
+ if (xf86LoadOneModule(idev->driver, NULL))
+ drv = xf86LookupInputDriver(idev->driver);
+ if (!drv) {
+ xf86Msg(X_ERROR, "No input driver matching `%s'\n", idev->driver);
+ rval = BadName;
+ goto unwind;
+ }
+
+ if (!drv->PreInit) {
+ xf86Msg(X_ERROR,
+ "Input driver `%s' has no PreInit function (ignoring)\n",
+ drv->driverName);
+ rval = BadImplementation;
+ goto unwind;
+ }
+
+ pInfo = drv->PreInit(drv, idev, 0);
+
+ 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;
+ goto unwind;
+ }
+
+ if (!xf86ActivateDevice(pInfo))
+ {
+ rval = BadAlloc;
+ goto unwind;
+ }
+
+ dev = pInfo->dev;
+ rval = ActivateDevice(dev);
+ if (rval != Success)
+ {
+ xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
+ RemoveDevice(dev);
+ 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);
+ /* send enter/leave event, update sprite window */
+ CheckMotion(NULL, dev);
+ }
+
+ *pdev = dev;
+ return Success;
+
+unwind:
+ if(pInfo) {
+ if(drv->UnInit)
+ drv->UnInit(drv, pInfo, 0);
+ else
+ xf86DeleteInput(pInfo, 0);
+ }
+ return rval;
+}
+
+_X_EXPORT int
+NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
+{
+ IDevRec *idev = NULL;
+ InputOption *option = NULL;
int rval = Success;
int is_auto = 0;
@@ -333,18 +588,6 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
rval = BadRequest;
goto unwind;
}
- /* Memory leak for every attached device if we don't
- * test if the module is already loaded first */
- drv = xf86LookupInputDriver(option->value);
- if (!drv)
- if (xf86LoadOneModule(option->value, NULL))
- drv = xf86LookupInputDriver(option->value);
- if (!drv) {
- xf86Msg(X_ERROR, "No input driver matching `%s'\n",
- option->value);
- rval = BadName;
- goto unwind;
- }
idev->driver = xstrdup(option->value);
if (!idev->driver) {
rval = BadAlloc;
@@ -382,12 +625,9 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
goto unwind;
}
- if (!drv->PreInit) {
- xf86Msg(X_ERROR,
- "Input driver `%s' has no PreInit function (ignoring)\n",
- drv->driverName);
- rval = BadImplementation;
- goto unwind;
+ if (!idev->identifier) {
+ xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
+ return BadMatch;
}
for (option = options; option; option = option->next) {
@@ -399,40 +639,12 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
option->value = NULL;
}
- pInfo = drv->PreInit(drv, idev, 0);
-
- 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;
- goto unwind;
- }
-
- xf86ActivateDevice(pInfo);
-
- dev = pInfo->dev;
- ActivateDevice(dev);
- /* Enable it if it's properly initialised, we're currently in the VT, and
- * either it's a manual request, or we're automatically enabling devices. */
- if (dev->inited && dev->startup && xf86Screens[0]->vtSema &&
- (!is_auto || xf86Info.autoEnableDevices))
- EnableDevice(dev);
-
- *pdev = dev;
- return Success;
+ rval = xf86NewInputDevice(idev, pdev,
+ (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
+ if (rval == Success)
+ return Success;
unwind:
- if(pInfo) {
- if(drv->UnInit)
- drv->UnInit(drv, pInfo, 0);
- else
- xf86DeleteInput(pInfo, 0);
- }
if(idev->driver)
xfree(idev->driver);
if(idev->identifier)
@@ -442,50 +654,51 @@ unwind:
return rval;
}
-void
+_X_EXPORT void
DeleteInputDeviceRequest(DeviceIntPtr pDev)
{
LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
- InputDriverPtr drv;
- IDevRec *idev;
- BOOL found;
+ InputDriverPtr drv = NULL;
+ IDevRec *idev = NULL;
IDevPtr *it;
+ Bool isMaster = pDev->isMaster;
if (pInfo) /* need to get these before RemoveDevice */
{
drv = pInfo->drv;
idev = pInfo->conf_idev;
}
- RemoveDevice(pDev);
- if (!pInfo) /* VCP and VCK */
- return;
-
- if(drv->UnInit)
- 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++;
+ OsBlockSignals();
+ RemoveDevice(pDev);
- if (!(*it)) /* end of list, not in the layout */
+ if (!isMaster)
{
- xfree(idev->driver);
- xfree(idev->identifier);
- xf86optionListFree(idev->commonOptions);
- xfree(idev);
+ if(drv->UnInit)
+ 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 */
+ {
+ xfree(idev->driver);
+ xfree(idev->identifier);
+ xf86optionListFree(idev->commonOptions);
+ xfree(idev);
+ }
}
+ OsReleaseSignals();
}
/*
* convenient functions to post events
*/
-#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */
-
_X_EXPORT void
xf86PostMotionEvent(DeviceIntPtr device,
int is_absolute,
@@ -498,8 +711,8 @@ xf86PostMotionEvent(DeviceIntPtr device,
static int valuators[MAX_VALUATORS];
if (num_valuators > MAX_VALUATORS) {
- xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
- " is greater than MAX_VALUATORS\n", num_valuators);
+ xf86Msg(X_ERROR, "%s: num_valuator %d is greater than"
+ " MAX_VALUATORS\n", __FUNCTION__, num_valuators);
return;
}
@@ -519,15 +732,15 @@ xf86PostMotionEventP(DeviceIntPtr device,
int *valuators)
{
int i = 0, nevents = 0;
- int dx, dy;
+ int dx = 0, dy = 0;
Bool drag = xf86SendDragEvents(device);
xEvent *xE = NULL;
int index;
int flags = 0;
if (num_valuators > MAX_VALUATORS) {
- xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
- " is greater than MAX_VALUATORS\n", num_valuators);
+ xf86Msg(X_ERROR, "%s: num_valuator %d is greater than"
+ " MAX_VALUATORS\n", __FUNCTION__, num_valuators);
return;
}
@@ -537,36 +750,41 @@ xf86PostMotionEventP(DeviceIntPtr device,
flags = POINTER_RELATIVE | POINTER_ACCELERATE;
#if XFreeXDGA
- if (first_valuator == 0 && num_valuators >= 2) {
- if (miPointerGetScreen(inputInfo.pointer)) {
- index = miPointerGetScreen(inputInfo.pointer)->myNum;
- if (is_absolute) {
- dx = valuators[0] - device->valuator->lastx;
- dy = valuators[1] - device->valuator->lasty;
- }
- else {
+ /* The evdev driver may not always send all axes across. */
+ if (num_valuators >= 1 && first_valuator <= 1) {
+ if (miPointerGetScreen(device)) {
+ index = miPointerGetScreen(device)->myNum;
+ if (first_valuator == 0)
+ {
dx = valuators[0];
- dy = valuators[1];
+ if (is_absolute)
+ dx -= device->last.valuators[0];
}
- if (DGAStealMotionEvent(index, dx, dy))
+
+ if (first_valuator == 1 || num_valuators >= 2)
+ {
+ dy = valuators[1 - first_valuator];
+ if (is_absolute)
+ dy -= device->last.valuators[1];
+ }
+
+ if (DGAStealMotionEvent(device, index, dx, dy))
return;
}
}
#endif
- if (!xf86Events)
- FatalError("Didn't allocate event store\n");
-
+ GetEventList(&xf86Events);
nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
flags, first_valuator, num_valuators,
valuators);
for (i = 0; i < nevents; i++) {
- xE = xf86Events + i;
+ xE = (xf86Events + i)->event;
/* Don't post core motion events for devices not registered to send
* drag events. */
if (xE->u.u.type != MotionNotify || drag) {
- mieqEnqueue(device, xf86Events + i);
+ mieqEnqueue(device, (xf86Events + i)->event);
}
}
}
@@ -584,8 +802,8 @@ xf86PostProximityEvent(DeviceIntPtr device,
if (num_valuators > MAX_VALUATORS) {
- xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
- " is greater than MAX_VALUATORS\n", num_valuators);
+ xf86Msg(X_ERROR, "%s: num_valuator %d is greater than"
+ " MAX_VALUATORS\n", __FUNCTION__, num_valuators);
return;
}
@@ -594,14 +812,12 @@ xf86PostProximityEvent(DeviceIntPtr device,
valuators[i] = va_arg(var, int);
va_end(var);
- if (!xf86Events)
- FatalError("Didn't allocate event store\n");
-
+ GetEventList(&xf86Events);
nevents = GetProximityEvents(xf86Events, device,
is_in ? ProximityIn : ProximityOut,
first_valuator, num_valuators, valuators);
for (i = 0; i < nevents; i++)
- mieqEnqueue(device, xf86Events + i);
+ mieqEnqueue(device, (xf86Events + i)->event);
}
@@ -620,34 +836,32 @@ xf86PostButtonEvent(DeviceIntPtr device,
int index;
#if XFreeXDGA
- if (miPointerGetScreen(inputInfo.pointer)) {
- index = miPointerGetScreen(inputInfo.pointer)->myNum;
- if (DGAStealButtonEvent(index, button, is_down))
+ if (miPointerGetScreen(device)) {
+ index = miPointerGetScreen(device)->myNum;
+ if (DGAStealButtonEvent(device, index, button, is_down))
return;
}
#endif
if (num_valuators > MAX_VALUATORS) {
- xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
- " is greater than MAX_VALUATORS\n", num_valuators);
+ xf86Msg(X_ERROR, "%s: num_valuator %d is greater than"
+ " MAX_VALUATORS\n", __FUNCTION__, num_valuators);
return;
}
-
+
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuators[i] = va_arg(var, int);
va_end(var);
- if (!xf86Events)
- FatalError("Didn't allocate event store\n");
-
+ GetEventList(&xf86Events);
nevents = GetPointerEvents(xf86Events, device,
is_down ? ButtonPress : ButtonRelease, button,
- is_absolute ? POINTER_ABSOLUTE :
- POINTER_RELATIVE,
+ (is_absolute) ? POINTER_ABSOLUTE : POINTER_RELATIVE,
first_valuator, num_valuators, valuators);
for (i = 0; i < nevents; i++)
- mieqEnqueue(device, xf86Events + i);
+ mieqEnqueue(device, (xf86Events + i)->event);
+
}
_X_EXPORT void
@@ -669,20 +883,18 @@ xf86PostKeyEvent(DeviceIntPtr device,
"broken.\n");
if (num_valuators > MAX_VALUATORS) {
- xf86Msg(X_ERROR, "xf86PostMotionEvent: num_valuator %d"
- " is greater than MAX_VALUATORS\n", num_valuators);
+ xf86Msg(X_ERROR, "%s: num_valuator %d is greater than"
+ " MAX_VALUATORS\n", __FUNCTION__, num_valuators);
return;
}
- if (!xf86Events)
- FatalError("Didn't allocate event store\n");
-
if (is_absolute) {
va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
valuators[i] = va_arg(var, int);
va_end(var);
+ GetEventList(&xf86Events);
nevents = GetKeyboardValuatorEvents(xf86Events, device,
is_down ? KeyPress : KeyRelease,
key_code, first_valuator,
@@ -695,7 +907,7 @@ xf86PostKeyEvent(DeviceIntPtr device,
}
for (i = 0; i < nevents; i++)
- mieqEnqueue(device, xf86Events + i);
+ mieqEnqueue(device, (xf86Events + i)->event);
}
_X_EXPORT void
@@ -707,21 +919,24 @@ xf86PostKeyboardEvent(DeviceIntPtr device,
int index;
#if XFreeXDGA
- if (miPointerGetScreen(inputInfo.pointer)) {
- index = miPointerGetScreen(inputInfo.pointer)->myNum;
- if (DGAStealKeyEvent(index, key_code, is_down))
+ DeviceIntPtr pointer;
+
+ /* Some pointers send key events, paired device is wrong then. */
+ pointer = IsPointerDevice(device) ? device : GetPairedDevice(device);
+
+ if (miPointerGetScreen(pointer)) {
+ index = miPointerGetScreen(pointer)->myNum;
+ if (DGAStealKeyEvent(device, index, key_code, is_down))
return;
}
#endif
- if (!xf86Events)
- FatalError("Didn't allocate event store\n");
-
+ GetEventList(&xf86Events);
nevents = GetKeyboardEvents(xf86Events, device,
is_down ? KeyPress : KeyRelease, key_code);
for (i = 0; i < nevents; i++)
- mieqEnqueue(device, xf86Events + i);
+ mieqEnqueue(device, (xf86Events + i)->event);
}
_X_EXPORT LocalDevicePtr
@@ -763,10 +978,10 @@ xf86ScaleAxis(int Cx,
ErrorF ("Divide by Zero in xf86ScaleAxis");
}
- if (X > Sxlow)
- X = Sxlow;
- if (X < Sxhigh)
+ if (X > Sxhigh)
X = Sxhigh;
+ if (X < Sxlow)
+ X = Sxlow;
return (X);
}
@@ -810,12 +1025,15 @@ xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
{
if (axnum == 0) {
dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
- dev->valuator->lastx = dev->valuator->axisVal[0];
+ dev->last.valuators[0] = dev->valuator->axisVal[0];
}
else if (axnum == 1) {
dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
- dev->valuator->lasty = dev->valuator->axisVal[1];
+ dev->last.valuators[1] = dev->valuator->axisVal[1];
}
+
+ if(axnum == 0) /* to prevent double invocation */
+ ApplyAccelerationSettings(dev);
}