PXR_Input.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. using LitJson;
  12. using System;
  13. using UnityEngine;
  14. using UnityEngine.XR;
  15. namespace Unity.XR.PXR
  16. {
  17. public static class PXR_Input
  18. {
  19. public enum ControllerDevice
  20. {
  21. G2 = 3,
  22. Neo2,
  23. Neo3,
  24. PICO_4,
  25. G3,
  26. NewController = 10
  27. }
  28. public enum Controller
  29. {
  30. LeftController,
  31. RightController,
  32. }
  33. public enum VibrateController
  34. {
  35. No = 0,
  36. Left = 1,
  37. Right = 2,
  38. LeftAndRight = 3,
  39. }
  40. public enum VibrateType
  41. {
  42. None = 0,
  43. LeftController = 1,
  44. RightController = 2,
  45. BothController = 3,
  46. }
  47. public enum CacheType
  48. {
  49. DontCache = 0,
  50. CacheAndVibrate = 1,
  51. CacheNoVibrate = 2,
  52. }
  53. public enum ChannelFlip
  54. {
  55. No,
  56. Yes,
  57. }
  58. public enum CacheConfig {
  59. CacheAndVibrate = 1,
  60. CacheNoVibrate = 2,
  61. }
  62. /// <summary>
  63. /// Gets the current dominant controller.
  64. /// </summary>
  65. /// <returns>The current dominant controller: `LeftController`; `RightController`.</returns>
  66. public static Controller GetDominantHand()
  67. {
  68. return (Controller)PXR_Plugin.Controller.UPxr_GetControllerMainInputHandle();
  69. }
  70. /// <summary>
  71. /// Sets a controller as the dominant controller.
  72. /// </summary>
  73. /// <param name="controller">The controller to be set as the dominant controller: `0`-left controller; `1`-right controller.</param>
  74. public static void SetDominantHand(Controller controller)
  75. {
  76. PXR_Plugin.Controller.UPxr_SetControllerMainInputHandle((UInt32)controller);
  77. }
  78. /// <summary>
  79. /// Sets controller vibration, including vibration amplitude and duration.
  80. /// @note The `SendHapticImpulse` method offered by UnityXR is also supported. Click [here](https://docs.unity3d.com/ScriptReference/XR.InputDevice.SendHapticImpulse.html) for more information.
  81. /// </summary>
  82. /// <param name="strength">Vibration amplitude. The valid value ranges from `0` to `1`. The greater the value, the stronger the vibration amplitude. To stop controller vibration, call this function again and set this parameter to `0`.</param>
  83. /// <param name="time">Vibration duration. The valid value ranges from `0` to `65535` ms.</param>
  84. /// <param name="controller">The controller to set vibration for:
  85. /// * `0`: left controller
  86. /// * `1`: right controller
  87. /// </param>
  88. [Obsolete("Please use SendHapticImpulse instead")]
  89. public static void SetControllerVibration(float strength, int time, Controller controller)
  90. {
  91. PXR_Plugin.Controller.UPxr_SetControllerVibration((UInt32)controller, strength, time);
  92. }
  93. /// <summary>
  94. /// Gets the device model.
  95. /// </summary>
  96. /// <returns>The device model. Enumerations: `G2`, `Neo2`, `Neo3`, `NewController`, `PICO_4`.</returns>
  97. public static ControllerDevice GetControllerDeviceType()
  98. {
  99. return (ControllerDevice)PXR_Plugin.Controller.UPxr_GetControllerType();
  100. }
  101. /// <summary>
  102. /// Gets the connection status for a specified controller.
  103. /// </summary>
  104. /// <param name="controller">The controller to get connection status for:
  105. /// * `0`: left controller
  106. /// * `1`: right controller
  107. /// </param>
  108. /// <returns>The connection status of the specified controller:
  109. /// * `true`: connected
  110. /// * `false`: not connected
  111. /// </returns>
  112. public static bool IsControllerConnected(Controller controller)
  113. {
  114. var state = false;
  115. switch (controller)
  116. {
  117. case Controller.LeftController:
  118. InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).TryGetFeatureValue(PXR_Usages.controllerStatus, out state);
  119. return state;
  120. case Controller.RightController:
  121. InputDevices.GetDeviceAtXRNode(XRNode.RightHand).TryGetFeatureValue(PXR_Usages.controllerStatus, out state);
  122. return state;
  123. }
  124. return state;
  125. }
  126. /// <summary>
  127. /// Sets the offset of the controller's display position to its real position.
  128. /// </summary>
  129. /// <param name="hand">The controller to set an offset for:
  130. /// * `0`: left controller
  131. /// * `1`: right controller
  132. /// </param>
  133. /// <param name="offset">The offset (in meters).</param>
  134. public static void SetControllerOriginOffset(Controller controller, Vector3 offset)
  135. {
  136. PXR_Plugin.Controller.UPxr_SetControllerOriginOffset((int)controller, offset);
  137. }
  138. /// <summary>
  139. /// Gets the predicted orientation of a specified controller after a specified time.
  140. /// </summary>
  141. /// <param name="hand">The controller to get the predicted rotation for:
  142. /// * `0`: left controller
  143. /// * `1`: right controller
  144. /// </param>
  145. /// <param name="predictTime">The time for prediction (in milliseconds).</param>
  146. /// <returns>The predicted orientation.</returns>
  147. public static Quaternion GetControllerPredictRotation(Controller controller, double predictTime)
  148. {
  149. PxrControllerTracking pxrControllerTracking = new PxrControllerTracking();
  150. float[] headData = new float[7] { 0, 0, 0, 0, 0, 0, 0 };
  151. PXR_Plugin.Controller.UPxr_GetControllerTrackingState((uint)controller, predictTime, headData, ref pxrControllerTracking);
  152. return new Quaternion(
  153. pxrControllerTracking.localControllerPose.pose.orientation.x,
  154. pxrControllerTracking.localControllerPose.pose.orientation.y,
  155. pxrControllerTracking.localControllerPose.pose.orientation.z,
  156. pxrControllerTracking.localControllerPose.pose.orientation.w);
  157. }
  158. /// <summary>
  159. /// Gets the predicted position of a specified controller after a specified time.
  160. /// </summary>
  161. /// <param name="hand">The controller to get the predicted position for:
  162. /// * `0`: left controller
  163. /// * `1`: right controller
  164. /// </param>
  165. /// <param name="predictTime">The time for prediction (in milliseconds).</param>
  166. /// <returns>The predicted position.</returns>
  167. public static Vector3 GetControllerPredictPosition(Controller controller, double predictTime)
  168. {
  169. PxrControllerTracking pxrControllerTracking = new PxrControllerTracking();
  170. float[] headData = new float[7] { 0, 0, 0, 0, 0, 0, 0 };
  171. PXR_Plugin.Controller.UPxr_GetControllerTrackingState((uint)controller, predictTime, headData, ref pxrControllerTracking);
  172. return new Vector3(
  173. pxrControllerTracking.localControllerPose.pose.position.x,
  174. pxrControllerTracking.localControllerPose.pose.position.y,
  175. pxrControllerTracking.localControllerPose.pose.position.z);
  176. }
  177. /// @deprecated Use \ref SendHapticImpulse instead.
  178. /// <summary>
  179. /// Sets event-triggered vibration for a specified controller.
  180. /// </summary>
  181. /// <param name="hand">The controller to enable vibration for:
  182. /// * `0`: left controller
  183. /// * `1`: right controller
  184. /// </param>
  185. /// <param name="frequency">Vibration frequency, which ranges from `50` to `500` Hz.</param>
  186. /// <param name="strength">Vibration amplitude. Its valid value ranges from `0` to `1`. The higher the value, the stronger the vibration amplitude.</param>
  187. /// <param name="time">Vibration duration, which ranges from `0` to `65535` ms.</param>
  188. [Obsolete("Please use SendHapticImpulse instead")]
  189. public static int SetControllerVibrationEvent(UInt32 hand, int frequency, float strength, int time)
  190. {
  191. return PXR_Plugin.Controller.UPxr_SetControllerVibrationEvent(hand, frequency, strength, time);
  192. }
  193. /// @deprecated Use \ref StopHapticBuffer(int sourceId, bool clearCache) instead.
  194. /// <summary>
  195. /// Stops audio-triggered vibration.
  196. /// </summary>
  197. /// <param name="id">A reserved parameter, set it to the source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache` to stop the corresponding vibration,
  198. /// or set it to `0` to stop all vibrations.</param>
  199. [Obsolete("Please use StopHapticBuffer instead")]
  200. public static int StopControllerVCMotor(int sourceId)
  201. {
  202. return PXR_Plugin.Controller.UPxr_StopControllerVCMotor(sourceId);
  203. }
  204. /// @deprecated Deprecated.
  205. /// <summary>
  206. /// Starts audio-triggered vibration for specified controller(s). The audio data come from an audio file.
  207. /// </summary>
  208. /// <param name="file">The path to the audio file.</param>
  209. /// <param name="vibrateController">The controller(s) to enable vibration for:
  210. /// * `0`: none
  211. /// * `1`: left controller
  212. /// * `2`: right controller
  213. /// * `3`: left and right controllers
  214. /// </param>
  215. [Obsolete("Deprecated")]
  216. public static int StartControllerVCMotor(string file, VibrateController vibrateController)
  217. {
  218. return PXR_Plugin.Controller.UPxr_StartControllerVCMotor(file, (int)vibrateController);
  219. }
  220. /// @deprecated Deprecated.
  221. /// <summary>
  222. /// Sets the amplitude for audio-triggered vibration. Support changing the vibration amplitude during audio playback.
  223. /// </summary>
  224. /// <param name="mode">Vibration amplitude level:
  225. /// * `0`: no vibration
  226. /// * `1`: standard amplitude
  227. /// * `2`: 2×standard amplitude
  228. /// * `3`: 3×standard amplitude
  229. /// * `4`: 4×standard amplitude
  230. /// @note "3×standard amplitude" and "4×standard amplitude" are NOT recommended as they will cause serious loss of vibration details.
  231. /// </param>
  232. [Obsolete("Deprecated")]
  233. public static int SetControllerAmp(float mode)
  234. {
  235. return PXR_Plugin.Controller.UPxr_SetControllerAmp(mode);
  236. }
  237. /// @deprecated Use \ref SendHapticBuffer(VibrateType vibrateType, AudioClip audioClip, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType) instead.
  238. /// <summary>
  239. /// Starts audio-triggered vibration for specified controller(s). The audio data come from an audio clip passed to the Unity Engine.
  240. /// </summary>
  241. /// <param name="audioClip">The path to the audio clip.</param>
  242. /// <param name="vibrateController">The controller(s) to enable vibration for:
  243. /// * `0`: none
  244. /// * `1`: left controller
  245. /// * `2`: right controller
  246. /// * `3`: left and right controllers
  247. /// </param>
  248. /// <param nname="channelFlip">Whether to enable audio channel inversion:
  249. /// * `Yes`: enable
  250. /// * `No`: disable
  251. /// Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  252. /// </param>
  253. /// <param nname="sourceId">Returns the unique ID for controlling the corresponding vibration,
  254. /// which will be used in `StartVibrateByCache`, `ClearVibrateByCache` or `StopControllerVCMotor`.</param>
  255. [Obsolete("Please use SendHapticBuffer instead")]
  256. public static int StartVibrateBySharem(AudioClip audioClip, VibrateController vibrateController, ChannelFlip channelFlip, ref int sourceId)
  257. {
  258. if (audioClip == null)
  259. {
  260. return 0;
  261. }
  262. float[] data = new float[audioClip.samples * audioClip.channels];
  263. int buffersize = audioClip.samples * audioClip.channels;
  264. audioClip.GetData(data, 0);
  265. int sampleRate = audioClip.frequency;
  266. int channelMask = audioClip.channels;
  267. return PXR_Plugin.Controller.UPxr_StartVibrateBySharem(data, (int)vibrateController, buffersize, sampleRate, channelMask, 32, (int)channelFlip, ref sourceId);
  268. }
  269. /**
  270. * @deprecated Use \ref SendHapticBuffer(VibrateType vibrateType, float[] pcmData, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType) instead.
  271. */
  272. /// <summary>
  273. /// Starts audio-triggered vibration for specified controller(s). This function is the overloaded version.
  274. /// </summary>
  275. /// <param name="data">The PCM data.</param>
  276. /// <param name="vibrateController">The controller(s) to enable vibration for:
  277. /// * `0`: none
  278. /// * `1`: left controller
  279. /// * `2`: right controller
  280. /// * `3`: left and right controllers
  281. /// </param>
  282. /// <param name="buffersize">The length of PCM data. Formula: (audioClip.samples)×(audioClip.channels).</param>
  283. /// <param name="frequency">Audio sampling rate.</param>
  284. /// <param name="channelMask">The number of channels.</param>
  285. /// <param name="channelFlip">Whether to enable audio channel inversion:
  286. /// * `Yes`: enable
  287. /// * `No`: disable
  288. /// Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  289. /// </param>
  290. /// <param name="sourceId">Returns the unique ID for controlling the corresponding vibration,
  291. /// which will be used in `StartVibrateByCache`, `ClearVibrateByCache` or `StopControllerVCMotor`.</param>
  292. [Obsolete("Please use SendHapticBuffer instead")]
  293. public static int StartVibrateBySharem(float[] data, VibrateController vibrateController, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, ref int sourceId)
  294. {
  295. return PXR_Plugin.Controller.UPxr_StartVibrateBySharem(data, (int)vibrateController, buffersize, frequency, channelMask, 32, (int)channelFlip, ref sourceId);
  296. }
  297. /// @deprecated Use \ref SendHapticBuffer(VibrateType vibrateType, AudioClip audioClip, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType) instead.
  298. /// <summary>
  299. /// Caches audio-triggered vibration data for specified controller(s).
  300. /// @note The cached data can be extracted from the cache directory and then transmitted, which reduces resource consumption and improves service performance.
  301. /// </summary>
  302. /// <param name="audioClip">The path to the audio clip.</param>
  303. /// <param name="vibrateController">The controller(s) to cache data for:
  304. /// * `0`: none
  305. /// * `1`: left controller
  306. /// * `2`: right controller
  307. /// * `3`: left and right controllers</param>
  308. /// <param name="channelFlip">Whether to enable audio channel inversion:
  309. /// * `Yes`: enable
  310. /// * `No`: disable
  311. /// Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  312. /// </param>
  313. /// <param name="cacheConfig">Whether to keep the controller vibrating while caching audio-based vibration data:
  314. /// * `CacheAndVibrate`: cache and keep vibrating
  315. /// * `CacheNoVibrate`: cache and stop vibrating
  316. /// </param>
  317. /// <param name="sourceId">Returns the unique ID for controlling the corresponding vibration,
  318. /// which will be used in `StartVibrateByCache`, `ClearVibrateByCache` or `StopControllerVCMotor`.</param>
  319. /// <returns>
  320. /// * `0`: success
  321. /// * `-1`: failure
  322. /// </returns>
  323. [Obsolete("Please use SendHapticBuffer instead")]
  324. public static int SaveVibrateByCache(AudioClip audioClip, VibrateController vibrateController, ChannelFlip channelFlip, CacheConfig cacheConfig, ref int sourceId)
  325. {
  326. if (audioClip == null)
  327. {
  328. return 0;
  329. }
  330. float[] data = new float[audioClip.samples * audioClip.channels];
  331. int buffersize = audioClip.samples * audioClip.channels;
  332. audioClip.GetData(data, 0);
  333. int sampleRate = audioClip.frequency;
  334. int channelMask = audioClip.channels;
  335. return PXR_Plugin.Controller.UPxr_SaveVibrateByCache(data, (int)vibrateController, buffersize, sampleRate, channelMask, 32, (int)channelFlip, (int)cacheConfig, ref sourceId);
  336. }
  337. /// @deprecated Use \ref SendHapticBuffer(VibrateType vibrateType, float[] pcmData, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType)
  338. /// <summary>
  339. /// Caches audio-triggered vibration data for specified controller(s). This function is the overloaded version.
  340. /// @note The cached data can be extracted from the cache directory and then transmitted, which reduces resource consumption and improves service performance.
  341. /// </summary>
  342. /// <param name="data">The PCM data.</param>
  343. /// <param name="vibrateController">The controller(s) to cache data for:
  344. /// * `0`: none
  345. /// * `1`: left controller
  346. /// * `2`: right controller
  347. /// * `3`: left and right controllers
  348. /// </param>
  349. /// <param name="buffersize">The length of PCM data. Formula: (audioClip.samples)×(audioClip.channels)</param>
  350. /// <param name="frequency">Audio sampling rate.</param>
  351. /// <param name="channelMask">The number of channels.</param>
  352. /// <param name="channelFlip">Whether to enable audio channel inversion:
  353. /// * `Yes`: enable
  354. /// * `No`: disable
  355. /// Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  356. /// </param>
  357. /// <param name="cacheConfig">Whether to keep the controller vibrating while caching audio-based vibration data:
  358. /// * `CacheAndVibrate`: cache and keep vibrating
  359. /// * `CacheNoVibrate`: cache and stop vibrating
  360. /// </param>
  361. /// <param name="sourceId">Returns the unique ID for controlling the corresponding vibration,
  362. /// which will be used in `StartVibrateByCache`, `ClearVibrateByCache` or `StopControllerVCMotor`.</param>
  363. /// <returns>
  364. /// * `0`: success
  365. /// * `-1`: failure
  366. /// </returns>
  367. [Obsolete("Please use SendHapticBuffer instead")]
  368. public static int SaveVibrateByCache(float[] data, VibrateController vibrateController, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, CacheConfig cacheConfig, ref int sourceId)
  369. {
  370. return PXR_Plugin.Controller.UPxr_SaveVibrateByCache(data, (int)vibrateController, buffersize, frequency, channelMask, 32, (int)channelFlip, (int)cacheConfig, ref sourceId);
  371. }
  372. /// @deprecated Use \ref StartHapticBuffer instead.
  373. /// <summary>
  374. /// Plays cached audio-triggered vibration data.
  375. /// </summary>
  376. /// <param name="sourceId">The source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache`.</param>
  377. /// <returns>
  378. /// * `0`: success
  379. /// * `-1`: failure
  380. /// </returns>
  381. [Obsolete("Please use StartHapticBuffer instead")]
  382. public static int StartVibrateByCache(int sourceId)
  383. {
  384. return PXR_Plugin.Controller.UPxr_StartVibrateByCache(sourceId);
  385. }
  386. /// @deprecated Use \ref StopHapticBuffer(clearCache) instead.
  387. /// <summary>
  388. /// Clears cached audio-triggered vibration data.
  389. /// </summary>
  390. /// <param name="sourceId">The source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache`.</param>
  391. /// <returns>
  392. /// * `0`: success
  393. /// * `-1`: failure
  394. /// </returns>
  395. [Obsolete("Please use StopHapticBuffer(clearCache) instead")]
  396. public static int ClearVibrateByCache(int sourceId)
  397. {
  398. return PXR_Plugin.Controller.UPxr_ClearVibrateByCache(sourceId);
  399. }
  400. public static int SetControllerEnableKey(bool isEnable, PxrControllerKeyMap Key)
  401. {
  402. return PXR_Plugin.Controller.UPxr_SetControllerEnableKey(isEnable, Key);
  403. }
  404. /// @deprecated Use \ref SendHapticBuffer(VibrateType vibrateType, TextAsset phfText, ChannelFlip channelFlip, float amplitudeScale, ref int sourceId) instead.
  405. /// <summary>
  406. /// Starts PHF-triggered vibration for specified controller(s). PHF stands for PICO haptic file.
  407. /// </summary>
  408. /// <param name="phfText">The path to the PHF file.</param>
  409. /// <param name="sourceId">The source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache`.</param>
  410. /// <param name="vibrateController">The controller(s) to enable vibration for:
  411. /// * `0`: none
  412. /// * `1`: left controller
  413. /// * `2`: right controller
  414. /// * `3`: left and right controllers
  415. /// </param>
  416. /// <param name="channelFlip">Whether to enable audio channel inversion:
  417. /// * `Yes`: enable
  418. /// * `No`: disable
  419. /// Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.</param>
  420. /// <param name="amp">The vibration gain, the valid value range from `0` to `2`:
  421. /// * `0`: no vibration
  422. /// * `1`: standard amplitude
  423. /// * `2`: 2×standard amplitude</param>
  424. /// <returns>
  425. /// * `0`: success
  426. /// * `-1`: failure
  427. /// </returns>
  428. [Obsolete("Please use SendHapticBuffer instead")]
  429. public static int StartVibrateByPHF(TextAsset phfText, ref int sourceId, VibrateController vibrateController, ChannelFlip channelFlip, float amp)
  430. {
  431. return PXR_Plugin.Controller.UPxr_StartVibrateByPHF(phfText.text, phfText.text.Length, ref sourceId, (int)vibrateController, (int)channelFlip, amp);
  432. }
  433. /// @deprecated Use \ref PauseHapticBuffer instead.
  434. /// <summary>
  435. /// Pauses PHF-triggered vibration.
  436. /// </summary>
  437. /// <param name="sourceId">The source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache`.</param>
  438. /// <returns>
  439. /// * `0`: success
  440. /// * `-1`: failure
  441. /// </returns>
  442. [Obsolete("Please use PauseHapticBuffer instead")]
  443. public static int PauseVibrate(int sourceId)
  444. {
  445. return PXR_Plugin.Controller.UPxr_PauseVibrate(sourceId);
  446. }
  447. /// @deprecated Use \ref ResumeHapticBuffer instead.
  448. /// <summary>
  449. /// Resumes PHF-triggered vibration.
  450. /// </summary>
  451. /// <param name="sourceId">The source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache`.</param>
  452. /// <returns>
  453. /// * `0`: success
  454. /// * `-1`: failure
  455. /// </returns>
  456. [Obsolete("Please use ResumeHapticBuffer instead")]
  457. public static int ResumeVibrate(int sourceId)
  458. {
  459. return PXR_Plugin.Controller.UPxr_ResumeVibrate(sourceId);
  460. }
  461. /// @deprecated Use \ref UpdateHapticBuffer instead.
  462. /// <summary>
  463. /// Dynamically updates PHF and AudioClip vibration data.
  464. /// </summary>
  465. /// <param name="sourceId">The source ID returned by `StartVibrateBySharem` or `SaveVibrateByCache`.</param>
  466. /// <param name="vibrateController">The controller(s) to update PHF and AudioClip vibration data for:
  467. /// * `0`: none
  468. /// * `1`: left controller
  469. /// * `2`: right controller
  470. /// * `3`: left and right controllers
  471. /// </param>
  472. /// <param name="channelFlip">Whether to enable audio channel inversion:
  473. /// * `Yes`: enable
  474. /// * `No`: disable
  475. /// Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.</param>
  476. /// <param name="amp">The vibration gain, the valid value range from `0` to `2`:
  477. /// * `0`: no vibration
  478. /// * `1`: standard amplitude
  479. /// * `2`: 2×standard amplitude</param>
  480. /// <returns>
  481. /// * `0`: success
  482. /// * `-1`: failure
  483. /// </returns>
  484. [Obsolete("Please use UpdateHapticBuffer instead")]
  485. public static int UpdateVibrateParams(int sourceId, VibrateController vibrateController, ChannelFlip channelFlip, float amp)
  486. {
  487. return PXR_Plugin.Controller.UPxr_UpdateVibrateParams(sourceId, (int)vibrateController, (int)channelFlip, amp);
  488. }
  489. /// <summary>
  490. /// Gets the data about the poses of body joints.
  491. /// </summary>
  492. /// <param name="predictTime">Reserved parameter, pass `0`.</param>
  493. /// <param name="bodyTrackerResult">Contains the data about the poses of body joints, including position, action, and more.</param>
  494. public static int GetBodyTrackingPose(double predictTime, ref BodyTrackerResult bodyTrackerResult)
  495. {
  496. return PXR_Plugin.Controller.UPxr_GetBodyTrackingPose(predictTime, ref bodyTrackerResult);
  497. }
  498. /// <summary>
  499. /// Gets the number of PICO Motion Trackers currently connected and their IDs.
  500. /// </summary>
  501. /// <param name="state">The number and IDs of connected PICO Motion Trackers.</param>
  502. public static int GetFitnessBandConnectState(ref PxrFitnessBandConnectState state)
  503. {
  504. return PXR_Plugin.Controller.UPxr_GetFitnessBandConnectState(ref state);
  505. }
  506. /// <summary>
  507. /// Gets the battery of a specified PICO Motion Traker.
  508. /// </summary>
  509. /// <param name="trackerId">The ID of the motion tracker to get battery for.</param>
  510. /// <param name="battery">The motion tracker's battery. Value range: [0,5]. The smaller the value, the lower the battery level.</param>
  511. public static int GetFitnessBandBattery(int trackerId, ref int battery)
  512. {
  513. return PXR_Plugin.Controller.UPxr_GetFitnessBandBattery(trackerId, ref battery);
  514. }
  515. /// <summary>
  516. /// Gets whether the PICO Motion Tracker has completed calibration.
  517. /// </summary>
  518. /// <param name="calibrated">Indicates the calibration status:
  519. /// `0`: calibration uncompleted
  520. /// `1`: calibration completed
  521. /// </param>
  522. public static int GetFitnessBandCalibState(ref int calibrated) {
  523. return PXR_Plugin.Controller.UPxr_GetFitnessBandCalibState(ref calibrated);
  524. }
  525. /// <summary>
  526. /// Sets a body tracking mode for PICO Motion Tracker. If this API is not called, the mode defaults to leg tracking.
  527. /// @note If you want to set the mode to full-body tracking, you must call this API before calling `OpenFitnessBandCalibrationAPP`.
  528. /// </summary>
  529. /// <param name="mode">Selects a body tracking mode from the following:
  530. /// * `0`: leg tracking, nodes numbered 0 to 15 in `BodyTrackerRole` enum will return data.
  531. /// * `1`: full-body tracking, nodes numbered 0 to 23 in `BodyTrackerRole` enum will return data.
  532. /// </param>
  533. /// <returns>
  534. /// * `0`: success
  535. /// * `1`: failure
  536. /// </returns>
  537. public static int SetSwiftMode(int mode)
  538. {
  539. return PXR_Plugin.Controller.UPxr_SetSwiftMode(mode);
  540. }
  541. /// <summary>
  542. /// Sets bone lengths for different parts of the avatar. The data will be sent to PICO'S algorithm to make the avatar's poses more accurate.
  543. /// </summary>
  544. /// <param name="boneLength">Sets the bone lengths for different parts of the avatar. See the `BodyTrackingBoneLength` for details.</param>
  545. /// <returns>
  546. /// * `0`: success
  547. /// * `1`: failure
  548. /// </returns>
  549. public static int SetBodyTrackingBoneLength(BodyTrackingBoneLength boneLength)
  550. {
  551. return PXR_Plugin.Controller.UPxr_SetBodyTrackingBoneLength(boneLength);
  552. }
  553. /// <summary>
  554. /// Launches the calibration app if the PICO Motion Tracker hasn't completed calibration.
  555. /// </summary>
  556. public static void OpenFitnessBandCalibrationAPP() {
  557. PXR_Plugin.System.UPxr_OpenFitnessBandCalibrationAPP();
  558. }
  559. /// <summary>
  560. /// Sends a haptic impulse to specified controller(s) to trigger vibration.
  561. /// @note To stop vibration, call this API again and set both `amplitude` and `duration` to `0`.
  562. /// </summary>
  563. /// <param name="vibrateType">The controller(s) to send the haptic impulse to:
  564. /// * `None`
  565. /// * `LeftController`
  566. /// * `RightController`
  567. /// * `BothController`
  568. /// </param>
  569. /// <param name="amplitude">Vibration amplitude, which ranges from `0` to `1`. The higher the value, the stronger the vibration amplitude.</param>
  570. /// <param name="duration">Vibration duration, which ranges from `0` to `65535` ms.</param>
  571. /// <param name="frequency">Vibration frequency, which ranges from `50` to `500` Hz.</param>
  572. public static void SendHapticImpulse(VibrateType vibrateType, float amplitude, int duration, int frequency = 150)
  573. {
  574. switch (vibrateType)
  575. {
  576. case VibrateType.None:
  577. break;
  578. case VibrateType.LeftController:
  579. PXR_Plugin.Controller.UPxr_SetControllerVibrationEvent(0, frequency, amplitude, duration);
  580. break;
  581. case VibrateType.RightController:
  582. PXR_Plugin.Controller.UPxr_SetControllerVibrationEvent(1, frequency, amplitude, duration);
  583. break;
  584. case VibrateType.BothController:
  585. PXR_Plugin.Controller.UPxr_SetControllerVibrationEvent(0, frequency, amplitude, duration);
  586. PXR_Plugin.Controller.UPxr_SetControllerVibrationEvent(1, frequency, amplitude, duration);
  587. break;
  588. default:
  589. break;
  590. }
  591. }
  592. /// <summary>
  593. /// Sends a buffer of haptic data to specified controller(s) to trigger vibration.
  594. /// </summary>
  595. /// <param name="vibrateType">The controller(s) to send the haptic data to:
  596. /// * `None`
  597. /// * `LeftController`
  598. /// * `RightController`
  599. /// * `BothController`
  600. /// </param>
  601. /// <param name="audioClip">The audio data pulled from the audio file stored in the AudioClip component is used as the haptic data.</param>
  602. /// <param name="channelFlip">Determines whether to enable audio channel inversion. Once enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  603. /// * `Yes`: enable
  604. /// * `No`: disable
  605. /// </param>
  606. /// <param name="sourceId">Returns the unique ID for controlling the corresponding buffered haptic,
  607. /// which will be used in `PauseHapticBuffer`, `ResumeHapticBuffer`, `UpdateHapticBuffer`, or `StopHapticBuffer`.</param>
  608. /// <param name="cacheType">Whether to keep the controller vibrating while caching haptic data:
  609. /// * `DontCache`: don't cache.
  610. /// * `CacheAndVibrate`: cache and keep vibrating.
  611. /// * `CacheNoVibrate`: cache and stop vibrating. Call `StartHapticBuffer` to start haptic after caching the data.
  612. /// @note If not defined, `DontCache` will be passed by default.
  613. /// </param>
  614. /// <returns>
  615. /// * `0`: success
  616. /// * `1`: failure
  617. /// </returns>
  618. /**
  619. * \overload int SendHapticBuffer(VibrateType vibrateType, AudioClip audioClip, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType)
  620. */
  621. public static int SendHapticBuffer(VibrateType vibrateType, AudioClip audioClip, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType = CacheType.DontCache)
  622. {
  623. if (audioClip == null)
  624. {
  625. return 0;
  626. }
  627. float[] data = new float[audioClip.samples * audioClip.channels];
  628. int buffersize = audioClip.samples * audioClip.channels;
  629. audioClip.GetData(data, 0);
  630. int sampleRate = audioClip.frequency;
  631. int channelMask = audioClip.channels;
  632. if (cacheType == CacheType.DontCache)
  633. {
  634. return PXR_Plugin.Controller.UPxr_StartVibrateBySharem(data, (int)vibrateType, buffersize, sampleRate, channelMask, 32, (int)channelFlip, ref sourceId);
  635. }
  636. else
  637. {
  638. return PXR_Plugin.Controller.UPxr_SaveVibrateByCache(data, (int)vibrateType, buffersize, sampleRate, channelMask, 32, (int)channelFlip, (int)cacheType, ref sourceId);
  639. }
  640. }
  641. /// <summary>
  642. /// Sends a buffer of haptic data to specified controller(s) to trigger vibration.
  643. /// </summary>
  644. /// <param name="vibrateType">The controller(s) to send the haptic data to:
  645. /// * `None`
  646. /// * `LeftController`
  647. /// * `RightController`
  648. /// * `BothController`
  649. /// </param>
  650. /// <param name="pcmData">The PCM data is converted from the audio file stored in the AudioClip component in the Unity Engine.</param>
  651. /// <param name="buffersize">The length of PCM data. Calculation formula: (audioClip.samples)×(audioClip.channels). Sample refers to the data in each channel.</param>
  652. /// <param name="frequency">Sample rate. The higher the sample rate, the closer the recorded signal is to the original.</param>
  653. /// <param name="channelMask">The number of channels that play the haptic data.</param>
  654. /// <param name="channelFlip">Determines whether to enable audio channel inversion. Once enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  655. /// * `Yes`: enable
  656. /// * `No`: disable
  657. /// </param>
  658. /// <param name="sourceId">Returns the unique ID for controlling the corresponding buffered haptic,
  659. /// which will be used in `PauseHapticBuffer`, `ResumeHapticBuffer`, `UpdateHapticBuffer`, or `StopHapticBuffer`.</param>
  660. /// <param name="cacheType">Whether to keep the controller vibrating while caching haptic data:
  661. /// * `DontCache`: don't cache.
  662. /// * `CacheAndVibrate`: cache and keep vibrating.
  663. /// * `CacheNoVibrate`: cache and stop vibrating. Call `StartHapticBuffer` to start vibration after caching the data.
  664. /// @note If not defined, `DontCache` will be passed by default.
  665. /// </param>
  666. /// <returns>
  667. /// * `0`: success
  668. /// * `-1`: failure
  669. /// </returns>
  670. /**
  671. * \overload int SendHapticBuffer(VibrateType vibrateType, float[] pcmData, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType)
  672. */
  673. public static int SendHapticBuffer(VibrateType vibrateType, float[] pcmData, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, ref int sourceId, CacheType cacheType = CacheType.DontCache)
  674. {
  675. if (cacheType == CacheType.DontCache)
  676. {
  677. return PXR_Plugin.Controller.UPxr_StartVibrateBySharem(pcmData, (int)vibrateType, buffersize, frequency, channelMask, 32, (int)channelFlip, ref sourceId);
  678. }
  679. else
  680. {
  681. return PXR_Plugin.Controller.UPxr_SaveVibrateByCache(pcmData, (int)vibrateType, buffersize, frequency, channelMask, 32, (int)channelFlip, (int)cacheType, ref sourceId);
  682. }
  683. }
  684. /// <summary>
  685. /// Sends a buffer of haptic data to specified controller(s) to trigger vibration.
  686. /// </summary>
  687. /// <param name="vibrateType">The controller(s) to send the haptic data to:
  688. /// * `None`
  689. /// * `LeftController`
  690. /// * `RightController`
  691. /// * `BothController`
  692. /// </param>
  693. /// <param name="phfText">The PHF file (.json) that contains haptic data.</param>
  694. /// <param name="channelFlip">Determines whether to enable audio channel inversion. Once enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  695. /// * `Yes`: enable
  696. /// * `No`: disable
  697. /// <param name="amplitudeScale">Vibration amplitude, the higher the amplitude, the stronger the haptic effect. The valid value range from `0` to `2`:
  698. /// * `0`: no vibration
  699. /// * `1`: standard amplitude
  700. /// * `2`: 2×standard amplitude
  701. /// </param>
  702. /// <param name="sourceId">Returns the unique ID for controlling the corresponding buffered haptic,
  703. /// which will be used in `PauseHapticBuffer`, `ResumeHapticBuffer`, `UpdateHapticBuffer`, or `StopHapticBuffer`.</param>
  704. /// <returns>
  705. /// * `0`: success
  706. /// * `-1`: failure
  707. /// </returns>
  708. public static int SendHapticBuffer(VibrateType vibrateType, TextAsset phfText, ChannelFlip channelFlip, float amplitudeScale, ref int sourceId)
  709. {
  710. return PXR_Plugin.Controller.UPxr_StartVibrateByPHF(phfText.text, phfText.text.Length, ref sourceId, (int)vibrateType, (int)channelFlip, amplitudeScale);
  711. }
  712. /// <summary>
  713. /// Stops a specified buffered haptic.
  714. /// </summary>
  715. /// <param name="sourceId">The source ID returned by `SendHapticBuffer`. Set it to the target source ID to stop a specific buffered haptic,
  716. /// or set it to `0` to stop all buffered haptics. If not defined, `0` will be passed to stop all buffered haptics by default.</param>
  717. /// <param name="clearCache">Determines whether to clear the cached data of the specified haptic.
  718. /// If not defined, `false` will be passed to keep the cached data by default.</param>
  719. /// <returns>
  720. /// * `0`: success
  721. /// * `1`: failure
  722. /// </returns>
  723. public static int StopHapticBuffer(int sourceId = 0, bool clearCache = false)
  724. {
  725. if (clearCache)
  726. {
  727. PXR_Plugin.Controller.UPxr_ClearVibrateByCache(sourceId);
  728. }
  729. return PXR_Plugin.Controller.UPxr_StopControllerVCMotor(sourceId);
  730. }
  731. /// <summary>
  732. /// Pauses a specified buffered haptic.
  733. /// </summary>
  734. /// <param name="sourceId">The source ID returned by `SendHapticBuffer`.
  735. /// Set it to the target source ID to stop a specific buffered haptic.</param>
  736. /// <returns>
  737. /// * `0`: success
  738. /// * `-1`: failure
  739. /// </returns>
  740. public static int PauseHapticBuffer(int sourceId)
  741. {
  742. return PXR_Plugin.Controller.UPxr_PauseVibrate(sourceId);
  743. }
  744. /// <summary>
  745. /// Resumes a paused buffered haptic.
  746. /// </summary>
  747. /// <param name="sourceId">The source ID returned by `SendHapticBuffer`.
  748. /// Set it to the target source ID to resume a specific buffered haptic.</param>
  749. /// <returns>
  750. /// * `0`: success
  751. /// * `-1`: failure
  752. /// </returns>
  753. public static int ResumeHapticBuffer(int sourceId)
  754. {
  755. return PXR_Plugin.Controller.UPxr_ResumeVibrate(sourceId);
  756. }
  757. /// <summary>
  758. /// Starts a specified buffered haptic.
  759. /// @note If you pass `CacheNoVibrate` in `SendHapticBuffer`, call this API if you want to start haptic after caching the data.
  760. /// </summary>
  761. /// <param name="sourceId">The source ID returned by `SendHapticBuffer` when there is cached data for the haptic.</param>
  762. /// <returns>
  763. /// * `0`: success
  764. /// * `-1`: failure
  765. /// </returns>
  766. public static int StartHapticBuffer(int sourceId)
  767. {
  768. return PXR_Plugin.Controller.UPxr_StartVibrateByCache(sourceId);
  769. }
  770. /// <summary>
  771. /// Updates the settings for a specified buffered haptic.
  772. /// </summary>
  773. /// <param name="sourceId">The source ID returned by `SendHapticBuffer`.
  774. /// Set it to the target source ID to update a specific buffered haptic.</param>
  775. /// <param name="vibrateType">The controller(s) that the vibration is applied to:
  776. /// * `None`
  777. /// * `LeftController`
  778. /// * `RightController`
  779. /// * `BothController`
  780. /// </param>
  781. /// <param name="channelFlip">Determines whether to enable audio channel inversion. Once enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
  782. /// * `Yes`: enable
  783. /// * `No`: disable
  784. /// <param name="amplitudeScale">Vibration amplitude, the higher the amplitude, the stronger the haptic effect. The valid value range from `0` to `2`:
  785. /// * `0`: no vibration
  786. /// * `1`: standard amplitude
  787. /// * `2`: 2×standard amplitude
  788. /// </param>
  789. /// <returns>
  790. /// * `0`: success
  791. /// * `-1`: failure
  792. /// </returns>
  793. public static int UpdateHapticBuffer(int sourceId, VibrateType vibrateType, ChannelFlip channelFlip, float amplitudeScale)
  794. {
  795. return PXR_Plugin.Controller.UPxr_UpdateVibrateParams(sourceId, (int)vibrateType, (int)channelFlip, amplitudeScale);
  796. }
  797. /// <summary>Creates a haptic stream.</summary>
  798. /// <param name="phfVersion">The version of the PICO haptic file (PHF) that the stream uses.</param>
  799. /// <param name="frameDurationMs">Interframe space, which is the amount of time in milliseconds existing between the transmissions of frames.</param>
  800. /// <param name="hapticInfo">The information about this haptic stream you create.</param>
  801. /// <param name="speed">The streaming speed.</param>
  802. /// <param name="id">Returns the ID of the stream.</param>
  803. /// <returns>
  804. /// * `0`: success
  805. /// * `1`: failure
  806. /// </returns>
  807. public static int CreateHapticStream(string phfVersion, UInt32 frameDurationMs, ref VibrateInfo hapticInfo, float speed, ref int id)
  808. {
  809. return PXR_Plugin.Controller.UPxr_CreateHapticStream(phfVersion, frameDurationMs, ref hapticInfo, speed, ref id);
  810. }
  811. /// <summary>
  812. /// Writes haptic data to a specified stream.
  813. /// </summary>
  814. /// <param name="id">The ID of the target stream.</param>
  815. /// <param name="frames">The data contained in the PICO haptic file (PHF).</param>
  816. /// <param name="numFrames">The number of frames.</param>
  817. /// <returns>
  818. /// * `0`: success
  819. /// * `1`: failure
  820. /// </returns>
  821. public static int WriteHapticStream(int id, ref PxrPhfParamsNum frames, UInt32 numFrames)
  822. {
  823. return PXR_Plugin.Controller.UPxr_WriteHapticStream(id, ref frames, numFrames);
  824. }
  825. /// <summary>
  826. /// Sets a transmission speed for a specified haptic stream.
  827. /// </summary>
  828. /// <param name="id">The ID of the stream.</param>
  829. /// <param name="speed">The transmission speed to set for the stream.</param>
  830. /// <returns>
  831. /// * `0`: success
  832. /// * `1`: failure
  833. /// </returns>
  834. public static int SetHapticStreamSpeed(int id, float speed)
  835. {
  836. return PXR_Plugin.Controller.UPxr_SetPHFHapticSpeed(id, speed);
  837. }
  838. /// <summary>
  839. /// Gets the transmission speed of a specified haptic stream.
  840. /// </summary>
  841. /// <param name="id">The ID of the stream.</param>
  842. /// <param name="speed">Returns the stream's transmission speed.</param>
  843. /// <returns>
  844. /// * `0`: success
  845. /// * `1`: failure
  846. /// </returns>
  847. public static int GetHapticStreamSpeed(int id, ref float speed)
  848. {
  849. return PXR_Plugin.Controller.UPxr_GetPHFHapticSpeed(id, ref speed);
  850. }
  851. /// <summary>
  852. /// Gets the No. of the frame that the controller currently plays.
  853. /// </summary>
  854. /// <param name="id">The ID of the haptic stream that triggers the vibration.</param>
  855. /// <param name="frameSequence">Returns the current frame's sequence No.</param>
  856. /// <returns>
  857. /// * `0`: success
  858. /// * `1`: failure
  859. /// </returns>
  860. public static int GetHapticStreamCurrentFrameSequence(int id, ref UInt64 frameSequence)
  861. {
  862. return PXR_Plugin.Controller.UPxr_GetCurrentFrameSequence(id, ref frameSequence);
  863. }
  864. /// <summary>
  865. /// Starts the transmission of a specified haptic stream.
  866. /// </summary>
  867. /// <param name="source_id">The ID of the haptic stream.</param>
  868. /// <returns>
  869. /// * `0`: success
  870. /// * `1`: failure
  871. /// </returns>
  872. public static int StartHapticStream(int source_id)
  873. {
  874. return PXR_Plugin.Controller.UPxr_StartPHFHaptic(source_id);
  875. }
  876. /// <summary>
  877. /// Stops the transmission of a specified haptic stream.
  878. /// </summary>
  879. /// <param name="source_id">The ID of the haptic stream.</param>
  880. /// <returns>
  881. /// * `0`: success
  882. /// * `1`: failure
  883. /// </returns>
  884. public static int StopHapticStream(int source_id)
  885. {
  886. return PXR_Plugin.Controller.UPxr_StopPHFHaptic(source_id);
  887. }
  888. /// <summary>
  889. /// Removes a specified haptic stream.
  890. /// </summary>
  891. /// <param name="source_id">The ID of the stream.</param>
  892. /// <returns>
  893. /// * `0`: success
  894. /// * `1`: failure
  895. /// </returns>
  896. public static int RemoveHapticStream(int source_id)
  897. {
  898. return PXR_Plugin.Controller.UPxr_RemovePHFHaptic(source_id);
  899. }
  900. /// <summary>
  901. /// Parses the haptic data in a specified PICO haptic file (PHF).
  902. /// </summary>
  903. /// <param name="phfText">The PICO haptic file (.json) to parse.</param>
  904. public static PxrPhfFile AnalysisHapticStreamPHF(TextAsset phfText)
  905. {
  906. String str = phfText.text;
  907. return JsonMapper.ToObject<PxrPhfFile>(str);
  908. }
  909. /// <summary>
  910. /// Recenters the controller on PICO G3.
  911. /// </summary>
  912. public static void ResetController()
  913. {
  914. PXR_Plugin.Controller.UPxr_ResetController();
  915. }
  916. /// <summary>
  917. /// Sets arm model parameters on PICO G3.
  918. /// </summary>
  919. /// <param name="gazetype">Gaze type, which is used to define the way of getting the HMD data.</param>
  920. /// <param name="armmodeltype">Arm model type</param>
  921. /// <param name="elbowHeight">The elbow's height, which changes the arm's length.Value range: (0.0f, 0.2f). The default value is 0.0f.</param>
  922. /// <param name="elbowDepth">The elbow's depth, which changes the arm's position.Value range: (0.0f, 0.2f). The default value is 0.0f.</param>
  923. /// <param name="pointerTiltAngle">The ray's tilt angle. Value range: (0.0f, 30.0f). The default value is 0.0f.</param>
  924. public static void SetArmModelParameters(PxrGazeType gazetype, PxrArmModelType armmodeltype, float elbowHeight, float elbowDepth, float pointerTiltAngle)
  925. {
  926. PXR_Plugin.Controller.UPxr_SetArmModelParameters(gazetype, armmodeltype, elbowHeight, elbowDepth, pointerTiltAngle);
  927. }
  928. /// <summary>
  929. /// Gets the current user's dominant hand in the system on PICO G3.
  930. /// </summary>
  931. /// <param name="deviceID">Specifies the ID of the PICO device.</param>
  932. public static void GetControllerHandness(ref int deviceID)
  933. {
  934. PXR_Plugin.Controller.UPxr_GetControllerHandness(ref deviceID);
  935. }
  936. }
  937. }
粤ICP备19079148号