JFLib

plat/evq.rs#

Source: lib/plat/evq.rs

evq -- the platform event ring (shared by every platform and the script runner)
                                                                       [src/plat/evq.s]

  evq_push(ev) -> false when the event was dropped (ring and overflow full)
  evq_pop() -> Some(event)        evq_count()        evq_clear()
  evq_dropped() -> events dropped so far (tests)
  evq_pen_data(pressure, type, tilt_x, tilt_y) -> u32   (PN1) Event::data of a pointer
       event: pressure -1 = the device has none (-> 0), else clamped to 1..PRESSURE_ONE;
       type PTR_*; tilts in degrees, clamped to -63..63.  0 for PTR_MOUSE and while pen
       input is off.
  finger(win, phase, id, x, y, age_ms) -> false when it was dropped: a host's raw finger, any
       platform (the UI's gesture recogniser takes it: ui/touch.rs); finger_event: its Event
  pen_enable(on)    pen input on (default) / off: off = pens report plain mouse events
  pen_enabled() -> bool

The OS layer pushes from its message handlers, the UI core pops between frames (one
thread; the lock only makes the static safe).

A burst larger than the ring (one socket read of synthetic keys on X11 / Wayland, a client
flooding input: their dispatch must read on to an awaited reply, so it cannot stop at a
full ring) waits in a second-level queue on the heap, in order; the ring takes from it as
it drains.  Only beyond EVQ_MORE_MAX is an event dropped: counted (evq_dropped) and
logged once per burst.  Windows keeps WM_CHAR bursts in its own message queue instead
(wait() stops pumping at EVQ_CAP - 64).
PD_PRESSURE: u32 = 0xFFFF  // bits 0..15 pressure 1..PRESSURE_ONE, 0 = none (full)
PD_TYPE_SHIFT: u32 = 16  // bits 16..17 PTR_*
PD_TILTX_SHIFT: u32 = 18  // bits 18..24 i7 tilt x in degrees (-63..63, + = right)
PD_TILTY_SHIFT: u32 = 25  // bits 25..31 i7 tilt y in degrees (+ = towards the user)
// a finger (finger_event, PTR_TOUCH) has no tilt: bits 18..30 how old the sample was when it was
// pushed (ms), bit 31 it was cancelled; Event::btn is the finger's id
PD_AGE_SHIFT: u32 = 18
PD_AGE_MASK: u32 = 0x1FFF
PD_CANCEL: u32 = 1 << 31
PRESSURE_ONE: i32 = 65535
  • fn evq_push(e: Event) -> bool append an event (behind a full ring: the overflow queue) -> false when it was dropped (more than EVQ_MORE_MAX events wait)

  • fn evq_pop() -> Option<Event> the oldest queued event

  • fn evq_count() -> u32 events queued (the ring and the overflow queue)

  • fn evq_clear()

  • fn evq_dropped() -> u32 events dropped since the start because more than EVQ_MORE_MAX waited (tests)

  • fn evq_pen_data(pressure: i32, typ: u32, tilt_x: i32, tilt_y: i32) -> u32 Event::data of a pen pointer event (0 for a mouse or while pen input is off)

  • enum FingerPhase what happens to a finger (finger)

    • Down
    • Move
    • Up
    • Cancel -- the system took it: no click, no fling
  • fn finger_event(win: u8, phase: FingerPhase, id: u8, x: i32, y: i32, age_ms: u32) -> Event the Event of a raw finger: E_DOWN / E_MOVE / E_UP with PTR_TOUCH in its data. id: the host's number of this finger while it is down (a second one has another); age_ms: how old the sample is now (the velocity needs it; 0 when the host does not know)

  • fn finger(win: u8, phase: FingerPhase, id: u8, x: i32, y: i32, age_ms: u32) -> bool A host's raw finger, in px of its window (Event::win as for every pointer event): this is all a platform does for touch; pan, fling, tap, long press and what takes the finger are decided in ui/touch.rs. Every finger goes through here, in the order they happen; a finger that goes away without an Up gets a Cancel. The browser and Android, whose windows live in one surface, come through jfgui_finger instead. -> false when the event was dropped

  • fn pen_enable(on: bool) pen input on (default) / off (pens become plain mouse events)

  • fn pen_enabled() -> bool

Source: docs/API.md in the JFLib repository.