bool QWSTslibMouseHandlerPrivate::get_sample(struct ts_sample *sample)
{
if (!calibrated)
return (ts_read_raw(dev, sample, 1) == 1);
return (ts_read(dev, sample, 1) == 1);
}
int StackCnt;
void QWSTslibMouseHandlerPrivate::readMouseData()
{
if (!qt_screen)
return;
for(;;) {
struct ts_sample sample = lastSample;
bool pressed = wasPressed;
// Fast return if there's no events.
if (!get_sample(&sample))
return;
pressed = (sample.pressure > 0);
// Only return last sample unless there's a press/release event.
while (pressed == wasPressed) {
if (!get_sample(&sample))
break;
pressed = (sample.pressure > 0);
}
// work around missing coordinates on mouse release in raw mode
if (!calibrated && !pressed && sample.x == 0 && sample.y == 0) {
sample.x = lastSample.x;
sample.y = lastSample.y;
}
int dx = sample.x - lastSample.x;
int dy = sample.y - lastSample.y;
// Remove small movements in oppsite direction
if (dx * lastdx < 0 && qAbs(dx) < jitter_limit) {
sample.x = lastSample.x;
dx = 0;
}
if (dy * lastdy < 0 && qAbs(dy) < jitter_limit) {
sample.y = lastSample.y;
dy = 0;
}
if (wasPressed == pressed && dx == 0 && dy == 0)
return;
#ifdef TSLIBMOUSEHANDLER_DEBUG
qDebug
() <<
"last" <<
QPoint(lastSample.
x, lastSample.
y) <<
"curr" <<
QPoint(sample.
x, sample.
y) <<
"ddx,ddy" <<
QPoint(dx
*lastdx, dy
*lastdy
) << "pressed" << wasPressed << pressed;
#endif
lastSample = sample;
wasPressed = pressed;
if (dx != 0)
lastdx = dx;
if (dy != 0)
lastdy = dy;
const QPoint p
(sample.
x, sample.
y);
if (calibrated) {
// tslib should do all the translation and filtering, so we send a
// "raw" mouse event
handler->QWSMouseHandler::mouseChanged(p, pressed);
} else {
handler->sendFiltered(p, pressed);
}
}
}
bool QWSTslibMouseHandlerPrivate::get_sample(struct ts_sample *sample)
{
if (!calibrated)
return (ts_read_raw(dev, sample, 1) == 1);
return (ts_read(dev, sample, 1) == 1);
}
int StackCnt;
void QWSTslibMouseHandlerPrivate::readMouseData()
{
if (!qt_screen)
return;
for(;;) {
struct ts_sample sample = lastSample;
bool pressed = wasPressed;
// Fast return if there's no events.
if (!get_sample(&sample))
return;
pressed = (sample.pressure > 0);
// Only return last sample unless there's a press/release event.
while (pressed == wasPressed) {
if (!get_sample(&sample))
break;
pressed = (sample.pressure > 0);
}
// work around missing coordinates on mouse release in raw mode
if (!calibrated && !pressed && sample.x == 0 && sample.y == 0) {
sample.x = lastSample.x;
sample.y = lastSample.y;
}
int dx = sample.x - lastSample.x;
int dy = sample.y - lastSample.y;
// Remove small movements in oppsite direction
if (dx * lastdx < 0 && qAbs(dx) < jitter_limit) {
sample.x = lastSample.x;
dx = 0;
}
if (dy * lastdy < 0 && qAbs(dy) < jitter_limit) {
sample.y = lastSample.y;
dy = 0;
}
if (wasPressed == pressed && dx == 0 && dy == 0)
return;
#ifdef TSLIBMOUSEHANDLER_DEBUG
qDebug() << "last" << QPoint(lastSample.x, lastSample.y)
<< "curr" << QPoint(sample.x, sample.y)
<< "dx,dy" << QPoint(dx, dy)
<< "ddx,ddy" << QPoint(dx*lastdx, dy*lastdy)
<< "pressed" << wasPressed << pressed;
#endif
lastSample = sample;
wasPressed = pressed;
if (dx != 0)
lastdx = dx;
if (dy != 0)
lastdy = dy;
const QPoint p(sample.x, sample.y);
if (calibrated) {
// tslib should do all the translation and filtering, so we send a
// "raw" mouse event
handler->QWSMouseHandler::mouseChanged(p, pressed);
} else {
handler->sendFiltered(p, pressed);
}
}
}
To copy to clipboard, switch view to plain text mode
qt_translateRawTouchEvent
(QWidget *window, QTouchEvent
::DeviceType deviceType,
const QList<QTouchEvent
::TouchPoint>
&touchPoints
);
qt_translateRawTouchEvent(QWidget *window, QTouchEvent::DeviceType deviceType, const QList<QTouchEvent::TouchPoint> &touchPoints);
To copy to clipboard, switch view to plain text mode
Bookmarks