Show / Hide Table of Contents

Class InputDevice

Abstract input device class.

To add new devices (e.g. xbox controller, steam controller, etc...), derive from this class and implement everything carefully.

If you want to use the MonoBehaviour.OnEnable or MonoBehaviour.OnDisable messages, please don't forget to override with a call to base.OnEnable(); or respectively base.OnDisable();.

Inheritance
System.Object
InputDevice
KeyboardAndMouse
Touchscreen
Namespace: GlitchedPolygons.Input
Assembly: UnityScriptsLibrary.dll
Syntax
public abstract class InputDevice : MonoBehaviour

Fields

| Improve this Doc View Source

LONG_BUTTON_PRESS_THRESHOLD

The minimum amount of seconds a button has to be held down for the ButtonPressedLong event to fire.

Declaration
public const float LONG_BUTTON_PRESS_THRESHOLD = 1.45F
Field Value
Type Description
System.Single

Methods

| Improve this Doc View Source

GetAxis(Int32)

Gets the current value of a game axis.

Declaration
public abstract float GetAxis(int axisIndex)
Parameters
Type Name Description
System.Int32 axisIndex

The axis to query (its integer index).

Returns
Type Description
System.Single

The current value of the game axis (usually this number is [-1;1] )

| Improve this Doc View Source

IsButtonDown(Int32)

Is a specific button currently held down?

Declaration
public bool IsButtonDown(int button)
Parameters
Type Name Description
System.Int32 button

Which button?

Returns
Type Description
System.Boolean

True if the specified button is held down; false if otherwise.

| Improve this Doc View Source

LoadFromJson(String)

Loads a json config that has been obtained with ToJson(Boolean) into this InputDevice instance.

Declaration
public void LoadFromJson(string json)
Parameters
Type Name Description
System.String json

The json config to load.

| Improve this Doc View Source

OnDisable()

Declaration
protected virtual void OnDisable()
| Improve this Doc View Source

OnEnable()

Declaration
protected virtual void OnEnable()
| Improve this Doc View Source

ToJson(Boolean)

Gets the device's configuration as a portable json string.

Declaration
public string ToJson(bool prettyPrint = false)
Parameters
Type Name Description
System.Boolean prettyPrint

Should the json look good?

Returns
Type Description
System.String

A portable json string representation of this InputDevice instance.

Events

| Improve this Doc View Source

ButtonPressed

This event is raised in the frame where the player presses a button.

Which button was pressed is passed as int argument.

Declaration
public abstract event Action<int> ButtonPressed
Event Type
Type Description
System.Action<System.Int32>
| Improve this Doc View Source

ButtonPressedLong

This event is raised when a button has been pressed and held down for at least LONG_BUTTON_PRESS_THRESHOLD seconds.

Declaration
public event Action<int> ButtonPressedLong
Event Type
Type Description
System.Action<System.Int32>
| Improve this Doc View Source

ButtonReleased

This event is invoked the frame when the user lets go of a button.

Which button was released is passed as int argument.

Declaration
public abstract event Action<int> ButtonReleased
Event Type
Type Description
System.Action<System.Int32>
  • Improve this Doc
  • View Source
Back to top Generated by DocFX