00001 #ifndef HEADER_INPUTHANDLER_H 00002 #define HEADER_INPUTHANDLER_H 00003 00004 class KeyStroke; 00005 class MouseStroke; 00006 00007 #include "NoCopy.h" 00008 #include "InputProvider.h" 00009 00010 /** 00011 * Handle input events. 00012 * Events: 00013 * - keyEvent() is called when new key is pressed. 00014 * - mouseEvent() is called when there is a mouse click. 00015 * - mouseState() is called every cycle to update mouse position 00016 * 00017 * Pressed keys are stored in m_pressed array, this array is shared 00018 * and updated by InputAgent. 00019 */ 00020 class InputHandler : public InputProvider, public NoCopy { 00021 private: 00022 Uint8 *m_pressed; 00023 Uint8 m_buttons; 00024 V2 m_mouseLoc; 00025 public: 00026 InputHandler(); 00027 void takePressed(Uint8 *pressed) { m_pressed = pressed; } 00028 void mouseState(const V2 &loc, Uint8 buttons); 00029 00030 virtual void keyEvent(const KeyStroke &/*stroke*/) {} 00031 virtual void mouseEvent(const MouseStroke &/*buttons*/) {} 00032 00033 virtual bool isPressed(SDLKey key) const; 00034 virtual bool isLeftPressed() const; 00035 virtual bool isMiddlePressed() const; 00036 virtual bool isRightPressed() const; 00037 virtual V2 getMouseLoc() const { return m_mouseLoc; } 00038 00039 virtual std::string toString() const; 00040 }; 00041 00042 #endif