Skip to main content

Module input_profile

Module input_profile 

Source
Expand description

Runtime hint describing the user’s primary input device.

Distinct from crate::platform::Platform (which tracks the OS family for shortcut labels — Cmd vs. Ctrl) because a Mac user with a touchscreen MacBook and an iPad user both run Platform::MacOS but need very different text-entry experiences.

The input profile drives features that should only exist on mobile touch devices:

  • The agg-gui on-screen software keyboard (crate::widgets::on_screen_keyboard)
  • Hit-target padding around small interactive widgets (future)
  • Long-press gesture timing (future)

Native builds default to InputProfile::Desktop. WASM hosts call set_input_profile after sniffing navigator.userAgent + matchMedia("(pointer: coarse)") so the agg-gui-side mobile features activate. The host can also call [platform_from_name] / set_platform so shortcut labels match the user’s keyboard while the on-screen keyboard mimics their phone OS.

Enums§

InputProfile
Where keyboard / pointer events originate and how text entry should behave.

Functions§

current_input_profile
Read the global input profile.
input_profile_from_hint
Parse a coarse browser identifier (“iPhone”, “iPad”, “Android”, …) into an InputProfile. Defaults to InputProfile::Desktop so a non-matching string (any desktop UA) keeps mobile features disabled.
is_mobile_touch
Convenience: detect mobile-touch from current profile.
set_input_profile
Replace the global input profile. Call once at startup from the platform shell after detecting the device, and at most once more if the device changes (e.g. a tablet docked into a desktop mode).