IInputSource
- Namespace: Turian.Engine.Core
- Source File: IInputSource.cs
Supplies keyboard and mouse state to gameplay code, decoupled from where the events come from. The standalone runtime feeds this from Silk.NET (SilkInputSource); the Studio's in-editor play mode feeds it from Avalonia events raised by the Game panel. Gameplay code should use the static Input facade rather than resolving this interface directly.
Remarks
Implementations are driven from the game-loop thread. NewFrame is called once per tick by SceneTicker, after all update callbacks have run.
Properties
MousePosition
(Vector2) : Gets the pointer position in viewport pixels, with the origin at the top-left.
MouseDelta
(Vector2) : Gets the pointer movement, in pixels, accumulated during the current frame.
MouseScrollDelta
(float) : Gets the scroll-wheel movement, in notches, accumulated during the current frame.
ConnectedGamepads
(IReadOnlyList
Public Methods
IsKeyDown
bool IsKeyDown(Key key)
Returns true while key is held down.
Parameters:
key(Key)
Returns: bool
WasKeyPressed
bool WasKeyPressed(Key key)
Returns true only during the frame in which key went down.
Parameters:
key(Key)
Returns: bool
WasKeyReleased
bool WasKeyReleased(Key key)
Returns true only during the frame in which key went up.
Parameters:
key(Key)
Returns: bool
IsMouseButtonDown
bool IsMouseButtonDown(MouseButton button)
Returns true while button is held down.
Parameters:
button(MouseButton)
Returns: bool
WasMouseButtonPressed
bool WasMouseButtonPressed(MouseButton button)
Returns true only during the frame in which button went down.
Parameters:
button(MouseButton)
Returns: bool
WasMouseButtonReleased
bool WasMouseButtonReleased(MouseButton button)
Returns true only during the frame in which button went up.
Parameters:
button(MouseButton)
Returns: bool
NewFrame
void NewFrame()
Ends the current frame: clears the per-frame edges reported by WasKeyPressed, WasKeyReleased and their mouse counterparts, and resets the accumulated deltas.
IsGamepadButtonDown
bool IsGamepadButtonDown(GamepadButton button, int playerIndex = -1)
Returns true while a gamepad button is held.
Parameters:
button(GamepadButton): The button to test.playerIndex(int): The player slot, or −1 for any attached gamepad. (Default:-1)
Returns: bool
WasGamepadButtonPressed
bool WasGamepadButtonPressed(GamepadButton button, int playerIndex = -1)
Returns true only during the frame in which a gamepad button went down.
Parameters:
button(GamepadButton): The button to test.playerIndex(int): The player slot, or −1 for any attached gamepad. (Default:-1)
Returns: bool
WasGamepadButtonReleased
bool WasGamepadButtonReleased(GamepadButton button, int playerIndex = -1)
Returns true only during the frame in which a gamepad button went up.
Parameters:
button(GamepadButton): The button to test.playerIndex(int): The player slot, or −1 for any attached gamepad. (Default:-1)
Returns: bool
GetGamepadAxis
float GetGamepadAxis(GamepadAxis axis, int playerIndex = -1)
Reads a gamepad axis: −1 to 1 for a stick, 0 to 1 for a trigger, already past its dead zone.
Parameters:
axis(GamepadAxis): The axis to read.playerIndex(int): The player slot, or −1 for the attached gamepad furthest from rest. (Default:-1)
Returns: float