NRSDKApiForUnity
Classes
NRInput

Inherits SingletonBehaviour< NRInput >.

Public Member Functions

string GetVersion (int index)
 

Static Public Member Functions

static void SetDomainHandMode (ControllerHandEnum handEnum)
 
static bool SetInputSource (InputSourceEnum inputSourceType)
 
static int GetAvailableControllersCount ()
 
static ControllerType GetControllerType ()
 
static ControllerConnectionState GetControllerConnectionState ()
 
static bool CheckControllerAvailable (ControllerHandEnum handEnum)
 
static bool GetControllerAvailableFeature (ControllerAvailableFeature feature)
 
static bool GetButton (ControllerButton button)
 
static bool GetButtonDown (ControllerButton button)
 
static bool GetButtonUp (ControllerButton button)
 
static bool IsTouching ()
 
static Vector2 GetTouch ()
 
static Vector2 GetDeltaTouch ()
 
static Vector3 GetPosition ()
 
static Quaternion GetRotation ()
 
static Vector3 GetGyro ()
 
static Vector3 GetAccel ()
 
static Vector3 GetMag ()
 
static int GetControllerBattery ()
 
static void TriggerHapticVibration (float durationSeconds=0.1f, float frequency=200f, float amplitude=0.8f)
 
static bool GetButton (ControllerHandEnum hand, ControllerButton button)
 
static bool GetButtonDown (ControllerHandEnum hand, ControllerButton button)
 
static bool GetButtonUp (ControllerHandEnum hand, ControllerButton button)
 
static bool IsTouching (ControllerHandEnum hand)
 
static Vector2 GetTouch (ControllerHandEnum hand)
 
static Vector2 GetDeltaTouch (ControllerHandEnum hand)
 
static Vector3 GetPosition (ControllerHandEnum hand)
 
static Quaternion GetRotation (ControllerHandEnum hand)
 
static Vector3 GetGyro (ControllerHandEnum hand)
 
static Vector3 GetAccel (ControllerHandEnum hand)
 
static Vector3 GetMag (ControllerHandEnum hand)
 
static int GetControllerBattery (ControllerHandEnum hand)
 
static void TriggerHapticVibration (ControllerHandEnum hand, float durationSeconds=0.1f, float frequency=200f, float amplitude=0.8f)
 
static void RecenterController ()
 
static void AddDownListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void RemoveDownListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void AddPressingListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void RemovePressingListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void AddUpListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void RemoveUpListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void AddClickListener (ControllerHandEnum hand, ControllerButton button, Action action)
 
static void RemoveClickListener (ControllerHandEnum hand, ControllerButton button, Action action)
 

Static Public Attributes

const int MAX_CONTROLLER_STATE_COUNT = 2
 
static Action< ControllerHandEnumOnDomainHandChanged
 
static Action OnControllerConnected
 
static Action OnControllerDisconnected
 
static Action OnBeforeControllerRecenter
 
static Action OnControllerRecentered
 
static Action OnControllerStatesUpdated
 
static NRHandsManager Hands = new NRHandsManager()
 

Properties

static bool ReticleVisualActive [getset]
 
static bool LaserVisualActive [getset]
 
static bool ControllerVisualActive [getset]
 
static bool HapticVibrationEnabled [getset]
 
static bool RaycastersActive [getset]
 
static bool? EmulateVirtualDisplayInEditor [get]
 
static ControllerAnchorsHelper AnchorsHelper [get]
 
static ControllerHandEnum DomainHand [get]
 
static RaycastModeEnum RaycastMode [getset]
 
static InputSourceEnum CurrentInputSourceType [get]
 
static float ClickInterval [getset]
 
static float DragThreshold [getset]
 
static Transform CameraCenter [get]
 

Detailed Description

The main class to handle controller related things, such as to get controller states, update controller states Through this class, application would create a controllerProvider which could be custom, then the controllerProvider iteself would define how to update the controller states, so that every frame NRInput could get the right states.There are max two states for one controllerProvider.

Member Function Documentation

◆ AddClickListener()

static void NRKernal.NRInput.AddClickListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Add button click event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ AddDownListener()

static void NRKernal.NRInput.AddDownListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Add button down event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ AddPressingListener()

static void NRKernal.NRInput.AddPressingListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Add button pressing event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ AddUpListener()

static void NRKernal.NRInput.AddUpListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Add button up event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ CheckControllerAvailable()

static bool NRKernal.NRInput.CheckControllerAvailable ( ControllerHandEnum  handEnum)
static

Returns true if the controller is available.

Parameters
handEnum.
Returns
True if it succeeds, false if it fails.

◆ GetAccel() [1/2]

static Vector3 NRKernal.NRInput.GetAccel ( )
static

Returns the accel sensor value of the domain controller.

Returns
The accel.

◆ GetAccel() [2/2]

static Vector3 NRKernal.NRInput.GetAccel ( ControllerHandEnum  hand)
static

Returns the accel sensor value of a certain handedness controller.

Parameters
handThe hand.
Returns
The accel.

◆ GetAvailableControllersCount()

static int NRKernal.NRInput.GetAvailableControllersCount ( )
static

Get the current count of controllers which are connected and available.

Returns
The available controllers count.

◆ GetButton() [1/2]

static bool NRKernal.NRInput.GetButton ( ControllerButton  button)
static

Returns true if the button is currently pressed this frame.

Parameters
buttonThe button.
Returns
True if it succeeds, false if it fails.

◆ GetButton() [2/2]

static bool NRKernal.NRInput.GetButton ( ControllerHandEnum  hand,
ControllerButton  button 
)
static

Returns true if the button is currently pressed this frame on a certain handedness controller.

Parameters
handThe hand.
buttonThe button.
Returns
True if it succeeds, false if it fails.

◆ GetButtonDown() [1/2]

static bool NRKernal.NRInput.GetButtonDown ( ControllerButton  button)
static

Returns true if the button was pressed down this frame.

Parameters
buttonThe button.
Returns
True if it succeeds, false if it fails.

◆ GetButtonDown() [2/2]

static bool NRKernal.NRInput.GetButtonDown ( ControllerHandEnum  hand,
ControllerButton  button 
)
static

Returns true if the button was pressed down this frame on a certain handedness controller.

Parameters
handThe hand.
buttonThe button.
Returns
True if it succeeds, false if it fails.

◆ GetButtonUp() [1/2]

static bool NRKernal.NRInput.GetButtonUp ( ControllerButton  button)
static

Returns true if the button was released this frame.

Parameters
buttonThe button.
Returns
True if it succeeds, false if it fails.

◆ GetButtonUp() [2/2]

static bool NRKernal.NRInput.GetButtonUp ( ControllerHandEnum  hand,
ControllerButton  button 
)
static

Returns true if the button was released this frame on a certain handedness controller.

Parameters
handThe hand.
buttonThe button.
Returns
True if it succeeds, false if it fails.

◆ GetControllerAvailableFeature()

static bool NRKernal.NRInput.GetControllerAvailableFeature ( ControllerAvailableFeature  feature)
static

Returns true if the current controller supports the certain feature.

Parameters
featureThe feature.
Returns
True if it succeeds, false if it fails.

◆ GetControllerBattery() [1/2]

static int NRKernal.NRInput.GetControllerBattery ( )
static

Returns the battery level of the domain controller.

Returns
The controller battery.

◆ GetControllerBattery() [2/2]

static int NRKernal.NRInput.GetControllerBattery ( ControllerHandEnum  hand)
static

Returns the battery level of a certain handedness controller, range from 0 to 100.

Parameters
handThe hand.
Returns
The controller battery.

◆ GetControllerConnectionState()

static ControllerConnectionState NRKernal.NRInput.GetControllerConnectionState ( )
static

Get the ConnectionState of current controller.

Returns
The controller connection state.

◆ GetControllerType()

static ControllerType NRKernal.NRInput.GetControllerType ( )
static

Get the ControllerType of current controller.

Returns
The controller type.

◆ GetDeltaTouch() [1/2]

static Vector2 NRKernal.NRInput.GetDeltaTouch ( )
static

Returns a Vector2 delta touch value on touchpad of the domain controller.

Returns
The delta touch.

◆ GetDeltaTouch() [2/2]

static Vector2 NRKernal.NRInput.GetDeltaTouch ( ControllerHandEnum  hand)
static

Returns a Vector2 delta touch value on touchpad of a certain handedness controller.

Parameters
handThe hand.
Returns
The delta touch.

◆ GetGyro() [1/2]

static Vector3 NRKernal.NRInput.GetGyro ( )
static

Returns the gyro sensor value of the domain controller.

Returns
The gyro.

◆ GetGyro() [2/2]

static Vector3 NRKernal.NRInput.GetGyro ( ControllerHandEnum  hand)
static

Returns the gyro sensor value of a certain handedness controller.

Parameters
handThe hand.
Returns
The gyro.

◆ GetMag() [1/2]

static Vector3 NRKernal.NRInput.GetMag ( )
static

Returns the magnetic sensor value of the domain controller.

Returns
The magnitude.

◆ GetMag() [2/2]

static Vector3 NRKernal.NRInput.GetMag ( ControllerHandEnum  hand)
static

Returns the magnetic sensor value of a certain handedness controller.

Parameters
handThe hand.
Returns
The magnitude.

◆ GetPosition() [1/2]

static Vector3 NRKernal.NRInput.GetPosition ( )
static

Returns the current position of the domain controller if 6dof, otherwise returns Vector3.zero.

Returns
The position.

◆ GetPosition() [2/2]

static Vector3 NRKernal.NRInput.GetPosition ( ControllerHandEnum  hand)
static

Returns the current position of a certain handedness controller if 6dof, otherwise returns Vector3.zero.

Parameters
handThe hand.
Returns
The position.

◆ GetRotation() [1/2]

static Quaternion NRKernal.NRInput.GetRotation ( )
static

Returns the current rotation of the domain controller.

Returns
The rotation.

◆ GetRotation() [2/2]

static Quaternion NRKernal.NRInput.GetRotation ( ControllerHandEnum  hand)
static

Returns the current rotation of a certain handedness controller.

Parameters
handThe hand.
Returns
The rotation.

◆ GetTouch() [1/2]

static Vector2 NRKernal.NRInput.GetTouch ( )
static

Returns a Vector2 touch position on touchpad of the domain controller, range: x(-1f ~ 1f), y(- 1f ~ 1f)

Returns
The touch.

◆ GetTouch() [2/2]

static Vector2 NRKernal.NRInput.GetTouch ( ControllerHandEnum  hand)
static

Returns a Vector2 touch position on touchpad of a certain handedness controller, range: x(-1f ~ 1f), y(-1f ~ 1f)

Parameters
handThe hand.
Returns
The touch.

◆ GetVersion()

string NRKernal.NRInput.GetVersion ( int  index)

Gets a version.

Parameters
indexZero-based index of the.
Returns
The version.

◆ IsTouching() [1/2]

static bool NRKernal.NRInput.IsTouching ( )
static

Returns true if the touchpad is being touched.

Returns
True if touching, false if not.

◆ IsTouching() [2/2]

static bool NRKernal.NRInput.IsTouching ( ControllerHandEnum  hand)
static

Returns true if the touchpad is being touched this frame on a certain handedness controller.

Parameters
handThe hand.
Returns
True if touching, false if not.

◆ RemoveClickListener()

static void NRKernal.NRInput.RemoveClickListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Remove button click event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ RemoveDownListener()

static void NRKernal.NRInput.RemoveDownListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Remove button down event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ RemovePressingListener()

static void NRKernal.NRInput.RemovePressingListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Remove button pressing event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ RemoveUpListener()

static void NRKernal.NRInput.RemoveUpListener ( ControllerHandEnum  hand,
ControllerButton  button,
Action  action 
)
static

Remove button up event listerner.

Parameters
handThe hand.
buttonThe button.
actionThe action.

◆ SetDomainHandMode()

static void NRKernal.NRInput.SetDomainHandMode ( ControllerHandEnum  handEnum)
static

Set the current enumeration of handedness.

Parameters
handEnum.

◆ SetInputSource()

static bool NRKernal.NRInput.SetInputSource ( InputSourceEnum  inputSourceType)
static

Set the current input source.

Parameters
inputSourceType
Returns
The result of setting input source.

◆ TriggerHapticVibration() [1/2]

static void NRKernal.NRInput.TriggerHapticVibration ( ControllerHandEnum  hand,
float  durationSeconds = 0.1f,
float  frequency = 200f,
float  amplitude = 0.8f 
)
static

Trigger vibration of a certain handedness controller.

Parameters
handThe hand.
durationSeconds(Optional) The duration in seconds.
frequency(Optional) The frequency.
amplitude(Optional) The amplitude.

◆ TriggerHapticVibration() [2/2]

static void NRKernal.NRInput.TriggerHapticVibration ( float  durationSeconds = 0.1f,
float  frequency = 200f,
float  amplitude = 0.8f 
)
static

Trigger vibration of the domain controller.

Parameters
durationSeconds(Optional) The duration in seconds.
frequency(Optional) The frequency.
amplitude(Optional) The amplitude.

Property Documentation

◆ AnchorsHelper

ControllerAnchorsHelper NRKernal.NRInput.AnchorsHelper
staticget

It's a helper to get controller anchors which are frequently used.

The anchors helper.

◆ CameraCenter

Transform NRKernal.NRInput.CameraCenter
staticget

Get the transform of the camera which controllers are following.

The camera center.

◆ ClickInterval

float NRKernal.NRInput.ClickInterval
staticgetset

Get and set button click interval.

The click interval.

◆ ControllerVisualActive

bool NRKernal.NRInput.ControllerVisualActive
staticgetset

Determine whether to show controller visuals, could be get and set at runtime.

True if controller visual active, false if not.

◆ CurrentInputSourceType

InputSourceEnum NRKernal.NRInput.CurrentInputSourceType
staticget

Get the current input source type.

The input source type.

◆ DomainHand

ControllerHandEnum NRKernal.NRInput.DomainHand
staticget

Get the current enumeration of handedness.

The domain hand.

◆ DragThreshold

float NRKernal.NRInput.DragThreshold
staticgetset

Get and set pointer drag threshold.

The drag threshold.

◆ EmulateVirtualDisplayInEditor

bool? NRKernal.NRInput.EmulateVirtualDisplayInEditor
staticget

Determine whether emulate phone virtual display in Unity Editor.

True if emulate virtual display in editor, false if not.

◆ HapticVibrationEnabled

bool NRKernal.NRInput.HapticVibrationEnabled
staticgetset

Determine whether enable haptic vibration.

True if haptic vibration enabled, false if not.

◆ LaserVisualActive

bool NRKernal.NRInput.LaserVisualActive
staticgetset

Determine whether to show laser visuals, could be get and set at runtime.

True if laser visual active, false if not.

◆ RaycastersActive

bool NRKernal.NRInput.RaycastersActive
staticgetset

Determine whether to active raycaster gameobjects, could be get and set at runtime.

True if active raycaster gameobjects, false if not.

◆ RaycastMode

RaycastModeEnum NRKernal.NRInput.RaycastMode
staticgetset

Determine which raycast mode to use.

The raycast mode.

◆ ReticleVisualActive

bool NRKernal.NRInput.ReticleVisualActive
staticgetset

Determine whether to show reticle visuals, could be get and set at runtime.

True if reticle visual active, false if not.