Guides
Guides

SDK_BaseController

extends SDK_Base

Overview

The Base Controller SDK script provides a bridge to SDK methods that deal with the input devices.

This is an abstract class to implement the interface required by all implemented SDKs.

Class Variables

  • public enum ButtonTypes - Types of buttons on a controller
    • ButtonOne - Button One on the controller.
    • ButtonTwo - Button Two on the controller.
    • Grip - Grip on the controller.
    • GripHairline - Grip Hairline on the controller.
    • StartMenu - Start Menu on the controller.
    • Trigger - Trigger on the controller.
    • TriggerHairline - Trigger Hairline on the controller.
    • Touchpad - Touchpad on the controller.
    • TouchpadTwo - Touchpad Two on the controller.
    • MiddleFinger - Middle Finger on the controller.
    • RingFinger - Ring Finger on the controller.
    • PinkyFinger - Pinky Finger on the controller.
  • public enum ButtonPressTypes - Concepts of controller button press
    • Press - The button is currently being pressed.
    • PressDown - The button has just been pressed down.
    • PressUp - The button has just been released.
    • Touch - The button is currently being touched.
    • TouchDown - The button has just been touched.
    • TouchUp - The button is no longer being touched.
  • public enum ControllerElements - The elements of a generic controller
    • AttachPoint - The default point on the controller to attach grabbed objects to.
    • Trigger - The trigger button.
    • GripLeft - The left part of the grip button collection.
    • GripRight - The right part of the grip button collection.
    • Touchpad - The touch pad/stick.
    • ButtonOne - The first generic button.
    • ButtonTwo - The second generic button.
    • SystemMenu - The system menu button.
    • Body - The encompassing mesh of the controller body.
    • StartMenu - The start menu button.
    • TouchpadTwo - The touch pad/stick two.
  • public enum ControllerHand - Controller hand reference.
    • None - No hand is assigned.
    • Left - The left hand is assigned.
    • Right - The right hand is assigned.
  • public enum ControllerType - SDK Controller types.
    • Undefined - No controller type.
    • Custom - A custom controller type.
    • Simulator_Hand - The Simulator default hand controller.
    • SteamVR_ViveWand - The HTC Vive wand controller for SteamVR.
    • SteamVR_OculusTouch - The Oculus Touch controller for SteamVR.
    • Oculus_OculusTouch - The Oculus Touch controller for Oculus Utilities.
    • Daydream_Controller - The Daydream controller for Google Daydream SDK.
    • Ximmerse_Flip - The Flip controller for Ximmerse SDK.
    • SteamVR_ValveKnuckles - The Valve Knuckles controller for SteamVR.
    • Oculus_OculusGamepad - The Oculus Gamepad for Oculus Utilities.
    • Oculus_OculusRemote - The Oculus Remote for Oculus Utilities.
    • Oculus_GearVRHMD - The Oculus GearVR HMD controls for Oculus Utilities.
    • Oculus_GearVRController - The Oculus GearVR controller for Oculus Utilities.
    • WindowsMR_MotionController - The Windows Mixed Reality Motion Controller for Windows Mixed Reality.
    • SteamVR_WindowsMRController - The Windows Mixed Reality Motion Controller for SteamVR.

Class Methods

ProcessUpdate/2

public abstract void ProcessUpdate(VRTK_ControllerReference controllerReference, Dictionary<string, object> options);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference for the controller.
    • Dictionary<string, object> options - A dictionary of generic options that can be used to within the update.
  • Returns
    • none

The ProcessUpdate method enables an SDK to run logic for every Unity Update

ProcessFixedUpdate/2

public abstract void ProcessFixedUpdate(VRTK_ControllerReference controllerReference, Dictionary<string, object> options);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference for the controller.
    • Dictionary<string, object> options - A dictionary of generic options that can be used to within the fixed update.
  • Returns
    • none

The ProcessFixedUpdate method enables an SDK to run logic for every Unity FixedUpdate

GetCurrentControllerType/1

public abstract ControllerType GetCurrentControllerType(VRTK_ControllerReference controllerReference = null);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the controller to get type of.
  • Returns
    • ControllerType - The ControllerType based on the SDK and headset being used.

The GetCurrentControllerType method returns the current used ControllerType based on the SDK and headset being used.

GetControllerDefaultColliderPath/1

public abstract string GetControllerDefaultColliderPath(ControllerHand hand);

  • Parameters
    • ControllerHand hand - The controller hand to check for
  • Returns
    • string - A path to the resource that contains the collider GameObject.

The GetControllerDefaultColliderPath returns the path to the prefab that contains the collider objects for the default controller of this SDK.

GetControllerElementPath/3

public abstract string GetControllerElementPath(ControllerElements element, ControllerHand hand, bool fullPath = false);

  • Parameters
    • ControllerElements element - The controller element to look up.
    • ControllerHand hand - The controller hand to look up.
    • bool fullPath - Whether to get the initial path or the full path to the element.
  • Returns
    • string - A string containing the path to the game object that the controller element resides in.

