libgui-sdl/include/gui-sdl/gui/input/ControllerManager.h
2020-10-02 19:57:53 +02:00

38 lines
967 B
C++

#pragma once
#include <map>
#include <functional>
#include <gui/GuiTrigger.h>
#include <gui/input/SDLController.h>
#include <gui/input/SDLControllerMouse.h>
class ControllerManager {
public:
ControllerManager(int32_t screenWidth, int32_t screenHeight) : screenWidth(screenWidth), screenHeight(screenHeight){
}
void attachController(GuiTrigger::eChannels channels, SDLController *controller);
void prepare();
bool attachJoystick(int32_t deviceId);
void detachJoystick(int32_t deviceId);
void processEvent(SDL_JoystickID joystickId, int32_t channel, SDL_Event *event);
void finish();
void callPerController(std::function<void(GuiController*)> func);
private:
GuiTrigger::eChannels increaseChannel(GuiTrigger::eChannels channel);
std::map<GuiTrigger::eChannels, SDLController *> controllerList;
std::map<int32_t, GuiTrigger::eChannels> joystickToChannel;
int32_t screenWidth;
int32_t screenHeight;
};