Example #1
0
 private GamePadStickDirection DetectStickDirection(Vector2 position, GamePadStickType stickType)
 {
     if (position.X > RADIUS_THRESHOLD)
     {
         return(GamePadStickDirection.Right);
     }
     else if (position.X < -RADIUS_THRESHOLD)
     {
         return(GamePadStickDirection.Left);
     }
     else if (position.Y > RADIUS_THRESHOLD)
     {
         return(GamePadStickDirection.Up);
     }
     else if (position.Y < RADIUS_THRESHOLD)
     {
         return(GamePadStickDirection.Down);
     }
     else
     {
         return(GamePadStickDirection.Center);
     }
 }
Example #2
0
        public override void SendMouseMoveInput(int x, int y, GamePadStickType type)
        {
            float X = x;
            float Y = y;

            float magnitude = (float)Math.Sqrt(X * X + Y * Y);

            float normalizedX         = X / magnitude;
            float normalizedY         = Y / magnitude;
            float normalizedMagnitude = 0;

            if (magnitude > (int)XInputWrapper.GP.XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
            {
                if (magnitude > 32767)
                {
                    magnitude = 32767;
                }
                magnitude -= (float)XInputWrapper.GP.XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;

                switch (type)
                {
                case GamePadStickType.Left:
                    if (!Controller.GetProfile().LeftThumbStickAcceleration)
                    {
                        normalizedMagnitude = 1 * ((float)Controller.GetProfile().LeftThumbStickSpeed / 10);
                    }
                    else
                    {
                        normalizedMagnitude = magnitude
                                              / (32767.0f - (float)XInputWrapper.GP.XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
                    }
                    break;

                case GamePadStickType.Right:
                    if (!Controller.GetProfile().RightThumbStickAcceleration)
                    {
                        normalizedMagnitude = 1 * ((float)Controller.GetProfile().RightThumbStickSpeed / 10);
                    }
                    else
                    {
                        normalizedMagnitude = magnitude
                                              / (32767.0f - (float)XInputWrapper.GP.XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
                    }
                    break;

                default:
                    normalizedMagnitude = magnitude
                                          / (32767.0f - (float)XInputWrapper.GP.XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
                    break;
                }

                POINT point;
                User32Wrapper.GetCursorPos(out point);

                int refreshRate = 60;
                if (Controller.GetProfile().RepeatMode == RepeatType.HalfDisplayFrequence)
                {
                    refreshRate = 30;
                }

                point.X = (int)(normalizedX * normalizedMagnitude * (refreshRate / 3) + point.X);
                point.Y = (int)(-normalizedY * normalizedMagnitude * (refreshRate / 3) + point.Y);

                User32Wrapper.SetCursorPos(point.X, point.Y);
            }
        }
Example #3
0
 public abstract void SendMouseMoveInput(int x, int y, GamePadStickType type);
Example #4
0
 public GamePadStickDirectionControlType(int gamePad, GamePadStickType stick, GamePadStickDirectionType direction)
 {
     GamePad = gamePad;
     Stick = stick;
     Direction = direction;
 }
Example #5
0
 public GamePadStickDirection(int gamePadIndex, GamePadStickType stick, GamePadStickDirectionType direction)
 {
     _gamePadIndex = gamePadIndex;
     _stick = stick;
     _direction = direction;
 }