mirror of
https://github.com/Maschell/libgui-sdl.git
synced 2024-11-16 13:09:20 +01:00
38 lines
967 B
C++
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;
|
|
};
|