The GetControllerElementPath returns the path to the game object that the given controller element for the given hand resides in.

GetControllerIndex/1

public abstract uint GetControllerIndex(GameObject controller);

  • Parameters
    • GameObject controller - The GameObject containing the controller.
  • Returns
    • uint - The index of the given controller.

The GetControllerIndex method returns the index of the given controller.

GetControllerByIndex/2

public abstract GameObject GetControllerByIndex(uint index, bool actual = false);

  • Parameters
    • uint index - The index of the controller to find.
    • bool actual - If true it will return the actual controller, if false it will return the script alias controller GameObject.
  • Returns
    • GameObject - The GameObject of the controller

The GetControllerByIndex method returns the GameObject of a controller with a specific index.

GetControllerOrigin/1

public abstract Transform GetControllerOrigin(VRTK_ControllerReference controllerReference);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the controller to retrieve the origin from.
  • Returns
    • Transform - A Transform containing the origin of the controller.

The GetControllerOrigin method returns the origin of the given controller.

GetControllerLeftHand/1

public abstract GameObject GetControllerLeftHand(bool actual = false);

  • Parameters
    • bool actual - If true it will return the actual controller, if false it will return the script alias controller GameObject.
  • Returns
    • GameObject - The GameObject containing the left hand controller.

The GetControllerLeftHand method returns the GameObject containing the representation of the left hand controller.

GetControllerRightHand/1

public abstract GameObject GetControllerRightHand(bool actual = false);

  • Parameters
    • bool actual - If true it will return the actual controller, if false it will return the script alias controller GameObject.
  • Returns
    • GameObject - The GameObject containing the right hand controller.

The GetControllerRightHand method returns the GameObject containing the representation of the right hand controller.

IsControllerLeftHand/1

public abstract bool IsControllerLeftHand(GameObject controller);

  • Parameters
    • GameObject controller - The GameObject to check.
  • Returns
    • bool - Returns true if the given controller is the left hand controller.

The IsControllerLeftHand/1 method is used to check if the given controller is the the left hand controller.

IsControllerRightHand/1

public abstract bool IsControllerRightHand(GameObject controller);

  • Parameters
    • GameObject controller - The GameObject to check.
  • Returns
    • bool - Returns true if the given controller is the right hand controller.

The IsControllerRightHand/1 method is used to check if the given controller is the the right hand controller.

IsControllerLeftHand/2

public abstract bool IsControllerLeftHand(GameObject controller, bool actual);

  • Parameters
    • GameObject controller - The GameObject to check.
    • bool actual - If true it will check the actual controller, if false it will check the script alias controller.
  • Returns
    • bool - Returns true if the given controller is the left hand controller.

The IsControllerLeftHand/2 method is used to check if the given controller is the the left hand controller.

IsControllerRightHand/2

public abstract bool IsControllerRightHand(GameObject controller, bool actual);

  • Parameters
    • GameObject controller - The GameObject to check.
    • bool actual - If true it will check the actual controller, if false it will check the script alias controller.
  • Returns
    • bool - Returns true if the given controller is the right hand controller.

The IsControllerRightHand/2 method is used to check if the given controller is the the right hand controller.

WaitForControllerModel/1

public abstract bool WaitForControllerModel(ControllerHand hand);

  • Parameters
    • ControllerHand hand - The hand to determine if the controller model will be ready for.
  • Returns
    • bool - Returns true if the controller model requires loading in at runtime and therefore needs waiting for. Returns false if the controller model will be available at start.

The WaitForControllerModel method determines whether the controller model for the given hand requires waiting to load in on scene start.

GetControllerModel/1

public abstract GameObject GetControllerModel(GameObject controller);

  • Parameters
    • GameObject controller - The GameObject to get the model alias for.
  • Returns
    • GameObject - The GameObject that has the model alias within it.

The GetControllerModel method returns the model alias for the given GameObject.

GetControllerModel/1

public abstract GameObject GetControllerModel(ControllerHand hand);

  • Parameters
    • ControllerHand hand - The hand enum of which controller model to retrieve.
  • Returns
    • GameObject - The GameObject that has the model alias within it.

The GetControllerModel method returns the model alias for the given controller hand.

GetControllerModelHand/1

public virtual ControllerHand GetControllerModelHand(GameObject controllerModel)

  • Parameters
    • GameObject controllerModel - The controller model GameObject to get the hand for.
  • Returns
    • ControllerHand - The hand enum for which the given controller model is for.

The GetControllerModelHand method returns the hand for the given controller model GameObject.

GetControllerRenderModel/1

public abstract GameObject GetControllerRenderModel(VRTK_ControllerReference controllerReference);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the controller to check.
  • Returns
    • GameObject - A GameObject containing the object that has a render model for the controller.

