If core motion history is required, scale back to screen coords and INT16.
This commit is contained in:
parent
0b88510069
commit
1883485edd
|
@ -135,7 +135,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
|
|||
size = sizeof(Time) + (axes * sizeof(INT32));
|
||||
rep.nEvents = GetMotionHistory(dev, (xTimecoord **) &coords,/* XXX */
|
||||
start.milliseconds, stop.milliseconds,
|
||||
(ScreenPtr) NULL);
|
||||
(ScreenPtr) NULL, FALSE);
|
||||
}
|
||||
if (rep.nEvents > 0) {
|
||||
length = (rep.nEvents * size + 3) >> 2;
|
||||
|
|
|
@ -2308,12 +2308,9 @@ ProcGetMotionEvents(ClientPtr client)
|
|||
{
|
||||
if (CompareTimeStamps(stop, currentTime) == LATER)
|
||||
stop = currentTime;
|
||||
coords = (xTimecoord *)xalloc(mouse->valuator->numMotionEvents
|
||||
* sizeof(xTimecoord));
|
||||
if (!coords)
|
||||
return BadAlloc;
|
||||
count = GetMotionHistory(mouse, coords, start.milliseconds,
|
||||
stop.milliseconds, pWin->drawable.pScreen);
|
||||
count = GetMotionHistory(mouse, &coords, start.milliseconds,
|
||||
stop.milliseconds, pWin->drawable.pScreen,
|
||||
TRUE);
|
||||
xmin = pWin->drawable.x - wBorderWidth (pWin);
|
||||
xmax = pWin->drawable.x + (int)pWin->drawable.width +
|
||||
wBorderWidth (pWin);
|
||||
|
|
|
@ -258,15 +258,16 @@ AllocateMotionHistory(DeviceIntPtr pDev)
|
|||
pDev->name, size * pDev->valuator->numMotionEvents);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dump the motion history between start and stop into the supplied buffer.
|
||||
* Only records the event for a given screen in theory, but in practice, we
|
||||
* sort of ignore this.
|
||||
*
|
||||
* If core is set, we only generate x/y, in INT16, scaled to screen coords.
|
||||
*/
|
||||
_X_EXPORT int
|
||||
GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
|
||||
unsigned long stop, ScreenPtr pScreen)
|
||||
unsigned long stop, ScreenPtr pScreen, BOOL core)
|
||||
{
|
||||
char *ibuff = NULL, *obuff;
|
||||
int i = 0, ret = 0;
|
||||
|
@ -277,10 +278,15 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
|
|||
int dflt;
|
||||
AxisInfo from, *to; /* for scaling */
|
||||
CARD32 *ocbuf, *icbuf; /* pointer to coordinates for copying */
|
||||
INT16 *corebuf;
|
||||
AxisInfo core_axis = {0};
|
||||
|
||||
if (!pDev->valuator || !pDev->valuator->numMotionEvents)
|
||||
return 0;
|
||||
|
||||
if (core && !pScreen)
|
||||
return 0;
|
||||
|
||||
if (pDev->isMaster)
|
||||
size = (sizeof(INT32) * 3 * MAX_VALUATORS) + sizeof(Time);
|
||||
else
|
||||
|
@ -304,7 +310,36 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
|
|||
return ret;
|
||||
}
|
||||
else if (current >= start) {
|
||||
if (pDev->isMaster)
|
||||
if (core)
|
||||
{
|
||||
memcpy(obuff, ibuff, sizeof(Time)); /* copy timestamp */
|
||||
|
||||
icbuf = (INT32*)(ibuff + sizeof(Time));
|
||||
corebuf = (INT16*)(obuff + sizeof(Time));
|
||||
|
||||
/* fetch x coordinate + range */
|
||||
memcpy(&from.min_value, icbuf++, sizeof(INT32));
|
||||
memcpy(&from.max_value, icbuf++, sizeof(INT32));
|
||||
memcpy(&coord, icbuf++, sizeof(INT32));
|
||||
|
||||
/* scale to screen coords */
|
||||
to = &core_axis;
|
||||
to->max_value = pScreen->width;
|
||||
coord = rescaleValuatorAxis(coord, &from, to, pScreen->width);
|
||||
|
||||
memcpy(corebuf, &coord, sizeof(INT16));
|
||||
corebuf++;
|
||||
|
||||
/* fetch y coordinate + range */
|
||||
memcpy(&from.min_value, icbuf++, sizeof(INT32));
|
||||
memcpy(&from.max_value, icbuf++, sizeof(INT32));
|
||||
memcpy(&coord, icbuf++, sizeof(INT32));
|
||||
|
||||
to->max_value = pScreen->height;
|
||||
coord = rescaleValuatorAxis(coord, &from, to, pScreen->height);
|
||||
memcpy(corebuf, &coord, sizeof(INT16));
|
||||
|
||||
} else if (pDev->isMaster)
|
||||
{
|
||||
memcpy(obuff, ibuff, sizeof(Time)); /* copy timestamp */
|
||||
|
||||
|
@ -345,6 +380,9 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
|
|||
|
||||
/* don't advance by size here. size may be different to the
|
||||
* actually written size if the MD has less valuators than MAX */
|
||||
if (core)
|
||||
obuff += sizeof(INT32) + sizeof(Time);
|
||||
else
|
||||
obuff += (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
|
||||
ret++;
|
||||
}
|
||||
|
|
|
@ -2933,9 +2933,9 @@ xf86MotionHistoryAllocate(LocalDevicePtr local)
|
|||
|
||||
_X_EXPORT int
|
||||
xf86GetMotionEvents(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
|
||||
unsigned long stop, ScreenPtr pScreen)
|
||||
unsigned long stop, ScreenPtr pScreen, BOOL core)
|
||||
{
|
||||
return GetMotionHistory(pDev, buff, start, stop, pScreen);
|
||||
return GetMotionHistory(pDev, buff, start, stop, pScreen, core);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
|
|
|
@ -197,7 +197,7 @@ void xf86DeleteInput(InputInfoPtr pInp, int flags);
|
|||
void xf86MotionHistoryAllocate(LocalDevicePtr local);
|
||||
int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
|
||||
unsigned long start, unsigned long stop,
|
||||
ScreenPtr pScreen);
|
||||
ScreenPtr pScreen, BOOL core);
|
||||
|
||||
/* xf86Option.c */
|
||||
void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
|
||||
|
|
|
@ -486,7 +486,8 @@ extern int GetMotionHistory(
|
|||
xTimecoord **buff,
|
||||
unsigned long start,
|
||||
unsigned long stop,
|
||||
ScreenPtr pScreen);
|
||||
ScreenPtr pScreen,
|
||||
BOOL core);
|
||||
|
||||
extern void SwitchCorePointer(DeviceIntPtr pDev);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user