BufferedInputSource
- Namespace: Turian.Engine.Core
- Source File: BufferedInputSource.cs
An IInputSource that is fed by pushing events into it, tracking held state and per-frame press/release edges. The Studio's Game panel pushes translated Avalonia events here; SilkInputSource pushes Silk.NET events here. Neither the interface nor gameplay code can tell the difference.
Remarks
Pushes may originate from the UI thread while the game loop reads on the same thread; state is guarded so an out-of-band push cannot corrupt a set mid-enumeration.
Properties
MousePosition
(Vector2)
MouseDelta
(Vector2)
MouseScrollDelta
(float)
ConnectedGamepads
(IReadOnlyList
Public Methods
IsKeyDown
public bool IsKeyDown(Key key)
Parameters:
key(Key)
Returns: bool
WasKeyPressed
public bool WasKeyPressed(Key key)
Parameters:
key(Key)
Returns: bool
WasKeyReleased
public bool WasKeyReleased(Key key)
Parameters:
key(Key)
Returns: bool
IsMouseButtonDown
public bool IsMouseButtonDown(MouseButton button)
Parameters:
button(MouseButton)
Returns: bool
WasMouseButtonPressed
public bool WasMouseButtonPressed(MouseButton button)
Parameters:
button(MouseButton)
Returns: bool
WasMouseButtonReleased
public bool WasMouseButtonReleased(MouseButton button)
Parameters:
button(MouseButton)
Returns: bool
IsGamepadButtonDown
public bool IsGamepadButtonDown(GamepadButton button, int playerIndex = -1)
Parameters:
button(GamepadButton)playerIndex(int) (Default:-1)
Returns: bool
WasGamepadButtonPressed
public bool WasGamepadButtonPressed(GamepadButton button, int playerIndex = -1)
Parameters:
button(GamepadButton)playerIndex(int) (Default:-1)
Returns: bool
WasGamepadButtonReleased
public bool WasGamepadButtonReleased(GamepadButton button, int playerIndex = -1)
Parameters:
button(GamepadButton)playerIndex(int) (Default:-1)
Returns: bool
GetGamepadAxis
public float GetGamepadAxis(GamepadAxis axis, int playerIndex = -1)
The axis value, taking the reading furthest from rest when no player is named — with two pads attached and one at rest, the one being moved is obviously the one that meant it.
Parameters:
axis(GamepadAxis): The axis to read.playerIndex(int): The player slot, or −1 for any attached gamepad. (Default:-1)
Returns: float
NewFrame
public void NewFrame()
PushGamepadConnected
public void PushGamepadConnected(int playerIndex)
Records that a gamepad attached to a player slot, so its controls can be read.
Parameters:
playerIndex(int): The slot the gamepad occupies.
PushGamepadDisconnected
public void PushGamepadDisconnected(int playerIndex)
Records that a gamepad detached, dropping everything it was holding.
Parameters:
playerIndex(int): The slot the gamepad occupied.
PushGamepadButtonDown
public void PushGamepadButtonDown(int playerIndex, GamepadButton button)
Records that a gamepad button went down.
Parameters:
playerIndex(int): The slot the gamepad occupies.button(GamepadButton): The button.
PushGamepadButtonUp
public void PushGamepadButtonUp(int playerIndex, GamepadButton button)
Records that a gamepad button went up.
Parameters:
playerIndex(int): The slot the gamepad occupies.button(GamepadButton): The button.
PushGamepadAxis
public void PushGamepadAxis(int playerIndex, GamepadAxis axis, float value)
Records a gamepad axis reading, already past its dead zone.
Parameters:
playerIndex(int): The slot the gamepad occupies.axis(GamepadAxis): The axis.value(float): The reading: −1 to 1 for a stick, 0 to 1 for a trigger.
PushKeyDown
public void PushKeyDown(Key key)
Records that key went down. Auto-repeat is ignored.
Parameters:
key(Key)
PushKeyUp
public void PushKeyUp(Key key)
Records that key went up.
Parameters:
key(Key)
PushMouseDown
public void PushMouseDown(MouseButton button)
Records that button went down.
Parameters:
button(MouseButton)
PushMouseUp
public void PushMouseUp(MouseButton button)
Records that button went up.
Parameters:
button(MouseButton)
PushMouseMove
public void PushMouseMove(Vector2 position)
Records an absolute pointer position, accumulating the movement into the frame delta.
Parameters:
position(Vector2)
PushMouseScroll
public void PushMouseScroll(float notches)
Accumulates notches of scroll-wheel movement into the frame delta.
Parameters:
notches(float)
Clear
public void Clear()
Drops all held state and pending edges. Called when the viewport loses focus so keys do not stay stuck down, and when a play session ends.