using UnityEngine;

public class InputHandler : MonoBehaviour
{
    private Vector2 lastMousePosition;
    private float lastScrollValue;
    private bool isRightMouseHeld;
    private bool isMiddleMouseHeld;
    private bool isOrbitActive;
    private bool isZoomActive;

    private void Update()
    {
        // 마우스 버튼 상태 업데이트
        isRightMouseHeld = Input.GetMouseButton(1);
        isMiddleMouseHeld = Input.GetMouseButton(2);
        isOrbitActive = Input.GetKey(KeyCode.LeftAlt) && Input.GetMouseButton(0);  // Alt + 좌클릭으로 궤도 회전
        isZoomActive = Input.GetKey(KeyCode.LeftControl) && Input.GetMouseButton(0);  // Ctrl + 좌클릭으로 줌

        // 마우스 위치 업데이트
        lastMousePosition = Input.mousePosition;
        lastScrollValue = Input.mouseScrollDelta.y;
    }

    public bool IsRightMouseHeld() => isRightMouseHeld;
    public bool IsMiddleMouseHeld() => isMiddleMouseHeld;
    public bool IsOrbitActive() => isOrbitActive;
    public bool IsZoomActive() => isZoomActive;

    public Vector2 GetLookDelta()
    {
        return new Vector2(
            Input.GetAxis("Mouse X"),
            Input.GetAxis("Mouse Y")
        );
    }

    public float GetZoomDelta()
    {
        return Input.mouseScrollDelta.y;
    }

    public Vector2 GetMousePosition()
    {
        return Input.mousePosition;
    }
}