Inputclass

Allows querying of player button presses and other inputs.

objectInput
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public static abstract sealed class Sandbox.Input

Methods22

Showing 22 methods

public static void Clear(string action)PUBLICSTATIC

Remove this action, so it's no longer being pressed.

ParameterTypeDescription
actionstring
Returns:void

public static void ClearActions()PUBLICSTATIC

Clears the current input actions, so that none of them are active.

Returns:void

public static bool Down(string action, bool complainOnMissing = True)PUBLICSTATIC

Action is currently pressed down

ParameterTypeDescription
actionstring
complainOnMissing = Truebool
Returns:bool

public static System.Collections.Generic.IEnumerable`1<Sandbox.InputAction> GetActions()PUBLICSTATIC

Copies all input actions to be used publicly

Returns:IEnumerable<InputAction>

public static float GetAnalog(Sandbox.InputAnalog analog)PUBLICSTATIC

An analog input, when fetched, is between -1 and 1 (0 being default)

ParameterTypeDescription
analogInputAnalog
Returns:float

public static string GetGroupName(string action)PUBLICSTATIC

Finds the `Sandbox.InputAction.GroupName` of the given action.

ParameterTypeDescription
actionstringAction name to find the group name of.
Returns:string

public static bool Pressed(string action)PUBLICSTATIC

Action wasn't pressed but now it is

ParameterTypeDescription
actionstring
Returns:bool

public static void ReleaseAction(string name)PUBLICSTATIC

Releases the action, and it won't be active again until it's pressed again.

ParameterTypeDescription
namestring
Returns:void

public static void ReleaseActions()PUBLICSTATIC

Clears the current input actions, so that none of them are active. Unlike ClearActions this will unpress the buttons, so they won't be active again until they're pressed again.

Returns:void

public static bool Released(string action)PUBLICSTATIC

Action was pressed but now it isn't

ParameterTypeDescription
actionstring
Returns:bool

public static void SetAction(string action, bool down)PUBLICSTATIC

ParameterTypeDescription
actionstring
downbool
Returns:void

public static void StopAllHaptics()PUBLICSTATIC

Stop all vibration events on the current controller.

Returns:void

Properties13

Showing 13 properties

public static System.Collections.Generic.IEnumerable`1<string> Sandbox.Input.ActionNames { get; set; }PUBLICSTATICGETSET

Names of all actions from the current game's input settings.

Returns:IEnumerable<string>

public static Angles Sandbox.Input.AnalogLook { get; set; }PUBLICSTATICGETSET

Analog look value from the default input device. This is scaled by Preferences.Sensitivity - so you don't need to scale it afterwards.

Returns:Angles

public static Vector3 Sandbox.Input.AnalogMove { get; set; }PUBLICSTATICGETSET

Analog move value from the default input device.

Returns:Vector3

public static int Sandbox.Input.ControllerCount { get; set; }PUBLICSTATICGETSET

How many controllers are active right now?

Returns:int

public static bool Sandbox.Input.EnableVirtualCursor { get; set; }PUBLICSTATICGETSET

Whether or not the Virtual Cursor should show when using a controller. Disable this to control the cursor manually.

Returns:bool

public static bool Sandbox.Input.EscapePressed { get; set; }PUBLICSTATICGETSET

True if escape was pressed

Returns:bool

public static Sandbox.InputMotionData Sandbox.Input.MotionData { get; set; }PUBLICSTATICGETSET

Current state of the current input device's motion sensor(s) if supported. This is only supported on: Dualshock 4+, Switch Controllers, Steam Controller, Steam Deck.

Returns:InputMotionData

public static bool Sandbox.Input.MouseCursorVisible { get; set; }PUBLICSTATICGETSET

True if the mouse cursor is visible (using UI etc)

Returns:bool

public static Vector2 Sandbox.Input.MouseDelta { get; set; }PUBLICSTATICGETSET

Movement delta from the mouse.

Returns:Vector2

public static Vector2 Sandbox.Input.MouseWheel { get; set; }PUBLICSTATICGETSET

The state of the mouse wheel.

Returns:Vector2

public static bool Sandbox.Input.Suppressed { get; set; }PUBLICSTATICGETSET

If the input is suppressed then everything will act like there is no input

Returns:bool

public static bool Sandbox.Input.UsingController { get; set; }PUBLICSTATICGETSET

Was the last button pressed a game controller button?

Returns:bool

public static Sandbox.VR.VRInput Sandbox.Input.VR { get; set; }PUBLICSTATICGETSET

Virtual Reality specific input data.

Returns:VRInput

On this page

Methodspublic static System.Void Clear(System.String action)public static System.Void ClearActions()public static System.Boolean Down(System.String action, System.Boolean complainOnMissing = True)public static System.Collections.Generic.IEnumerable`1<Sandbox.InputAction> GetActions()public static System.Single GetAnalog(Sandbox.InputAnalog analog)public static System.String GetButtonOrigin(Sandbox.InputAnalog analog)public static System.String GetButtonOrigin(System.String name, System.Boolean ignoreController = False)public static Sandbox.Texture GetGlyph(Sandbox.InputAnalog analog, Sandbox.InputGlyphSize size = 0, System.Boolean outline = False)public static Sandbox.Texture GetGlyph(System.String name, Sandbox.InputGlyphSize size = 0, Sandbox.GlyphStyle style = null)public static Sandbox.Texture GetGlyph(System.String name, Sandbox.InputGlyphSize size = 0, System.Boolean outline = False)public static System.String GetGroupName(System.String action)public static System.IDisposable PlayerScope(Sandbox.Input.PlayerIndex player)public static System.IDisposable PlayerScope(System.Int32 index)public static System.Boolean Pressed(System.String action)public static System.Void ReleaseAction(System.String name)public static System.Void ReleaseActions()public static System.Boolean Released(System.String action)public static System.Void SetAction(System.String action, System.Boolean down)public static System.Void StopAllHaptics()public static System.Void TriggerHaptics(Sandbox.HapticEffect pattern, System.Single lengthScale = 1, System.Single frequencyScale = 1, System.Single amplitudeScale = 1)public static System.Void TriggerHaptics(Sandbox.HapticEffect pattern, System.Single frequencyScale, System.Single amplitudeScale)public static System.Void TriggerHaptics(System.Single leftMotor, System.Single rightMotor, System.Single leftTrigger = 0, System.Single rightTrigger = 0, System.Int32 duration = 500)Propertiespublic static System.Collections.Generic.IEnumerable`1<System.String> Sandbox.Input.ActionNames { get; set; }public static Angles Sandbox.Input.AnalogLook { get; set; }public static Vector3 Sandbox.Input.AnalogMove { get; set; }public static System.Int32 Sandbox.Input.ControllerCount { get; set; }public static System.Boolean Sandbox.Input.EnableVirtualCursor { get; set; }public static System.Boolean Sandbox.Input.EscapePressed { get; set; }public static Sandbox.InputMotionData Sandbox.Input.MotionData { get; set; }public static System.Boolean Sandbox.Input.MouseCursorVisible { get; set; }public static Vector2 Sandbox.Input.MouseDelta { get; set; }public static Vector2 Sandbox.Input.MouseWheel { get; set; }public static System.Boolean Sandbox.Input.Suppressed { get; set; }public static System.Boolean Sandbox.Input.UsingController { get; set; }public static Sandbox.VR.VRInput Sandbox.Input.VR { get; set; }Metadata