|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
#include "luabindings.hpp"
|
|
|
|
|
|
|
|
|
|
#include <SDL_events.h>
|
|
|
|
|
|
|
|
|
|
#include <components/lua/luastate.hpp>
|
|
|
|
|
#include <components/queries/luabindings.hpp>
|
|
|
|
|
|
|
|
|
@ -8,6 +10,12 @@
|
|
|
|
|
#include "eventqueue.hpp"
|
|
|
|
|
#include "worldview.hpp"
|
|
|
|
|
|
|
|
|
|
namespace sol
|
|
|
|
|
{
|
|
|
|
|
template <>
|
|
|
|
|
struct is_automagical<SDL_Keysym> : std::false_type {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace MWLua
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -160,5 +168,17 @@ namespace MWLua
|
|
|
|
|
return context.mLua->makeReadOnly(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void initInputBindings(const Context& context)
|
|
|
|
|
{
|
|
|
|
|
sol::usertype<SDL_Keysym> keyEvent = context.mLua->sol().new_usertype<SDL_Keysym>("KeyEvent");
|
|
|
|
|
keyEvent["symbol"] = sol::readonly_property([](const SDL_Keysym& e) { return std::string(1, static_cast<char>(e.sym)); });
|
|
|
|
|
keyEvent["code"] = sol::readonly_property([](const SDL_Keysym& e) -> int { return e.sym; });
|
|
|
|
|
keyEvent["modifiers"] = sol::readonly_property([](const SDL_Keysym& e) -> int { return e.mod; });
|
|
|
|
|
keyEvent["withShift"] = sol::readonly_property([](const SDL_Keysym& e) -> bool { return e.mod & KMOD_SHIFT; });
|
|
|
|
|
keyEvent["withCtrl"] = sol::readonly_property([](const SDL_Keysym& e) -> bool { return e.mod & KMOD_CTRL; });
|
|
|
|
|
keyEvent["withAlt"] = sol::readonly_property([](const SDL_Keysym& e) -> bool { return e.mod & KMOD_ALT; });
|
|
|
|
|
keyEvent["withSuper"] = sol::readonly_property([](const SDL_Keysym& e) -> bool { return e.mod & KMOD_GUI; });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|