#pragma once
#include "types.h"
#include <glm/gtc/matrix_transform.hpp>
#include <SDL3/SDL.h>

struct Camera {
  vec3  pos        = vec3(0.0f, 0.0f,  2.0f);
  vec3  target     = vec3(0.0f, 0.0f,  0.0f);
  vec3  up         = vec3(0.0f, 1.0f,  0.0f);
  float fov        = 60.0f;
  float move_speed = 0.5f;
  float look_speed = 1.0f;
  float pitch      = 0.0f;
  float yaw        = -90.0f;

  bool move_forward  = false;
  bool move_backward = false;
  bool move_left     = false;
  bool move_right    = false;
  bool move_up       = false;
  bool move_down     = false;
  bool look_up       = false;
  bool look_down     = false;
  bool look_left     = false;
  bool look_right    = false;
  bool shifted       = false;

  void update();
  void on_key(SDL_Scancode scancode, bool pressed);
  void on_mouse_motion(float dx, float dy);
  void on_gamepad(SDL_Gamepad* gamepad);
  CameraUBO ubo(float aspect) const;

private:
  vec3 dir() const;
};
