Expand description
Browser input → blinc_platform::InputEvent conversion
Every function in this module is pure (no web-sys dep) so it
compiles and unit-tests on every host. The wasm-bindgen runner module
reads web_sys::MouseEvent / KeyboardEvent / WheelEvent /
TouchEvent fields, then hands the primitive values
(button index, key string, dx/dy, …) to the helpers here.
Splitting the conversion this way mirrors how
blinc_platform_desktop::input keeps winit out of its
convert_* signatures by passing in primitives where possible.
§Key string mapping
The W3C KeyboardEvent.key value is a string like "ArrowLeft",
"Enter", "a", or "F1". This module’s convert_key_from_dom
consumes that string directly. The full set of named keys is
specified at https://www.w3.org/TR/uievents-key/#named-key-attribute-values.
Functions§
- convert_
key_ from_ dom - Convert a W3C
KeyboardEvent.keystring to a BlincKey. - convert_
mouse_ button - Convert a W3C
MouseEvent.buttonvalue to a BlincMouseButton. - convert_
pointer_ button - Pointer events expose
pointer.buttonasi32rather thani16. Convenience wrapper aroundconvert_mouse_button. - keyboard_
event - Build a keyboard event with state + modifiers.
- modifiers_
from_ keyboard - Same as
modifiers_from_mousebut spelled differently for keyboard events. Browsers expose the identical four booleans on both event types — we keep separate names purely for call-site readability. - modifiers_
from_ mouse - Build a
Modifiersstruct from the four boolean fields aweb_sys::MouseEventexposes (shiftKey,ctrlKey,altKey,metaKey). Kept primitive so it’s testable withoutweb-sys. - mouse_
moved - Build a
Mouse(Moved)event from canvas-local coordinates. - mouse_
pressed - Build a
Mouse(ButtonPressed)event from canvas-local coordinates. - mouse_
released - Build a
Mouse(ButtonReleased)event from canvas-local coordinates.