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