Expand description
Project authored HUD shapes once for both drawing and existing touch routing.
Geometry is in host logical screen pixels, never framebuffer pixels. A
viewport adds its safe origin once; a canvas adds its world offset once. DPR
belongs to the host. Rectangles/circles and stick travel radii scale together;
output channels, floating-stick policy and authored slot order never change.
There is no implicit cropping, enlargement, overlap avoidance or font scaling.
Draw the returned Control::region with a screen camera (or a zero-inset,
responsive UI viewport), rather than projecting it a second time.
Install TouchLayout::controls as the authored PlayerInput layout, then
draw TouchLayout::resolve using the player’s loaded settings. Installing
an already resolved layout would apply customization twice. This preserves
the existing editor, save indexes, hit priority and resize cancellation.
Hidden suffixes are supported, including an entirely hidden layout. Hidden gaps return an error: PlayerInput indexes saved edits by slice position and has no per-slot enable mask. Never compact a hidden middle slot or park its geometry offscreen (saved edits could move that geometry back onscreen).
use ferravex_render::{input::{PlayerInput, touch::{Output, TouchLayoutSettings},
touch_layout::{TouchLayout, TouchSlot, MinimumTouchSize}}, ui::{UiRect, Viewport}};
let viewport = Viewport::responsive([390., 844.], [10., 24., 12., 16.]).unwrap();
let slots = [TouchSlot::rect(0, UiRect { min: [8., 700.], size: [56.; 2] },
Output::Button(3)), TouchSlot::hidden(1)];
let authored = TouchLayout::from_viewport(viewport, &slots, MinimumTouchSize::Require(44.))?;
let mut input = PlayerInput::transient("touch-geometry-example");
input.set_touch_layout(authored.controls())?; // Loads any saved settings first.
let drawing = authored.resolve(input.touch_settings(), [390., 844.])?;
assert_eq!(drawing.controls().len(), 1);
assert_eq!(input.touch_settings(), TouchLayoutSettings::default());
// Paint drawing.controls()[0].region in absolute logical screen coordinates.Structs§
- Touch
Layout - Fixed-capacity projected controls; construction/resolution allocate nothing. Rebuild from authored slots on resize; do not feed resolved geometry back in. Empty layouts release existing captures when installed through PlayerInput.
- Touch
Slot - Explicit saved-layout identity. Visible slots must be a prefix in slot order.
Enums§
- Minimum
Touch Size - Minimum screen logical extent after projection, never a silent resize.
- Touch
Geometry Error