public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } if (recompiling) { return(false); } if (!ReInput.isReady) { return(false); } bool shouldActivate = false; // Combine input for all players for (int i = 0; i < playerIds.Length; i++) { Rewired.Player player = ReInput.players.GetPlayer(playerIds[i]); if (player == null) { continue; } shouldActivate |= player.GetButtonDown(m_SubmitButton); shouldActivate |= player.GetButtonDown(m_CancelButton); if (moveOneElementPerAxisPress) // axis press moves only to the next UI element with each press { shouldActivate |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis); shouldActivate |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis); } else // default behavior - axis press scrolls quickly through UI elements { shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_VerticalAxis), 0.0f); } } if (isMouseSupported) { shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= ReInput.controllers.Mouse.GetButtonDown(0); } return(shouldActivate); }
public void UpdateMouse() { if (StopInput) { return; } bool yawInverse = Settings.GameSettingsManager.Instance.ControlSettings.Save.ControlInvertedMouseX != 0; Yaw += (yawInverse ? -1 : 1) * (Inputs.GetAxisRaw("MouseX") * (float)Settings.GameSettingsManager.Instance.ControlSettings.Save.ControlMouseXSensitivity / 100); Yaw %= 360.0f; bool pitchInverse = Settings.GameSettingsManager.Instance.ControlSettings.Save.ControlInvertedMouseY != 0; Pitch += (pitchInverse ? -1 : 1) * (-Inputs.GetAxisRaw("MouseY") * (float)Settings.GameSettingsManager.Instance.ControlSettings.Save.ControlMouseYSensitivity / 100); Pitch = Mathf.Clamp(Pitch, -90.0f, 90.0f); }
public override float GetAxis(int axis) { if (!isEnabled) { return(0); } return(input.GetAxisRaw(axis)); }
private Vector2 GetRawMoveVector() { if (recompiling) { return(Vector2.zero); } Vector2 move = Vector2.zero; bool horizButton = false; bool vertButton = false; // Combine inputs of all Players for (int i = 0; i < playerIds.Length; i++) { Rewired.Player player = ReInput.players.GetPlayer(playerIds[i]); if (player == null) { continue; } if (usePlayingPlayersOnly && !player.isPlaying) { continue; } if (moveOneElementPerAxisPress) // axis press moves only to the next UI element with each press { float x = 0.0f; if (player.GetButtonDown(m_HorizontalAxis)) { x = 1.0f; } else if (player.GetNegativeButtonDown(m_HorizontalAxis)) { x = -1.0f; } float y = 0.0f; if (player.GetButtonDown(m_VerticalAxis)) { y = 1.0f; } else if (player.GetNegativeButtonDown(m_VerticalAxis)) { y = -1.0f; } move.x += x; move.y += y; } else // default behavior - axis press scrolls quickly through UI elements { move.x += player.GetAxisRaw(m_HorizontalAxis); move.y += player.GetAxisRaw(m_VerticalAxis); } horizButton |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis); vertButton |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis); } if (horizButton) { if (move.x < 0) { move.x = -1f; } if (move.x > 0) { move.x = 1f; } } if (vertButton) { if (move.y < 0) { move.y = -1f; } if (move.y > 0) { move.y = 1f; } } return(move); }
public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } if (recompiling) { return(false); } if (!ReInput.isReady) { return(false); } bool shouldActivate = m_ForceModuleActive; // Combine input for all players for (int i = 0; i < playerIds.Length; i++) { Rewired.Player player = ReInput.players.GetPlayer(playerIds[i]); if (player == null) { continue; } if (usePlayingPlayersOnly && !player.isPlaying) { continue; } shouldActivate |= player.GetButtonDown(m_SubmitButton); shouldActivate |= player.GetButtonDown(m_CancelButton); if (moveOneElementPerAxisPress) // axis press moves only to the next UI element with each press { shouldActivate |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis); shouldActivate |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis); } else // default behavior - axis press scrolls quickly through UI elements { shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_VerticalAxis), 0.0f); } } // Mouse input if (isMouseSupported) { shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= UnityEngine.Input.GetMouseButtonDown(0); } // Touch input if (isTouchSupported) { for (int i = 0; i < Input.touchCount; ++i) { Touch input = Input.GetTouch(i); shouldActivate |= input.phase == TouchPhase.Began || input.phase == TouchPhase.Moved || input.phase == TouchPhase.Stationary; } } return(shouldActivate); }
public float GetAxisRaw(string Axis) { return(player.GetAxisRaw(Axis)); }
void Update() { UpdateHandlingPlayerAllInputs(); if (GetButtonDown("Pause")) { Escape(); } if (DialogWindow.m_openedWindows.Count == 0) { if (GetButtonDown("UIInteract2")) { GoBack(); } string openedMenuButton = GetButtonRelatedToSingleOpenMenu(); if (openedMenuButton == "" && GetButtonDown("Inventory") && !m_paused && m_onInventoryEvent) { m_onInventoryEvent.Raise(); } if (openedMenuButton == "" && GetButtonDown("Character") && !m_paused && m_onCharacterEvent) { m_onCharacterEvent.Raise(); } if ((openedMenuButton == "" || openedMenuButton == "Skillbook") && GetButtonDown("Skillbook") && !m_paused && m_onSkillbookEvent) { m_onSkillbookEvent.Raise(); } if ((openedMenuButton == "" || openedMenuButton == "Map") && GetButtonDown("Map") && !m_paused && m_onMapEvent) { m_onMapEvent.Raise(); } if ((openedMenuButton == "" || openedMenuButton == "QuestLog") && GetButtonDown("QuestLog") && !m_paused && m_onQuestLogEvent) { m_onQuestLogEvent.Raise(); } } GameObject selected = EventSystem.current.currentSelectedGameObject; // if the player moves the UI with a selectable way of navigation (d-pad), set the selectable properly (it's unset when moving cursor) if (m_handlingPlayer != null && !selected && (m_handlingPlayer.GetAxisRaw("UIMoveX") != 0 || m_handlingPlayer.GetAxisRaw("UIMoveY") != 0)) { if (m_lastSelectedGameObject != null && m_lastSelectedGameObject.activeSelf) { EventSystem.current.SetSelectedGameObject(m_lastSelectedGameObject); } } else if (m_handlingPlayer != null && selected && m_lastSelectedGameObject != selected) // save the last selected game object { m_lastSelectedGameObject = selected; } }