1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2026-02-10 05:38:30 +00:00

Expose controller menus setting to Lua

This commit is contained in:
Andrew Lanzone 2025-07-04 11:53:36 -07:00
parent 64284063b3
commit ce0ae47478
2 changed files with 11 additions and 3 deletions

View file

@ -7,6 +7,7 @@
#include <components/lua/inputactions.hpp>
#include <components/lua/luastate.hpp>
#include <components/sdlutil/events.hpp>
#include <components/settings/values.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
@ -69,9 +70,8 @@ namespace MWLua
= 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["position"] = sol::readonly_property([](const SDLUtil::TouchEvent& e) -> osg::Vec2f {
return { e.mX, e.mY };
});
touchpadEvent["position"]
= sol::readonly_property([](const SDLUtil::TouchEvent& e) -> osg::Vec2f { return { e.mX, e.mY }; });
touchpadEvent["pressure"]
= sol::readonly_property([](const SDLUtil::TouchEvent& e) -> float { return e.mPressure; });
return sol::table(lua, sol::create);
@ -239,6 +239,7 @@ namespace MWLua
api["isMouseButtonPressed"]
= [](int button) -> bool { return SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(button); };
api["_isGamepadCursorActive"] = [input]() -> bool { return input->isGamepadGuiCursorEnabled(); };
api["_isControllerMenusEnabled"] = [input]() -> bool { return Settings::gui().mControllerMenus; };
api["_setGamepadCursorActive"] = [input](bool v) {
input->setGamepadGuiCursorEnabled(v);
MWBase::Environment::get().getWindowManager()->setCursorActive(v);

View file

@ -20,6 +20,13 @@ return {
return input._isGamepadCursorActive()
end,
--- Checks if the controller menu option is enabled. If true, UI is replaced with a more controller appropriate interface.
-- @function [parent=#GamepadControls] isControllerMenusEnabled
-- @return #boolean
isControllerMenusEnabled = function()
return input._isControllerMenusEnabled()
end,
--- Sets if the gamepad cursor is active. If it is active, the left stick can move the cursor, and A will be interpreted as a mouse click.
-- @function [parent=#GamepadControls] setGamepadCursorActive
-- @param #boolean value