8#include <PhosphorPointer/phosphorpointer_export.h>
108 static_assert(
kCapacity > 1,
"the sample interval divides by kCapacity - 1");
164 return m_trailSeconds;
170 return m_sampleIntervalMs;
189 void noteButtons(Qt::MouseButtons now, Qt::MouseButtons before,
const QPointF& devicePx, qint64 nowMs);
237 bool strokeStart =
false;
240 const Sample& sampleAt(
int newestFirstIndex)
const;
241 static double secondsBetween(qint64 laterMs, qint64 earlierMs);
244 static double speedOver(
const QPointF& earlierPos, qint64 earlierMs,
const QPointF& devicePx, qint64 nowMs);
248 void acceptEvent(
const QPointF& devicePx, qint64 nowMs,
double speed,
bool hasPrev,
const QPointF& prevPos,
252 [[nodiscard]]
double filteredSpeed()
const;
254 double m_trailSeconds = 0.0;
255 qint64 m_sampleIntervalMs = kMinSampleGapMs;
257 std::array<Sample, kCapacity> m_ring{};
261 qint64 m_lastMotionMs = 0;
262 bool m_hasMotion =
false;
267 QPointF m_lastEventPos;
268 qint64 m_lastEventMs = 0;
269 double m_lastEventSpeed = 0.0;
270 QPointF m_prevEventPos;
271 qint64 m_prevEventMs = 0;
272 bool m_hasPrevEvent =
false;
275 qint64 m_pressMs = 0;
276 int m_pressButton = 0;
277 bool m_hasPress =
false;
279 QPointF m_releasePos;
280 qint64 m_releaseMs = 0;
281 int m_releaseButton = 0;
282 bool m_hasRelease =
false;
284 int m_buttonsMask = 0;
double trailSeconds() const
The window currently in force.
Definition PointerHistory.h:162
static constexpr qint64 kVelocityHoldMs
How long after the newest sample the velocity is still reported, and the longest gap between two samp...
Definition PointerHistory.h:132
static constexpr qint64 kMinSampleGapMs
Definition PointerHistory.h:105
qint64 sampleIntervalMs() const
Minimum gap between two appended samples, in ms.
Definition PointerHistory.h:168
static constexpr int kCapacity
Definition PointerHistory.h:97
static constexpr double kVelocityMinDtSeconds
Floor on the dt a speed is divided by, guarding against a zero or denormal gap between two events tha...
Definition PointerHistory.h:127
void noteButtons(Qt::MouseButtons now, Qt::MouseButtons before, const QPointF &devicePx, qint64 nowMs)
Record a button transition from before to now at devicePx.
static constexpr double kMaxTrailSeconds
Upper bound on the accepted trail window.
Definition PointerHistory.h:113
void setTrailSeconds(double seconds)
The window the ring must span, in seconds: the furthest back any pack this history feeds actually REA...
void seedPosition(const QPointF &devicePx, qint64 nowMs)
Give an EMPTY ring a position without recording motion: the slot lands (age 0, speed 0,...
PointerFrameState frameState(qint64 nowMs, double scale) const
The contract tail for a frame at nowMs with canvas scale scale.
QRectF damageRect(double reachDevicePx, qint64 nowMs, double trailSeconds) const
Bounding box of the trail samples, press and release points younger than trailSeconds,...
void notePointer(const QPointF &devicePx, qint64 nowMs)
Record a pointer position at nowMs (see the sampling rule above).
bool isLive(qint64 nowMs, double trailSeconds) const
True while a motion or button event is younger than trailSeconds.
static constexpr double kSpeedFilterTauSeconds
Time constant of the speed filter (filteredSpeed()), in seconds.
Definition PointerHistory.h:150
static constexpr double kMinSampleDistancePx
DEVICE px, deliberately, like every other position in this class: the ring stores device px and the p...
Definition PointerHistory.h:104
constexpr int kMaxTrailPoints
Ring capacity of uPointerTrail.
Definition PointerShaderContract.h:166
Definition PointerFrameState.h:16
Plain-data snapshot of everything the pointer contract's tail carries for one frame.
Definition PointerFrameState.h:27