pub struct KeypadDevice { /* private fields */ }Expand description
LPAR-04 §8 Keypad input device adapter with §9.7 tick-counted auto-repeat.
Routes KeyDown/KeyUp to the focused object via
dispatch_object_event(root, DispatchInput::Focused { event: ObjectEvent::Key(key) }).
§Auto-repeat (§9.7)
While a key is held (a KeyDown received without a matching KeyUp),
tick re-delivers ObjectEvent::Key to the focused object
after KEY_REPEAT_DELAY_TICKS ticks, then every
KEY_REPEAT_PERIOD_TICKS ticks thereafter. These are synthetic
ObjectEvent::Key re-deliveries — the stream never sees extra KeyDown
events for repeats.
§Unconsumed keys
When dispatch returns Disposition::Unconsumed or
Disposition::NoTarget, the key was not consumed by the focused object.
The caller’s existing app-level post-dispatch path receives it through the
normal application pump — KeypadDevice does not swallow unconsumed
keys.
Implementations§
Source§impl KeypadDevice
impl KeypadDevice
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a keypad device with the default auto-repeat constants
(KEY_REPEAT_DELAY_TICKS / KEY_REPEAT_PERIOD_TICKS).
Sourcepub fn with_repeat(delay_ticks: u32, period_ticks: u32) -> Self
pub fn with_repeat(delay_ticks: u32, period_ticks: u32) -> Self
Create a keypad device with custom auto-repeat timing.
delay_ticks is the hold duration before the first repeat.
period_ticks is the interval between subsequent repeats.
period_ticks is clamped to at least 1 to prevent infinite loops.
Sourcepub fn key_down(&mut self, root: &mut ObjectNode, key: Key) -> Disposition
pub fn key_down(&mut self, root: &mut ObjectNode, key: Key) -> Disposition
Process a KeyDown event: route to the focused object and arm
auto-repeat.
Returns the Disposition from dispatch_object_event.
Sourcepub fn key_up(&mut self, _root: &mut ObjectNode, _key: Key) -> Disposition
pub fn key_up(&mut self, _root: &mut ObjectNode, _key: Key) -> Disposition
Process a KeyUp event: disarm auto-repeat.
Returns Disposition::Unconsumed — key-up has no ObjectEvent
counterpart in v1; the caller’s app-level handler receives it through
the normal pump.
Sourcepub fn tick(&mut self, root: &mut ObjectNode) -> Disposition
pub fn tick(&mut self, root: &mut ObjectNode) -> Disposition
Advance the auto-repeat timer one tick.
If a key is currently held and the repeat schedule fires, re-delivers
ObjectEvent::Key to the focused object. Returns the
Disposition of the re-delivery, or Disposition::NoTarget when
no repeat occurred this tick.