|
|
@ -38,13 +38,13 @@ namespace MWLua
|
|
|
|
|
|
|
|
|
|
|
|
sol::table initInputPackage(const Context& context)
|
|
|
|
sol::table initInputPackage(const Context& context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
sol::state_view lua = context.sol();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sol::state_view& lua = context.mLua->sol();
|
|
|
|
|
|
|
|
if (lua["openmw_input"] != sol::nil)
|
|
|
|
if (lua["openmw_input"] != sol::nil)
|
|
|
|
return lua["openmw_input"];
|
|
|
|
return lua["openmw_input"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sol::usertype<SDL_Keysym> keyEvent = context.mLua->sol().new_usertype<SDL_Keysym>("KeyEvent");
|
|
|
|
sol::usertype<SDL_Keysym> keyEvent = lua.new_usertype<SDL_Keysym>("KeyEvent");
|
|
|
|
keyEvent["symbol"] = sol::readonly_property([](const SDL_Keysym& e) {
|
|
|
|
keyEvent["symbol"] = sol::readonly_property([](const SDL_Keysym& e) {
|
|
|
|
if (e.sym > 0 && e.sym <= 255)
|
|
|
|
if (e.sym > 0 && e.sym <= 255)
|
|
|
|
return std::string(1, static_cast<char>(e.sym));
|
|
|
|
return std::string(1, static_cast<char>(e.sym));
|
|
|
@ -57,7 +57,7 @@ namespace MWLua
|
|
|
|
keyEvent["withAlt"] = sol::readonly_property([](const SDL_Keysym& e) -> bool { return e.mod & KMOD_ALT; });
|
|
|
|
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; });
|
|
|
|
keyEvent["withSuper"] = sol::readonly_property([](const SDL_Keysym& e) -> bool { return e.mod & KMOD_GUI; });
|
|
|
|
|
|
|
|
|
|
|
|
auto touchpadEvent = context.mLua->sol().new_usertype<SDLUtil::TouchEvent>("TouchpadEvent");
|
|
|
|
auto touchpadEvent = lua.new_usertype<SDLUtil::TouchEvent>("TouchpadEvent");
|
|
|
|
touchpadEvent["device"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> int { return e.mDevice; });
|
|
|
|
touchpadEvent["device"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> int { return e.mDevice; });
|
|
|
|
touchpadEvent["finger"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> int { return e.mFinger; });
|
|
|
|
touchpadEvent["finger"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> int { return e.mFinger; });
|
|
|
|
touchpadEvent["position"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> osg::Vec2f {
|
|
|
|
touchpadEvent["position"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> osg::Vec2f {
|
|
|
@ -66,7 +66,7 @@ namespace MWLua
|
|
|
|
touchpadEvent["pressure"]
|
|
|
|
touchpadEvent["pressure"]
|
|
|
|
= sol::readonly_property([](const SDLUtil::TouchEvent& e) -> float { return e.mPressure; });
|
|
|
|
= sol::readonly_property([](const SDLUtil::TouchEvent& e) -> float { return e.mPressure; });
|
|
|
|
|
|
|
|
|
|
|
|
auto inputActions = context.mLua->sol().new_usertype<LuaUtil::InputAction::Registry>("InputActions");
|
|
|
|
auto inputActions = lua.new_usertype<LuaUtil::InputAction::Registry>("InputActions");
|
|
|
|
inputActions[sol::meta_function::index]
|
|
|
|
inputActions[sol::meta_function::index]
|
|
|
|
= [](LuaUtil::InputAction::Registry& registry, std::string_view key) { return registry[key]; };
|
|
|
|
= [](LuaUtil::InputAction::Registry& registry, std::string_view key) { return registry[key]; };
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -85,7 +85,7 @@ namespace MWLua
|
|
|
|
inputActions[sol::meta_function::pairs] = pairs;
|
|
|
|
inputActions[sol::meta_function::pairs] = pairs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto actionInfo = context.mLua->sol().new_usertype<LuaUtil::InputAction::Info>("ActionInfo");
|
|
|
|
auto actionInfo = lua.new_usertype<LuaUtil::InputAction::Info>("ActionInfo");
|
|
|
|
actionInfo["key"] = sol::readonly_property(
|
|
|
|
actionInfo["key"] = sol::readonly_property(
|
|
|
|
[](const LuaUtil::InputAction::Info& info) -> std::string_view { return info.mKey; });
|
|
|
|
[](const LuaUtil::InputAction::Info& info) -> std::string_view { return info.mKey; });
|
|
|
|
actionInfo["name"] = sol::readonly_property(
|
|
|
|
actionInfo["name"] = sol::readonly_property(
|
|
|
@ -98,7 +98,7 @@ namespace MWLua
|
|
|
|
actionInfo["defaultValue"]
|
|
|
|
actionInfo["defaultValue"]
|
|
|
|
= sol::readonly_property([](const LuaUtil::InputAction::Info& info) { return info.mDefaultValue; });
|
|
|
|
= sol::readonly_property([](const LuaUtil::InputAction::Info& info) { return info.mDefaultValue; });
|
|
|
|
|
|
|
|
|
|
|
|
auto inputTriggers = context.mLua->sol().new_usertype<LuaUtil::InputTrigger::Registry>("InputTriggers");
|
|
|
|
auto inputTriggers = lua.new_usertype<LuaUtil::InputTrigger::Registry>("InputTriggers");
|
|
|
|
inputTriggers[sol::meta_function::index]
|
|
|
|
inputTriggers[sol::meta_function::index]
|
|
|
|
= [](LuaUtil::InputTrigger::Registry& registry, std::string_view key) { return registry[key]; };
|
|
|
|
= [](LuaUtil::InputTrigger::Registry& registry, std::string_view key) { return registry[key]; };
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -117,7 +117,7 @@ namespace MWLua
|
|
|
|
inputTriggers[sol::meta_function::pairs] = pairs;
|
|
|
|
inputTriggers[sol::meta_function::pairs] = pairs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto triggerInfo = context.mLua->sol().new_usertype<LuaUtil::InputTrigger::Info>("TriggerInfo");
|
|
|
|
auto triggerInfo = lua.new_usertype<LuaUtil::InputTrigger::Info>("TriggerInfo");
|
|
|
|
triggerInfo["key"] = sol::readonly_property(
|
|
|
|
triggerInfo["key"] = sol::readonly_property(
|
|
|
|
[](const LuaUtil::InputTrigger::Info& info) -> std::string_view { return info.mKey; });
|
|
|
|
[](const LuaUtil::InputTrigger::Info& info) -> std::string_view { return info.mKey; });
|
|
|
|
triggerInfo["name"] = sol::readonly_property(
|
|
|
|
triggerInfo["name"] = sol::readonly_property(
|
|
|
@ -128,14 +128,15 @@ namespace MWLua
|
|
|
|
[](const LuaUtil::InputTrigger::Info& info) -> std::string_view { return info.mL10n; });
|
|
|
|
[](const LuaUtil::InputTrigger::Info& info) -> std::string_view { return info.mL10n; });
|
|
|
|
|
|
|
|
|
|
|
|
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
|
|
|
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
|
|
|
sol::table api(context.mLua->sol(), sol::create);
|
|
|
|
sol::table api(lua, sol::create);
|
|
|
|
|
|
|
|
|
|
|
|
api["ACTION_TYPE"]
|
|
|
|
api["ACTION_TYPE"]
|
|
|
|
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, LuaUtil::InputAction::Type>({
|
|
|
|
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, LuaUtil::InputAction::Type>(lua,
|
|
|
|
{ "Boolean", LuaUtil::InputAction::Type::Boolean },
|
|
|
|
{
|
|
|
|
{ "Number", LuaUtil::InputAction::Type::Number },
|
|
|
|
{ "Boolean", LuaUtil::InputAction::Type::Boolean },
|
|
|
|
{ "Range", LuaUtil::InputAction::Type::Range },
|
|
|
|
{ "Number", LuaUtil::InputAction::Type::Number },
|
|
|
|
}));
|
|
|
|
{ "Range", LuaUtil::InputAction::Type::Range },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
api["actions"] = std::ref(context.mLuaManager->inputActions());
|
|
|
|
api["actions"] = std::ref(context.mLuaManager->inputActions());
|
|
|
|
api["registerAction"] = [manager = context.mLuaManager](sol::table options) {
|
|
|
|
api["registerAction"] = [manager = context.mLuaManager](sol::table options) {
|
|
|
@ -231,215 +232,219 @@ namespace MWLua
|
|
|
|
|
|
|
|
|
|
|
|
api["getKeyName"] = [](SDL_Scancode code) { return SDL_GetScancodeName(code); };
|
|
|
|
api["getKeyName"] = [](SDL_Scancode code) { return SDL_GetScancodeName(code); };
|
|
|
|
|
|
|
|
|
|
|
|
api["ACTION"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, MWInput::Actions>({
|
|
|
|
api["ACTION"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, MWInput::Actions>(lua,
|
|
|
|
{ "GameMenu", MWInput::A_GameMenu },
|
|
|
|
{
|
|
|
|
{ "Screenshot", MWInput::A_Screenshot },
|
|
|
|
{ "GameMenu", MWInput::A_GameMenu },
|
|
|
|
{ "Inventory", MWInput::A_Inventory },
|
|
|
|
{ "Screenshot", MWInput::A_Screenshot },
|
|
|
|
{ "Console", MWInput::A_Console },
|
|
|
|
{ "Inventory", MWInput::A_Inventory },
|
|
|
|
|
|
|
|
{ "Console", MWInput::A_Console },
|
|
|
|
{ "MoveLeft", MWInput::A_MoveLeft },
|
|
|
|
|
|
|
|
{ "MoveRight", MWInput::A_MoveRight },
|
|
|
|
{ "MoveLeft", MWInput::A_MoveLeft },
|
|
|
|
{ "MoveForward", MWInput::A_MoveForward },
|
|
|
|
{ "MoveRight", MWInput::A_MoveRight },
|
|
|
|
{ "MoveBackward", MWInput::A_MoveBackward },
|
|
|
|
{ "MoveForward", MWInput::A_MoveForward },
|
|
|
|
|
|
|
|
{ "MoveBackward", MWInput::A_MoveBackward },
|
|
|
|
{ "Activate", MWInput::A_Activate },
|
|
|
|
|
|
|
|
{ "Use", MWInput::A_Use },
|
|
|
|
{ "Activate", MWInput::A_Activate },
|
|
|
|
{ "Jump", MWInput::A_Jump },
|
|
|
|
{ "Use", MWInput::A_Use },
|
|
|
|
{ "AutoMove", MWInput::A_AutoMove },
|
|
|
|
{ "Jump", MWInput::A_Jump },
|
|
|
|
{ "Rest", MWInput::A_Rest },
|
|
|
|
{ "AutoMove", MWInput::A_AutoMove },
|
|
|
|
{ "Journal", MWInput::A_Journal },
|
|
|
|
{ "Rest", MWInput::A_Rest },
|
|
|
|
{ "Run", MWInput::A_Run },
|
|
|
|
{ "Journal", MWInput::A_Journal },
|
|
|
|
{ "CycleSpellLeft", MWInput::A_CycleSpellLeft },
|
|
|
|
{ "Run", MWInput::A_Run },
|
|
|
|
{ "CycleSpellRight", MWInput::A_CycleSpellRight },
|
|
|
|
{ "CycleSpellLeft", MWInput::A_CycleSpellLeft },
|
|
|
|
{ "CycleWeaponLeft", MWInput::A_CycleWeaponLeft },
|
|
|
|
{ "CycleSpellRight", MWInput::A_CycleSpellRight },
|
|
|
|
{ "CycleWeaponRight", MWInput::A_CycleWeaponRight },
|
|
|
|
{ "CycleWeaponLeft", MWInput::A_CycleWeaponLeft },
|
|
|
|
{ "AlwaysRun", MWInput::A_AlwaysRun },
|
|
|
|
{ "CycleWeaponRight", MWInput::A_CycleWeaponRight },
|
|
|
|
{ "Sneak", MWInput::A_Sneak },
|
|
|
|
{ "AlwaysRun", MWInput::A_AlwaysRun },
|
|
|
|
|
|
|
|
{ "Sneak", MWInput::A_Sneak },
|
|
|
|
{ "QuickSave", MWInput::A_QuickSave },
|
|
|
|
|
|
|
|
{ "QuickLoad", MWInput::A_QuickLoad },
|
|
|
|
{ "QuickSave", MWInput::A_QuickSave },
|
|
|
|
{ "QuickMenu", MWInput::A_QuickMenu },
|
|
|
|
{ "QuickLoad", MWInput::A_QuickLoad },
|
|
|
|
{ "ToggleWeapon", MWInput::A_ToggleWeapon },
|
|
|
|
{ "QuickMenu", MWInput::A_QuickMenu },
|
|
|
|
{ "ToggleSpell", MWInput::A_ToggleSpell },
|
|
|
|
{ "ToggleWeapon", MWInput::A_ToggleWeapon },
|
|
|
|
{ "TogglePOV", MWInput::A_TogglePOV },
|
|
|
|
{ "ToggleSpell", MWInput::A_ToggleSpell },
|
|
|
|
|
|
|
|
{ "TogglePOV", MWInput::A_TogglePOV },
|
|
|
|
{ "QuickKey1", MWInput::A_QuickKey1 },
|
|
|
|
|
|
|
|
{ "QuickKey2", MWInput::A_QuickKey2 },
|
|
|
|
{ "QuickKey1", MWInput::A_QuickKey1 },
|
|
|
|
{ "QuickKey3", MWInput::A_QuickKey3 },
|
|
|
|
{ "QuickKey2", MWInput::A_QuickKey2 },
|
|
|
|
{ "QuickKey4", MWInput::A_QuickKey4 },
|
|
|
|
{ "QuickKey3", MWInput::A_QuickKey3 },
|
|
|
|
{ "QuickKey5", MWInput::A_QuickKey5 },
|
|
|
|
{ "QuickKey4", MWInput::A_QuickKey4 },
|
|
|
|
{ "QuickKey6", MWInput::A_QuickKey6 },
|
|
|
|
{ "QuickKey5", MWInput::A_QuickKey5 },
|
|
|
|
{ "QuickKey7", MWInput::A_QuickKey7 },
|
|
|
|
{ "QuickKey6", MWInput::A_QuickKey6 },
|
|
|
|
{ "QuickKey8", MWInput::A_QuickKey8 },
|
|
|
|
{ "QuickKey7", MWInput::A_QuickKey7 },
|
|
|
|
{ "QuickKey9", MWInput::A_QuickKey9 },
|
|
|
|
{ "QuickKey8", MWInput::A_QuickKey8 },
|
|
|
|
{ "QuickKey10", MWInput::A_QuickKey10 },
|
|
|
|
{ "QuickKey9", MWInput::A_QuickKey9 },
|
|
|
|
{ "QuickKeysMenu", MWInput::A_QuickKeysMenu },
|
|
|
|
{ "QuickKey10", MWInput::A_QuickKey10 },
|
|
|
|
|
|
|
|
{ "QuickKeysMenu", MWInput::A_QuickKeysMenu },
|
|
|
|
{ "ToggleHUD", MWInput::A_ToggleHUD },
|
|
|
|
|
|
|
|
{ "ToggleDebug", MWInput::A_ToggleDebug },
|
|
|
|
{ "ToggleHUD", MWInput::A_ToggleHUD },
|
|
|
|
{ "TogglePostProcessorHUD", MWInput::A_TogglePostProcessorHUD },
|
|
|
|
{ "ToggleDebug", MWInput::A_ToggleDebug },
|
|
|
|
|
|
|
|
{ "TogglePostProcessorHUD", MWInput::A_TogglePostProcessorHUD },
|
|
|
|
{ "ZoomIn", MWInput::A_ZoomIn },
|
|
|
|
|
|
|
|
{ "ZoomOut", MWInput::A_ZoomOut },
|
|
|
|
{ "ZoomIn", MWInput::A_ZoomIn },
|
|
|
|
}));
|
|
|
|
{ "ZoomOut", MWInput::A_ZoomOut },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
// input.CONTROL_SWITCH is deprecated, remove after releasing 0.49
|
|
|
|
// input.CONTROL_SWITCH is deprecated, remove after releasing 0.49
|
|
|
|
api["CONTROL_SWITCH"]
|
|
|
|
api["CONTROL_SWITCH"]
|
|
|
|
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, std::string_view>({
|
|
|
|
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, std::string_view>(lua,
|
|
|
|
{ "Controls", "playercontrols" },
|
|
|
|
{
|
|
|
|
{ "Fighting", "playerfighting" },
|
|
|
|
{ "Controls", "playercontrols" },
|
|
|
|
{ "Jumping", "playerjumping" },
|
|
|
|
{ "Fighting", "playerfighting" },
|
|
|
|
{ "Looking", "playerlooking" },
|
|
|
|
{ "Jumping", "playerjumping" },
|
|
|
|
{ "Magic", "playermagic" },
|
|
|
|
{ "Looking", "playerlooking" },
|
|
|
|
{ "ViewMode", "playerviewswitch" },
|
|
|
|
{ "Magic", "playermagic" },
|
|
|
|
{ "VanityMode", "vanitymode" },
|
|
|
|
{ "ViewMode", "playerviewswitch" },
|
|
|
|
}));
|
|
|
|
{ "VanityMode", "vanitymode" },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
api["CONTROLLER_BUTTON"]
|
|
|
|
api["CONTROLLER_BUTTON"]
|
|
|
|
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, SDL_GameControllerButton>({
|
|
|
|
= LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, SDL_GameControllerButton>(lua,
|
|
|
|
{ "A", SDL_CONTROLLER_BUTTON_A },
|
|
|
|
{
|
|
|
|
{ "B", SDL_CONTROLLER_BUTTON_B },
|
|
|
|
{ "A", SDL_CONTROLLER_BUTTON_A },
|
|
|
|
{ "X", SDL_CONTROLLER_BUTTON_X },
|
|
|
|
{ "B", SDL_CONTROLLER_BUTTON_B },
|
|
|
|
{ "Y", SDL_CONTROLLER_BUTTON_Y },
|
|
|
|
{ "X", SDL_CONTROLLER_BUTTON_X },
|
|
|
|
{ "Back", SDL_CONTROLLER_BUTTON_BACK },
|
|
|
|
{ "Y", SDL_CONTROLLER_BUTTON_Y },
|
|
|
|
{ "Guide", SDL_CONTROLLER_BUTTON_GUIDE },
|
|
|
|
{ "Back", SDL_CONTROLLER_BUTTON_BACK },
|
|
|
|
{ "Start", SDL_CONTROLLER_BUTTON_START },
|
|
|
|
{ "Guide", SDL_CONTROLLER_BUTTON_GUIDE },
|
|
|
|
{ "LeftStick", SDL_CONTROLLER_BUTTON_LEFTSTICK },
|
|
|
|
{ "Start", SDL_CONTROLLER_BUTTON_START },
|
|
|
|
{ "RightStick", SDL_CONTROLLER_BUTTON_RIGHTSTICK },
|
|
|
|
{ "LeftStick", SDL_CONTROLLER_BUTTON_LEFTSTICK },
|
|
|
|
{ "LeftShoulder", SDL_CONTROLLER_BUTTON_LEFTSHOULDER },
|
|
|
|
{ "RightStick", SDL_CONTROLLER_BUTTON_RIGHTSTICK },
|
|
|
|
{ "RightShoulder", SDL_CONTROLLER_BUTTON_RIGHTSHOULDER },
|
|
|
|
{ "LeftShoulder", SDL_CONTROLLER_BUTTON_LEFTSHOULDER },
|
|
|
|
{ "DPadUp", SDL_CONTROLLER_BUTTON_DPAD_UP },
|
|
|
|
{ "RightShoulder", SDL_CONTROLLER_BUTTON_RIGHTSHOULDER },
|
|
|
|
{ "DPadDown", SDL_CONTROLLER_BUTTON_DPAD_DOWN },
|
|
|
|
{ "DPadUp", SDL_CONTROLLER_BUTTON_DPAD_UP },
|
|
|
|
{ "DPadLeft", SDL_CONTROLLER_BUTTON_DPAD_LEFT },
|
|
|
|
{ "DPadDown", SDL_CONTROLLER_BUTTON_DPAD_DOWN },
|
|
|
|
{ "DPadRight", SDL_CONTROLLER_BUTTON_DPAD_RIGHT },
|
|
|
|
{ "DPadLeft", SDL_CONTROLLER_BUTTON_DPAD_LEFT },
|
|
|
|
|
|
|
|
{ "DPadRight", SDL_CONTROLLER_BUTTON_DPAD_RIGHT },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api["CONTROLLER_AXIS"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, int>(lua,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
{ "LeftX", SDL_CONTROLLER_AXIS_LEFTX },
|
|
|
|
|
|
|
|
{ "LeftY", SDL_CONTROLLER_AXIS_LEFTY },
|
|
|
|
|
|
|
|
{ "RightX", SDL_CONTROLLER_AXIS_RIGHTX },
|
|
|
|
|
|
|
|
{ "RightY", SDL_CONTROLLER_AXIS_RIGHTY },
|
|
|
|
|
|
|
|
{ "TriggerLeft", SDL_CONTROLLER_AXIS_TRIGGERLEFT },
|
|
|
|
|
|
|
|
{ "TriggerRight", SDL_CONTROLLER_AXIS_TRIGGERRIGHT },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "LookUpDown", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_LookUpDown) },
|
|
|
|
|
|
|
|
{ "LookLeftRight", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_LookLeftRight) },
|
|
|
|
|
|
|
|
{ "MoveForwardBackward", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_MoveForwardBackward) },
|
|
|
|
|
|
|
|
{ "MoveLeftRight", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_MoveLeftRight) },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api["KEY"] = LuaUtil::makeStrictReadOnly(LuaUtil::tableFromPairs<std::string_view, SDL_Scancode>(lua,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
{ "_0", SDL_SCANCODE_0 },
|
|
|
|
|
|
|
|
{ "_1", SDL_SCANCODE_1 },
|
|
|
|
|
|
|
|
{ "_2", SDL_SCANCODE_2 },
|
|
|
|
|
|
|
|
{ "_3", SDL_SCANCODE_3 },
|
|
|
|
|
|
|
|
{ "_4", SDL_SCANCODE_4 },
|
|
|
|
|
|
|
|
{ "_5", SDL_SCANCODE_5 },
|
|
|
|
|
|
|
|
{ "_6", SDL_SCANCODE_6 },
|
|
|
|
|
|
|
|
{ "_7", SDL_SCANCODE_7 },
|
|
|
|
|
|
|
|
{ "_8", SDL_SCANCODE_8 },
|
|
|
|
|
|
|
|
{ "_9", SDL_SCANCODE_9 },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "NP_0", SDL_SCANCODE_KP_0 },
|
|
|
|
|
|
|
|
{ "NP_1", SDL_SCANCODE_KP_1 },
|
|
|
|
|
|
|
|
{ "NP_2", SDL_SCANCODE_KP_2 },
|
|
|
|
|
|
|
|
{ "NP_3", SDL_SCANCODE_KP_3 },
|
|
|
|
|
|
|
|
{ "NP_4", SDL_SCANCODE_KP_4 },
|
|
|
|
|
|
|
|
{ "NP_5", SDL_SCANCODE_KP_5 },
|
|
|
|
|
|
|
|
{ "NP_6", SDL_SCANCODE_KP_6 },
|
|
|
|
|
|
|
|
{ "NP_7", SDL_SCANCODE_KP_7 },
|
|
|
|
|
|
|
|
{ "NP_8", SDL_SCANCODE_KP_8 },
|
|
|
|
|
|
|
|
{ "NP_9", SDL_SCANCODE_KP_9 },
|
|
|
|
|
|
|
|
{ "NP_Divide", SDL_SCANCODE_KP_DIVIDE },
|
|
|
|
|
|
|
|
{ "NP_Enter", SDL_SCANCODE_KP_ENTER },
|
|
|
|
|
|
|
|
{ "NP_Minus", SDL_SCANCODE_KP_MINUS },
|
|
|
|
|
|
|
|
{ "NP_Multiply", SDL_SCANCODE_KP_MULTIPLY },
|
|
|
|
|
|
|
|
{ "NP_Delete", SDL_SCANCODE_KP_PERIOD },
|
|
|
|
|
|
|
|
{ "NP_Plus", SDL_SCANCODE_KP_PLUS },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "F1", SDL_SCANCODE_F1 },
|
|
|
|
|
|
|
|
{ "F2", SDL_SCANCODE_F2 },
|
|
|
|
|
|
|
|
{ "F3", SDL_SCANCODE_F3 },
|
|
|
|
|
|
|
|
{ "F4", SDL_SCANCODE_F4 },
|
|
|
|
|
|
|
|
{ "F5", SDL_SCANCODE_F5 },
|
|
|
|
|
|
|
|
{ "F6", SDL_SCANCODE_F6 },
|
|
|
|
|
|
|
|
{ "F7", SDL_SCANCODE_F7 },
|
|
|
|
|
|
|
|
{ "F8", SDL_SCANCODE_F8 },
|
|
|
|
|
|
|
|
{ "F9", SDL_SCANCODE_F9 },
|
|
|
|
|
|
|
|
{ "F10", SDL_SCANCODE_F10 },
|
|
|
|
|
|
|
|
{ "F11", SDL_SCANCODE_F11 },
|
|
|
|
|
|
|
|
{ "F12", SDL_SCANCODE_F12 },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "A", SDL_SCANCODE_A },
|
|
|
|
|
|
|
|
{ "B", SDL_SCANCODE_B },
|
|
|
|
|
|
|
|
{ "C", SDL_SCANCODE_C },
|
|
|
|
|
|
|
|
{ "D", SDL_SCANCODE_D },
|
|
|
|
|
|
|
|
{ "E", SDL_SCANCODE_E },
|
|
|
|
|
|
|
|
{ "F", SDL_SCANCODE_F },
|
|
|
|
|
|
|
|
{ "G", SDL_SCANCODE_G },
|
|
|
|
|
|
|
|
{ "H", SDL_SCANCODE_H },
|
|
|
|
|
|
|
|
{ "I", SDL_SCANCODE_I },
|
|
|
|
|
|
|
|
{ "J", SDL_SCANCODE_J },
|
|
|
|
|
|
|
|
{ "K", SDL_SCANCODE_K },
|
|
|
|
|
|
|
|
{ "L", SDL_SCANCODE_L },
|
|
|
|
|
|
|
|
{ "M", SDL_SCANCODE_M },
|
|
|
|
|
|
|
|
{ "N", SDL_SCANCODE_N },
|
|
|
|
|
|
|
|
{ "O", SDL_SCANCODE_O },
|
|
|
|
|
|
|
|
{ "P", SDL_SCANCODE_P },
|
|
|
|
|
|
|
|
{ "Q", SDL_SCANCODE_Q },
|
|
|
|
|
|
|
|
{ "R", SDL_SCANCODE_R },
|
|
|
|
|
|
|
|
{ "S", SDL_SCANCODE_S },
|
|
|
|
|
|
|
|
{ "T", SDL_SCANCODE_T },
|
|
|
|
|
|
|
|
{ "U", SDL_SCANCODE_U },
|
|
|
|
|
|
|
|
{ "V", SDL_SCANCODE_V },
|
|
|
|
|
|
|
|
{ "W", SDL_SCANCODE_W },
|
|
|
|
|
|
|
|
{ "X", SDL_SCANCODE_X },
|
|
|
|
|
|
|
|
{ "Y", SDL_SCANCODE_Y },
|
|
|
|
|
|
|
|
{ "Z", SDL_SCANCODE_Z },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "LeftArrow", SDL_SCANCODE_LEFT },
|
|
|
|
|
|
|
|
{ "RightArrow", SDL_SCANCODE_RIGHT },
|
|
|
|
|
|
|
|
{ "UpArrow", SDL_SCANCODE_UP },
|
|
|
|
|
|
|
|
{ "DownArrow", SDL_SCANCODE_DOWN },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "LeftAlt", SDL_SCANCODE_LALT },
|
|
|
|
|
|
|
|
{ "LeftCtrl", SDL_SCANCODE_LCTRL },
|
|
|
|
|
|
|
|
{ "LeftBracket", SDL_SCANCODE_LEFTBRACKET },
|
|
|
|
|
|
|
|
{ "LeftSuper", SDL_SCANCODE_LGUI },
|
|
|
|
|
|
|
|
{ "LeftShift", SDL_SCANCODE_LSHIFT },
|
|
|
|
|
|
|
|
{ "RightAlt", SDL_SCANCODE_RALT },
|
|
|
|
|
|
|
|
{ "RightCtrl", SDL_SCANCODE_RCTRL },
|
|
|
|
|
|
|
|
{ "RightSuper", SDL_SCANCODE_RGUI },
|
|
|
|
|
|
|
|
{ "RightBracket", SDL_SCANCODE_RIGHTBRACKET },
|
|
|
|
|
|
|
|
{ "RightShift", SDL_SCANCODE_RSHIFT },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "Apostrophe", SDL_SCANCODE_APOSTROPHE },
|
|
|
|
|
|
|
|
{ "BackSlash", SDL_SCANCODE_BACKSLASH },
|
|
|
|
|
|
|
|
{ "Backspace", SDL_SCANCODE_BACKSPACE },
|
|
|
|
|
|
|
|
{ "CapsLock", SDL_SCANCODE_CAPSLOCK },
|
|
|
|
|
|
|
|
{ "Comma", SDL_SCANCODE_COMMA },
|
|
|
|
|
|
|
|
{ "Delete", SDL_SCANCODE_DELETE },
|
|
|
|
|
|
|
|
{ "End", SDL_SCANCODE_END },
|
|
|
|
|
|
|
|
{ "Enter", SDL_SCANCODE_RETURN },
|
|
|
|
|
|
|
|
{ "Equals", SDL_SCANCODE_EQUALS },
|
|
|
|
|
|
|
|
{ "Escape", SDL_SCANCODE_ESCAPE },
|
|
|
|
|
|
|
|
{ "Home", SDL_SCANCODE_HOME },
|
|
|
|
|
|
|
|
{ "Insert", SDL_SCANCODE_INSERT },
|
|
|
|
|
|
|
|
{ "Minus", SDL_SCANCODE_MINUS },
|
|
|
|
|
|
|
|
{ "NumLock", SDL_SCANCODE_NUMLOCKCLEAR },
|
|
|
|
|
|
|
|
{ "PageDown", SDL_SCANCODE_PAGEDOWN },
|
|
|
|
|
|
|
|
{ "PageUp", SDL_SCANCODE_PAGEUP },
|
|
|
|
|
|
|
|
{ "Period", SDL_SCANCODE_PERIOD },
|
|
|
|
|
|
|
|
{ "Pause", SDL_SCANCODE_PAUSE },
|
|
|
|
|
|
|
|
{ "PrintScreen", SDL_SCANCODE_PRINTSCREEN },
|
|
|
|
|
|
|
|
{ "ScrollLock", SDL_SCANCODE_SCROLLLOCK },
|
|
|
|
|
|
|
|
{ "Semicolon", SDL_SCANCODE_SEMICOLON },
|
|
|
|
|
|
|
|
{ "Slash", SDL_SCANCODE_SLASH },
|
|
|
|
|
|
|
|
{ "Space", SDL_SCANCODE_SPACE },
|
|
|
|
|
|
|
|
{ "Tab", SDL_SCANCODE_TAB },
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
api["CONTROLLER_AXIS"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, int>({
|
|
|
|
|
|
|
|
{ "LeftX", SDL_CONTROLLER_AXIS_LEFTX },
|
|
|
|
|
|
|
|
{ "LeftY", SDL_CONTROLLER_AXIS_LEFTY },
|
|
|
|
|
|
|
|
{ "RightX", SDL_CONTROLLER_AXIS_RIGHTX },
|
|
|
|
|
|
|
|
{ "RightY", SDL_CONTROLLER_AXIS_RIGHTY },
|
|
|
|
|
|
|
|
{ "TriggerLeft", SDL_CONTROLLER_AXIS_TRIGGERLEFT },
|
|
|
|
|
|
|
|
{ "TriggerRight", SDL_CONTROLLER_AXIS_TRIGGERRIGHT },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "LookUpDown", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_LookUpDown) },
|
|
|
|
|
|
|
|
{ "LookLeftRight", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_LookLeftRight) },
|
|
|
|
|
|
|
|
{ "MoveForwardBackward", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_MoveForwardBackward) },
|
|
|
|
|
|
|
|
{ "MoveLeftRight", SDL_CONTROLLER_AXIS_MAX + static_cast<int>(MWInput::A_MoveLeftRight) },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
api["KEY"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, SDL_Scancode>({
|
|
|
|
|
|
|
|
{ "_0", SDL_SCANCODE_0 },
|
|
|
|
|
|
|
|
{ "_1", SDL_SCANCODE_1 },
|
|
|
|
|
|
|
|
{ "_2", SDL_SCANCODE_2 },
|
|
|
|
|
|
|
|
{ "_3", SDL_SCANCODE_3 },
|
|
|
|
|
|
|
|
{ "_4", SDL_SCANCODE_4 },
|
|
|
|
|
|
|
|
{ "_5", SDL_SCANCODE_5 },
|
|
|
|
|
|
|
|
{ "_6", SDL_SCANCODE_6 },
|
|
|
|
|
|
|
|
{ "_7", SDL_SCANCODE_7 },
|
|
|
|
|
|
|
|
{ "_8", SDL_SCANCODE_8 },
|
|
|
|
|
|
|
|
{ "_9", SDL_SCANCODE_9 },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "NP_0", SDL_SCANCODE_KP_0 },
|
|
|
|
|
|
|
|
{ "NP_1", SDL_SCANCODE_KP_1 },
|
|
|
|
|
|
|
|
{ "NP_2", SDL_SCANCODE_KP_2 },
|
|
|
|
|
|
|
|
{ "NP_3", SDL_SCANCODE_KP_3 },
|
|
|
|
|
|
|
|
{ "NP_4", SDL_SCANCODE_KP_4 },
|
|
|
|
|
|
|
|
{ "NP_5", SDL_SCANCODE_KP_5 },
|
|
|
|
|
|
|
|
{ "NP_6", SDL_SCANCODE_KP_6 },
|
|
|
|
|
|
|
|
{ "NP_7", SDL_SCANCODE_KP_7 },
|
|
|
|
|
|
|
|
{ "NP_8", SDL_SCANCODE_KP_8 },
|
|
|
|
|
|
|
|
{ "NP_9", SDL_SCANCODE_KP_9 },
|
|
|
|
|
|
|
|
{ "NP_Divide", SDL_SCANCODE_KP_DIVIDE },
|
|
|
|
|
|
|
|
{ "NP_Enter", SDL_SCANCODE_KP_ENTER },
|
|
|
|
|
|
|
|
{ "NP_Minus", SDL_SCANCODE_KP_MINUS },
|
|
|
|
|
|
|
|
{ "NP_Multiply", SDL_SCANCODE_KP_MULTIPLY },
|
|
|
|
|
|
|
|
{ "NP_Delete", SDL_SCANCODE_KP_PERIOD },
|
|
|
|
|
|
|
|
{ "NP_Plus", SDL_SCANCODE_KP_PLUS },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "F1", SDL_SCANCODE_F1 },
|
|
|
|
|
|
|
|
{ "F2", SDL_SCANCODE_F2 },
|
|
|
|
|
|
|
|
{ "F3", SDL_SCANCODE_F3 },
|
|
|
|
|
|
|
|
{ "F4", SDL_SCANCODE_F4 },
|
|
|
|
|
|
|
|
{ "F5", SDL_SCANCODE_F5 },
|
|
|
|
|
|
|
|
{ "F6", SDL_SCANCODE_F6 },
|
|
|
|
|
|
|
|
{ "F7", SDL_SCANCODE_F7 },
|
|
|
|
|
|
|
|
{ "F8", SDL_SCANCODE_F8 },
|
|
|
|
|
|
|
|
{ "F9", SDL_SCANCODE_F9 },
|
|
|
|
|
|
|
|
{ "F10", SDL_SCANCODE_F10 },
|
|
|
|
|
|
|
|
{ "F11", SDL_SCANCODE_F11 },
|
|
|
|
|
|
|
|
{ "F12", SDL_SCANCODE_F12 },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "A", SDL_SCANCODE_A },
|
|
|
|
|
|
|
|
{ "B", SDL_SCANCODE_B },
|
|
|
|
|
|
|
|
{ "C", SDL_SCANCODE_C },
|
|
|
|
|
|
|
|
{ "D", SDL_SCANCODE_D },
|
|
|
|
|
|
|
|
{ "E", SDL_SCANCODE_E },
|
|
|
|
|
|
|
|
{ "F", SDL_SCANCODE_F },
|
|
|
|
|
|
|
|
{ "G", SDL_SCANCODE_G },
|
|
|
|
|
|
|
|
{ "H", SDL_SCANCODE_H },
|
|
|
|
|
|
|
|
{ "I", SDL_SCANCODE_I },
|
|
|
|
|
|
|
|
{ "J", SDL_SCANCODE_J },
|
|
|
|
|
|
|
|
{ "K", SDL_SCANCODE_K },
|
|
|
|
|
|
|
|
{ "L", SDL_SCANCODE_L },
|
|
|
|
|
|
|
|
{ "M", SDL_SCANCODE_M },
|
|
|
|
|
|
|
|
{ "N", SDL_SCANCODE_N },
|
|
|
|
|
|
|
|
{ "O", SDL_SCANCODE_O },
|
|
|
|
|
|
|
|
{ "P", SDL_SCANCODE_P },
|
|
|
|
|
|
|
|
{ "Q", SDL_SCANCODE_Q },
|
|
|
|
|
|
|
|
{ "R", SDL_SCANCODE_R },
|
|
|
|
|
|
|
|
{ "S", SDL_SCANCODE_S },
|
|
|
|
|
|
|
|
{ "T", SDL_SCANCODE_T },
|
|
|
|
|
|
|
|
{ "U", SDL_SCANCODE_U },
|
|
|
|
|
|
|
|
{ "V", SDL_SCANCODE_V },
|
|
|
|
|
|
|
|
{ "W", SDL_SCANCODE_W },
|
|
|
|
|
|
|
|
{ "X", SDL_SCANCODE_X },
|
|
|
|
|
|
|
|
{ "Y", SDL_SCANCODE_Y },
|
|
|
|
|
|
|
|
{ "Z", SDL_SCANCODE_Z },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "LeftArrow", SDL_SCANCODE_LEFT },
|
|
|
|
|
|
|
|
{ "RightArrow", SDL_SCANCODE_RIGHT },
|
|
|
|
|
|
|
|
{ "UpArrow", SDL_SCANCODE_UP },
|
|
|
|
|
|
|
|
{ "DownArrow", SDL_SCANCODE_DOWN },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "LeftAlt", SDL_SCANCODE_LALT },
|
|
|
|
|
|
|
|
{ "LeftCtrl", SDL_SCANCODE_LCTRL },
|
|
|
|
|
|
|
|
{ "LeftBracket", SDL_SCANCODE_LEFTBRACKET },
|
|
|
|
|
|
|
|
{ "LeftSuper", SDL_SCANCODE_LGUI },
|
|
|
|
|
|
|
|
{ "LeftShift", SDL_SCANCODE_LSHIFT },
|
|
|
|
|
|
|
|
{ "RightAlt", SDL_SCANCODE_RALT },
|
|
|
|
|
|
|
|
{ "RightCtrl", SDL_SCANCODE_RCTRL },
|
|
|
|
|
|
|
|
{ "RightSuper", SDL_SCANCODE_RGUI },
|
|
|
|
|
|
|
|
{ "RightBracket", SDL_SCANCODE_RIGHTBRACKET },
|
|
|
|
|
|
|
|
{ "RightShift", SDL_SCANCODE_RSHIFT },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ "Apostrophe", SDL_SCANCODE_APOSTROPHE },
|
|
|
|
|
|
|
|
{ "BackSlash", SDL_SCANCODE_BACKSLASH },
|
|
|
|
|
|
|
|
{ "Backspace", SDL_SCANCODE_BACKSPACE },
|
|
|
|
|
|
|
|
{ "CapsLock", SDL_SCANCODE_CAPSLOCK },
|
|
|
|
|
|
|
|
{ "Comma", SDL_SCANCODE_COMMA },
|
|
|
|
|
|
|
|
{ "Delete", SDL_SCANCODE_DELETE },
|
|
|
|
|
|
|
|
{ "End", SDL_SCANCODE_END },
|
|
|
|
|
|
|
|
{ "Enter", SDL_SCANCODE_RETURN },
|
|
|
|
|
|
|
|
{ "Equals", SDL_SCANCODE_EQUALS },
|
|
|
|
|
|
|
|
{ "Escape", SDL_SCANCODE_ESCAPE },
|
|
|
|
|
|
|
|
{ "Home", SDL_SCANCODE_HOME },
|
|
|
|
|
|
|
|
{ "Insert", SDL_SCANCODE_INSERT },
|
|
|
|
|
|
|
|
{ "Minus", SDL_SCANCODE_MINUS },
|
|
|
|
|
|
|
|
{ "NumLock", SDL_SCANCODE_NUMLOCKCLEAR },
|
|
|
|
|
|
|
|
{ "PageDown", SDL_SCANCODE_PAGEDOWN },
|
|
|
|
|
|
|
|
{ "PageUp", SDL_SCANCODE_PAGEUP },
|
|
|
|
|
|
|
|
{ "Period", SDL_SCANCODE_PERIOD },
|
|
|
|
|
|
|
|
{ "Pause", SDL_SCANCODE_PAUSE },
|
|
|
|
|
|
|
|
{ "PrintScreen", SDL_SCANCODE_PRINTSCREEN },
|
|
|
|
|
|
|
|
{ "ScrollLock", SDL_SCANCODE_SCROLLLOCK },
|
|
|
|
|
|
|
|
{ "Semicolon", SDL_SCANCODE_SEMICOLON },
|
|
|
|
|
|
|
|
{ "Slash", SDL_SCANCODE_SLASH },
|
|
|
|
|
|
|
|
{ "Space", SDL_SCANCODE_SPACE },
|
|
|
|
|
|
|
|
{ "Tab", SDL_SCANCODE_TAB },
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sol::state_view& lua = context.mLua->sol();
|
|
|
|
|
|
|
|
lua["openmw_input"] = LuaUtil::makeReadOnly(api);
|
|
|
|
lua["openmw_input"] = LuaUtil::makeReadOnly(api);
|
|
|
|
return lua["openmw_input"];
|
|
|
|
return lua["openmw_input"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|