IHostInput
namespace Griff.Runtime;
public interface IHostInput : IInputA game’s input as its host drives it (HostInput), where IInput is what the game reads: what the keyboard, mouse, touch screen and controllers do, as they do it; its frames; the project’s controls; the player’s rebinding, kept in the game’s saves; and what the game asks of the host back (the controllers’ rumble, the pointer, holding the mouse). A platform feeds this and nothing else, so a new one’s input keeps the actions, rebinding and local players every other has: InputState does those once, for all of them.
Properties
Section titled “Properties”IsMouseInView
Section titled “IsMouseInView”public abstract bool IsMouseInView { get; set; }Whether the mouse is over the game’s view.
IsMouseLocked
Section titled “IsMouseLocked”public abstract bool IsMouseLocked { get; set; }Whether the host holds the mouse for the game (see WantsMouseLock).
MouseOnScreen
Section titled “MouseOnScreen”public abstract Vector2? MouseOnScreen { get; set; }Where the mouse is on the view (-1..1 each way, up positive), set after MouseWorld; null when unknown.
MouseWorld
Section titled “MouseWorld”public abstract Vector2 MouseWorld { get; set; }Where the mouse is in the world, which the host works out through the camera. Setting it forgets MouseOnScreen.
RumbleStrength
Section titled “RumbleStrength”public abstract float RumbleStrength { get; }How hard the controllers should be shaking now, 0..1 (the strongest).
Methods
Section titled “Methods”AddMouseDelta
Section titled “AddMouseDelta”public abstract void AddMouseDelta(Vector2 pixels)The mouse moved this many pixels (right and up positive), for MouseDelta.
AddScroll
Section titled “AddScroll”public abstract void AddScroll(float notches)The wheel turned this many notches.
AddText
Section titled “AddText”public abstract void AddText(string text)Characters were typed.
BeginFrame
Section titled “BeginFrame”public abstract void BeginFrame(float realSeconds)Starts a step: what changed since the last is seen from now on (the game calls it).
EndFrame
Section titled “EndFrame”public abstract void EndFrame()Ends a step: “pressed” and “released” are over, and the frame’s typing, scrolling and mouse movement.
HoldGamepadButton
Section titled “HoldGamepadButton”public abstract void HoldGamepadButton(int index, GamepadButton button, bool down)Holds (or lets go of) one button on controller index, leaving the rest as they are.
MouseMoved
Section titled “MouseMoved”public abstract void MouseMoved()The real mouse moved (so the keyboard and mouse are what’s being played with).
PlaceTouches
Section titled “PlaceTouches”public abstract void PlaceTouches(Func<Vector2, Vector2> toWorld)Puts the fingers given on the screen in the world, through toWorld (the view as it is now).
ReleaseAll
Section titled “ReleaseAll”public abstract void ReleaseAll()Everything held is let go (the game lost the keyboard).
RumbleStrengthOf
Section titled “RumbleStrengthOf”public abstract float RumbleStrengthOf(int index)How hard controller index should be shaking now, 0..1.
SetGamepad
Section titled “SetGamepad”public abstract void SetGamepad(int index, IEnumerable<GamepadButton> down, Vector2 leftStick, Vector2 rightStick, float leftTrigger = 0f, float rightTrigger = 0f)Controller index this frame: what’s held, its sticks and triggers (0..1).
SetGamepadConnected
Section titled “SetGamepadConnected”public abstract void SetGamepadConnected(int index, bool connected)Controller index was plugged in or pulled out.
SetKey
Section titled “SetKey”public abstract void SetKey(Key key, bool down)A key went down or up.
SetMouseButton
Section titled “SetMouseButton”public abstract void SetMouseButton(MouseButton button, bool down)A mouse button went down or up.
SetTouch
Section titled “SetTouch”public abstract void SetTouch(int id, Vector2 at, bool down, bool onScreen = false)A finger at at, down or lifted: in the world, or with onScreen on the view (-1..1 across it), put in the world by PlaceTouches.
StopRumble
Section titled “StopRumble”public abstract void StopRumble()Stops every controller shaking (the game stopped or paused).
TypeBackspace
Section titled “TypeBackspace”public abstract void TypeBackspace()Backspace was pressed (or repeated).
UseControls
Section titled “UseControls”public abstract void UseControls(IReadOnlyDictionary<string, IReadOnlyList<InputBinding>> controls)Plays with the project’s controls: its own actions and the built-in ones it changed.
UseSaveData
Section titled “UseSaveData”public abstract void UseSaveData(SaveData saveData)Keeps the player’s rebinding (Rebind) in saveData, and plays with what’s there.