PICO Unity XR SDK
PXR_Input Class Reference

Public Types

enum  ControllerDevice {
  G2 = 3 , Neo2 , Neo3 , PICO_4 ,
  NewController = 10
}
 
enum  Controller { LeftController , RightController }
 
enum  VibrateController { No = 0 , Left = 1 , Right = 2 , LeftAndRight = 3 }
 
enum  ChannelFlip { No , Yes }
 
enum  CacheConfig { CacheAndVibrate = 1 , CacheNoVibrate = 2 }
 

Static Public Member Functions

static Controller GetDominantHand ()
 Gets the current dominant controller. More...
 
static void SetDominantHand (Controller controller)
 Sets a controller as the dominant controller. More...
 
static void SetControllerVibration (float strength, int time, Controller controller)
 Sets controller vibration, including vibration amplitude and duration. More...
 
static ControllerDevice GetControllerDeviceType ()
 Gets the device model. More...
 
static bool IsControllerConnected (Controller controller)
 Gets controller's connection status. More...
 
static void SetControllerOriginOffset (Controller controller, Vector3 offset)
 Sets the offset of the controller's display position to its real position. More...
 
static Quaternion GetControllerPredictRotation (Controller controller, double predictTime)
 Gets the predicted rotation of a specified controller after a specified time. More...
 
static Vector3 GetControllerPredictPosition (Controller controller, double predictTime)
 Gets the predicted position of a specified controller after a specified time. More...
 
static int SetControllerVibrationEvent (UInt32 hand, int frequency, float strength, int time)
 Sets event-based vibration. More...
 
static int StopControllerVCMotor (int sourceId)
 Stops sound vibration. More...
 
static int StartControllerVCMotor (string file, VibrateController vibrateController)
 Starts sound vibration through an audio file. More...
 
static int SetControllerAmp (float mode)
 Sets the amplitude for sound vibrations. Support changing the vibration amplitude during audio playback. More...
 
static int StartVibrateBySharem (AudioClip audioClip, VibrateController vibrateController, ChannelFlip channelFlip, ref int sourceId)
 Starts sound vibration through an audio clip passed to the Unity Engine. More...
 
static int StartVibrateBySharem (float[] data, VibrateController vibrateController, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, ref int sourceId)
 Starts sound vibration. This function is the overloaded version. More...
 
static int SaveVibrateByCache (AudioClip audioClip, VibrateController vibrateController, ChannelFlip channelFlip, CacheConfig cacheConfig, ref int sourceId)
 Caches sound vibration data. More...
 
static int SaveVibrateByCache (float[] data, VibrateController vibrateController, int buffersize, int frequency, int channelMask, ChannelFlip channelFlip, CacheConfig cacheConfig, ref int sourceId)
 Caches sound vibration data. This function is the overloaded version. More...
 
static int StartVibrateByCache (int sourceId)
 Plays cached sound vibration data. More...
 
static int ClearVibrateByCache (int sourceId)
 Clears cached sound vibration data. More...
 
static int SetControllerEnableKey (bool isEnable, PxrControllerKeyMap Key)
 
static int StartVibrateByPHF (TextAsset phfText, ref int sourceId, VibrateController vibrateController, ChannelFlip channelFlip, float amp)
 Starts PHF vibration. More...
 
static int PauseVibrate (int sourceId)
 Pauses PHF vibration. More...
 
static int ResumeVibrate (int sourceId)
 Resumes PHF vibration. More...
 
static int UpdateVibrateParams (int sourceId, VibrateController vibrateController, ChannelFlip channelFlip, float amp)
 Dynamically updates PHF and AudioClip vibration data. More...
 

Member Enumeration Documentation

◆ CacheConfig

Enumerator
CacheAndVibrate 
CacheNoVibrate 

◆ ChannelFlip

Enumerator
No 
Yes 

◆ Controller

enum Controller
Enumerator
LeftController 
RightController 

◆ ControllerDevice

Enumerator
G2 
Neo2 
Neo3 
PICO_4 
NewController 

◆ VibrateController

Enumerator
No 
Left 
Right 
LeftAndRight 

Member Function Documentation

◆ ClearVibrateByCache()

static int ClearVibrateByCache ( int  sourceId)
static

Clears cached sound vibration data.

Parameters
sourceIdThe source ID returned by StartVibrateBySharem or SaveVibrateByCache.
Returns
  • 0: success
  • -1: failure

◆ GetControllerDeviceType()

static ControllerDevice GetControllerDeviceType ( )
static

Gets the device model.

Returns
The device model. Enumerations: G2, Neo2, Neo3, NewController.


◆ GetControllerPredictPosition()

static Vector3 GetControllerPredictPosition ( Controller  controller,
double  predictTime 
)
static

Gets the predicted position of a specified controller after a specified time.

Parameters
handThe controller to get the predicted position for: 0-left controller; 1-right controller.
predictTimeThe time for prediction (in milliseconds).
Returns
The predicted position value.

