Beispiel #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);
        }
Beispiel #2
0
        private void MCenterPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            JoyDirection dir = JoyDirection.NA;

            if (sender == mCenterPin)
            {
                dir = JoyDirection.CENTER;
            }
            if (JoyButtonChanged != null)
            {
                JoyButtonChanged(JoyDirection.CENTER, args.Edge == GpioPinEdge.FallingEdge);
            }
        }
Beispiel #3
0
 private void MGPIO_JoyButtonChanged(JoyDirection dir, bool push)
 {
     if (push)
     {
         switch (dir)
         {
         case JoyDirection.CENTER:
             if (mIsPlaying)
             {
                 mArduino.Suspend();
                 App.Current.Exit();
             }
             else
             {
                 mGPIO.ResetAckFail();
                 mPlayer.Play();
                 mIsPlaying = true;
             }
             break;
         }
     }
 }
Beispiel #4
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);
                }
            }
        }