506void QMutableEventPoint::update(
const QEventPoint &other, QEventPoint &target)
509 setPressure(target, other.pressure());
511 switch (other.state()) {
512 case QEventPoint::State::Pressed:
513 setGlobalPressPosition(target, other.globalPosition());
514 setGlobalLastPosition(target, other.globalPosition());
515 if (target.pressure() < 0)
516 setPressure(target, 1);
519 case QEventPoint::State::Released:
520 if (target.globalPosition() != other.globalPosition())
521 setGlobalLastPosition(target, target.globalPosition());
522 setPressure(target, 0);
526 if (target.globalPosition() != other.globalPosition())
527 setGlobalLastPosition(target, target.globalPosition());
528 if (target.pressure() < 0)
529 setPressure(target, 1);
533 setState(target, other.state());
534 setPosition(target, other.position());
535 setScenePosition(target, other.scenePosition());
536 setGlobalPosition(target, other.globalPosition());
537 setEllipseDiameters(target, other.ellipseDiameters());
538 setRotation(target, other.rotation());
539 setVelocity(target, other.velocity());
540 setUniqueId(target, other.uniqueId());
561void QMutableEventPoint::setTimestamp(QEventPoint &p, ulong t)
569 if (p.state() == QEventPoint::State::Pressed) {
570 p.d->pressTimestamp = t;
571 p.d->globalPressPos = p.d->globalPos;
573 if (p.d->timestamp == t)
580 QEventPointPrivate *pd = QPointingDevicePrivate::get(
581 const_cast<QPointingDevice *>(p.d->device))->pointById(p.id())->eventPoint.d.get();
582 if (t > pd->timestamp) {
583 pd->lastTimestamp = pd->timestamp;
585 if (p.state() == QEventPoint::State::Pressed)
586 pd->pressTimestamp = t;
587 if (pd->lastTimestamp > 0 && !p.device()->capabilities().testFlag(QInputDevice::Capability::Velocity)) {
589 QVector2D newVelocity = QVector2D(pd->globalPos - pd->globalLastPos) / (t - pd->lastTimestamp) * 1000;
592 static const float KalmanGain = 0.7f;
593 pd->velocity = newVelocity * KalmanGain + pd->velocity * (1.0f - KalmanGain);
594 qCDebug(lcPointerVel) <<
"velocity" << newVelocity <<
"filtered" << pd->velocity <<
595 "based on movement" << pd->globalLastPos <<
"->" << pd->globalPos <<
596 "over time" << pd->lastTimestamp <<
"->" << pd->timestamp;
599 p.d->lastTimestamp = pd->lastTimestamp;
600 p.d->velocity = pd->velocity;