/// <summary> Refresh information texts. </summary> private void RefreshInfoTexts() { mainInfoText.text = "controller count: " + NRInput.GetAvailableControllersCount().ToString() + "\n" + "type: " + NRInput.GetControllerType().ToString() + "\n" + "current debug hand: " + m_CurrentDebugHand.ToString() + "\n" + "position available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_POSITION).ToString() + "\n" + "rotation available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_ROTATION).ToString() + "\n" + "gyro available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_GYRO).ToString() + "\n" + "accel available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_ACCEL).ToString() + "\n" + "mag available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_MAG).ToString() + "\n" + "battery available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_BATTERY).ToString() + "\n" + "vibration available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_HAPTIC_VIBRATE).ToString() + "\n" + "rotation: " + NRInput.GetRotation(m_CurrentDebugHand).ToString("F3") + "\n" + "position: " + NRInput.GetPosition(m_CurrentDebugHand).ToString("F3") + "\n" + "touch: " + NRInput.GetTouch(m_CurrentDebugHand).ToString("F3") + "\n" + "trigger button: " + NRInput.GetButton(m_CurrentDebugHand, ControllerButton.TRIGGER).ToString() + "\n" + "home button: " + NRInput.GetButton(m_CurrentDebugHand, ControllerButton.HOME).ToString() + "\n" + "app button: " + NRInput.GetButton(m_CurrentDebugHand, ControllerButton.APP).ToString() + "\n" + "grip button: " + NRInput.GetButton(m_CurrentDebugHand, ControllerButton.GRIP).ToString() + "\n" + "touchpad button: " + NRInput.GetButton(m_CurrentDebugHand, ControllerButton.TOUCHPAD_BUTTON).ToString() + "\n" + "gyro: " + NRInput.GetGyro(m_CurrentDebugHand).ToString("F3") + "\n" + "accel: " + NRInput.GetAccel(m_CurrentDebugHand).ToString("F3") + "\n" + "mag: " + NRInput.GetMag(m_CurrentDebugHand).ToString("F3") + "\n" + "battery: " + NRInput.GetControllerBattery(m_CurrentDebugHand); extraInfoText.text = m_ExtraInfoStr; //Debug.Log("istouching:" + NRInput.IsTouching() + " value:" + NRInput.GetTouch(m_CurrentDebugHand).ToString("F3")); PrintInputState(); }
/// <summary> Updates this object. </summary> private void Update() { if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { m_PreviousPos = NRInput.GetTouch(); } else if (NRInput.GetButton(ControllerButton.TRIGGER)) { UpdateScroll(); } else if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { m_PreviousPos = Vector2.zero; } }
private void CheckButtonLongPress() { if (NRInput.GetButton(ControllerButton.HOME)) { m_ButtonPressTimer += Time.deltaTime; if (m_ButtonPressTimer > BUTTON_LONG_PRESS_DURATION) { m_ButtonPressTimer = float.MinValue; NRHomeMenu.Show(); } } else { m_ButtonPressTimer = 0f; } }
/// <summary> Check button long press. </summary> private void CheckButtonLongPress() { if (NRInput.GetButton(ControllerButton.HOME)) { m_ButtonPressTimer += Time.deltaTime; if (m_ButtonPressTimer > BUTTON_LONG_PRESS_DURATION) { m_ButtonPressTimer = float.MinValue; // Reset layser when long press Home btn. NRInput.RecenterController(); } } else { m_ButtonPressTimer = 0f; } }
private void JudgeDrop() { if (!IsMoveable) { return; } if (!IsBeingSelected) { return; } if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { m_TriggerDownTime = Time.time; m_TouchDownPos = NRInput.GetTouch(); } if (NRInput.GetButton(ControllerButton.TRIGGER) && !m_TouchMoved) { m_TouchMoved = Vector2.Distance(NRInput.GetTouch(), m_TouchDownPos) > JUDGE_TOUCH_MOVED_DISTANCE; } if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { if ((Time.time - m_TriggerDownTime) < SelectingRaycaster.clickInterval) { forceDeselectOnce = true; } if (NRInput.GetControllerType() == ControllerType.CONTROLLER_TYPE_PHONE && m_TouchMoved) { forceDeselectOnce = false; } m_TouchMoved = false; } else if (NRInput.GetButtonUp(ControllerButton.HOME)) { forceDeselectOnce = true; } if (forceDeselectOnce) { forceDeselectOnce = false; Deselected(); } }
private void CheckQuit() { if (Input.GetKeyDown(KeyCode.Escape)) { QuitApplication(); return; } #if !UNITY_EDITOR if (!hasNRInput) { if (Input.GetMouseButtonDown(1)) { QuitApplication(); } return; } #endif if (quitLongPressTime == 0f && NRInput.GetButtonDown(ControllerButton.HOME)) { QuitApplication(); return; } if (NRInput.GetButton(ControllerButton.HOME)) { quitTimer += Time.deltaTime; if (quitTimer > quitLongPressTime) { quitTimer = 0f; QuitApplication(); } } else { quitTimer = 0f; } }
private void RefreshInfoTexts() { mainInfoText.text = "controller count: " + NRInput.GetAvailableControllersCount().ToString() + "\n" + "type: " + NRInput.GetControllerType().ToString() + "\n" + "domain hand: " + NRInput.DomainHand.ToString() + "\n" + "position available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_POSITION).ToString() + "\n" + "rotation available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_ROTATION).ToString() + "\n" + "gyro available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_GYRO).ToString() + "\n" + "accel available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_ACCEL).ToString() + "\n" + "mag available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_MAG).ToString() + "\n" + "battery available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_BATTERY).ToString() + "\n" + "vibration available: " + NRInput.GetControllerAvailableFeature(ControllerAvailableFeature.CONTROLLER_AVAILABLE_FEATURE_HAPTIC_VIBRATE).ToString() + "\n" + "rotation: " + NRInput.GetRotation().ToString("F3") + "\n" + "position: " + NRInput.GetPosition().ToString("F3") + "\n" + "touch: " + NRInput.GetTouch().ToString("F3") + "\n" + "trigger, home, app: " + NRInput.GetButton(ControllerButton.TRIGGER).ToString() + NRInput.GetButton(ControllerButton.HOME).ToString() + NRInput.GetButton(ControllerButton.APP).ToString() + "\n" + "gyro: " + NRInput.GetGyro().ToString("F3") + "\n" + "accel: " + NRInput.GetAccel().ToString("F3") + "\n" + "mag: " + NRInput.GetMag().ToString("F3") + "\n" + "battery: " + NRInput.GetControllerBattery(); extraInfoText.text = m_ExtraInfoStr; }
private void PrintInputState() { Debug.LogFormat("istouching:{0} getbutton app:{1} trigger:{2} home:{3} \n" + "getbuttondown app:{4} trigger:{5} home:{6} \n" + "getbuttonup app:{7} trigger:{8} home:{9} \n" + "origin touch:[{10}] gettouch:{11}", NRInput.IsTouching(), NRInput.GetButton(ControllerButton.APP), NRInput.GetButton(ControllerButton.TRIGGER), NRInput.GetButton(ControllerButton.HOME) , NRInput.GetButtonDown(ControllerButton.APP), NRInput.GetButtonDown(ControllerButton.TRIGGER), NRInput.GetButtonDown(ControllerButton.HOME) , NRInput.GetButtonUp(ControllerButton.APP), NRInput.GetButtonUp(ControllerButton.TRIGGER), NRInput.GetButtonUp(ControllerButton.HOME) , NRVirtualDisplayer.SystemButtonState.ToString(), NRInput.GetTouch(m_CurrentDebugHand).ToString("F3")); }
bool IInputController.IsTouch(ControllerType type) => NRInput.GetButton(ControllerButton.TRIGGER);
public void UpdateController() { if (!Enabled) { return; } var controllerAnchor = NRInput.DomainHand == ControllerHandEnum.Left ? ControllerAnchorEnum.LeftModelAnchor : ControllerAnchorEnum.RightModelAnchor; var pointerAnchor = NRInput.RaycastMode == RaycastModeEnum.Gaze ? ControllerAnchorEnum.GazePoseTrackerAnchor : controllerAnchor; var controller = NRInput.AnchorsHelper.GetAnchor(pointerAnchor); // hand pose var lastState = TrackingState; TrackingState = NRInput.CheckControllerAvailable(NRInput.DomainHand) ? TrackingState.Tracked : TrackingState.NotTracked; if (lastState != TrackingState) { CoreServices.InputSystem?.RaiseSourceTrackingStateChanged(InputSource, this, TrackingState); } if (TrackingState == TrackingState.Tracked) { CoreServices.InputSystem?.RaiseSourcePoseChanged(InputSource, this, new MixedRealityPose(controller.position, controller.rotation)); } // hand interaction if (Interactions == null) { Debug.LogError($"No interaction configuration for Nreal Light Controller Source"); Enabled = false; } for (int i = 0; i < Interactions?.Length; i++) { switch (Interactions[i].InputType) { case DeviceInputType.None: break; case DeviceInputType.SpatialPointer: var pointer = new MixedRealityPose(controller.position, controller.rotation); Interactions[i].PoseData = pointer; if (Interactions[i].Changed) { CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction, pointer); } break; case DeviceInputType.Select: case DeviceInputType.TriggerPress: Interactions[i].BoolData = NRInput.GetButton(ControllerButton.TRIGGER); if (Interactions[i].Changed) { if (Interactions[i].BoolData) { CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction); } else { CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[i].MixedRealityInputAction); } } break; } } }
private void Update() { brain1 = GameObject.Find("Brain"); solar = GameObject.Find("Rotate"); var rotate = solar.GetComponent <Button>(); var button = brain1.GetComponent <Button>(); // var button2 = button.onClick.AddListener(() => { if (brn == false) { brn = true; brnenum = brnlist.Brain2; brainText.text = "Brain 2"; } else { brn = false; brnenum = brnlist.Brain1; brainText.text = "Brain 1"; } }); rotate.onClick.AddListener(() => { if (controlZoom == false) { controlZoom = true; buttonText.text = "Zoom"; } else { controlZoom = false; buttonText.text = "Rotate"; } }); switch (brnenum) { case brnlist.Brain1: brain1.SetActive(true); brain2.SetActive(false); break; case brnlist.Brain2: brain1.SetActive(false); brain2.SetActive(true); break; } if (NRInput.GetButtonDown(ControllerButton.TRIGGER)) { m_PreviousPos = NRInput.GetTouch(); } else if (NRInput.GetButton(ControllerButton.TRIGGER)) { UpdateScroll(); } else if (NRInput.GetButtonUp(ControllerButton.TRIGGER)) { m_PreviousPos = Vector2.zero; } }