Beispiel #1
0
 private void On_TouchJoystick_Pressed(EInputAxis inputAxis, EInputButton inputButton)
 {
     if (inputButton != EInputButton.NONE)
     {
         InvokeButtonPressed(EControllerID.TOUCH, inputButton);
     }
 }
Beispiel #2
0
        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);
                //}
            }
        }
Beispiel #3
0
    // fix AxisInput for KeyboardPlayers

    /// <summary>
    /// returns input value for given axis and player
    /// </summary>
    /// <param name="axis">enum for movement Axis</param>
    /// <param name="playerID">ID of player</param>
    /// <returns>value between -1 and 1</returns>
    public float InputAxis(EInputAxis axis, int playerID = -1)
    {
        string playerString = getPlayerString(playerID);

        float inputValue = 0f;

        switch (axis)
        {
        case EInputAxis.movementHorizontal:
            inputValue = Input.GetAxis("move_x" + playerString);
            break;

        case EInputAxis.movementVertical:
            inputValue = Input.GetAxis("move_y" + playerString);
            break;

        case EInputAxis.viewHorizontal:
            inputValue = Input.GetAxis("view_x" + playerString);
            break;

        case EInputAxis.viewVertical:
            inputValue = Input.GetAxis("view_y" + playerString);
            break;

        case EInputAxis.triggerLeft:
            inputValue = Input.GetAxis("left_trigger" + playerString);
            break;

        case EInputAxis.triggerRight:
            inputValue = Input.GetAxis("right_trigger" + playerString);
            break;
        }
        return(inputValue);
    }
Beispiel #4
0
 protected void InvokeAxisUpdated(EControllerID controllerID, EInputAxis inputAxis, float x, float y)
 {
     if (AxisUpdated != null)
     {
         AxisUpdated.Invoke(controllerID, inputAxis, x, y);
     }
 }
Beispiel #5
0
 public static float GetNativeAxisValue(EInputAxis nativeAxis)
 {
     lock (m_axisMutex)
     {
         return(m_nativeAxisValues[(int)nativeAxis]);
     }
 }
Beispiel #6
0
        public static float GetAxisValue(EInputAxis axis)
        {
            if (Input.IsInputClassActive(EInputClass.Default))
            {
                return(Input.GetNativeAxisValue(axis));
            }

            return(0.0f);
        }
Beispiel #7
0
        public void SendJoystickMoved(EInputAxis joystickType, float horizontalDelta, float verticalDelta)
        {
            //debugX = horizontalDelta;
            //debugY = verticalDelta;

            //if (client.isConnected)
            //{
            //    StringMessage message = new StringMessage();
            //    message.value = controllerGuid + "|" + (int)joystickType + "|" + horizontalDelta + "|" + verticalDelta;
            //    client.Send(NET_CONTROLLER_MESSAGE_JOYSTICK_MOVED, message);
            //}
        }
Beispiel #8
0
        private void On_InputSource_JoystickMoved(EControllerID controllerID, EInputAxis inputAxis, float x, float y)
        {
            if (IS_VALUE_CONTAINED(connectedControllers, controllerID))
            {
                EPlayerID playerID = PlayerManager.Instance.GetAssignedPlayerID(controllerID);

                if (inputAxis != EInputAxis.NONE)
                {
                    BEventsCollection.INPUT_AxisUpdated.Invoke(new BEHandle <EControllerID, EInputAxis, float, float>(controllerID, inputAxis, x, y), BEventReplicationType.LOCAL, MotherOfManagers.Instance.DebugJoystickEvents);
                }
            }
        }
