UxrControllerInput Class

Controller base class for all VR input devices, supporting single controllers and dual controller setups.

Inheritance Hierarchy

System.Object
  Object
    Component
      Behaviour
        MonoBehaviour
          UltimateXR.Core.Components.UxrComponent
            UltimateXR.Core.Components.UxrComponent(UxrControllerInput)
              UltimateXR.Core.Components.Composite.UxrAvatarComponent(UxrControllerInput)
                UltimateXR.Devices.UxrControllerInput
                  UltimateXR.Devices.Integrations.SteamVR.UxrSteamVRControllerInput
                  UltimateXR.Devices.Integrations.UxrDummyControllerInput
                  UltimateXR.Devices.Integrations.UxrGamepadInput
                  UltimateXR.Devices.Integrations.UxrUnityXRControllerInput
Namespace: UltimateXR.Devices
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0

Syntax

C#

public abstract class UxrControllerInput : UxrAvatarComponent<UxrControllerInput>, 
	IUxrControllerInput, IUxrDevice


The UxrControllerInput type exposes the following members.

Constructors

NameDescription
Protected methodUxrControllerInput

Properties

NameDescription
Public propertyStatic memberCurrent Gets the current input component, which is the enabled input component belonging to the local avatar. If the avatar has no input component enabled, it will return a dummy input so that there is no need to check for nulls. This dummy component doesn’t generate input events. The only way to get a null would be if there is no local avatar in the scene.
Public propertyHandedness

Gets or sets the handedness, which is the Primary -dominant- hand in Dual controller setups. In Single controller setups where the controller is grabbed with one hand, it determines which hand is being used. If IsHandednessSupported false, such as in gamepads, the handedness value should be ignored.

Public propertyIsHandednessSupported

Gets whether Handedness can be used. In Single devices, it may be used to control which hand is holding the controller. In Dual devices it is used to determine which hands have the Primary (dominant) and Secondary (non-dominant) roles. Devices such as gamepads don’t support handedness and will target the single device no matter which UxrHandSide is used. In this case it is good practice to use Primary to target the device in order to make the code cleaner.

Public propertyJoystickDeadZone Gets the controller’s joystick dead zone [0.0, 1.0]. Some controllers may have a more sensitive joystick, and this property can be used to compensate in different implementations.
Public propertyLeftController3DModel Gets the left instanced 3D controller model, if available. In Single configurations where IsHandednessSupported is false, both sides will return the same model.
Public propertyLeftControllerName Gets the left controller name, or empty if not connected / doesn’t exist. In Single configurations where IsHandednessSupported is not available, both sides will return the same name.
Public propertyStatic memberLogLevel Gets or sets the current log level. This controls the amount of information sent.
Public propertyMainJoystickIsTouchpad Gets a value indicating whether the main two-axis input element is a touchpad. If false, it usually means the main joystick is a thumbstick.
Public propertyPrimary

Gets which hand is holding the controller in Single setups where IsHandednessSupported is available. In Dual setups it identifies the dominant hand. In both cases, Handedness determines which hand it is. In Single devices where handedness is not applicable ( IsHandednessSupported is false) it is good practice to use Primary to address the device, even if both left and right can too.

Protected propertyRaiseConnectOnStart Used by child classes to notify that the Connect event should be forcefully raised during Start(). This is required to propagate Connect events properly when a new scene is loaded and the devices are already connected and thus not sending any events. We still need to get Connect notifications, so child classes need to detect during Awake() if the device(s) are already connected and if so, notify that the Connect event needs to be raised.
Public propertyRightController3DModel Gets the right instanced 3D controller model, if available. In Single configurations where IsHandednessSupported is false, both sides will return the same model.
Public propertyRightControllerName Gets the right controller name, or empty if not connected / doesn’t exist. In Single configurations where IsHandednessSupported is not available, both sides will return the same name.
Public propertySDKDependency Gets the SDK the implemented device needs in order to be available. It should be null or empty if there is no SDK dependency. Otherwise is should use any of the SDK names in UxrManager. For example if requires the Oculus SDK, it should return SdkOculus.
Public propertySecondary Gets which hand is not holding the controller in Single setups where IsHandednessSupported is available. In Dual setups it identifies the non-dominant hand.
Public propertySetupType Gets the setup type. See UxrControllerSetupType.

Methods

