//
// Created by sfd on 25-6-5.
//

#include <Hazel/Core/Application.h>
#include <Hazel/Core/Input.h>
#include <SDL3/SDL_video.h>

namespace Hazel
{
    bool Input::IsKeyPressed(const KeyCode key)
    {
        const auto state = SDL_GetKeyboardState(nullptr);

        return state[(SDL_Scancode)key];
    }

    bool Input::IsMouseButtonPressed(const MouseButton button)
    {
        const auto mod = SDL_GetMouseState(nullptr, nullptr);
        return mod & SDL_BUTTON_MASK((SDL_Scancode)button);
    }

    std::pair<float, float> Input::GetMousePosition()
    {
        float xpos, ypos;
        SDL_GetMouseState(&xpos, &ypos);

        return {xpos, ypos};
    }

    float Input::GetMouseX()
    {
        return GetMousePosition().first;
    }

    float Input::GetMouseY()
    {
        return GetMousePosition().second;
    }
}