The GetControllerRenderModel method gets the game object that contains the given controller's render model.

SetControllerRenderModelWheel/2

public abstract void SetControllerRenderModelWheel(GameObject renderModel, bool state);

  • Parameters
    • GameObject renderModel - The GameObject containing the controller render model.
    • bool state - If true and the render model has a scroll wheen then it will be displayed, if false then the scroll wheel will be hidden.
  • Returns
    • none

The SetControllerRenderModelWheel method sets the state of the scroll wheel on the controller render model.

HapticPulse/2

public abstract void HapticPulse(VRTK_ControllerReference controllerReference, float strength = 0.5f);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the tracked object to initiate the haptic pulse on.
    • float strength - The intensity of the rumble of the controller motor. 0 to 1.
  • Returns
    • none

The HapticPulse/2 method is used to initiate a simple haptic pulse on the tracked object of the given controller reference.

HapticPulse/2

public abstract bool HapticPulse(VRTK_ControllerReference controllerReference, AudioClip clip);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the tracked object to initiate the haptic pulse on.
    • AudioClip clip - The audio clip to use for the haptic pattern.
  • Returns
    • none

The HapticPulse/2 method is used to initiate a haptic pulse based on an audio clip on the tracked object of the given controller reference.

GetHapticModifiers/0

public abstract SDK_ControllerHapticModifiers GetHapticModifiers();

  • Parameters
    • none
  • Returns
    • SDK_ControllerHapticModifiers - An SDK_ControllerHapticModifiers object with a given durationModifier and an intervalModifier.

The GetHapticModifiers method is used to return modifiers for the duration and interval if the SDK handles it slightly differently.

GetVelocity/1

public abstract Vector3 GetVelocity(VRTK_ControllerReference controllerReference);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the tracked object to check for.
  • Returns
    • Vector3 - A Vector3 containing the current velocity of the tracked object.

The GetVelocity method is used to determine the current velocity of the tracked object on the given controller reference.

GetAngularVelocity/1

public abstract Vector3 GetAngularVelocity(VRTK_ControllerReference controllerReference);

  • Parameters
    • VRTK_ControllerReference controllerReference - The reference to the tracked object to check for.
  • Returns
    • Vector3 - A Vector3 containing the current angular velocity of the tracked object.

The GetAngularVelocity method is used to determine the current angular velocity of the tracked object on the given controller reference.

IsTouchpadStatic/4

public abstract bool IsTouchpadStatic(bool isTouched, Vector2 currentAxisValues, Vector2 previousAxisValues, int compareFidelity);

  • Parameters
    • Vector2 currentAxisValues -
    • Vector2 previousAxisValues -
    • int compareFidelity -
  • Returns
    • bool - Returns true if the touchpad is not currently being touched or moved.

The IsTouchpadStatic method is used to determine if the touchpad is currently not being moved.

GetButtonAxis/2

public abstract Vector2 GetButtonAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference);

  • Parameters
    • ButtonTypes buttonType - The type of button to check for the axis on.
    • VRTK_ControllerReference controllerReference - The reference to the controller to check the button axis on.
  • Returns
    • Vector2 - A Vector2 of the X/Y values of the button axis. If no axis values exist for the given button, then a Vector2.Zero is returned.

The GetButtonAxis method retrieves the current X/Y axis values for the given button type on the given controller reference.

GetButtonSenseAxis/2

public abstract float GetButtonSenseAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference);

  • Parameters
    • ButtonTypes buttonType - The type of button to check for the sense axis on.
    • VRTK_ControllerReference controllerReference - The reference to the controller to check the sense axis on.
  • Returns
    • float - The current sense axis value.

The GetButtonSenseAxis method retrieves the current sense axis value for the given button type on the given controller reference.

GetButtonHairlineDelta/2

public abstract float GetButtonHairlineDelta(ButtonTypes buttonType, VRTK_ControllerReference controllerReference);

  • Parameters
    • ButtonTypes buttonType - The type of button to get the hairline delta for.
    • VRTK_ControllerReference controllerReference - The reference to the controller to get the hairline delta for.
  • Returns
    • float - The delta between the button presses.

The GetButtonHairlineDelta method is used to get the difference between the current button press and the previous frame button press.

GetControllerButtonState/3

public abstract bool GetControllerButtonState(ButtonTypes buttonType, ButtonPressTypes pressType, VRTK_ControllerReference controllerReference);

  • Parameters
    • ButtonTypes buttonType - The type of button to check for the state of.
    • ButtonPressTypes pressType - The button state to check for.
    • VRTK_ControllerReference controllerReference - The reference to the controller to check the button state on.
  • Returns
    • bool - Returns true if the given button is in the state of the given press type on the given controller reference.

The GetControllerButtonState method is used to determine if the given controller button for the given press type on the given controller reference is currently taking place.