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
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InputManager(Window* window);
|
|
|
|
~InputManager();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
void loadConfig();
|
|
|
|
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
|
|
|
void setNumPlayers(int num);
|
|
|
|
int getNumPlayers();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
int getNumJoysticks();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
bool parseEvent(const SDL_Event& ev);
|
2012-07-22 21:15:55 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
InputConfig* getInputConfigByPlayer(int player);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const int DEADZONE = 23000;
|
|
|
|
|
|
|
|
Window* mWindow;
|
|
|
|
|
|
|
|
//non-InputManager classes shouldn't use this, as you can easily miss the keyboard
|
|
|
|
InputConfig* getInputConfigByDevice(int device);
|
|
|
|
|
|
|
|
int mNumJoysticks;
|
|
|
|
int mNumPlayers;
|
|
|
|
SDL_Joystick** mJoysticks;
|
|
|
|
InputConfig** mInputConfigs;
|
|
|
|
InputConfig* mKeyboardInputConfig;
|
|
|
|
std::map<int, int>* mPrevAxisValues;
|
|
|
|
};
|
2012-07-20 01:08:29 +00:00
|
|
|
|
|
|
|
#endif
|