#include "core/input/global_inputs.hpp"

#include "core/input/input.h"
#include "core/rendering/screen.h"

namespace GlobalInputs {

    auto handle() -> bool {
        if (Screen::get() == nullptr || Input::get() == nullptr) { return false; }

        if (Input::get()->checkInput(WINDOW_FULLSCREEN, REPEAT_FALSE)) {
            Screen::get()->toggleVideoMode();
            return true;
        }
        if (Input::get()->checkInput(WINDOW_DEC_ZOOM, REPEAT_FALSE)) {
            Screen::get()->decWindowZoom();
            return true;
        }
        if (Input::get()->checkInput(WINDOW_INC_ZOOM, REPEAT_FALSE)) {
            Screen::get()->incWindowZoom();
            return true;
        }
        if (Input::get()->checkInput(TOGGLE_SHADER, REPEAT_FALSE)) {
            Screen::get()->toggleShaderEnabled();
            return true;
        }
        // F5/F6 només actuen quan el post-procesado està actiu.
        if (Screen::get()->isShaderEnabled()) {
            if (Input::get()->checkInput(TOGGLE_SHADER_TYPE, REPEAT_FALSE)) {
                Screen::get()->toggleActiveShader();
                return true;
            }
            if (Input::get()->checkInput(NEXT_SHADER_PRESET, REPEAT_FALSE)) {
                Screen::get()->nextPreset();
                return true;
            }
        }
        return false;
    }

}  // namespace GlobalInputs
