Ejemplo n.º 1
0
        public static void GetInstantJoyEvent(InputDevice controller, JoyDirection direction, ref bool outJustPressed, ref bool outJustReleased, ref bool outLongPush)
        {
            InputDevice  c    = GetLeftOrRightHandedController(controller);
            JoyInputPair pair = new JoyInputPair(c, direction);

            outJustPressed  = joyJustPressed.Contains(pair);
            outJustReleased = joyJustReleased.Contains(pair);
            outLongPush     = joyLongPush.Contains(pair);
        }
Ejemplo n.º 2
0
        static void UpdateControllerDelta(InputDevice controller, InputFeatureUsage <Vector2> usage)
        {
            Vector2 v2PrevValue;
            Vector2 v2CurrValue;

            remapLeftRightHandedDevices = false;
            v2PrevValue = GetPrevValue(controller, usage);
            v2CurrValue = GetValue(controller, usage);
            remapLeftRightHandedDevices = true;

            float prevLen = v2PrevValue.magnitude;
            float currLen = v2CurrValue.magnitude;

            JoyDirection prevQuadrant = GetQuadrant(v2PrevValue);
            JoyDirection currQuadrant = GetQuadrant(v2CurrValue);

            JoyInputPair prevPair = new JoyInputPair(controller, prevQuadrant);
            JoyInputPair currPair = new JoyInputPair(controller, currQuadrant);

            if (currLen > deadZoneIn)
            {
                if (prevLen <= deadZoneIn)
                {
                    // justPressed center -> exterior
                    joyJustPressed.Add(currPair);
                    longPushTimer = 0.0f;
                }
                else
                {
                    // still in EXT zone
                    if (prevQuadrant == currQuadrant)
                    {
                        longPushTimer += Time.unscaledDeltaTime;
                        if (longPushTimer > 0.6f && !joyLongPush.Contains(currPair)) // TODO: put timer threshold in GlobalState.Settings
                        {
                            joyLongPush.Add(currPair);
                        }
                    }
                    else
                    {
                        // quadrant changed
                        joyJustPressed.Add(currPair);
                        joyJustReleased.Add(prevPair);
                        longPushTimer = 0.0f;
                        ClearLongPush(controller);
                    }
                }
            }
            else
            {
                if (prevLen > deadZoneIn)
                {
                    // justReleased EXT -> Center
                    joyJustReleased.Add(currPair);
                    ClearLongPush(controller);
                }
                else
                {
                    // still in center
                    ClearLongPush(controller);
                }
            }
        }