ES-DE/es-core/src/InputManager.h

61 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#ifndef ES_CORE_INPUT_MANAGER_H
#define ES_CORE_INPUT_MANAGER_H
2017-11-01 22:21:10 +00:00
#include <SDL_joystick.h>
#include <map>
class InputConfig;
class Window;
2017-11-01 22:21:10 +00:00
union SDL_Event;
//you should only ever instantiate one of these, by the way
class InputManager
{
private:
InputManager();
static InputManager* mInstance;
static const int DEADZONE = 23000;
void loadDefaultKBConfig();
std::map<SDL_JoystickID, SDL_Joystick*> mJoysticks;
std::map<SDL_JoystickID, InputConfig*> mInputConfigs;
InputConfig* mKeyboardInputConfig;
std::map<SDL_JoystickID, int*> mPrevAxisValues;
bool initialized() const;
void addJoystickByDeviceIndex(int id);
void removeJoystickByJoystickID(SDL_JoystickID id);
bool loadInputConfig(InputConfig* config); // returns true if successfully loaded, false if not (or didn't exist)
public:
virtual ~InputManager();
static InputManager* getInstance();
void writeDeviceConfig(InputConfig* config);
void doOnFinish();
2013-04-08 16:52:40 +00:00
static std::string getConfigPath();
static std::string getTemporaryConfigPath();
2013-04-08 16:52:40 +00:00
void init();
void deinit();
int getNumJoysticks();
int getButtonCountByDevice(int deviceId);
int getNumConfiguredDevices();
std::string getDeviceGUIDString(int deviceId);
InputConfig* getInputConfigByDevice(int deviceId);
bool parseEvent(const SDL_Event& ev, Window* window);
};
#endif // ES_CORE_INPUT_MANAGER_H