Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
17 KiB

  1. // Fallback Controller|SDK_Fallback|003
  2. namespace VRTK
  3. {
  4. using UnityEngine;
  5. using System.Collections.Generic;
  6. /// <summary>
  7. /// The Fallback Controller SDK script provides a fallback collection of methods that return null or default headset values.
  8. /// </summary>
  9. /// <remarks>
  10. /// This is the fallback class that will just return default values.
  11. /// </remarks>
  12. [SDK_Description(typeof(SDK_FallbackSystem))]
  13. public class SDK_FallbackController : SDK_BaseController
  14. {
  15. /// <summary>
  16. /// The ProcessUpdate method enables an SDK to run logic for every Unity Update
  17. /// </summary>
  18. /// <param name="controllerReference">The reference for the controller.</param>
  19. /// <param name="options">A dictionary of generic options that can be used to within the update.</param>
  20. public override void ProcessUpdate(VRTK_ControllerReference controllerReference, Dictionary<string, object> options)
  21. {
  22. }
  23. /// <summary>
  24. /// The ProcessFixedUpdate method enables an SDK to run logic for every Unity FixedUpdate
  25. /// </summary>
  26. /// <param name="controllerReference">The reference for the controller.</param>
  27. /// <param name="options">A dictionary of generic options that can be used to within the fixed update.</param>
  28. public override void ProcessFixedUpdate(VRTK_ControllerReference controllerReference, Dictionary<string, object> options)
  29. {
  30. }
  31. /// <summary>
  32. /// The GetCurrentControllerType method returns the current used ControllerType based on the SDK and headset being used.
  33. /// </summary>
  34. /// <param name="controllerReference">The reference to the controller to get type of.</param>
  35. /// <returns>The ControllerType based on the SDK and headset being used.</returns>
  36. public override ControllerType GetCurrentControllerType(VRTK_ControllerReference controllerReference = null)
  37. {
  38. return ControllerType.Undefined;
  39. }
  40. /// <summary>
  41. /// The GetControllerDefaultColliderPath returns the path to the prefab that contains the collider objects for the default controller of this SDK.
  42. /// </summary>
  43. /// <param name="hand">The controller hand to check for</param>
  44. /// <returns>A path to the resource that contains the collider GameObject.</returns>
  45. public override string GetControllerDefaultColliderPath(ControllerHand hand)
  46. {
  47. return "";
  48. }
  49. /// <summary>
  50. /// The GetControllerElementPath returns the path to the game object that the given controller element for the given hand resides in.
  51. /// </summary>
  52. /// <param name="element">The controller element to look up.</param>
  53. /// <param name="hand">The controller hand to look up.</param>
  54. /// <param name="fullPath">Whether to get the initial path or the full path to the element.</param>
  55. /// <returns>A string containing the path to the game object that the controller element resides in.</returns>
  56. public override string GetControllerElementPath(ControllerElements element, ControllerHand hand, bool fullPath = false)
  57. {
  58. return "";
  59. }
  60. /// <summary>
  61. /// The GetControllerIndex method returns the index of the given controller.
  62. /// </summary>
  63. /// <param name="controller">The GameObject containing the controller.</param>
  64. /// <returns>The index of the given controller.</returns>
  65. public override uint GetControllerIndex(GameObject controller)
  66. {
  67. return uint.MaxValue;
  68. }
  69. /// <summary>
  70. /// The GetControllerByIndex method returns the GameObject of a controller with a specific index.
  71. /// </summary>
  72. /// <param name="index">The index of the controller to find.</param>
  73. /// <param name="actual">If true it will return the actual controller, if false it will return the script alias controller GameObject.</param>
  74. /// <returns>The GameObject of the controller</returns>
  75. public override GameObject GetControllerByIndex(uint index, bool actual = false)
  76. {
  77. return null;
  78. }
  79. /// <summary>
  80. /// The GetControllerOrigin method returns the origin of the given controller.
  81. /// </summary>
  82. /// <param name="controllerReference">The reference to the controller to retrieve the origin from.</param>
  83. /// <returns>A Transform containing the origin of the controller.</returns>
  84. public override Transform GetControllerOrigin(VRTK_ControllerReference controllerReference)
  85. {
  86. return null;
  87. }
  88. /// <summary>
  89. /// The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
  90. /// </summary>
  91. /// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
  92. /// <returns>A generated Transform that contains the custom pointer origin.</returns>
  93. [System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
  94. public override Transform GenerateControllerPointerOrigin(GameObject parent)
  95. {
  96. return null;
  97. }
  98. /// <summary>
  99. /// The GetControllerLeftHand method returns the GameObject containing the representation of the left hand controller.
  100. /// </summary>
  101. /// <param name="actual">If true it will return the actual controller, if false it will return the script alias controller GameObject.</param>
  102. /// <returns>The GameObject containing the left hand controller.</returns>
  103. public override GameObject GetControllerLeftHand(bool actual = false)
  104. {
  105. return null;
  106. }
  107. /// <summary>
  108. /// The GetControllerRightHand method returns the GameObject containing the representation of the right hand controller.
  109. /// </summary>
  110. /// <param name="actual">If true it will return the actual controller, if false it will return the script alias controller GameObject.</param>
  111. /// <returns>The GameObject containing the right hand controller.</returns>
  112. public override GameObject GetControllerRightHand(bool actual = false)
  113. {
  114. return null;
  115. }
  116. /// <summary>
  117. /// The IsControllerLeftHand/1 method is used to check if the given controller is the the left hand controller.
  118. /// </summary>
  119. /// <param name="controller">The GameObject to check.</param>
  120. /// <returns>Returns true if the given controller is the left hand controller.</returns>
  121. public override bool IsControllerLeftHand(GameObject controller)
  122. {
  123. return false;
  124. }
  125. /// <summary>
  126. /// The IsControllerRightHand/1 method is used to check if the given controller is the the right hand controller.
  127. /// </summary>
  128. /// <param name="controller">The GameObject to check.</param>
  129. /// <returns>Returns true if the given controller is the right hand controller.</returns>
  130. public override bool IsControllerRightHand(GameObject controller)
  131. {
  132. return false;
  133. }
  134. /// <summary>
  135. /// The IsControllerLeftHand/2 method is used to check if the given controller is the the left hand controller.
  136. /// </summary>
  137. /// <param name="controller">The GameObject to check.</param>
  138. /// <param name="actual">If true it will check the actual controller, if false it will check the script alias controller.</param>
  139. /// <returns>Returns true if the given controller is the left hand controller.</returns>
  140. public override bool IsControllerLeftHand(GameObject controller, bool actual)
  141. {
  142. return false;
  143. }
  144. /// <summary>
  145. /// The IsControllerRightHand/2 method is used to check if the given controller is the the right hand controller.
  146. /// </summary>
  147. /// <param name="controller">The GameObject to check.</param>
  148. /// <param name="actual">If true it will check the actual controller, if false it will check the script alias controller.</param>
  149. /// <returns>Returns true if the given controller is the right hand controller.</returns>
  150. public override bool IsControllerRightHand(GameObject controller, bool actual)
  151. {
  152. return false;
  153. }
  154. /// <summary>
  155. /// The WaitForControllerModel method determines whether the controller model for the given hand requires waiting to load in on scene start.
  156. /// </summary>
  157. /// <param name="hand">The hand to determine if the controller model will be ready for.</param>
  158. /// <returns>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.</returns>
  159. public override bool WaitForControllerModel(ControllerHand hand)
  160. {
  161. return false;
  162. }
  163. /// <summary>
  164. /// The GetControllerModel method returns the model alias for the given GameObject.
  165. /// </summary>
  166. /// <param name="controller">The GameObject to get the model alias for.</param>
  167. /// <returns>The GameObject that has the model alias within it.</returns>
  168. public override GameObject GetControllerModel(GameObject controller)
  169. {
  170. return null;
  171. }
  172. /// <summary>
  173. /// The GetControllerModel method returns the model alias for the given controller hand.
  174. /// </summary>
  175. /// <param name="hand">The hand enum of which controller model to retrieve.</param>
  176. /// <returns>The GameObject that has the model alias within it.</returns>
  177. public override GameObject GetControllerModel(ControllerHand hand)
  178. {
  179. return null;
  180. }
  181. /// <summary>
  182. /// The GetControllerRenderModel method gets the game object that contains the given controller's render model.
  183. /// </summary>
  184. /// <param name="controllerReference">The reference to the controller to check.</param>
  185. /// <returns>A GameObject containing the object that has a render model for the controller.</returns>
  186. public override GameObject GetControllerRenderModel(VRTK_ControllerReference controllerReference)
  187. {
  188. return null;
  189. }
  190. /// <summary>
  191. /// The SetControllerRenderModelWheel method sets the state of the scroll wheel on the controller render model.
  192. /// </summary>
  193. /// <param name="renderModel">The GameObject containing the controller render model.</param>
  194. /// <param name="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.</param>
  195. public override void SetControllerRenderModelWheel(GameObject renderModel, bool state)
  196. {
  197. }
  198. /// <summary>
  199. /// The HapticPulse/2 method is used to initiate a simple haptic pulse on the tracked object of the given controller reference.
  200. /// </summary>
  201. /// <param name="controllerReference">The reference to the tracked object to initiate the haptic pulse on.</param>
  202. /// <param name="strength">The intensity of the rumble of the controller motor. `0` to `1`.</param>
  203. public override void HapticPulse(VRTK_ControllerReference controllerReference, float strength = 0.5f)
  204. {
  205. }
  206. /// <summary>
  207. /// 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.
  208. /// </summary>
  209. /// <param name="controllerReference">The reference to the tracked object to initiate the haptic pulse on.</param>
  210. /// <param name="clip">The audio clip to use for the haptic pattern.</param>
  211. public override bool HapticPulse(VRTK_ControllerReference controllerReference, AudioClip clip)
  212. {
  213. //Return true so it just always prevents doing a fallback routine.
  214. return true;
  215. }
  216. /// <summary>
  217. /// The GetHapticModifiers method is used to return modifiers for the duration and interval if the SDK handles it slightly differently.
  218. /// </summary>
  219. /// <returns>An SDK_ControllerHapticModifiers object with a given `durationModifier` and an `intervalModifier`.</returns>
  220. public override SDK_ControllerHapticModifiers GetHapticModifiers()
  221. {
  222. return new SDK_ControllerHapticModifiers();
  223. }
  224. /// <summary>
  225. /// The GetVelocity method is used to determine the current velocity of the tracked object on the given controller reference.
  226. /// </summary>
  227. /// <param name="controllerReference">The reference to the tracked object to check for.</param>
  228. /// <returns>A Vector3 containing the current velocity of the tracked object.</returns>
  229. public override Vector3 GetVelocity(VRTK_ControllerReference controllerReference)
  230. {
  231. return Vector3.zero;
  232. }
  233. /// <summary>
  234. /// The GetAngularVelocity method is used to determine the current angular velocity of the tracked object on the given controller reference.
  235. /// </summary>
  236. /// <param name="controllerReference">The reference to the tracked object to check for.</param>
  237. /// <returns>A Vector3 containing the current angular velocity of the tracked object.</returns>
  238. public override Vector3 GetAngularVelocity(VRTK_ControllerReference controllerReference)
  239. {
  240. return Vector3.zero;
  241. }
  242. /// <summary>
  243. /// The IsTouchpadStatic method is used to determine if the touchpad is currently not being moved.
  244. /// </summary>
  245. /// <param name="currentAxisValues"></param>
  246. /// <param name="previousAxisValues"></param>
  247. /// <param name="compareFidelity"></param>
  248. /// <returns>Returns true if the touchpad is not currently being touched or moved.</returns>
  249. public override bool IsTouchpadStatic(bool isTouched, Vector2 currentAxisValues, Vector2 previousAxisValues, int compareFidelity)
  250. {
  251. return (!isTouched || VRTK_SharedMethods.Vector2ShallowCompare(currentAxisValues, previousAxisValues, compareFidelity));
  252. }
  253. /// <summary>
  254. /// The GetButtonAxis method retrieves the current X/Y axis values for the given button type on the given controller reference.
  255. /// </summary>
  256. /// <param name="buttonType">The type of button to check for the axis on.</param>
  257. /// <param name="controllerReference">The reference to the controller to check the button axis on.</param>
  258. /// <returns>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.</returns>
  259. public override Vector2 GetButtonAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference)
  260. {
  261. return Vector2.zero;
  262. }
  263. /// <summary>
  264. /// The GetButtonSenseAxis method retrieves the current sense axis value for the given button type on the given controller reference.
  265. /// </summary>
  266. /// <param name="buttonType">The type of button to check for the sense axis on.</param>
  267. /// <param name="controllerReference">The reference to the controller to check the sense axis on.</param>
  268. /// <returns>The current sense axis value.</returns>
  269. public override float GetButtonSenseAxis(ButtonTypes buttonType, VRTK_ControllerReference controllerReference)
  270. {
  271. return 0f;
  272. }
  273. /// <summary>
  274. /// The GetButtonHairlineDelta method is used to get the difference between the current button press and the previous frame button press.
  275. /// </summary>
  276. /// <param name="buttonType">The type of button to get the hairline delta for.</param>
  277. /// <param name="controllerReference">The reference to the controller to get the hairline delta for.</param>
  278. /// <returns>The delta between the button presses.</returns>
  279. public override float GetButtonHairlineDelta(ButtonTypes buttonType, VRTK_ControllerReference controllerReference)
  280. {
  281. return 0f;
  282. }
  283. /// <summary>
  284. /// 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.
  285. /// </summary>
  286. /// <param name="buttonType">The type of button to check for the state of.</param>
  287. /// <param name="pressType">The button state to check for.</param>
  288. /// <param name="controllerReference">The reference to the controller to check the button state on.</param>
  289. /// <returns>Returns true if the given button is in the state of the given press type on the given controller reference.</returns>
  290. public override bool GetControllerButtonState(ButtonTypes buttonType, ButtonPressTypes pressType, VRTK_ControllerReference controllerReference)
  291. {
  292. return false;
  293. }
  294. }
  295. }