Scripting API
Scripting API
InputState
Struct in Abyss.Core, from Abyss.Core.
Everything the engine knows about the keyboard and mouse this frame.
public struct InputStateRemarks
One value, read once. Bevy holds input as hash sets and a handful of resources, none of which can cross a C ABI, and asking across the boundary per question would put an FFI call on if (input.IsDown(Key.W)) — the per-item cost this engine exists to avoid. So the engine flattens it all into this and you read fields.
Get one with World.ReadInput at the top of your frame. Everything is zero on a world with no window.
To reach it from a system, register it as a resource of your own and copy this into it once a frame: the engine has nothing to add to that and a system then declares Res<InputState> like any other dependency.
Properties
MouseHeld
public readonly MouseButtons MouseHeld { get; }Mouse buttons currently down.
MousePressed
public readonly MouseButtons MousePressed { get; }Mouse buttons that went down this frame.
MouseReleased
public readonly MouseButtons MouseReleased { get; }Mouse buttons that came up this frame.
HasWindow
public readonly bool HasWindow { get; }Whether a window exists. Without one there is no input and every field is zero.
CursorInWindow
public readonly bool CursorInWindow { get; }Whether the cursor is inside the window, and therefore whether InputState.CursorX means anything.
CursorX
public readonly float CursorX { get; }Cursor x in logical pixels from the window's top left.
CursorY
public readonly float CursorY { get; }Cursor y in logical pixels from the window's top left.
MotionX
public readonly float MotionX { get; }How far the mouse moved this frame, horizontally.
Not the same as the change in InputState.CursorX: motion keeps accumulating when the cursor is locked or has run off the edge of the screen, which is what a first-person camera wants and what a cursor position cannot give it.
MotionY
public readonly float MotionY { get; }How far the mouse moved this frame, vertically.
ScrollX
public readonly float ScrollX { get; }Horizontal scroll this frame, in InputState.ScrollUnits.
ScrollY
public readonly float ScrollY { get; }Vertical scroll this frame, in InputState.ScrollUnits.
ScrollUnit
public readonly ScrollUnit ScrollUnit { get; }Whether the scroll deltas are lines or pixels.
Methods
IsDown
public readonly bool IsDown(Key key)Whether a key is currently down.
Parameters
key
WasPressed
public readonly bool WasPressed(Key key)Whether a key went down this frame.
Parameters
key
WasReleased
public readonly bool WasReleased(Key key)Whether a key came up this frame.
Parameters
key
AllDown
public readonly bool AllDown(params ReadOnlySpan<Key> keys)Whether every key in the combination is down.
Parameters
keys
The shape a shortcut wants: input.AllDown(Key.ControlLeft, Key.S). An empty combination is trivially down, which is what makes it safe to build one from configuration.
