2012-07-20 01:08:29 +00:00
|
|
|
#ifndef _INPUTMANAGER_H_
|
|
|
|
#define _INPUTMANAGER_H_
|
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
#include <SDL.h>
|
2012-07-20 01:08:29 +00:00
|
|
|
#include <vector>
|
2012-07-22 21:15:55 +00:00
|
|
|
#include <map>
|
2013-04-08 16:52:40 +00:00
|
|
|
#include <string>
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
class InputConfig;
|
|
|
|
class Window;
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
//you should only ever instantiate one of these, by the way
|
|
|
|
class InputManager
|
|
|
|
{
|
2014-03-22 01:12:57 +00:00
|
|
|
private:
|
2013-05-24 11:44:40 +00:00
|
|
|
static const int DEADZONE = 23000;
|
|
|
|
|
|
|
|
Window* mWindow;
|
|
|
|
|
2014-03-22 01:12:57 +00:00
|
|
|
void loadDefaultKBConfig();
|
2013-05-24 11:44:40 +00:00
|
|
|
|
2014-03-22 01:12:57 +00:00
|
|
|
std::map<SDL_JoystickID, SDL_Joystick*> mJoysticks;
|
2013-08-19 14:05:30 +00:00
|
|
|
std::map<SDL_JoystickID, InputConfig*> mInputConfigs;
|
|
|
|
InputConfig* mKeyboardInputConfig;
|
2013-05-24 11:44:40 +00:00
|
|
|
|
2013-08-19 14:05:30 +00:00
|
|
|
std::map<SDL_JoystickID, int*> mPrevAxisValues;
|
2013-05-24 11:44:40 +00:00
|
|
|
|
2013-08-19 14:05:30 +00:00
|
|
|
bool initialized() const;
|
2013-05-24 11:44:40 +00:00
|
|
|
|
2014-03-22 01:12:57 +00:00
|
|
|
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)
|
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
public:
|
|
|
|
InputManager(Window* window);
|
|
|
|
~InputManager();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2014-03-22 01:12:57 +00:00
|
|
|
void writeDeviceConfig(InputConfig* config);
|
2013-04-08 16:52:40 +00:00
|
|
|
static std::string getConfigPath();
|
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
void init();
|
|
|
|
void deinit();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
int getNumJoysticks();
|
2014-03-22 01:12:57 +00:00
|
|
|
int getButtonCountByDevice(int deviceId);
|
|
|
|
int getNumConfiguredDevices();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2014-03-22 01:12:57 +00:00
|
|
|
std::string getDeviceGUIDString(int deviceId);
|
|
|
|
|
|
|
|
InputConfig* getInputConfigByDevice(int deviceId);
|
2012-07-22 21:15:55 +00:00
|
|
|
|
2014-03-22 01:12:57 +00:00
|
|
|
bool parseEvent(const SDL_Event& ev);
|
2013-04-08 14:41:25 +00:00
|
|
|
};
|
2012-07-20 01:08:29 +00:00
|
|
|
|
|
|
|
#endif
|