Exemple #1
0
        public void HandleMouseCursor()
        {
            bool EnableMouseInput = InstanceSettings.EnableMouseInput && ProcessUtil.IsRemotePlayInForeground();

            if (EnableMouseInput)
            {
                Utility.ShowCursor(false);

                // mouse displacement relative to the anchor
                MouseDirection = FeedMouseCoords();
                // Log.Verbose("GamepadProcessor.HandleMouseCursor rawX={0}, rawY={1}", MouseDirection.X, MouseDirection.Y);

                if (IsAimingWithAimSpecificSensitivity())
                {
                    // Log.Verbose("GamepadProcessor.HandleMouseCursor MouseXAxisSensitivity_AIM_Modifier " + UserSettings.MouseXAxisSensitivityAimModifier);
                    MouseDirection = new Vector2i(
                        (int)(MouseDirection.X * UserSettings.MouseXAxisSensitivityAimModifier),
                        (int)(MouseDirection.Y * UserSettings.MouseYAxisSensitivityAimModifier));
                }
                else
                {
                    // Log.Verbose("GamepadProcessor.HandleMouseCursor MouseXAxisSensitivity_LOOK_Modifier " + UserSettings.MouseXAxisSensitivityLookModifier);
                    MouseDirection = new Vector2i(
                        (int)(MouseDirection.X * UserSettings.MouseXAxisSensitivityLookModifier),
                        (int)(MouseDirection.Y * UserSettings.MouseYAxisSensitivityLookModifier));
                }
                // Log.Verbose("GamepadProcessor.HandleMouseCursor modifiedX={0}, modifiedY={1}", MouseDirection.X, MouseDirection.Y);


                Vector2 direction = new Vector2(MouseDirection.X, MouseDirection.Y);

                // Cap length to fit range.

                double normalizedLength = Utility.mapcap(direction.Length(),
                                                         UserSettings.MouseDistanceLowerRange, UserSettings.MouseDistanceUpperRange,
                                                         UserSettings.AnalogStickLowerRange / 100f, UserSettings.AnalogStickUpperRange / 100f);

                direction = Vector2.Normalize(direction);


                // L3R3 center is 127,
                // full left/up is 0
                // full right/down is 255
                byte scaledX = (byte)Utility.map(direction.X * normalizedLength, -1, 1, 0, 255);
                byte scaledY = (byte)Utility.map(direction.Y * normalizedLength, -1, 1, 0, 255);

                direction.X *= (float)UserSettings.XYRatio;
                direction    = Vector2.Normalize(direction);

                if (float.IsNaN(direction.X) && float.IsNaN(direction.Y))
                {
                    scaledX = 127;
                    scaledY = 127;
                }

                if (scaledX != 127 && scaledX != 128 && scaledY != 127 && scaledY != 128)
                {
                    // Log.Verbose("GamepadProcessor.HandleMouseCursor scaledX={0} scaledY={1}", scaledX, scaledY);
                }

                if (UserSettings.MouseControlsL3)
                {
                    CurrentState.LX = scaledX;
                    CurrentState.LY = scaledY;
                }

                if (UserSettings.MouseControlsR3)
                {
                    CurrentState.RX = scaledX;
                    CurrentState.RY = scaledY;
                }
            }
        }