Skip to main content

Crate game_toolkit_input

Crate game_toolkit_input 

Source
Expand description

Input subsystem: keyboard + mouse + gamepads + touch, with held / just-pressed / just-released semantics.

Call Input::handle_window_event for every winit::event::WindowEvent and Input::poll_gamepads once per frame before update, then Input::end_frame once per frame after update to clear edge state.

Structs§

Gamepad
Per-controller state, with the same held / just-pressed / just-released model as the keyboard. Obtain via Input::gamepads or Input::first_gamepad.
GamepadId
Gamepad ID.
Input
PointerMapping
Maps window positions (physical pixels) to the space the game draws in, e.g. a virtual-resolution canvas scaled into the window: game = (window - origin) * scale. The toolkit sets it each frame from the renderer; see Input::set_pointer_mapping.
Touch
One finger on a touchscreen. Positions are in the same space as Input::mouse_pos: physical window pixels, or canvas pixels with a virtual resolution (more precisely, mapped by the PointerMapping in effect when the event arrived). Obtain via Input::touches, Input::touches_started or Input::touches_ended.

Enums§

Axis
Gamepad’s elements which state can be represented by value from -1.0 to 1.0.
Button
Gamepad’s elements which state can be represented by value from 0.0 to 1.0.
Key
Code representing the location of a physical key
MouseButton