I am making a C++ SDL based game engine, currently doing the InputManager, check my class and make the necessary fixes, things I know are wrong:
- at method
- KeyPressed and KeyReleased are wrong.
- SetMouseKey not used yet, don't know if I need it.
- Only one gamepad is on support, I want to support X gamepads.
- other fixes.

class InputManager
{
    public:
        ~InputManager() = default;
        InputManager(const InputManager&) = delete;
        InputManager operator=(const InputManager&) = delete;
        static InputManager& GetInstance();
        void Update();
        bool IsKeyPressed(Input::KeyCode key) const;
        bool IsKeyReleased(Input::KeyCode key) const;
        bool IsMouseButtonPressed(Input::MouseButton button) const;
        Point GetMousePosition() const;
        bool IsGamepadButtonDown(Input::GamepadButton button, int gamepadIndex) const;

    private:
        InputManager();
        void KeyPressed(uint8_t keyPressed);
        void KeyReleased(uint8_t keyReleased);
        void SetMouseState(uint8_t mouseButton, bool pressed);
        SDL_GameController* GetGamepad();

        std::unordered_map<Input::KeyCode, bool> currentKeyboardState;
        std::unordered_map<Input::KeyCode, bool> previousKeyboardState;
        std::unordered_map<Input::MouseButton, bool> mouseButtonsState;
        SDL_GameController* gamepad;
};

#include "InputManager.h"

#include <cstddef>
#include <algorithm>

uint8_t KeyToSDL(Input::KeyCode keyCode);
Input::KeyCode KeyFromSDL(uint8_t sdlKeyCode);
uint8_t MouseButtonToSDL(Input::MouseButton mouseButton);
Input::MouseButton MouseButtonFromSDL(uint8_t sdlMouseButton);
SDL_GameControllerButton GamepadButtonToSDL(Input::GamepadButton gamepadButton);
Input::GamepadButton GamepadButtonFromSDL(SDL_GameControllerButton sdlGamepadButton);

InputManager::InputManager()
{
}

InputManager& InputManager::GetInstance()
{
    static InputManager instance;

    return instance;
}

void InputManager::Update()
{
    SDL_Event event;
    while (SDL_PollEvent(&event))
    {
        switch (event.type)
        {
            case SDL_KEYDOWN:
                {
                    KeyPressed(event.key.keysym.sym);
                    break;
                }
            case SDL_KEYUP:
                {
                    KeyReleased(event.key.keysym.sym);
                    break;
                }
            case SDL_MOUSEBUTTONUP:
                {
                    SetMouseState(event.button.button, false);
                    break;
                }
            case SDL_MOUSEBUTTONDOWN:
                {
                    SetMouseState(event.button.button, true);
                    break;
                }
            case SDL_CONTROLLERDEVICEADDED:
                {
                    if (!gamepad)
                    {
                        gamepad = SDL_GameControllerOpen(event.cdevice.which);
                    }
                    break;
                }
            case SDL_CONTROLLERDEVICEREMOVED:
                {
                    if (gamepad && event.cdevice.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamepad)))
                    {
                        SDL_GameControllerClose(gamepad);
                        gamepad = GetGamepad();
                    }
                    break;
                }
            }
        }
}

bool InputManager::IsKeyPressed(Input::KeyCode key) const
{
    return currentKeyboardState.at(key) && !previousKeyboardState.at(key);
}

bool InputManager::IsKeyReleased(Input::KeyCode key) const
{
    return !currentKeyboardState.at(key) && previousKeyboardState.at(key);
}

bool InputManager::IsMouseButtonPressed(Input::MouseButton button) const
{
    return mouseButtonsState.at(button);
}

Point InputManager::GetMousePosition() const
{
    int x = 0;
    int y = 0;
    SDL_GetMouseState(&x, &y);

    return Point(x, y);
}

bool InputManager::IsGamepadButtonDown(Input::GamepadButton button, int gamepadIndex) const
{
    return SDL_GameControllerGetButton(gamepad, GamepadButtonToSDL(button));
}

void InputManager::KeyPressed(uint8_t keyPressed)
{
    previousKeyboardState.at(KeyFromSDL(keyPressed)) = false;
    currentKeyboardState.at(KeyFromSDL(keyPressed)) = true;
}

void InputManager::KeyReleased(uint8_t keyReleased)
{
    previousKeyboardState.at(KeyFromSDL(keyReleased)) = true;
    currentKeyboardState.at(KeyFromSDL(keyReleased)) = false;
}

void InputManager::SetMouseState(uint8_t mouseButton, bool pressed)
{
    mouseButtonsState[MouseButtonFromSDL(mouseButton)] = pressed;
}

SDL_GameController* InputManager::GetGamepad()
{
    for (int i = 0; i < SDL_NumJoysticks(); ++i)
    {
        if (SDL_IsGameController(i))
        {
            return SDL_GameControllerOpen(i);
        }
    }

    return nullptr;
}