2008-12-29 15:30:38 +01:00
|
|
|
#ifndef EVENTHANDER_H
|
|
|
|
#define EVENTHANDER_H 1
|
|
|
|
#include <queue>
|
|
|
|
#include "Event.hpp"
|
|
|
|
|
2008-12-30 11:35:52 +01:00
|
|
|
typedef bool (*listenFuncPtr) (sf::Event);
|
2008-12-29 21:12:19 +01:00
|
|
|
enum InputType
|
|
|
|
{
|
|
|
|
KeyboardInput,
|
|
|
|
MouseInput,
|
|
|
|
JoystickInput
|
|
|
|
};
|
|
|
|
|
2008-12-30 11:35:52 +01:00
|
|
|
enum Modifiers {
|
|
|
|
UseAlt = 1,
|
|
|
|
UseShift = 2,
|
|
|
|
UseCtrl = 4
|
|
|
|
};
|
|
|
|
|
2008-12-29 21:12:19 +01:00
|
|
|
struct Keys
|
|
|
|
{
|
|
|
|
InputType inputType;
|
2008-12-30 11:35:52 +01:00
|
|
|
sf::Event::EventType eventType;
|
2008-12-29 21:12:19 +01:00
|
|
|
sf::Key::Code keyCode;
|
2008-12-30 11:35:52 +01:00
|
|
|
int mods;
|
2008-12-29 21:12:19 +01:00
|
|
|
sf::Mouse::Button mouseButton;
|
|
|
|
};
|
2008-12-29 15:30:38 +01:00
|
|
|
|
|
|
|
class EventHandler {
|
|
|
|
|
|
|
|
private:
|
2008-12-30 11:35:52 +01:00
|
|
|
listenFuncPtr keys[sf::Key::Count][8];
|
2008-12-29 22:47:45 +01:00
|
|
|
listenFuncPtr mouse[sf::Mouse::Count];
|
|
|
|
listenFuncPtr joys[sf::Joy::Count];
|
2008-12-30 11:35:52 +01:00
|
|
|
std::queue<sf::Event> eventQueue;
|
2008-12-29 15:30:38 +01:00
|
|
|
public:
|
2008-12-30 11:35:52 +01:00
|
|
|
bool RegisterEventListener(listenFuncPtr func, Keys key);
|
2008-12-29 15:30:38 +01:00
|
|
|
void Update();
|
2008-12-30 11:35:52 +01:00
|
|
|
bool addEvent(sf::Event *e);
|
2008-12-29 21:12:19 +01:00
|
|
|
static bool TestEvent (Keys k, sf::Event e);
|
2008-12-29 22:47:45 +01:00
|
|
|
static int wxCharCodeWXToSF(int id);
|
2008-12-29 21:12:19 +01:00
|
|
|
static void SFKeyToString(unsigned int keycode, char *keyStr);
|
2008-12-29 15:30:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|