Skip to main content

Module hover_stabilizer

Module hover_stabilizer 

Source
Expand description

Hover jitter stabilization using CUSUM change-point detection.

Eliminates hover flicker when the pointer jitters around widget boundaries while maintaining responsiveness for intentional target changes.

§Algorithm

The stabilizer uses a simplified CUSUM (Cumulative Sum) change-point detector:

  • Track signed distance d_t to current target boundary (positive = inside)
  • Compute cumulative sum: S_t = max(0, S_{t-1} + d_t - k) where k is drift allowance
  • Switch target only when S_t > h (threshold) indicating strong evidence of intent

A hysteresis band around boundaries prevents oscillation from single-cell jitter.

§Invariants

  1. Hover target only changes when evidence exceeds threshold
  2. Single-cell jitter sequences do not cause target flicker
  3. Intentional crossing (steady motion) triggers switch within ~2 frames
  4. No measurable overhead (<2%) on hit-test pipeline

§Failure Modes

  • If hit-test returns None consistently, stabilizer holds last known target
  • If threshold is too high, responsiveness degrades (tune via config)
  • If drift allowance is too low, jitter causes accumulation (tune k parameter)

§Evidence Ledger

In debug mode, the stabilizer logs:

  • CUSUM score at each update
  • Hysteresis state (inside band vs. outside)
  • Target switch events with evidence values

Structs§

HoverStabilizer
Stateful hover stabilizer that prevents jitter-induced target flicker.
HoverStabilizerConfig
Configuration for hover jitter stabilization.