NameDescription
Public methodAreAllControllerElementsBlinking Checks if all elements of a specific controller element are currently blinking
Protected methodAwake Initializes internal data (Overrides UxrAvatarComponent<T>.Awake().)
Public methodStatic memberButtonToControllerElement Gets the controller element (UxrControllerElements) enum value given a controller button ( UxrInputButtons) enum value.
Public methodStatic memberControllerElementToButton Gets the controller button (UxrInputButtons) enum value given a controller element ( UxrControllerElements) enum value.
Public methodStatic memberControllerElementToInput1D Gets the UxrInput1D enum value given a controller element (UxrControllerElements ) enum value.
Public methodStatic memberControllerElementToInput2D Gets the UxrInput2D enum value given a controller element (UxrControllerElements ) enum value.
Protected methodStatic memberFilterTwoAxesDeadZone Filters a two-axis input using a dead-zone. Values inside the dead-zone will remain (0.0, 0.0).
Protected methodGetButtonFlags Gets flags representing the current button state
Public methodGetButtonPressFlags Gets an uint value representing press states for each the controller UxrInputButtons flags in the current frame.
Public methodGetButtonPressFlagsLastFrame Gets an uint value representing press states for each the in the last frame.
Public methodGetButtonsEvent Checks if a given input event took place for a button or all buttons in a set in the current frame.
Public methodGetButtonsEventAny Checks if a given input event took place for a button or any button in a set in the current frame.
Public methodGetButtonsPress Checks if the given button or buttons are being pressed in the current frame.
Public methodGetButtonsPressAny Checks if the given button or any button in a set is being pressed in the current frame.
Public methodGetButtonsPressDown Checks if the given button or buttons are being pressed in the current frame but weren’t the previous frame (press-down).
Public methodGetButtonsPressDownAny Checks if the given button or any button in a set is being pressed in the current frame but wasn’t the previous frame (press-down).
Public methodGetButtonsPressUp Checks if the given button or buttons aren’t being pressed in the current frame but were during the previous frame (release press).
Public methodGetButtonsPressUpAny Checks if the given button or any button in a set isn’t being pressed in the current frame but was during the previous frame (release press).
Public methodGetButtonsTouch Checks if the given button or all buttons in a set are being touched in the current frame.
Public methodGetButtonsTouchAny Checks if the given button or any button in a set is being touched in the current frame.
Public methodGetButtonsTouchDown Checks if the given button or buttons are being touched in the current frame but weren’t the previous frame (touch-down).
Public methodGetButtonsTouchDownAny Checks if the given button or any button in a set is being touched in the current frame but not in the previous frame (touch-down).
Public methodGetButtonsTouchUp Checks if the given button or buttons aren’t being touched in the current frame but were during the previous frame (release touch).
Public methodGetButtonsTouchUpAny Checks if the given button or any button in a set isn’t being touched in the current frame but was during the previous frame (release touch).
Public methodGetButtonTouchFlags Gets an uint value representing touch states for each the controller UxrInputButtons flags in the current frame.
Public methodGetButtonTouchFlagsLastFrame Gets an uint value representing touch states for each the controller UxrInputButtons flags in the last frame.
Public methodGetController3DModel Gets the instanced controller 3D model for a given hand.
Public methodGetControllerCapabilities Gets the capabilities of the XR controller.
Public methodGetControllerElementsGameObjects Returns a list of GameObjects that represent parts of the instantiated controller. This can be useful to highlight buttons or other elements during tutorials. Functionality to make these elements blink is also provided by the framework.
Public methodStatic memberGetIgnoreControllerInput Gets whether the given controller input should be ignored.
Public methodGetInput1D Gets the state of an analog controller input element.
Public methodGetInput2D Gets the state of a 2D input element (joystick, touchpad…).
Public methodHasControllerElements Checks if the given controller has specific elements.
Public methodStatic memberInput1DToControllerElement Gets the controller elements UxrControllerElements enum value given a UxrInput1D enum value.
Protected methodStatic memberInput2DToAngle Transforms a two-axis input to an angle. 0 degrees is right and degrees increase counterclockwise.
Public methodStatic memberInput2DToControllerElement Gets the controller elements UxrControllerElements enum value given a UxrInput2D enum value.
Public methodIsAnyControllerElementBlinking Checks if any specific controller element is currently blinking
Public methodIsControllerEnabled Checks whether the given controller is enabled.
Protected methodStatic memberIsInput2dDPadDown(Single) Checks if the given 2-axis input represented as an angle in degrees corresponds to a down press in a digital pad. 0 degrees is right and degrees increase counterclockwise.
Protected methodStatic memberIsInput2dDPadDown(Vector2) Checks if the given 2-axis input corresponds to a down press in a digital pad.
Protected methodStatic memberIsInput2dDPadLeft(Single) Checks if the given 2-axis input represented as an angle in degrees corresponds to a left press in a digital pad. 0 degrees is right and degrees increase counterclockwise.
Protected methodStatic memberIsInput2dDPadLeft(Vector2) Checks if the given 2-axis input corresponds to a left press in a digital pad.
Protected methodStatic memberIsInput2dDPadRight(Single) Checks if the given 2-axis input represented as an angle in degrees corresponds to a right press in a digital pad. 0 degrees is right and degrees increase counterclockwise.
Protected methodStatic memberIsInput2dDPadRight(Vector2) Checks if the given 2-axis input corresponds to a right press in a digital pad.
Protected methodStatic memberIsInput2dDPadUp(Single) Checks if the given 2-axis input represented as an angle in degrees corresponds to an up press in a digital pad. 0 degrees is right and degrees increase counterclockwise.
Protected methodStatic memberIsInput2dDPadUp(Vector2) Checks if the given 2-axis input corresponds to an up press in a digital pad.
Protected methodOnButtonStateChanged Event trigger for the ButtonStateChanged event
Protected methodOnDestroy Sets events to null in order to help remove unused references (Overrides UxrComponent<T>.OnDestroy().)
Protected methodOnDeviceConnected Event trigger for the DeviceConnected event
Protected methodOnHapticRequesting Event trigger for the HapticRequesting event
Protected methodOnInput1DChanged Event trigger for the Input1DChanged event
Protected methodOnInput2DChanged Event trigger for the Input2DChanged event
Protected methodOnUpdated Event trigger for the Updated event
Protected methodOnUpdating Event trigger for the Updating event
Public methodSendGrabbableHapticFeedback(UxrGrabbableObject, UxrHapticClip) Sends haptic feedback to XR controllers that are being used to manipulate a grabbable object. Each hand associated to an XR controller that is grabbing the object will receive haptic feedback.
Public methodSendGrabbableHapticFeedback(UxrGrabbableObject, UxrHapticClipType, Single, Single, UxrHapticMode) Sends haptic feedback to XR controllers that are being used to manipulate a grabbable object. Each hand associated to an XR controller that is grabbing the object will receive haptic feedback.
Public methodSendHapticFeedback(UxrHandSide, UxrHapticClip) Sends haptic feedback to a controller if the controller supports it.
Public methodSendHapticFeedback(UxrHandSide, Single, Single, Single, UxrHapticMode) Sends haptic feedback to a controller if the controller supports it.
Public methodSendHapticFeedback(UxrHandSide, UxrHapticClipType, Single, Single, UxrHapticMode) Sends a predefined haptic clip to a controller.
Protected methodSetButtonFlags Sets the given button flags
Public methodStatic memberSetIgnoreControllerInput Sets whether the given controller input should be ignored.
Protected methodShouldIgnoreInput Checks whether the given hand input should be ignored.
Protected methodStart Unity Start event (Overrides UxrComponent.Start().)
Public methodStartControllerElementsBlinking Starts blinking one or more elements in a controller. This can be useful during tutorials to highlight which button(s) to press.
Public methodStopAllBlinking Stops all controller elements to blink
Public methodStopControllerElementsBlinking Stops controller elements to blink
Public methodStopHapticFeedback Stops all current haptics in a given controller.
Protected methodUpdateInput Virtual method that should be overriden in child classes in order to update the current input state information (buttons and all the other elements in the controllers).

