public static Quaternion GetOrientation(SvrControllerState svrControllerState) { if (instance == null) { return(Quaternion.identity); } instance.Update(); switch (svrControllerState) { case SvrControllerState.GvrController: return(instance.controllerStateRight.orientation); case SvrControllerState.NoloLeftContoller: return(instance.controllerStateLeft.orientation); case SvrControllerState.NoloRightContoller: return(instance.controllerStateRight.orientation); case SvrControllerState.NoloHead: return(instance.controllerStateHead.orientation); default: return(Quaternion.identity); } }
private void GvrControllerInput_OnConterollerChanged(SvrControllerState state, SvrControllerState oldState) { SvrControllerState target = SvrControllerState.NoloLeftContoller | SvrControllerState.NoloRightContoller; if ((state & target) != 0) { gameObject.SetActive(false); if (GvrPointerInputModule.Pointer == mBasePointer) { GvrPointerInputModule.Pointer = null; } } else { //OnControllerStateChanged(GvrControllerInput.State, GvrControllerInput.State); if (isDeactivatedWhenDisconnected && enabled) { gameObject.SetActive(state == SvrControllerState.GvrController); if (gameObject.activeSelf) { GvrPointerInputModule.Pointer = GetComponentInChildren <GvrBasePointer>(); } else { if (GvrPointerInputModule.Pointer == mBasePointer) { GvrPointerInputModule.Pointer = null; } } } } }
private void GvrControllerInput_OnConterollerChanged(SvrControllerState state, SvrControllerState oldState) { if ((state & (SvrControllerState.NoloHead)) == 0) { InRange(); } }
public static Vector3 GetPosition(SvrControllerState svrControllerState) { if (instance == null) { return(Vector3.zero); } instance.Update(); switch (svrControllerState) { case SvrControllerState.NoloLeftContoller: return(instance.controllerStateLeft.accel); case SvrControllerState.NoloRightContoller: return(instance.controllerStateRight.accel); case SvrControllerState.NoloHead: if (instance.controllerStateHead.connectionState == GvrConnectionState.Connected) { return(instance.controllerStateHead.accel); } else { return(Vector3.zero); } default: return(Vector3.zero); } }
public static ControllerState GetControllerState(SvrControllerState index) { if (instance == null) { return(new ControllerState(SvrControllerIndex.SVR_CONTROLLER_INDEX_RIGHT)); } instance.Update(); switch (index) { case SvrControllerState.GvrController: return(instance.controllerStateRight); case SvrControllerState.NoloLeftContoller: return(instance.controllerStateLeft); case SvrControllerState.NoloRightContoller: return(instance.controllerStateRight); case SvrControllerState.NoloHead: return(instance.controllerStateHead); default: return(new ControllerState(SvrControllerIndex.SVR_CONTROLLER_INDEX_RIGHT)); } }
private SvrControllerState ReadSvrContollerState() { SvrControllerState svrControllerState = SvrControllerState.None; if (Svr.SvrSetting.GetNoloConnected) { if (controllerStateLeft.connectionState == GvrConnectionState.Connected) { svrControllerState |= SvrControllerState.NoloLeftContoller; Svr.SvrSetting.SetNoloHandedness(Svr.SvrNoloHandedness.Left); } if (controllerStateRight.connectionState == GvrConnectionState.Connected) { svrControllerState |= SvrControllerState.NoloRightContoller; Svr.SvrSetting.SetNoloHandedness(Svr.SvrNoloHandedness.Right); } } else { if (controllerStateRight.connectionState == GvrConnectionState.Connected) { svrControllerState |= SvrControllerState.GvrController; } } return(svrControllerState); }
/// <summary> /// Controllers the state of the get. /// </summary> /// <returns>The get state.</returns> /// <param name="handle">Handle.</param> //--------------------------------------------------------------------------------------------- public override SvrControllerState ControllerGetState(int handle) { SvrControllerState state = new SvrControllerState(); SvrControllerGetState(handle, ref state); //dumpState (state); return(state); }
/// <summary> /// Dumps the state. /// </summary> /// <param name="state">State.</param> //--------------------------------------------------------------------------------------------- private void dumpState(SvrControllerState state) { String s = "{" + state.rotation + "}\n"; s += "[" + state.position + "]\n"; s += "<" + state.timestamp + ">\n"; Debug.Log(s); }
private void GvrControllerInput_OnConterollerChanged(SvrControllerState state, SvrControllerState oldState) { if ((state & deviceType) != 0) { gameObject.SetActive(true); if (mPointer == null) { mPointer = GetComponentInChildren <GvrBasePointer>(); } switch (Svr.SvrSetting.NoloHandedness) { case Svr.SvrNoloHandedness.Left: if (deviceType == SvrControllerState.NoloLeftContoller) { mPointer.gameObject.SetActive(true); GvrPointerInputModule.Pointer = mPointer; } else { mPointer.gameObject.SetActive(false); if (GvrPointerInputModule.Pointer == mPointer) { GvrPointerInputModule.Pointer = null; } } break; case Svr.SvrNoloHandedness.Right: if (deviceType == SvrControllerState.NoloRightContoller) { mPointer.gameObject.SetActive(true); GvrPointerInputModule.Pointer = mPointer; } else { mPointer.gameObject.SetActive(false); if (GvrPointerInputModule.Pointer == mPointer) { GvrPointerInputModule.Pointer = null; } } break; default: break; } } else { gameObject.SetActive(false); } }
private void GvrControllerInput_OnStateChanged(SvrControllerState state, SvrControllerState oldState) { #if !SVR_USE_GAZE if (state == SvrControllerState.GvrController) { m_HandleButton.sprite = m_HandleConnected; m_HandleButton.SetNativeSize(); } else { m_HandleButton.sprite = m_HandleDisConnected; m_HandleButton.SetNativeSize(); } #endif }
private void GvrControllerInput_OnConterollerChanged(SvrControllerState state, SvrControllerState oldState) { SVR.AtwAPI.BeginTrace("Input_Changed"); SVR.AtwAPI.BeginTrace("1"); SvrControllerState target = SvrControllerState.NoloLeftContoller | SvrControllerState.NoloRightContoller | SvrControllerState.GvrController; SVR.AtwAPI.EndTrace(); //Svr.SvrLog.Log("GvrControllerInput_OnConterollerChanged "+ state); if ((state & target) != 0) { gameObject.SetActive(false); SVR.AtwAPI.ShowDualSurface(false); //Svr.SvrLog.Log("ShowDualSurface false"); if (GvrPointerInputModule.Pointer == mBasePointer) { GvrPointerInputModule.Pointer = null; } } else { SVR.AtwAPI.BeginTrace("2"); //OnControllerStateChanged(GvrControllerInput.State, GvrControllerInput.State); if (enabled) { gameObject.SetActive(true); SVR.AtwAPI.ShowDualSurface(true); //Svr.SvrLog.Log("ShowDualSurface true"); if (gameObject.activeSelf) { GvrPointerInputModule.Pointer = mBasePointer; } else { if (GvrPointerInputModule.Pointer == mBasePointer) { GvrPointerInputModule.Pointer = null; } } } SVR.AtwAPI.EndTrace(); } SVR.AtwAPI.EndTrace(); }
private static SvrControllerState GetTargetNolo() { SvrControllerState controllerState = SvrControllerState.None; switch (Svr.SvrSetting.NoloHandedness) { case Svr.SvrNoloHandedness.Left: controllerState |= SvrControllerState.NoloLeftContoller; break; case Svr.SvrNoloHandedness.Right: controllerState |= SvrControllerState.NoloRightContoller; break; default: break; } return(controllerState); }
private static extern void SvrControllerGetState(int handle, ref SvrControllerState state);
//private ControllerState m_PreviousState = new ControllerState(); void Update() { if (lastUpdatedFrameCount != Time.frameCount) { SVR.AtwAPI.BeginTrace("input-update"); // The controller state must be updated prior to any function using the // controller API to ensure the state is consistent throughout a frame. lastUpdatedFrameCount = Time.frameCount; Svr.Controller.SvrController.CallBegin(); //GvrConnectionState oldState = State; SvrControllerState oldSvrState = SvrState; //UnityEngine.Profiling.Profiler.BeginSample("1"); if (controllerProvider != null) { controllerProvider.ReadState(controllerStateRight); controllerProvider.ReadState(controllerStateLeft); controllerProvider.ReadState(controllerStateHead); //Svr.SvrLog.Log("controllerState:" + controllerStateRight.connectionState + "," + controllerStateLeft.connectionState + "," + controllerStateHead.connectionState); } //UnityEngine.Profiling.Profiler.EndSample(); //UnityEngine.Profiling.Profiler.BeginSample("2"); UpdateTouchPosCentered(); mSvrState = ReadSvrContollerState(); #if UNITY_EDITOR // Make sure the EditorEmulator is updated immediately. if (GvrEditorEmulator.Instance != null) { GvrEditorEmulator.Instance.UpdateEditorEmulation(); } #endif // UNITY_EDITOR //if (OnStateChanged != null && State != oldState) //{ // OnStateChanged(State, oldState); //} //UnityEngine.Profiling.Profiler.EndSample(); //UnityEngine.Profiling.Profiler.BeginSample("3"); if (OnConterollerChanged != null && SvrState != oldSvrState) { OnConterollerChanged(SvrState, oldSvrState); //if ((SvrState & (SvrControllerState.NoloLeftContoller | SvrControllerState.NoloRightContoller)) != 0) //{ // //Have Nolo // Svr.SvrSetting.SetNoloConnected(true); //} //else //{ // //Nolo DisConnected // Svr.SvrSetting.SetNoloConnected(false); //} } if (OnControllerInputUpdated != null) { OnControllerInputUpdated(); } if (OnPostControllerInputUpdated != null) { OnPostControllerInputUpdated(); } //UnityEngine.Profiling.Profiler.EndSample(); SVR.AtwAPI.EndTrace(); } }
private void GvrControllerInput_OnStateChanged(SvrControllerState state, SvrControllerState oldState) { CurGvrConnectionState = state; }