void ReactToInputKeyboard() { if (GetInteractableView() == null) { return; } string currentInputString = Input.inputString; float vertical = 0.0f; float horizontal = 0.0f; foreach (var device in InputManager.Devices) { horizontal += device.Name == "Keyboard/Mouse" ? device.LeftStickX : Mathf.Pow(Mathf.Abs(device.LeftStickX), 2f) * Mathf.Sign(device.LeftStickX); vertical += device.Name == "Keyboard/Mouse" ? device.LeftStickY : Mathf.Pow(Mathf.Abs(device.LeftStickY), 2f) * Mathf.Sign(device.LeftStickY); } horizontal += InputManager.ActiveDevice.DPadLeft.IsPressed ? -1.0f : 0.0f; horizontal += InputManager.ActiveDevice.DPadRight.IsPressed ? 1.0f : 0.0f; vertical += InputManager.ActiveDevice.DPadUp.IsPressed ? 1.0f : 0.0f; vertical += InputManager.ActiveDevice.DPadDown.IsPressed ? -1.0f : 0.0f; SHGUIinput key = SHGUIinput.none; //float vertical = Input.GetAxisRaw ("Vertical"); //float horizontal = Input.GetAxisRaw ("Horizontal"); bool enter = Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter) || (InputManager.ActiveDevice.Action1.WasReleased && Time.unscaledDeltaTime < 0.1f); bool esc = Input.GetKeyDown(KeyCode.Backspace) || Input.GetKeyDown(KeyCode.Escape) || (InputManager.ActiveDevice.Action2.WasPressed && InputManager.ActiveDevice.Name != "Keyboard/Mouse") || InputManager.ActiveDevice.GetControl(InputControlType.Start).WasPressed; if (vertical < -0.5f) { key = SHGUIinput.down; } if (vertical > 0.5f) { key = SHGUIinput.up; } if (horizontal > 0.5f) { key = SHGUIinput.right; } if (horizontal < -0.5f) { key = SHGUIinput.left; } if (enter) { key = SHGUIinput.enter; } if (esc) { key = SHGUIinput.esc; } if (key != SHGUIinput.none) { cursorActive = false; } if (!enter && !esc && currentInputString != "" && currentInputString != lastInputString) { key = SHGUIinput.any; } //check for random gamepad mashing if (key == SHGUIinput.none && InputManager.ActiveDevice.Name != "Keyboard/Mouse") { if (InputManager.ActiveDevice.LeftStick.HasChanged || InputManager.ActiveDevice.RightStick.HasChanged || InputManager.ActiveDevice.LeftTrigger.HasChanged || InputManager.ActiveDevice.RightTrigger.HasChanged || InputManager.ActiveDevice.LeftBumper.WasPressed || InputManager.ActiveDevice.RightBumper.WasPressed || InputManager.ActiveDevice.AnyButton.WasPressed) { key = SHGUIinput.any; } } SHGUIinput k = key; if (lastKey == key) { keyTimer += Time.unscaledDeltaTime; if (keyTimer > .3f) { keyTimer = .275f; } else { key = SHGUIinput.none; } } else { keyTimer = 0; } lastKey = k; SHGUIview interactable = GetInteractableView(); interactable.ReactToInputKeyboard(key); if (!string.IsNullOrEmpty(Input.inputString)) { lastInputString = Input.inputString; } //views [views.Count - 1].ReactToInput (key); }