◆ GetControllerPredictRotation()

static Quaternion GetControllerPredictRotation ( Controller  controller,
double  predictTime 
)
static

Gets the predicted rotation of a specified controller after a specified time.

Parameters
handThe controller to get the predicted rotation for: 0-left controller; 1-right controller.
predictTimeThe time for prediction (in milliseconds).
Returns
The predicted rotation value.

◆ GetDominantHand()

static Controller GetDominantHand ( )
static

Gets the current dominant controller.

Returns
The current dominant controller: LeftController; RightController.

◆ IsControllerConnected()

static bool IsControllerConnected ( Controller  controller)
static

Gets controller's connection status.

Parameters
controllerThe controller to get the connection status for: 0-left controller; 1-right controller.
Returns
The connection status of the specified controller: true-connected; false-not connected.

◆ PauseVibrate()

static int PauseVibrate ( int  sourceId)
static

Pauses PHF vibration.

Parameters
sourceIdThe source ID returned by StartVibrateBySharem or SaveVibrateByCache.
Returns
  • 0: success
  • -1: failure

◆ ResumeVibrate()

static int ResumeVibrate ( int  sourceId)
static

Resumes PHF vibration.

Parameters
sourceIdThe source ID returned by StartVibrateBySharem or SaveVibrateByCache.
Returns
  • 0: success
  • -1: failure

◆ SaveVibrateByCache() [1/2]

static int SaveVibrateByCache ( AudioClip  audioClip,
VibrateController  vibrateController,
ChannelFlip  channelFlip,
CacheConfig  cacheConfig,
ref int  sourceId 
)
static

Caches sound vibration data.

Note
Cached audio data can be extracted from the cache directory and then transmitted, which reduces resource consumption and improves service performance.
Parameters
audioClipThe audio clip file.
vibrateControllerThe controller(s) to cache sound vibration data for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers
channelFlipWhether to enable audio channel inversion:
  • Yes: enable
  • No: disable Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
cacheConfigWhether to keep the controller vibrating while caching audio-based vibration data:
  • CacheAndVibrate: cache and keep vibrating
  • CacheNoVibrate: cache and stop vibrating
sourceIdReturns the unique ID for controlling the corresponding vibration, which will be used in StartVibrateByCache, ClearVibrateByCache or StopControllerVCMotor.
Returns
  • 0: success
  • -1: failure

◆ SaveVibrateByCache() [2/2]

static int SaveVibrateByCache ( float[]  data,
VibrateController  vibrateController,
int  buffersize,
int  frequency,
int  channelMask,
ChannelFlip  channelFlip,
CacheConfig  cacheConfig,
ref int  sourceId 
)
static

Caches sound vibration data. This function is the overloaded version.

Note
Cached audio data can be extracted from the cache directory and then transmitted, which reduces resource consumption and improves service performance.
Parameters
dataThe PCM data.
vibrateControllerThe controller(s) to cache sound vibration data for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers
buffersizeThe length of PCM data. Formula: (audioClip.samples)×(audioClip.channels)
frequencyAudio sampling rate.
channelMaskThe number of channels.
channelFlipWhether to enable audio channel inversion:
  • Yes: enable
  • No: disable Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
cacheConfigWhether to keep the controller vibrating while caching audio-based vibration data:
  • CacheAndVibrate: cache and keep vibrating
  • CacheNoVibrate: cache and stop vibrating
sourceIdReturns the unique ID for controlling the corresponding vibration, which will be used in StartVibrateByCache, ClearVibrateByCache or StopControllerVCMotor.
Returns
  • 0: success
  • -1: failure

◆ SetControllerAmp()

static int SetControllerAmp ( float  mode)
static

Sets the amplitude for sound vibrations. Support changing the vibration amplitude during audio playback.

Parameters
modeVibration amplitude level:
  • 0: no vibration
  • 1: standard amplitude
  • 2: 2×standard amplitude
  • 3: 3×standard amplitude
  • 4: 4×standard amplitude

"3×standard amplitude" and "4×standard amplitude" are NOT recommended as they will cause serious loss of vibration details.

◆ SetControllerEnableKey()

static int SetControllerEnableKey ( bool  isEnable,
PxrControllerKeyMap  Key 
)
static

◆ SetControllerOriginOffset()

static void SetControllerOriginOffset ( Controller  controller,
Vector3  offset 
)
static

Sets the offset of the controller's display position to its real position.

Parameters
handThe controller to set an offset for: 0-left controller; 1-right controller.
offsetThe offset (in meters).

◆ SetControllerVibration()

static void SetControllerVibration ( float  strength,
int  time,
Controller  controller 
)
static

Sets controller vibration, including vibration amplitude and duration.

Note
The SendHapticImpulse method offered by UnityXR is also supported. Click here for more information.
Parameters
strengthVibration 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.
timeVibration duration. The valid value ranges from 0 to 65535 ms.
controllerThe controller to set vibration for:
  • 0: left controller
  • 1: right controller

