dix: Allocate MD's motion history to be large enough for potential valuators
Since we can't predict how many valuators may be in a future SD attached to an MD, we need to preallocate a history buffer that is large enough to keep MAX_VALUATORS coordinates per event. In addition, the history buffer needs to memorize the coordinate ranges at the time, thus requiring MDs to store (min_val, max_val, current_val, time) instead of (current_val, time) for each motion history entry. This commit only fixes the allocation.
This commit is contained in:
parent
0877de13ac
commit
d22c25bda4
|
@ -232,15 +232,25 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
|
||||||
_X_EXPORT void
|
_X_EXPORT void
|
||||||
AllocateMotionHistory(DeviceIntPtr pDev)
|
AllocateMotionHistory(DeviceIntPtr pDev)
|
||||||
{
|
{
|
||||||
|
int size;
|
||||||
if (pDev->valuator->motion)
|
if (pDev->valuator->motion)
|
||||||
xfree(pDev->valuator->motion);
|
xfree(pDev->valuator->motion);
|
||||||
|
|
||||||
if (pDev->valuator->numMotionEvents < 1)
|
if (pDev->valuator->numMotionEvents < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pDev->valuator->motion = xalloc(((sizeof(INT32) * pDev->valuator->numAxes)
|
/* An MD must have a motion history size large enough to keep all
|
||||||
+ sizeof(Time)) *
|
* potential valuators, plus the respective range of the valuators.
|
||||||
pDev->valuator->numMotionEvents);
|
* 3 * INT32 for (min_val, max_val, curr_val))
|
||||||
|
*/
|
||||||
|
if (pDev->isMaster)
|
||||||
|
size = sizeof(INT32) * 3 * MAX_VALUATORS;
|
||||||
|
else
|
||||||
|
size = sizeof(INT32) * pDev->valuator->numAxes;
|
||||||
|
|
||||||
|
size += sizeof(Time);
|
||||||
|
|
||||||
|
pDev->valuator->motion = xcalloc(pDev->valuator->numMotionEvents, size);
|
||||||
pDev->valuator->first_motion = 0;
|
pDev->valuator->first_motion = 0;
|
||||||
pDev->valuator->last_motion = 0;
|
pDev->valuator->last_motion = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,9 +167,9 @@ typedef struct _ValuatorClassRec {
|
||||||
int numMotionEvents;
|
int numMotionEvents;
|
||||||
int first_motion;
|
int first_motion;
|
||||||
int last_motion;
|
int last_motion;
|
||||||
void *motion; /* motion history buffer */
|
void *motion; /* motion history buffer. Different layout
|
||||||
|
for MDs and SDs!*/
|
||||||
WindowPtr motionHintWindow;
|
WindowPtr motionHintWindow;
|
||||||
|
|
||||||
AxisInfoPtr axes;
|
AxisInfoPtr axes;
|
||||||
unsigned short numAxes;
|
unsigned short numAxes;
|
||||||
|
|
Loading…
Reference in New Issue