#include "core/input/input_types.hpp"

#include <utility>  // Para pair

// Definición de los mapas
const std::unordered_map<InputAction, std::string> ACTION_TO_STRING = {
    {InputAction::FIRE_LEFT, "FIRE_LEFT"},
    {InputAction::FIRE_CENTER, "FIRE_CENTER"},
    {InputAction::FIRE_RIGHT, "FIRE_RIGHT"},
    {InputAction::START, "START"},
    {InputAction::SERVICE, "SERVICE"},
    {InputAction::UP, "UP"},
    {InputAction::DOWN, "DOWN"},
    {InputAction::LEFT, "LEFT"},
    {InputAction::RIGHT, "RIGHT"},
    {InputAction::SM_SELECT, "SM_SELECT"},
    {InputAction::SM_BACK, "SM_BACK"},
    {InputAction::BACK, "BACK"},
    {InputAction::EXIT, "EXIT"},
    {InputAction::PAUSE, "PAUSE"},
    {InputAction::WINDOW_FULLSCREEN, "WINDOW_FULLSCREEN"},
    {InputAction::WINDOW_INC_SIZE, "WINDOW_INC_SIZE"},
    {InputAction::WINDOW_DEC_SIZE, "WINDOW_DEC_SIZE"},
    {InputAction::TOGGLE_VIDEO_POSTFX, "TOGGLE_VIDEO_POSTFX"},
    {InputAction::NEXT_SHADER, "NEXT_SHADER"},
    {InputAction::NEXT_POSTFX_PRESET, "NEXT_POSTFX_PRESET"},
    {InputAction::TOGGLE_SUPERSAMPLING, "TOGGLE_SUPERSAMPLING"},
    {InputAction::TOGGLE_VIDEO_INTEGER_SCALE, "TOGGLE_VIDEO_INTEGER_SCALE"},
    {InputAction::TOGGLE_VIDEO_VSYNC, "TOGGLE_VIDEO_VSYNC"},
    {InputAction::RESET, "RESET"},
    {InputAction::TOGGLE_AUDIO, "TOGGLE_AUDIO"},
    {InputAction::CHANGE_LANG, "CHANGE_LANG"},
    {InputAction::SHOW_INFO, "SHOW_INFO"},
    {InputAction::CONFIG, "CONFIG"},
    {InputAction::SWAP_CONTROLLERS, "SWAP_CONTROLLERS"},
    {InputAction::TOGGLE_AUTO_FIRE, "TOGGLE_AUTO_FIRE"},
    {InputAction::NONE, "NONE"}};

const std::unordered_map<std::string, InputAction> STRING_TO_ACTION = {
    {"FIRE_LEFT", InputAction::FIRE_LEFT},
    {"FIRE_CENTER", InputAction::FIRE_CENTER},
    {"FIRE_RIGHT", InputAction::FIRE_RIGHT},
    {"START", InputAction::START},
    {"SERVICE", InputAction::SERVICE},
    {"UP", InputAction::UP},
    {"DOWN", InputAction::DOWN},
    {"LEFT", InputAction::LEFT},
    {"RIGHT", InputAction::RIGHT},
    {"SM_SELECT", InputAction::SM_SELECT},
    {"SM_BACK", InputAction::SM_BACK},
    {"BACK", InputAction::BACK},
    {"EXIT", InputAction::EXIT},
    {"PAUSE", InputAction::PAUSE},
    {"WINDOW_FULLSCREEN", InputAction::WINDOW_FULLSCREEN},
    {"WINDOW_INC_SIZE", InputAction::WINDOW_INC_SIZE},
    {"WINDOW_DEC_SIZE", InputAction::WINDOW_DEC_SIZE},
    {"TOGGLE_VIDEO_POSTFX", InputAction::TOGGLE_VIDEO_POSTFX},
    {"NEXT_SHADER", InputAction::NEXT_SHADER},
    {"NEXT_POSTFX_PRESET", InputAction::NEXT_POSTFX_PRESET},
    {"TOGGLE_SUPERSAMPLING", InputAction::TOGGLE_SUPERSAMPLING},
    {"TOGGLE_VIDEO_INTEGER_SCALE", InputAction::TOGGLE_VIDEO_INTEGER_SCALE},
    {"TOGGLE_VIDEO_VSYNC", InputAction::TOGGLE_VIDEO_VSYNC},
    {"RESET", InputAction::RESET},
    {"TOGGLE_AUDIO", InputAction::TOGGLE_AUDIO},
    {"CHANGE_LANG", InputAction::CHANGE_LANG},
    {"SHOW_INFO", InputAction::SHOW_INFO},
    {"CONFIG", InputAction::CONFIG},
    {"SWAP_CONTROLLERS", InputAction::SWAP_CONTROLLERS},
    {"TOGGLE_AUTO_FIRE", InputAction::TOGGLE_AUTO_FIRE},
    {"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)}};

const std::unordered_map<InputAction, InputAction> ACTION_TO_ACTION = {
    {InputAction::SM_SELECT, InputAction::FIRE_LEFT},
    {InputAction::SM_BACK, InputAction::FIRE_CENTER},
};