◆ SetControllerVibrationEvent()

static int SetControllerVibrationEvent ( UInt32  hand,
int  frequency,
float  strength,
int  time 
)
static

Sets event-based vibration.

Parameters
handThe controller to enable event-based vibration for:
  • 0: left controller
  • 1: right controller
frequencyVibration frequency, which ranges from 50 to 500 Hz.
strengthVibration amplitude. Its valid value ranges from 0 to 1. The higher the value, the stronger the vibration amplitude.
timeVibration duration, which ranges from 0 to 65535 ms.
Returns

◆ SetDominantHand()

static void SetDominantHand ( Controller  controller)
static

Sets a controller as the dominant controller.

Parameters
controllerThe controller to be set as the dominant controller: 0-left controller; 1-right controller.

◆ StartControllerVCMotor()

static int StartControllerVCMotor ( string  file,
VibrateController  vibrateController 
)
static

Starts sound vibration through an audio file.

Parameters
fileThe file path that the audio data comes from.
vibrateControllerThe controller(s) to enable sound vibration for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers

◆ StartVibrateByCache()

static int StartVibrateByCache ( int  sourceId)
static

Plays cached sound vibration data.

Parameters
sourceIdThe source ID returned by StartVibrateBySharem or SaveVibrateByCache.
Returns
  • 0: success
  • -1: failure

◆ StartVibrateByPHF()

static int StartVibrateByPHF ( TextAsset  phfText,
ref int  sourceId,
VibrateController  vibrateController,
ChannelFlip  channelFlip,
float  amp 
)
static

Starts PHF vibration.

Parameters
phfTextThe PHF file.
sourceIdThe source ID returned by StartVibrateBySharem or SaveVibrateByCache.
vibrateControllerThe controller(s) to enable PHF vibration for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers
channelFlipWhether to enable audio channel inversion:
  • Yes: enable
  • No: disable Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
ampThe vibration gain, the valid value range from 0 to 2:
  • 0: no vibration
  • 1: standard amplitude
  • 2: 2×standard amplitude
Returns
  • 0: success
  • -1: failure

◆ StartVibrateBySharem() [1/2]

static int StartVibrateBySharem ( AudioClip  audioClip,
VibrateController  vibrateController,
ChannelFlip  channelFlip,
ref int  sourceId 
)
static

Starts sound vibration through an audio clip passed to the Unity Engine.

Parameters
audioClipThe audio clip file.
vibrateControllerThe controller(s) to enable sound vibration for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers

Whether to enable audio channel inversion:

  • Yes: enable
  • No: disable Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.

Returns the unique ID for controlling the corresponding vibration, which will be used in StartVibrateByCache, ClearVibrateByCache or StopControllerVCMotor.

◆ StartVibrateBySharem() [2/2]

static int StartVibrateBySharem ( float[]  data,
VibrateController  vibrateController,
int  buffersize,
int  frequency,
int  channelMask,
ChannelFlip  channelFlip,
ref int  sourceId 
)
static

Starts sound vibration. This function is the overloaded version.

Parameters
dataThe PCM data.
vibrateControllerThe controller(s) to enable sound vibration for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers
buffersizeThe length of PCM data. Formula: (audioClip.samples)×(audioClip.channels).
frequencyAudio sampling rate.
channelMaskThe number of channels.
channelFlipWhether to enable audio channel inversion:
  • Yes: enable
  • No: disable Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
sourceIdReturns the unique ID for controlling the corresponding vibration, which will be used in StartVibrateByCache, ClearVibrateByCache or StopControllerVCMotor.
Returns

◆ StopControllerVCMotor()

static int StopControllerVCMotor ( int  sourceId)
static

Stops sound vibration.

Parameters
idA reserved parameter, set it to the source ID returned by StartVibrateBySharem or SaveVibrateByCache to stop the corresponding vibration, or set it to 0 to stop all vibrations.

◆ UpdateVibrateParams()

static int UpdateVibrateParams ( int  sourceId,
VibrateController  vibrateController,
ChannelFlip  channelFlip,
float  amp 
)
static

Dynamically updates PHF and AudioClip vibration data.

Parameters
sourceIdThe source ID returned by StartVibrateBySharem or SaveVibrateByCache.
vibrateControllerThe controller(s) to update PHF and AudioClip vibration data for:
  • 0: none
  • 1: left controller
  • 2: right controller
  • 3: left and right controllers
channelFlipWhether to enable audio channel inversion:
  • Yes: enable
  • No: disable Once audio channel inversion is enabled, the left controller vibrates with the audio data from the right channel, and vice versa.
ampThe vibration gain, the valid value range from 0 to 2:
  • 0: no vibration
  • 1: standard amplitude
  • 2: 2×standard amplitude
Returns
  • 0: success
  • -1: failure

The documentation for this class was generated from the following file: