/// <summary> /// Gets the touch-pad. /// Center point = 0. /// left top = -0.5, /// </summary> /// <returns><c>true</c>, if touch pad was gotten, <c>false</c> otherwise.</returns> /// <param name="touchPad">Touch pad.</param> public static bool GetTouchPad(out Vector2 touchPad, int controllerIndex = 0) { //NOT supported: if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer) { touchPad = Vector2.zero; return(false); } XDevicePlugin.ActParam_TouchpadState tpad_st = new XDevicePlugin.ActParam_TouchpadState(); int tpad_act_rs = XDevicePlugin.DoAction(DevicerHandle.GetController(controllerIndex), XDevicePlugin.XActions.kXAct_Get_TouchPadState, ref tpad_st); if (tpad_act_rs >= 0 && tpad_st.pressed) { touchPad = new Vector2((tpad_st.x - 0.5f) / 0.5f, ((tpad_st.y - 0.5f) * -1) / 0.5f); return(true); } else { touchPad = Vector2.zero; return(false); } }
/// <summary> /// Stops pairing. /// </summary> public static void StopPairing() { int ret = XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_StopPairingController); Debug.LogFormat("Stop pairing result : {0}", ret); }
/// <summary> /// Disconnect the controller at the index. /// </summary> /// <param name="Index">Index.</param> public static void Disconnect(int Index) { XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_DisconnectControllerByIndex, Index); }
public static void DisconnectAll() { int result = XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_DisconnectAllControllers); Debug.LogFormat("Disconnect result: {0}", result); }
/// <summary> /// Connects all paired device. /// </summary> public static void ConnectAll() { int result = XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_ConnectAllPairedControllers); Debug.LogFormat("Connect-All result: {0}", result); }
/// <summary> /// Starts pairing. /// </summary> public static void StartPairing(XDevicePlugin.XControllerTypes controllerType) { XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_StartPairingController, (int)controllerType); }
/// <summary> /// Gets the controller01 rotation. /// </summary> /// <returns>The controller01 rotation.</returns> public static Quaternion GetController01Rotation() { XDevicePlugin.ActParam_ControllerState state = new XDevicePlugin.ActParam_ControllerState(); XDevicePlugin.DoAction(DevicerHandle.Controller01, XDevicePlugin.XActions.kXAct_GetControllerState, ref state); return(new Quaternion(state.rotation[0], state.rotation[1], state.rotation[2], state.rotation[3])); }
/// <summary> /// Unpair the specified controllerIndex. /// </summary> /// <param name="controllerIndex">Controller index.</param> public static void Unpair(int controllerIndex) { var ret = XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_UnpairController, controllerIndex); Debug.LogFormat("Unpair controller: {0}, result: {1}", controllerIndex, ret); }
/// <summary> /// Unpairs all. /// </summary> public static void UnpairAll() { int ret3 = XDevicePlugin.DoAction(DevicerHandle.HmdHandle, XDevicePlugin.XActions.kXAct_UnpairAllControllers); Debug.LogFormat("Unpair all controllers: {0}", ret3); }
/// <summary> /// Vibrate the controller of index with specified strength, duration. /// </summary> /// <param name="strength">Strength.</param> /// <param name="duration">Duration.</param> /// <param name="ControllerIndex">Controller index.</param> public void Vibrate(int strength, float duration) { XDevicePlugin.ActParam_VibrateArgs arg = new XDevicePlugin.ActParam_VibrateArgs(strength, (int)(duration * 1000)); XDevicePlugin.DoAction(this.ctrlHandle, XDevicePlugin.XActions.kXAct_Vibrate, arg); }