//! How the interface is being driven — a finger, or a pointer. //! //! # Why this is a platform question //! //! It is the last `cfg(target_os)` anyone should want, and it earns its place //! the way the rest of this crate does: the answer differs per platform, every //! entry point needs it, and resolving it in `apps/` would mean writing it //! twice. //! //! # Why it is not the layout class //! //! [`crate::display`] answers "how much room is there", and `dr-ui` turns that //! into a layout class from the window's width, deliberately not from the //! device (FR-UI-1). That was the right call and this does not revisit it: a //! narrow desktop window still gets the compact layout, and a tablet in //! landscape still gets the expanded one. //! //! This answers a different question — "what is the user pointing with" — //! which width cannot stand in for. The two 12-inch targets DarkRoom is built //! for are the same size and the same layout class, and one of them has no //! hover, no modifier keys and a 44-pixel minimum target. //! //! # Why it is a guess, and says so //! //! There is no reliable runtime answer on either platform. Android devices //! have touchscreens and can have a mouse attached; desktops have mice and can //! have touchscreens. Reporting the *usual* case per platform and letting the //! photographer override it is honest; probing input devices and being //! confidently wrong is not. The override lives in //! `dr_types::GroupNavigation`, which takes this as an input rather than //! reading it. /// What this build is usually driven with. /// /// `true` on Android, `false` everywhere else. Deliberately a plain bool /// rather than an enum: there are exactly two answers today, and the thing /// that consumes it — [`dr_types::GroupNavigation::groups_in_rail`] — is a /// choice between two controls. pub const fn is_touch_first() -> bool { cfg!(target_os = "android") } #[cfg(test)] mod tests { use super::*; #[test] fn the_desktop_build_is_pointer_first() { // Asserted rather than assumed, because the value is a `cfg!` and a // typo in the target name compiles to a silent `false` — which on // desktop is the right answer for the wrong reason and would pass // unnoticed until the tablet build shipped with the desktop layout. assert_eq!(is_touch_first(), cfg!(target_os = "android")); #[cfg(not(target_os = "android"))] assert!(!is_touch_first()); } }