Click or drag to resize

InputState Class

[This is preliminary documentation and is subject to change.]

The main component of the library. You need to add this to every scene that uses components that query input. You should also give it priority over everything else in the script execution order settings.
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          RavingBots.MultiInputInputState

Namespace:  RavingBots.MultiInput
Assembly:  RavingBots.MultiInput (in RavingBots.MultiInput.dll) Version: 0.12
Syntax
C#
public sealed class InputState : MonoBehaviour

The InputState type exposes the following members.

Constructors
  NameDescription
Public methodInputState
Initializes a new instance of the InputState class
Top
Properties
  NameDescription
Public propertyDevices
The list of currently active devices. Subscribe to the DeviceStateChanged event to be notified when this list changes.
Top
Methods
Fields
  NameDescription
Public fieldDevicesEnumerated
Event fired after the Devices list is first populated. Will only be fired once during the component lifetime (use DeviceStateChanged event to get updates).
Public fieldDeviceStateChanged
Event fired when the Devices list changes.
Public fieldLifetimeManagement
Toggles lifetime management. If true, DontDestroyOnLoad will be called on GameObject containing this component and extraneous instances will be automatically destroyed. InputState must strictly outlive all device objects, so this is necessary if you want IDevice objects to be usable after scene changes.
Public fieldLogLevel
Preferred log level.
Public fieldUseFixedUpdate
Switches to using FixedUpdate to drain events and poll for updates.
Top
Extension Methods
  NameDescription
Public Extension MethodCode exampleFindFirst(FuncIDevice, IVirtualAxis, Boolean)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirst(FuncIDevice, IVirtualAxis, Boolean, InputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirst(FuncIDevice, IVirtualAxis, Boolean, IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirst(IDevice, IVirtualAxis, FuncIDevice, IVirtualAxis, Boolean)Overloaded.
Queries all axes on all devices, and returns first for which a given predicate returns true. If you don't require a custom predicate (i.e. you just want to check IsHeld or similar), you should use simpler variants like FindFirstHeld(InputState, IDevice, IVirtualAxis).
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirst(IDevice, IVirtualAxis, FuncIDevice, IVirtualAxis, Boolean, InputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstDownOverloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstDown(InputCode)Overloaded.
Overload of FindFirstDown(InputState, IDevice, IVirtualAxis) that only returns the device and limits the search to selected axes, given as params argument. Use this form if you only need the device object and you're specifying input codes manually.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstDown(IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstDown(IDevice, IVirtualAxis)Overloaded.
Queries all axes on all devices, and returns the first for which IsDown is true.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstDown(IDevice, IVirtualAxis, InputCode)Overloaded.
Overload of FindFirstDown(InputState, IDevice, IVirtualAxis) that limits the search to selected axes, given as params argument. Use this form if you're specifying input codes manually.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstDown(IDevice, IVirtualAxis, IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstHeldOverloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstHeld(InputCode)Overloaded.
Overload of FindFirstHeld(InputState, IDevice, IVirtualAxis) that only returns the device and limits the search to selected axes, given as params argument. Use this form if you only need the device object and you're specifying input codes manually.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstHeld(IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstHeld(IDevice, IVirtualAxis)Overloaded.
Queries all axes on all devices, and returns the first for which IsHeld is true.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstHeld(IDevice, IVirtualAxis, InputCode)Overloaded.
Overload of FindFirstHeld(InputState, IDevice, IVirtualAxis) that limits the search to selected axes, given as params argument. Use this form if you're specifying input codes manually.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstHeld(IDevice, IVirtualAxis, IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstUpOverloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstUp(InputCode)Overloaded.
Overload of FindFirstUp(InputState, IDevice, IVirtualAxis) that only returns the device and limits the search to selected axes, given as params argument. Use this form if you only need the device object and you're specifying input codes manually.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstUp(IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstUp(IDevice, IVirtualAxis)Overloaded.
Queries all axes on all devices, and returns the first for which IsUp is true.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstUp(IDevice, IVirtualAxis, InputCode)Overloaded.
Overload of FindFirstUp(InputState, IDevice, IVirtualAxis) that limits the search to selected axes, given as params argument. Use this form if you're specifying input codes manually.
(Defined by InputStateExt.)
Public Extension MethodCode exampleFindFirstUp(IDevice, IVirtualAxis, IEnumerableInputCode)Overloaded. (Defined by InputStateExt.)
Top
Remarks
Important note Important
There should ever be only one alive instance of this component, and the instance must outlive all active IDevice objects. Having multiple active instances is unsupported and might cause issues. If you don't have special requirements you should leave LifetimeManagement set to true.

This component initializes and controls the native code used to query the OS for state of devices and their virtual axes. All of the currently detected devices can be found through the Devices property. Additionally, you can subscribe to the DeviceStateChanged event to be notified when a new device is plugged in, or an old device is unplugged.

InputStateExt class contains a set of convenience methods for querying a range of devices on a range of axes.

Thread Safety
Static members of this type are not safe for multi-threaded operations. Instance members of this type are not safe for multi-threaded operations.
See Also