// FlexiMotion // https://kybernetik.com.au/flexi-motion // Copyright 2023-2025 Kybernetik //

using UnityEngine;

#if UNITY_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif

namespace FlexiMotion.Samples
{
    /// <summary>
    /// A standard wrapper for receiving input from the
    /// <see href="https://docs.unity3d.com/Packages/com.unity.inputsystem@latest">Input System</see> package or the
    /// <see href="https://docs.unity3d.com/Manual/class-InputManager.html">Legacy Input Manager</see>.
    /// <remarks>
    /// Documentation: <see href="https://kybernetik.com.au/animancer/docs/examples/basics/input">Input</see>
    /// </remarks>
    /// https://kybernetik.com.au/flexi-motion/api/FlexiMotion.Samples/SampleInput
    /// 
    [HelpURL(FMStrings.DocsURLs.SamplesAPIDocumentation + "/" + nameof(SampleInput))]
    public static class SampleInput
    {
        /************************************************************************************************************************/

        /// <summary>The current screen position of the mouse pointer.</summary>
        public static Vector2 MousePosition
#if UNITY_INPUT_SYSTEM
            => Mouse.current.position.ReadValue();
#else
            => Input.mousePosition;
#endif

        /// <summary>The amount that the mouse has moved since last frame.</summary>
        public static Vector2 MousePositionDelta
#if UNITY_INPUT_SYSTEM
            => Mouse.current.delta.ReadValue();
#else
            => new Vector2(Input.GetAxisRaw("Mouse X") * 20, Input.GetAxisRaw("Mouse Y") * 20);
#endif

        /// <summary>The amount that the mouse scroll value has changed since last frame.</summary>
        public static Vector2 MouseScrollDelta
#if UNITY_INPUT_SYSTEM
            => Mouse.current.scroll.ReadValue() * 0.01f;
#else
            => Input.mouseScrollDelta;
#endif

        /************************************************************************************************************************/

        /// <summary>Was the left mouse button pressed this frame?</summary>
        public static bool LeftMouseDown
#if UNITY_INPUT_SYSTEM
            => Mouse.current.leftButton.wasPressedThisFrame;
#else
            => Input.GetMouseButtonDown(0);
#endif

        /// <summary>Is the left mouse button currently being held down?</summary>
        public static bool LeftMouseHold
#if UNITY_INPUT_SYSTEM
            => Mouse.current.leftButton.isPressed;
#else
            => Input.GetMouseButton(0);
#endif

        /************************************************************************************************************************/

        /// <summary>Is the right mouse button currently being held down?</summary>
        public static bool RightMouseHold
#if UNITY_INPUT_SYSTEM
            => Mouse.current.rightButton.isPressed;
#else
            => Input.GetMouseButton(1);
#endif

        /************************************************************************************************************************/
    }
}
