Skip to content

LocalPlayerInput

namespace Griff.Runtime;
public sealed class LocalPlayerInput : IInput

One player’s share of this machine’s controls (see LocalPlayers): the keys of their side of the keyboard (or all of it, with the mouse), and their own controller. The actions are the game’s, read on those keys and that controller only: on the left keys Punch is F and Kick G, on the right K and L, and the rest are the action’s own keys on that side of the keyboard.

public IReadOnlyCollection<string> Actions { get; }
public InputBinding? AnyPressed { get; }
public MouseCursor Cursor { get; set; }
public float Horizontal { get; }
public bool IsGamepadConnected { get; }
public bool IsMouseInView { get; }
public bool IsMouseLocked { get; }
public KeySet Keys { get; }

Which keys it has.

public static IReadOnlyDictionary<string, Key[]> LeftKeys { get; }

The keys the actions have on the left side of the keyboard, where they aren’t simply their own keys on that side: WASD moves, F and G are the first buttons (Punch and Kick, Fire and Attack).

public Vector2 LeftStick { get; }
public float LeftTrigger { get; }
public Vector2 MouseDelta { get; }
public Vector2? MouseOnScreen { get; }
public Vector2 MouseWorld { get; }
public Vector2 Move { get; }
public int Pad { get; }

The platform’s number of its controller, or -1 for none.

public static IReadOnlyDictionary<string, Key[]> RightKeys { get; }

The keys the actions have on the right side of the keyboard: the arrows move, K and L (or the number pad’s 1 and 2) are the first buttons.

public Vector2 RightStick { get; }
public float RightTrigger { get; }
public float Scroll { get; }
public string TypedText { get; }
public bool UsingGamepad { get; }
public float Vertical { get; }
public bool WantsMouseLock { get; set; }
public Vector2 AimFrom(Vector2 origin)
public Vector2 AimFrom(Vector3 origin)
public void Bind(string action, params InputBinding[] bindings)
public IReadOnlyList<InputBinding> BindingsOf(string action)

The keys and buttons that are action for this player: their side’s keys, and the controller’s buttons.

public bool IsDown(string action)
public bool IsDown(Key key)
public bool IsDown(MouseButton button)
public bool IsDown(GamepadButton button)
public IReadOnlyList<Key> KeysOf(string action, KeySet side)

The keys action has on side of the keyboard (all of them for All).

public static bool OnLeft(Key key)

True if key is on the left side of the keyboard (as the left keys’ player has it).

public void Rebind(string action, params InputBinding[] bindings)
public void ResetBindings(string? action = null)
public void Rumble(float strength = 0.5f, float seconds = 0.2f)
public string TypeInto(string text, int maxLength = 2147483647)
public bool WasPressed(string action)
public bool WasPressed(Key key)
public bool WasPressed(MouseButton button)
public bool WasPressed(GamepadButton button)
public bool WasPressed(string action, float buffer)
public bool WasReleased(string action)
public bool WasReleased(Key key)
public bool WasReleased(MouseButton button)
public bool WasReleased(GamepadButton button)