0.1.0-0-pre.8

This commit is contained in:
2026-09-16 09:39:53 +02:00
parent 431665992c
commit 00808ea5a6
21 changed files with 410 additions and 30 deletions

View File

@@ -0,0 +1,52 @@
// file: crates/engines/engine-v1-common/src/pointer.rs
// version: 1
/// Platform-independent normalized primary pointer state for one engine update.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct PointerState {
active: bool,
x: f32,
y: f32,
}
impl PointerState {
/// Creates an inactive pointer at the normalized origin.
#[must_use]
pub const fn inactive() -> Self {
return Self { active: false, x: 0.0, y: 0.0 };
}
/// Creates a pointer state from normalized coordinates.
#[must_use]
pub fn normalized(active: bool, x: f32, y: f32) -> Self {
return Self { active, x: x.clamp(0.0, 1.0), y: y.clamp(0.0, 1.0) };
}
/// Reports whether the pointer is currently active.
#[must_use]
pub const fn active(self) -> bool {
return self.active;
}
/// Returns the normalized horizontal coordinate.
#[must_use]
pub const fn x(self) -> f32 {
return self.x;
}
/// Returns the normalized vertical coordinate.
#[must_use]
pub const fn y(self) -> f32 {
return self.y;
}
}
impl Default for PointerState {
fn default() -> Self {
return Self::inactive();
}
}
#[cfg(test)]
#[path = "../unit_tests/pointer.rs"]
mod tests;