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
Name | Description | |
---|---|---|
UxrControllerInput |
Properties
Name | Description | |
---|---|---|
Current | 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. | |
Handedness |
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. | |
IsHandednessSupported |
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. | |
JoystickDeadZone | 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. | |
LeftController3DModel | Gets the left instanced 3D controller model, if available. In Single configurations where IsHandednessSupported is false, both sides will return the same model. | |
LeftControllerName | 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. | |
LogLevel | Gets or sets the current log level. This controls the amount of information sent. | |
MainJoystickIsTouchpad | 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. | |
Primary |
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. | |
RaiseConnectOnStart | 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. | |
RightController3DModel | Gets the right instanced 3D controller model, if available. In Single configurations where IsHandednessSupported is false, both sides will return the same model. | |
RightControllerName | 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. | |
SDKDependency | 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. | |
Secondary | Gets which hand is not holding the controller in Single setups where IsHandednessSupported is available. In Dual setups it identifies the non-dominant hand. | |
SetupType | Gets the setup type. See UxrControllerSetupType. |
Methods
Name | Description | |
---|---|---|
AreAllControllerElementsBlinking | Checks if all elements of a specific controller element are currently blinking | |
Awake | Initializes internal data (Overrides UxrAvatarComponent<T>.Awake().) | |
ButtonToControllerElement | Gets the controller element (UxrControllerElements) enum value given a controller button ( UxrInputButtons) enum value. | |
ControllerElementToButton | Gets the controller button (UxrInputButtons) enum value given a controller element ( UxrControllerElements) enum value. | |
ControllerElementToInput1D | Gets the UxrInput1D enum value given a controller element (UxrControllerElements ) enum value. | |
ControllerElementToInput2D | Gets the UxrInput2D enum value given a controller element (UxrControllerElements ) enum value. | |
FilterTwoAxesDeadZone | Filters a two-axis input using a dead-zone. Values inside the dead-zone will remain (0.0, 0.0). | |
GetButtonFlags | Gets flags representing the current button state | |
GetButtonPressFlags | Gets an uint value representing press states for each the controller UxrInputButtons flags in the current frame. | |
GetButtonPressFlagsLastFrame | Gets an uint value representing press states for each the in the last frame. | |
GetButtonsEvent | Checks if a given input event took place for a button or all buttons in a set in the current frame. | |
GetButtonsEventAny | Checks if a given input event took place for a button or any button in a set in the current frame. | |
GetButtonsPress | Checks if the given button or buttons are being pressed in the current frame. | |
GetButtonsPressAny | Checks if the given button or any button in a set is being pressed in the current frame. | |
GetButtonsPressDown | Checks if the given button or buttons are being pressed in the current frame but weren’t the previous frame (press-down). | |
GetButtonsPressDownAny | 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). | |
GetButtonsPressUp | Checks if the given button or buttons aren’t being pressed in the current frame but were during the previous frame (release press). | |
GetButtonsPressUpAny | 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). | |
GetButtonsTouch | Checks if the given button or all buttons in a set are being touched in the current frame. | |
GetButtonsTouchAny | Checks if the given button or any button in a set is being touched in the current frame. | |
GetButtonsTouchDown | Checks if the given button or buttons are being touched in the current frame but weren’t the previous frame (touch-down). | |
GetButtonsTouchDownAny | 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). | |
GetButtonsTouchUp | Checks if the given button or buttons aren’t being touched in the current frame but were during the previous frame (release touch). | |
GetButtonsTouchUpAny | 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). | |
GetButtonTouchFlags | Gets an uint value representing touch states for each the controller UxrInputButtons flags in the current frame. | |
GetButtonTouchFlagsLastFrame | Gets an uint value representing touch states for each the controller UxrInputButtons flags in the last frame. | |
GetController3DModel | Gets the instanced controller 3D model for a given hand. | |
GetControllerCapabilities | Gets the capabilities of the XR controller. | |
GetControllerElementsGameObjects | 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. | |
GetIgnoreControllerInput | Gets whether the given controller input should be ignored. | |
GetInput1D | Gets the state of an analog controller input element. | |
GetInput2D | Gets the state of a 2D input element (joystick, touchpad…). | |
HasControllerElements | Checks if the given controller has specific elements. | |
Input1DToControllerElement | Gets the controller elements UxrControllerElements enum value given a UxrInput1D enum value. | |
Input2DToAngle | Transforms a two-axis input to an angle. 0 degrees is right and degrees increase counterclockwise. | |
Input2DToControllerElement | Gets the controller elements UxrControllerElements enum value given a UxrInput2D enum value. | |
IsAnyControllerElementBlinking | Checks if any specific controller element is currently blinking | |
IsControllerEnabled | Checks whether the given controller is enabled. | |
IsInput2dDPadDown(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. | |
IsInput2dDPadDown(Vector2) | Checks if the given 2-axis input corresponds to a down press in a digital pad. | |
IsInput2dDPadLeft(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. | |
IsInput2dDPadLeft(Vector2) | Checks if the given 2-axis input corresponds to a left press in a digital pad. | |
IsInput2dDPadRight(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. | |
IsInput2dDPadRight(Vector2) | Checks if the given 2-axis input corresponds to a right press in a digital pad. | |
IsInput2dDPadUp(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. | |
IsInput2dDPadUp(Vector2) | Checks if the given 2-axis input corresponds to an up press in a digital pad. | |
OnButtonStateChanged | Event trigger for the ButtonStateChanged event | |
OnDestroy | Sets events to null in order to help remove unused references (Overrides UxrComponent<T>.OnDestroy().) | |
OnDeviceConnected | Event trigger for the DeviceConnected event | |
OnHapticRequesting | Event trigger for the HapticRequesting event | |
OnInput1DChanged | Event trigger for the Input1DChanged event | |
OnInput2DChanged | Event trigger for the Input2DChanged event | |
OnUpdated | Event trigger for the Updated event | |
OnUpdating | Event trigger for the Updating event | |
SendGrabbableHapticFeedback(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. | |
SendGrabbableHapticFeedback(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. | |
SendHapticFeedback(UxrHandSide, UxrHapticClip) | Sends haptic feedback to a controller if the controller supports it. | |
SendHapticFeedback(UxrHandSide, Single, Single, Single, UxrHapticMode) | Sends haptic feedback to a controller if the controller supports it. | |
SendHapticFeedback(UxrHandSide, UxrHapticClipType, Single, Single, UxrHapticMode) | Sends a predefined haptic clip to a controller. | |
SetButtonFlags | Sets the given button flags | |
SetIgnoreControllerInput | Sets whether the given controller input should be ignored. | |
ShouldIgnoreInput | Checks whether the given hand input should be ignored. | |
Start | Unity Start event (Overrides UxrComponent.Start().) | |
StartControllerElementsBlinking | Starts blinking one or more elements in a controller. This can be useful during tutorials to highlight which button(s) to press. | |
StopAllBlinking | Stops all controller elements to blink | |
StopControllerElementsBlinking | Stops controller elements to blink | |
StopHapticFeedback | Stops all current haptics in a given controller. | |
UpdateInput | 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
Name | Description | |
---|---|---|
ButtonStateChanged | Event called after a controller button state changed. | |
DeviceConnected | Event called whenever the device is connected or disconnected | |
GlobalButtonStateChanged | Event called after any controller button state changed. | |
GlobalControllerConnected | Event called whenever any controller input device is connected or disconnected | |
GlobalHapticRequesting | Event called right before any haptic feedback was requested. | |
GlobalInput1DChanged | Event called after any UxrInput1D element changed. | |
GlobalInput2DChanged | Event called after any UxrInput2D element changed. | |
HapticRequesting | Event called right before haptic feedback was requested. | |
Input1DChanged | Event called after a UxrInput1D element changed. | |
Input2DChanged | Event called after a UxrInput2D element changed. | |
Updated | Event called right after the controller input state has been updated. | |
Updating | Event called right before the controller input state is updated. |
Fields
Name | Description | |
---|---|---|
_controller | ||
_enableObjectList | ||
_enableObjectListLeft | ||
_enableObjectListRight | ||
_leftController | ||
_rightController | ||
AnalogAsDPadThreshold | Minimum axis value required to consider an analog input as a DPad digital press in any direction. | |
DefaultHapticAmplitude | Default haptic amplitude if not specified |
Extension Methods
Name | Description | |
---|---|---|
CheckSetEnabled | Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.) | |
GetOrAddComponent<T> | Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.) | |
GetPathUnderScene | Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.) | |
GetSceneUid | Gets an unique identifier string for the given component. (Defined by ComponentExt.) | |
GetUniqueScenePath | 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.) | |
LoopCoroutine | Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.) | |
SafeGetComponentInParent<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.) | |
ShowInInspector(Boolean) | Overloaded. Controls whether to show the current object in the inspector. (Defined by ObjectExt.) | |
ShowInInspector(Boolean, Boolean) | Overloaded. Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.) | |
ThrowIfNull | Throws an exception if the object is null. (Defined by ObjectExt.) |