#ifndef GP1_DIRECTX_GAMEPADCONTROLLER_H
#define GP1_DIRECTX_GAMEPADCONTROLLER_H

#include <vector>

#include "SDL_gamecontroller.h"
#include "SDL.h"


struct GamePad{
    bool buttons[SDL_CONTROLLER_BUTTON_MAX];
    float axis[SDL_CONTROLLER_AXIS_MAX];
};

enum Controllers {PLAYER1, PLAYER2, PLAYER3, PLAYER4};

class GamePadController {
public:

    static GamePadController& GetInstance()
    {
        static GamePadController instance;
        return instance;
    }

    ~GamePadController();
    void Init();
    void Update();
    bool IsButtonDown(Controllers controller, int button) const;
    bool IsButtonUp(Controllers controller, int button) const;

    float GetAxis(Controllers controller, int axis) const;

    bool isAnyControllerConnected() const { return !m_pGameControllers.empty(); }

private:
    GamePadController();
    std::vector<SDL_GameController*> m_pGameControllers;
    std::vector<GamePad> m_GamePads;
};


#endif //GP1_DIRECTX_GAMEPADCONTROLLER_H
