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