21 #include "hx3d/window/event_manager.hpp" 23 #include "hx3d/core/core.hpp" 24 #include "hx3d/window/game.hpp" 25 #include "hx3d/window/application.hpp" 30 EventManager::EventManager() {
31 _keysPressed =
new bool[
static_cast<unsigned int>(KeyEvent::Key::None) + 1]{
false};
32 _keysReleased =
new bool[
static_cast<unsigned int>(KeyEvent::Key::None) + 1]{
false};
34 _mouseButtonClicked =
new bool[
static_cast<unsigned int>(MouseButtonEvent::Button::None) + 1]{
false};
35 _mouseButtonReleased =
new bool[
static_cast<unsigned int>(MouseButtonEvent::Button::None) + 1]{
false};
37 _mouseWheelTurned =
new bool[
static_cast<unsigned int>(MouseWheelEvent::Direction::None) + 1]{
false};
38 _windowEvents =
new bool[
static_cast<unsigned int>(WindowEvent::Type::None) + 1]{
false};
48 EventManager::~EventManager() {
60 unsigned int position =
static_cast<unsigned int>(type);
69 unsigned int position =
static_cast<unsigned int>(button);
74 unsigned int position =
static_cast<unsigned int>(button);
79 unsigned int position =
static_cast<unsigned int>(button);
88 unsigned int position =
static_cast<unsigned int>(button);
97 unsigned int position =
static_cast<unsigned int>(direction);
130 unsigned int position =
static_cast<unsigned int>(key);
135 unsigned int position =
static_cast<unsigned int>(key);
140 unsigned int position =
static_cast<unsigned int>(key);
149 unsigned int position =
static_cast<unsigned int>(key);
178 return (viewport ? viewport->screenToWorld(pos) : pos);
float _touchPressure
Touch pressure.
static window::Game * CurrentGame()
Get the game instance.
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.
glm::vec2 getScreenConvertedTouchPosition()
Get the screen converted touch position.
static window::Application * App()
Get the application instance.
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::ivec2 getSize()
Get the window size (ivec2)
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.
bool * _keysPressed
Keys pressed.
bool isKeyReleased(KeyEvent::Key key)
Test if the key have been released.
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.
const Ptr< graphics::viewports::Viewport > & getViewport()
Get the current viewport.
void setInputHandler(InputHandler *handler)
Define an input handler.
Direction
Mouse wheel direction.
glm::vec2 _mouseWheelMovement
Mouse wheel movement.
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.
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.
glm::vec2 _touchMovement
Touch movement.