#include "input_types.hpp"

#include <utility>  // Para pair

// Definición de los mapas
const std::unordered_map<InputAction, std::string> ACTION_TO_STRING = {
    {InputAction::LEFT, "LEFT"},
    {InputAction::RIGHT, "RIGHT"},
    {InputAction::JUMP, "JUMP"},
    {InputAction::DOWN, "DOWN"},
    {InputAction::PAUSE, "PAUSE"},
    {InputAction::EXIT, "EXIT"},
    {InputAction::ACCEPT, "ACCEPT"},
    {InputAction::CANCEL, "CANCEL"},
    {InputAction::WINDOW_INC_ZOOM, "WINDOW_INC_ZOOM"},
    {InputAction::WINDOW_DEC_ZOOM, "WINDOW_DEC_ZOOM"},
    {InputAction::TOGGLE_FULLSCREEN, "TOGGLE_FULLSCREEN"},
    {InputAction::TOGGLE_VSYNC, "TOGGLE_VSYNC"},
    {InputAction::TOGGLE_INTEGER_SCALE, "TOGGLE_INTEGER_SCALE"},
    {InputAction::TOGGLE_BORDER, "TOGGLE_BORDER"},
    {InputAction::TOGGLE_IN_GAME_MUSIC, "TOGGLE_MUSIC"},
    {InputAction::NEXT_PALETTE, "NEXT_PALETTE"},
    {InputAction::PREVIOUS_PALETTE, "PREVIOUS_PALETTE"},
    {InputAction::NEXT_PALETTE_SORT, "NEXT_PALETTE_SORT"},
    {InputAction::TOGGLE_SHADER, "TOGGLE_POSTFX"},
    {InputAction::NEXT_SHADER_PRESET, "NEXT_POSTFX_PRESET"},
    {InputAction::TOGGLE_SUPERSAMPLING, "TOGGLE_SUPERSAMPLING"},
    {InputAction::TOGGLE_INFO, "TOGGLE_DEBUG"},
    {InputAction::TOGGLE_CONSOLE, "TOGGLE_CONSOLE"},
    {InputAction::SCREENSHOT, "SCREENSHOT"},
    {InputAction::NONE, "NONE"}};

const std::unordered_map<std::string, InputAction> STRING_TO_ACTION = {
    {"LEFT", InputAction::LEFT},
    {"RIGHT", InputAction::RIGHT},
    {"JUMP", InputAction::JUMP},
    {"DOWN", InputAction::DOWN},
    {"PAUSE", InputAction::PAUSE},
    {"EXIT", InputAction::EXIT},
    {"ACCEPT", InputAction::ACCEPT},
    {"CANCEL", InputAction::CANCEL},
    {"WINDOW_INC_ZOOM", InputAction::WINDOW_INC_ZOOM},
    {"WINDOW_DEC_ZOOM", InputAction::WINDOW_DEC_ZOOM},
    {"TOGGLE_FULLSCREEN", InputAction::TOGGLE_FULLSCREEN},
    {"TOGGLE_VSYNC", InputAction::TOGGLE_VSYNC},
    {"TOGGLE_INTEGER_SCALE", InputAction::TOGGLE_INTEGER_SCALE},
    {"TOGGLE_BORDER", InputAction::TOGGLE_BORDER},
    {"TOGGLE_MUSIC", InputAction::TOGGLE_IN_GAME_MUSIC},
    {"NEXT_PALETTE", InputAction::NEXT_PALETTE},
    {"PREVIOUS_PALETTE", InputAction::PREVIOUS_PALETTE},
    {"NEXT_PALETTE_SORT", InputAction::NEXT_PALETTE_SORT},
    {"TOGGLE_POSTFX", InputAction::TOGGLE_SHADER},
    {"NEXT_POSTFX_PRESET", InputAction::NEXT_SHADER_PRESET},
    {"TOGGLE_SUPERSAMPLING", InputAction::TOGGLE_SUPERSAMPLING},
    {"TOGGLE_DEBUG", InputAction::TOGGLE_INFO},
    {"TOGGLE_CONSOLE", InputAction::TOGGLE_CONSOLE},
    {"SCREENSHOT", InputAction::SCREENSHOT},
    {"NONE", InputAction::NONE}};

const std::unordered_map<SDL_GamepadButton, std::string> BUTTON_TO_STRING = {
    {SDL_GAMEPAD_BUTTON_WEST, "WEST"},
    {SDL_GAMEPAD_BUTTON_NORTH, "NORTH"},
    {SDL_GAMEPAD_BUTTON_EAST, "EAST"},
    {SDL_GAMEPAD_BUTTON_SOUTH, "SOUTH"},
    {SDL_GAMEPAD_BUTTON_START, "START"},
    {SDL_GAMEPAD_BUTTON_BACK, "BACK"},
    {SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, "LEFT_SHOULDER"},
    {SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, "RIGHT_SHOULDER"},
    {SDL_GAMEPAD_BUTTON_DPAD_UP, "DPAD_UP"},
    {SDL_GAMEPAD_BUTTON_DPAD_DOWN, "DPAD_DOWN"},
    {SDL_GAMEPAD_BUTTON_DPAD_LEFT, "DPAD_LEFT"},
    {SDL_GAMEPAD_BUTTON_DPAD_RIGHT, "DPAD_RIGHT"},
    {static_cast<SDL_GamepadButton>(100), "L2_AS_BUTTON"},
    {static_cast<SDL_GamepadButton>(101), "R2_AS_BUTTON"}};

const std::unordered_map<std::string, SDL_GamepadButton> STRING_TO_BUTTON = {
    {"WEST", SDL_GAMEPAD_BUTTON_WEST},
    {"NORTH", SDL_GAMEPAD_BUTTON_NORTH},
    {"EAST", SDL_GAMEPAD_BUTTON_EAST},
    {"SOUTH", SDL_GAMEPAD_BUTTON_SOUTH},
    {"START", SDL_GAMEPAD_BUTTON_START},
    {"BACK", SDL_GAMEPAD_BUTTON_BACK},
    {"LEFT_SHOULDER", SDL_GAMEPAD_BUTTON_LEFT_SHOULDER},
    {"RIGHT_SHOULDER", SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER},
    {"DPAD_UP", SDL_GAMEPAD_BUTTON_DPAD_UP},
    {"DPAD_DOWN", SDL_GAMEPAD_BUTTON_DPAD_DOWN},
    {"DPAD_LEFT", SDL_GAMEPAD_BUTTON_DPAD_LEFT},
    {"DPAD_RIGHT", SDL_GAMEPAD_BUTTON_DPAD_RIGHT},
    {"L2_AS_BUTTON", static_cast<SDL_GamepadButton>(100)},
    {"R2_AS_BUTTON", static_cast<SDL_GamepadButton>(101)}};