private void UpdateInput() { string inputText = ""; lock (m_textInputMutex) { inputText = string.Copy(m_textInputBuffer); } m_imguiIO.AddInputCharactersUTF8(inputText); for (int i = 0; i < m_registredButtons.Count; ++i) { EInputButton button = m_registredButtons[i]; m_imguiIO.KeysDown[(int)button] = Input.IsButtonPressed(button); } m_imguiIO.KeyShift = Input.IsButtonPressed(EInputButton.LeftShift) || Input.IsButtonPressed(EInputButton.RightShift); m_imguiIO.KeyCtrl = Input.IsButtonPressed(EInputButton.LeftControl) || Input.IsButtonPressed(EInputButton.RightControl); m_imguiIO.KeyAlt = Input.IsButtonPressed(EInputButton.LeftAlt) || Input.IsButtonPressed(EInputButton.RightAlt); m_imguiIO.KeySuper = Input.IsButtonPressed(EInputButton.LeftWindowsKey) || Input.IsButtonPressed(EInputButton.RightWindowsKey); m_mouseAbsX = System.Windows.Forms.Cursor.Position.X - m_screenLeft; m_mouseAbsY = System.Windows.Forms.Cursor.Position.Y - m_screenTop; m_imguiIO.MousePos = new System.Numerics.Vector2(m_mouseAbsX, m_mouseAbsY); m_imguiIO.MouseWheel = Input.GetNativeAxisValue(EInputAxis.MouseWheel) / 120.0f; m_imguiIO.MouseDown[0] = Input.IsButtonPressed(EInputButton.MouseLeftButton); m_imguiIO.MouseDown[1] = Input.IsButtonPressed(EInputButton.MouseRightButton); m_imguiIO.MouseDown[2] = Input.IsButtonPressed(EInputButton.MouseMiddleButton); }
private void On_TouchJoystick_Moved(EInputAxis inputAxis, EInputButton inputButton, Vector2 newInputValues) { if ((inputAxis != EInputAxis.NONE) && (IS_KEY_CONTAINED(oldInputValuesMap, inputAxis))) //&& (Mathf.Abs(newInputValues.x) + Mathf.Abs(newInputValues.y) > BConsts.JOYSTICK_DEAD_ZONE)) { Vector2 oldInputValues = oldInputValuesMap[inputAxis]; float inputDistance = Vector2.Distance(oldInputValues, newInputValues); // Is new joystick input different enough from last registred one? //if (inputDistance > BConsts.THRESHOLD_JOYSTICK_DISTANCE_MOVEMENT) //{ //newInputValues.Normalize(); float newX = newInputValues.x; float newY = newInputValues.y; if (MotherOfManagers.Instance.TransformInpuAxisToCameraDirection == true) { BUtils.TransformAxisToCamera(ref newX, ref newY, Camera.main.transform.forward); } oldInputValuesMap[inputAxis] = new Vector2(newX, newY); InvokeAxisUpdated(EControllerID.TOUCH, EInputAxis.MOVEMENT, newX, newY); //} } }
private void On_TouchJoystick_Pressed(EInputAxis inputAxis, EInputButton inputButton) { if (inputButton != EInputButton.NONE) { InvokeButtonPressed(EControllerID.TOUCH, inputButton); } }
protected void InvokeButtonReleased(EControllerID controllerID, EInputButton inputButton) { if (ButtonReleased != null) { ButtonReleased.Invoke(controllerID, inputButton); } }
public void SendButtonReleased(EInputButton inputButton) { //if (client.isConnected) //{ // StringMessage message = new StringMessage(); // message.value = controllerGuid + "|" + ((int)inputButton).ToString(); // client.Send(NET_CONTROLLER_MESSAGE_BUTTON_RELEASED, message); //} }
public static bool IsButtonPressed(EInputButton button) { if (Input.IsInputClassActive(EInputClass.Default)) { return(Input.IsButtonPressed(button)); } return(false); }
private void On_InputSource_ButtonReleased(EControllerID controllerID, EInputButton inputButton) { if (IS_VALUE_CONTAINED(connectedControllers, controllerID)) { EPlayerID playerID = PlayerManager.Instance.GetAssignedPlayerID(controllerID); if (inputButton != EInputButton.NONE) { BEventsCollection.INPUT_ButtonReleased.Invoke(new BEHandle <EControllerID, EInputButton>(controllerID, inputButton), BEventReplicationType.LOCAL, MotherOfManagers.Instance.DebugButtonEvents); } } }
public void PlayerNCListener_OnButtonPressed(EControllerID controllerID, EInputButton inputButton) { LogConsole("ButtonPressed"); if (IS_KEY_CONTAINED(connectedNetworkControllers, controllerID)) { if (IS_NOT_NONE(inputButton)) { InvokeButtonPressed(controllerID, inputButton); } } }
private void ProcessButtonEvent(InputActionPhase actionPhase, EInputButton inputButton) { switch (actionPhase) { case InputActionPhase.Started: InvokeEventIfBound(ButtonPressed, myControllerID, inputButton); break; case InputActionPhase.Performed: InvokeEventIfBound(ButtonReleased, myControllerID, inputButton); break; } }
//private void UpdateAxisInput() //{ // MoveAxis = inputAction_Move.ReadValue<Vector2>(); // RotateAxis = inputAction_Rotate.ReadValue<Vector2>(); // Trigger_L_Axis = inputAction_Rotate.ReadValue<Vector2>(); //} private void UpdateDirectionalInput() { if (canPerformDirectionalButton == true) { // Joystick moved beyond threshold if (Vector2.Distance(MoveAxis, Vector2.zero) > 0.5f) { // Horizontal move if (Mathf.Abs(MoveAxis.x) > Mathf.Abs(MoveAxis.y)) { // Right move if (MoveAxis.x > 0.0f) { lastPerformedDirectionalButton = EInputButton.RIGHT; } // Left move else { lastPerformedDirectionalButton = EInputButton.LEFT; } } // Vertical move else { // Up move if (MoveAxis.y > 0.0f) { lastPerformedDirectionalButton = EInputButton.UP; } // Down move else { lastPerformedDirectionalButton = EInputButton.DOWN; } } InvokeEventIfBound(ButtonPressed, myControllerID, lastPerformedDirectionalButton); canPerformDirectionalButton = false; } } else { // Joystick moved below threshold if (Vector2.Distance(MoveAxis, Vector2.zero) < 0.5f) { InvokeEventIfBound(ButtonReleased, myControllerID, lastPerformedDirectionalButton); canPerformDirectionalButton = true; lastPerformedDirectionalButton = EInputButton.NONE; } } }
private static GamepadButtonFlags GetXInputFromInputButton(EInputButton inputButton) { switch (inputButton) { case EInputButton.DPadUp: return(GamepadButtonFlags.DPadUp); case EInputButton.DPadDown: return(GamepadButtonFlags.DPadDown); case EInputButton.DPadLeft: return(GamepadButtonFlags.DPadLeft); case EInputButton.DPadRight: return(GamepadButtonFlags.DPadRight); case EInputButton.Start: return(GamepadButtonFlags.Start); case EInputButton.Options: return(GamepadButtonFlags.Back); case EInputButton.LeftThumb: return(GamepadButtonFlags.LeftThumb); case EInputButton.RightThumb: return(GamepadButtonFlags.RightThumb); case EInputButton.LeftShoulder: return(GamepadButtonFlags.LeftShoulder); case EInputButton.RightShoulder: return(GamepadButtonFlags.RightShoulder); case EInputButton.ControllerActionUp: return(GamepadButtonFlags.Y); case EInputButton.ControllerActionDown: return(GamepadButtonFlags.A); case EInputButton.ControllerActionLeft: return(GamepadButtonFlags.X); case EInputButton.ControllerActionRight: return(GamepadButtonFlags.B); } return(GamepadButtonFlags.None); }
private void On_INPUT_ButtonReleased(BEHandle <EControllerID, EInputButton> eventHandle) { EInputButton inputButton = eventHandle.Arg2; if (CurrentBButtonHighlighted) { switch (inputButton) { case EInputButton.CONFIRM: if (canPressButton == true) { CurrentBButtonHighlighted.OnReleased(true); } break; } } }
private void Cmd_OnButtonReleased(EControllerID controllerID, EInputButton inputButton) { Debug.Log("Cmd_OnButtonReleased : " + inputButton + " - " + controllerID); // temporary solution NetControllerInputSource netControllerInputSource = InputManager.Instance.GetInputSource <NetControllerInputSource>(); if (netControllerInputSource) { Debug.Log("Calling ButtonReleased: " + inputButton + " - " + controllerID); netControllerInputSource.PlayerNCListener_OnButtonReleased(controllerID, inputButton); } // TODO: Fix //if (ButtonReleased != null) //{ // ButtonReleased.Invoke(controllerID, inputButton); //} }
private void On_TouchJoystick_Released(EInputAxis inputAxis, EInputButton inputButton) { // Reinitialize Movement and Rotation if (inputAxis != EInputAxis.NONE) { InvokeAxisUpdated(EControllerID.TOUCH, inputAxis, 0.0f, 0.0f); // Reinitialize old input values map if (IS_KEY_CONTAINED(oldInputValuesMap, inputAxis)) { oldInputValuesMap[inputAxis] = Vector2.zero; } } // Button Released event if (inputButton != EInputButton.NONE) { InvokeButtonReleased(EControllerID.TOUCH, inputButton); } }
private void On_INPUT_ButtonPressed(BEHandle <EControllerID, EInputButton> eventHandle) { EInputButton inputButton = eventHandle.Arg2; if (CurrentBButtonHighlighted) { BButton nextButton = null; switch (inputButton) { case EInputButton.CONFIRM: CurrentBButtonHighlighted.OnPressed(); canPressButton = true; break; case EInputButton.LEFT: nextButton = CurrentBButtonHighlighted.GetNextButton(EButtonDirection.LEFT); break; case EInputButton.RIGHT: nextButton = CurrentBButtonHighlighted.GetNextButton(EButtonDirection.RIGHT); break; case EInputButton.UP: nextButton = CurrentBButtonHighlighted.GetNextButton(EButtonDirection.UP); break; case EInputButton.DOWN: nextButton = CurrentBButtonHighlighted.GetNextButton(EButtonDirection.DOWN); break; } // Update highlighted button if (nextButton != null) { CurrentBButtonHighlighted.OnUnhighlighted(); CurrentBButtonHighlighted = nextButton; nextButton.OnHighlighted(); canPressButton = false; } } }
public static bool IsButtonPressed(EInputButton button) { lock (m_inputStateMutex) { int buttonIndex = (int)button; if (buttonIndex < (int)EInputButton.MouseFirst) { //Keyboard Key directInputKey = (Key)buttonIndex; return(m_currentKeyboardState.IsPressed(directInputKey)); } else if (buttonIndex < (int)EInputButton.ControllerFirst) { //Mouse int mouseButtonIndex = buttonIndex - (int)EInputButton.MouseFirst; return(m_currentMouseState.Buttons[mouseButtonIndex]); } else { GamepadButtonFlags gamepadButton = GetXInputFromInputButton(button); return(m_currentGamepadState.Gamepad.Buttons.HasFlag(gamepadButton)); } } }
private void On_AIPlayerController_ButtonReleased(EControllerID controllerID, EInputButton inputButton) { InvokeButtonReleased(controllerID, inputButton); }
public static bool IsButtonEqual(EInputButton a, EInputButton b) { return(a == b); }
private void On_TouchJoystickAdapter_ButtonPressed(EInputButton inputButton) { Debug.Log("On_TouchJoystickAdapter_ButtonPressed : " + inputButton); Cmd_OnButtonPressed(controllerID, inputButton); }
private void On_PlayerNCListener_ButtonPressed(EControllerID arg1, EInputButton arg2) { Debug.Log("On_PlayerNCListener_ButtonPressed"); }
private void On_PlayerInputListener_ButtonPressed(EControllerID controllerID, EInputButton inputButton) { InvokeButtonPressed(controllerID, inputButton); }