Beispiel #9
0
        private static void UpdateAxis()
        {
            lock (m_axisMutex)
            {
                for (int i = 0; i < m_nativeAxisValues.Length; i++)
                {
                    EInputAxis axis = (EInputAxis)i;
                    switch (axis)
                    {
                    case EInputAxis.MouseX:
                        m_nativeAxisValues[i] = m_currentMouseState.X;
                        break;

                    case EInputAxis.MouseY:
                        m_nativeAxisValues[i] = m_currentMouseState.Y;
                        break;

                    case EInputAxis.MouseWheel:
                        m_nativeAxisValues[i] = m_currentMouseState.Z;
                        break;

                    case EInputAxis.ControllerLeftStickX:
                        m_nativeAxisValues[i] = ((float)m_currentGamepadState.Gamepad.LeftThumbX) / short.MaxValue;
                        break;

                    case EInputAxis.ControllerLeftStickY:
                        m_nativeAxisValues[i] = ((float)m_currentGamepadState.Gamepad.LeftThumbY) / short.MaxValue;
                        break;

                    case EInputAxis.ControllerRightStickX:
                        m_nativeAxisValues[i] = ((float)m_currentGamepadState.Gamepad.RightThumbX) / short.MaxValue;
                        break;

                    case EInputAxis.ControllerRightStickY:
                        m_nativeAxisValues[i] = ((float)m_currentGamepadState.Gamepad.RightThumbY) / short.MaxValue;
                        break;

                    case EInputAxis.ControllerRightTrigger:
                        m_nativeAxisValues[i] = ((float)m_currentGamepadState.Gamepad.RightTrigger) / byte.MaxValue;
                        break;

                    case EInputAxis.ControllerLeftTrigger:
                        m_nativeAxisValues[i] = ((float)m_currentGamepadState.Gamepad.LeftTrigger) / byte.MaxValue;
                        break;

                    case EInputAxis.Count:
                        break;
                    }
                }
            }
        }
Beispiel #10
0
        public void PlayerNCListener_OnJoystickMoved(EControllerID controllerID, EInputAxis inputAxis, float x, float y)
        {
            if (IS_KEY_CONTAINED(connectedNetworkControllers, controllerID))
            {
                if (IS_NOT_NONE(inputAxis))
                {
                    InvokeAxisUpdated(controllerID, inputAxis, x, y);
                }

                // Debug
                debugX = x;
                debugY = y;
            }
        }
Beispiel #11
0
        /// <summary> Convert a joystickType enum to a char</summary>
        public static char GetCharFrom(EInputAxis inputAxis)
        {
            char resut = 'X';

            switch (inputAxis)
            {
            case EInputAxis.MOVEMENT:
                resut = 'L';
                break;

            case EInputAxis.ROTATION:
                resut = 'R';
                break;
            }
            return(resut);
        }
Beispiel #12
0
        private void Cmd_OnJoystickMoved(EControllerID controllerID, EInputAxis joystickType, float x, float y)
        {
            Debug.Log("Cmd_OnJoystickMoved : " + joystickType + " - " + controllerID);

            // temporary solution
            NetControllerInputSource netControllerInputSource = InputManager.Instance.GetInputSource <NetControllerInputSource>();

            if (netControllerInputSource)
            {
                netControllerInputSource.PlayerNCListener_OnJoystickMoved(controllerID, joystickType, x, y);
            }

            // TODO : Fix
            //if (JoystickMoved != null)
            //{
            //    Debug.Log("JoystickMoved");

            //    JoystickMoved.Invoke(controllerID, joystickType, x, y);
            //}
        }
Beispiel #13
0
        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);
            }
        }
Beispiel #14
0
        private void On_TouchJoystickAdapter_AxisUpdated(EInputAxis inputAxis, float x, float y)
        {
            Debug.Log("On_TouchJoystickAdapter_JoystickMoved : " + inputAxis);

            Cmd_OnJoystickMoved(controllerID, inputAxis, x, y);
        }
Beispiel #15
0
 private void On_PlayerInputListener_AxisUpdated(EControllerID controllerID, EInputAxis inputAxis, Vector2 axisValues)
 {
     InvokeAxisUpdated(controllerID, inputAxis, axisValues.x, axisValues.y);
 }
Beispiel #16
0
 private void On_AIPlayerController_JoystickMoved(EControllerID controllerID, EInputAxis axisInput, float x, float y)
 {
     InvokeAxisUpdated(controllerID, axisInput, x, y);
 }