Skip to main content

KeypadDevice

Struct KeypadDevice 

Source
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

Source

pub fn new() -> Self

Create a keypad device with the default auto-repeat constants (KEY_REPEAT_DELAY_TICKS / KEY_REPEAT_PERIOD_TICKS).

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for KeypadDevice

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.