Events

NameDescription
Public eventButtonStateChanged Event called after a controller button state changed.
Public eventDeviceConnected Event called whenever the device is connected or disconnected
Public eventStatic memberGlobalButtonStateChanged Event called after any controller button state changed.
Public eventStatic memberGlobalControllerConnected Event called whenever any controller input device is connected or disconnected
Public eventStatic memberGlobalHapticRequesting Event called right before any haptic feedback was requested.
Public eventStatic memberGlobalInput1DChanged Event called after any UxrInput1D element changed.
Public eventStatic memberGlobalInput2DChanged Event called after any UxrInput2D element changed.
Public eventHapticRequesting Event called right before haptic feedback was requested.
Public eventInput1DChanged Event called after a UxrInput1D element changed.
Public eventInput2DChanged Event called after a UxrInput2D element changed.
Public eventUpdated Event called right after the controller input state has been updated.
Public eventUpdating Event called right before the controller input state is updated.

Fields

NameDescription
Protected field_controller
Protected field_enableObjectList
Protected field_enableObjectListLeft
Protected field_enableObjectListRight
Protected field_leftController
Protected field_rightController
Protected fieldStatic memberAnalogAsDPadThreshold Minimum axis value required to consider an analog input as a DPad digital press in any direction.
Protected fieldStatic memberDefaultHapticAmplitude Default haptic amplitude if not specified

Extension Methods

NameDescription
Public Extension MethodCheckSetEnabled Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.)
Public Extension MethodGetOrAddComponent<T> Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.)
Public Extension MethodGetPathUnderScene Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.)
Public Extension MethodGetSceneUid Gets an unique identifier string for the given component. (Defined by ComponentExt.)
Public Extension MethodGetUniqueScenePath Gets an unique path in the scene for the given component. It will include scene name, sibling and component indices to make it unique. (Defined by ComponentExt.)
Public Extension MethodLoopCoroutine Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.)
Public Extension MethodSafeGetComponentInParent<T> Gets the Component of a given type in the GameObject or any of its parents. It also works on prefabs, where regular GetComponentInParent(Type, Boolean) will not work: https://issuetracker.unity3d.com/issues/getcomponentinparent-is-returning-null-when-the-gameobject-is-a-prefab (Defined by ComponentExt.)
Public Extension MethodShowInInspector(Boolean)Overloaded.
Controls whether to show the current object in the inspector. (Defined by ObjectExt.)
Public Extension MethodShowInInspector(Boolean, Boolean)Overloaded.
Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.)
Public Extension MethodThrowIfNull Throws an exception if the object is null. (Defined by ObjectExt.)

See Also

Reference

UltimateXR.Devices Namespace