8#include <entt/locator/locator.hpp>
9#include <entt_sol/dispatcher/bond.hpp>
26 void Lua::inject_events() noexcept
28 auto& lua = entt::locator<sol::state>::value();
30 auto gf_type = lua.new_usertype<GainedFocus>(sol::constructors<GainedFocus()>());
31 gf_type[
"type_id"] = &entt::type_hash<GainedFocus>::value;
35 auto ki_type = lua.new_usertype<KeyInput>(
"KeyInput", sol::constructors<KeyInput(std::string&&)>());
36 ki_type[
"type_id"] = &entt::type_hash<KeyInput>::value;
41 auto kp_type = lua.new_usertype<KeyPressed>(
"KeyPressed", sol::constructors<KeyPressed(const SDL_Scancode, const Keys, const KeyMods, const unsigned short, const bool)>());
42 kp_type[
"type_id"] = &entt::type_hash<KeyPressed>::value;
52 lua.new_usertype<KeyReleased>(
"KeyReleased", sol::constructors<KeyReleased(const SDL_Scancode, const Keys, const KeyMods, const unsigned short, const bool)>());
53 kr_type[
"type_id"] = &entt::type_hash<KeyReleased>::value;
62 auto lf_type = lua.new_usertype<LostFocus>(sol::constructors<LostFocus()>());
63 lf_type[
"type_id"] = &entt::type_hash<LostFocus>::value;
67 auto mm_type = lua.new_usertype<MouseMoved>(
"MouseMoved", sol::constructors<MouseMoved(const float, const float, const float, const float)>());
68 mm_type[
"type_id"] = &entt::type_hash<MouseMoved>::value;
72 auto mp_type = lua.new_usertype<MousePressed>(
"MousePressed", sol::constructors<MousePressed(const float, const float, const int, const MouseButton)>());
73 mp_type[
"type_id"] = &entt::type_hash<MousePressed>::value;
81 auto mr_type = lua.new_usertype<MouseReleased>(
"MouseReleased", sol::constructors<MouseReleased(const float, const float, const int, const MouseButton)>());
82 mr_type[
"type_id"] = &entt::type_hash<MouseReleased>::value;
90 auto mw_type = lua.new_usertype<MouseWheel>(
92 sol::constructors<MouseWheel(const float, const float, const SDL_MouseWheelDirection, const float, const float, const int, const int)>()
94 mw_type[
"type_id"] = &entt::type_hash<MouseWheel>::value;
104 auto wr_type = lua.new_usertype<WindowResized>(
"WindowResized", sol::constructors<WindowResized(const int, const int)>());
105 wr_type[
"type_id"] = &entt::type_hash<WindowResized>::value;
111 entt_sol::register_meta_event<GainedFocus>();
112 entt_sol::register_meta_event<KeyPressed>();
113 entt_sol::register_meta_event<KeyReleased>();
114 entt_sol::register_meta_event<LostFocus>();
115 entt_sol::register_meta_event<MouseMoved>();
116 entt_sol::register_meta_event<MousePressed>();
117 entt_sol::register_meta_event<MouseReleased>();
118 entt_sol::register_meta_event<MouseWheel>();
119 entt_sol::register_meta_event<WindowResized>();
bool consumed() const noexcept
Is this event already consumed?
void consume() noexcept
Mark this event as consumed.
bool m_repeat
True if this is a key repeat.
KeyMods m_mod
Current key modifiers.
unsigned short m_raw
The platform dependent scancode for this event.
SDL_Scancode m_scancode
SDL physical key code.
Keys m_key
SDL virtual key code.
bool m_repeat
True if this is a key repeat.
SDL_Scancode m_scancode
SDL physical key code.
Keys m_key
SDL virtual key code.
unsigned short m_raw
The platform dependent scancode for this event.
KeyMods m_mod
Current key modifiers.
MouseButton m_button
The mouse button index.
float m_ypos
Y coordinate, relative to window.
int m_clicks
1 for single-click, 2 for double-click, etc.
float m_xpos
X coordinate, relative to window.
int m_clicks
1 for single-click, 2 for double-click, etc.
float m_xpos
X coordinate, relative to window.
float m_ypos
Y coordinate, relative to window.
MouseButton m_button
The mouse button index.
float m_amount_y
The amount scrolled vertically, positive away from the user and negative toward the user.
int m_total_y
The amount scrolled vertically, accumulated to whole scroll "ticks".
int m_total_x
The amount scrolled horizontally, accumulated to whole scroll "ticks".
float m_mouse_y
Y coordinate, relative to window.
float m_mouse_x
X coordinate, relative to window.
float m_amount_x
The amount scrolled horizontally, positive to the right and negative to the left.
int m_height
New height of window.
int m_width
New width of window.