Interface IInput
Input Operations Yak2D supports Keyboard, Mouse and Gamepad input
Namespace: Yak2D
Assembly: Yak2D.Api.dll
Syntax
public interface IInput
Properties
IsMouseOverWindow
Whether the mouse is currently over the window. Please be aware: The implementation is reasonably performant, but registering an off screen requires capturing a previous SDL event that when extrapolating motion suggests the next frame the mouse will leave the window Therefore, an incorrect reading can (and usually will) be given if a window is covering the application window and the mouse moves into this window's area
Declaration
bool IsMouseOverWindow { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
MousePosition
Get mouse position over window (origin top-left)
Declaration
Vector2 MousePosition { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
MousePositionDeltaSinceLastFrame
How far the mouse has moved over the desktop since the last update
Declaration
Vector2 MousePositionDeltaSinceLastFrame { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
MouseVelocity
The velocity in pixels per second, the mouse cursor moved over the window
Declaration
Vector2 MouseVelocity { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
RawVeldridInputSnapshot
Am object of frame input data provided by the veldrid library
Declaration
InputSnapshot RawVeldridInputSnapshot { get; }
Property Value
| Type | Description |
|---|---|
| InputSnapshot |
Methods
ConnectedGamepadIds()
Returns list of positive integer indices which are connected gamepad references
Declaration
List<int> ConnectedGamepadIds()
Returns
| Type | Description |
|---|---|
| List<System.Int32> |
GamepadAxisValue(Int32, GamepadAxis)
Returns the current value of a gamepad axis (usually, -1 to +1)
Declaration
float GamepadAxisValue(int id, GamepadAxis axis)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
| GamepadAxis | axis | The axis to query |
Returns
| Type | Description |
|---|---|
| System.Single |
GamepadButtonsHeldDown(Int32)
Returns list of buttons currently held down
Declaration
List<GamepadButton> GamepadButtonsHeldDown(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
Returns
| Type | Description |
|---|---|
| List<GamepadButton> |
GamepadButtonsPressedThisFrame(Int32)
Returns list of buttons pressed since the last update
Declaration
List<GamepadButton> GamepadButtonsPressedThisFrame(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
Returns
| Type | Description |
|---|---|
| List<GamepadButton> |
GamepadButtonsReleasedThisFrame(Int32)
Returns list of buttons where this update is the first since being released
Declaration
List<GamepadButton> GamepadButtonsReleasedThisFrame(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
Returns
| Type | Description |
|---|---|
| List<GamepadButton> |
HowLongHasGamepadButtonBeenHeldDown(Int32, GamepadButton, Boolean)
Returns the number of seconds a button has been held down for
Declaration
float HowLongHasGamepadButtonBeenHeldDown(int id, GamepadButton button, bool countIfUpThisFrame = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
| GamepadButton | button | The button to query |
| System.Boolean | countIfUpThisFrame | If true, a time will be returned even if this is the first update since the button was released |
Returns
| Type | Description |
|---|---|
| System.Single |
HowLongHasKeyBeenHeldDown(KeyCode, Boolean)
Returns the number of seconds a key has been held down for
Declaration
float HowLongHasKeyBeenHeldDown(KeyCode key, bool countIfUpThisFrame = false)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyCode | key | The key to query |
| System.Boolean | countIfUpThisFrame | If true, a time will be returned even if this is the first update since the key was released |
Returns
| Type | Description |
|---|---|
| System.Single |
HowLongHasMouseBeenHeldDown(MouseButton, Boolean)
Returns the number of seconds a button has been held down for
Declaration
float HowLongHasMouseBeenHeldDown(MouseButton button, bool countIfUpThisFrame = false)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseButton | button | The button to query |
| System.Boolean | countIfUpThisFrame | If true, a time will be returned even if this is the first update since the button was released |
Returns
| Type | Description |
|---|---|
| System.Single |
IsGamepadButtonCurrentlyPressed(Int32, GamepadButton)
Gets whether a gamepad button is currently held down
Declaration
bool IsGamepadButtonCurrentlyPressed(int id, GamepadButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
| GamepadButton | button | The button to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsGamepadIdValid(Int32)
Returns whether the provided id is a valid for a connected gamepad
Declaration
bool IsGamepadIdValid(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | positive integer reference id for gamepad |
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsKeyCurrentlyPressed(KeyCode)
Gets whether a key is pressed
Declaration
bool IsKeyCurrentlyPressed(KeyCode key)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyCode | key | The key to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsMouseCurrentlyPressed(MouseButton)
Gets whether a button is pressed
Declaration
bool IsMouseCurrentlyPressed(MouseButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseButton | button | The button to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
KeysHeldDown()
Returns list of keys currently held down
Declaration
List<KeyCode> KeysHeldDown()
Returns
| Type | Description |
|---|---|
| List<KeyCode> |
KeysPressedThisFrame()
Returns list of keys pressed since the last update
Declaration
List<KeyCode> KeysPressedThisFrame()
Returns
| Type | Description |
|---|---|
| List<KeyCode> |
KeysReleasedThisFrame()
Returns list of keys where this update is the first since being released
Declaration
List<KeyCode> KeysReleasedThisFrame()
Returns
| Type | Description |
|---|---|
| List<KeyCode> |
MouseButtonsHeldDown()
Returns list of buttons currently held down
Declaration
List<MouseButton> MouseButtonsHeldDown()
Returns
| Type | Description |
|---|---|
| List<MouseButton> |
MouseButtonsPressedThisFrame()
Returns list of buttons pressed since the last update
Declaration
List<MouseButton> MouseButtonsPressedThisFrame()
Returns
| Type | Description |
|---|---|
| List<MouseButton> |
MouseButtonsReleasedThisFrame()
Returns list of buttons where this update is the first since being released
Declaration
List<MouseButton> MouseButtonsReleasedThisFrame()
Returns
| Type | Description |
|---|---|
| List<MouseButton> |
WasGamepadButtonPressedThisFrame(Int32, GamepadButton)
Returns true if this is the first UPDATE since the button was pressed. Do NOT use in DRAW calls
Declaration
bool WasGamepadButtonPressedThisFrame(int id, GamepadButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
| GamepadButton | button | The button to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
WasGamepadButtonReleasedThisFrame(Int32, GamepadButton)
Returns true if this is the first UPDATE since the button was released. Do NOT use in DRAW calls
Declaration
bool WasGamepadButtonReleasedThisFrame(int id, GamepadButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | Positive id reference for gamepad |
| GamepadButton | button | The button to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
WasKeyPressedThisFrame(KeyCode)
Returns true if this is the first UPDATE since the key was pressed. Do NOT use in DRAW calls
Declaration
bool WasKeyPressedThisFrame(KeyCode key)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyCode | key | The key to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
WasKeyReleasedThisFrame(KeyCode)
Returns true if this is the first UPDATE since the key was released. . Do NOT use in DRAW calls
Declaration
bool WasKeyReleasedThisFrame(KeyCode key)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyCode | key | The key to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
WasMousePressedThisFrame(MouseButton)
Returns true if this is the first UPDATE since the button was pressed. . Do NOT use in DRAW calls
Declaration
bool WasMousePressedThisFrame(MouseButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseButton | button | The button to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |
WasMouseReleasedThisFrame(MouseButton)
Returns true if this is the first UPDATE since the button was released. . Do NOT use in DRAW calls
Declaration
bool WasMouseReleasedThisFrame(MouseButton button)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseButton | button | The button to query |
Returns
| Type | Description |
|---|---|
| System.Boolean |