ui_input_state/
input_state.rs

1// Copyright 2025 the UI Events Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4use crate::KeyboardState;
5use crate::PrimaryPointerState;
6
7/// A stateful view of the input data for a frame, rather than
8/// processing it event-by-event.
9#[derive(Debug, Default)]
10pub struct InputState {
11    /// The state of the primary pointer.
12    pub primary_pointer: PrimaryPointerState,
13
14    /// The state of the keyboard.
15    pub keyboard: KeyboardState,
16}
17
18impl InputState {
19    /// Clear the per-frame state to prepare for a new frame.
20    pub fn clear_frame(&mut self) {
21        self.primary_pointer.clear_frame();
22        self.keyboard.clear_frame();
23    }
24}