hx3d  1
2D/3D Simple Game Framework
event_manager.hpp
1 /*
2  Event manager.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_WINDOW_EVENT_MANAGER
22 #define HX3D_WINDOW_EVENT_MANAGER
23 
24 #include <glm/vec2.hpp>
25 
26 #include "hx3d/utils/log.hpp"
27 #include "hx3d/utils/ptr.hpp"
28 
29 #include "hx3d/window/events.hpp"
30 
31 namespace hx3d {
32 namespace window {
33 
34 class InputHandler;
35 
39 class EventManager {
40 
41 public:
42  EventManager();
43  virtual ~EventManager();
44 
48  virtual void poll() = 0;
49 
58 
91 
100 
106  bool isScreenTouched();
112  bool isScreenReleased();
118  bool isScreenJustTouched();
124  bool isScreenJustReleased();
125 
133  bool isKeyPressed(KeyEvent::Key key);
141  bool isKeyReleased(KeyEvent::Key key);
158 
164  glm::vec2 getMousePosition();
170  glm::vec2 getMouseMovement();
176  glm::vec2 getMouseWheelMovement();
177 
183  glm::vec2 getTouchPosition();
195  glm::vec2 getTouchMovement();
201  float getTouchPressure();
202 
211  void emulateTouchWithMouse(bool value);
212 
218  void setInputHandler(InputHandler* handler);
219 
225  void setInputHandler(Ptr<InputHandler> handler);
226 
227  protected:
232 
237 
242 
247 
249  glm::vec2 _mousePosition;
251  glm::vec2 _mouseMovement;
254 
256  glm::vec2 _touchPosition;
258  glm::vec2 _touchMovement;
261 
264 
267 };
268 
269 } /* window */
270 } /* hx3d */
271 
272 #endif /* HX3D_WINDOW_EVENT_MANAGER */
float _touchPressure
Touch pressure.
glm::vec2 getTouchPosition()
Get the current touch position.
bool * _keysReleased
Keys released.
bool isScreenJustTouched()
Test if the screen have been just touched.
glm::vec2 _mouseMovement
Mouse movement.
bool * _mouseButtonReleased
Mouse buttons released.
bool _touchSimulation
Is touch simulated with mouse ?
glm::vec2 getTouchMovement()
Get the current touch movement.
bool isScreenReleased()
Test if the screen have been released.
Manage real-time inputs.
glm::vec2 getScreenConvertedTouchPosition()
Get the screen converted touch position.
hx3d framework namespace
Definition: audio.hpp:26
bool isMouseButtonJustClicked(MouseButtonEvent::Button button)
Test if a mouse button have just been clicked.
bool isKeyPressed(KeyEvent::Key key)
Test if the key have been pressed.
bool isScreenJustReleased()
Test if the screen have been just released.
glm::vec2 getMouseMovement()
Get the current mouse movement.
glm::vec2 _mousePosition
Mouse position.
InputHandler * _currentHandler
Current input handler.
glm::vec2 getMouseWheelMovement()
Get the current mouse wheel movement.
bool * _mouseButtonClicked
Mouse buttons clicked.
bool isMouseButtonReleased(MouseButtonEvent::Button button)
Test if a mouse button have been relased.
bool isKeyJustReleased(KeyEvent::Key key)
Test if the key have just been released.
glm::vec2 getMousePosition()
Get the current mouse position.
bool isScreenTouched()
Test if the screen have been touched.
virtual void poll()=0
Poll the event queue.
bool * _keysPressed
Keys pressed.
bool isKeyReleased(KeyEvent::Key key)
Test if the key have been released.
Button
Mouse button value.
Definition: events.hpp:101
bool isMouseWheelTurned(MouseWheelEvent::Direction direction)
Test if the mouse wheel have been turned in a direction.
bool _screenTouched
Screen touched ?
bool isMouseButtonClicked(MouseButtonEvent::Button button)
Test if a mouse button have been clicked.
float getTouchPressure()
Get the current touch pressure.
void setInputHandler(InputHandler *handler)
Define an input handler.
Direction
Mouse wheel direction.
Definition: events.hpp:124
glm::vec2 _mouseWheelMovement
Mouse wheel movement.
Type
Window event type.
Definition: events.hpp:71
bool * _mouseWheelTurned
Mouse wheels turned.
bool _screenReleased
Screen released ?
bool * _windowEvents
Window events.
bool isWindowState(WindowEvent::Type type)
Test the window state.
glm::vec2 _touchPosition
Touch position.
Input management: use with screens !
void emulateTouchWithMouse(bool value)
Emulate the touch system with the mouse.
bool isKeyJustPressed(KeyEvent::Key key)
Test if the key have just been pressed.
bool isMouseButtonJustReleased(MouseButtonEvent::Button button)
Test if a mouse button have just been released.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34
glm::vec2 _touchMovement
Touch movement.