Merge branch 'lua_controller_cursor' into 'master'

Add lua bindings for controller cursor mode

See merge request OpenMW/openmw!3623
master
psi29a 2 weeks ago
commit 3980bb15cc

@ -81,7 +81,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 49)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 59)
set(OPENMW_LUA_API_REVISION 60)
set(OPENMW_POSTPROCESSING_API_REVISION 1)
set(OPENMW_VERSION_COMMITHASH "")

@ -45,6 +45,7 @@ namespace MWBase
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& changed) = 0;
virtual void setDragDrop(bool dragDrop) = 0;
virtual bool isGamepadGuiCursorEnabled() = 0;
virtual void setGamepadGuiCursorEnabled(bool enabled) = 0;
virtual void toggleControlSwitch(std::string_view sw, bool value) = 0;

@ -102,6 +102,11 @@ namespace MWInput
mControllerManager->setGamepadGuiCursorEnabled(enabled);
}
bool InputManager::isGamepadGuiCursorEnabled()
{
return mControllerManager->gamepadGuiCursorEnabled();
}
void InputManager::changeInputMode(bool guiMode)
{
mControllerManager->setGuiCursorEnabled(guiMode);

@ -68,6 +68,7 @@ namespace MWInput
void setDragDrop(bool dragDrop) override;
void setGamepadGuiCursorEnabled(bool enabled) override;
bool isGamepadGuiCursorEnabled() override;
void toggleControlSwitch(std::string_view sw, bool value) override;
bool getControlSwitch(std::string_view sw) override;

@ -10,6 +10,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwinput/actions.hpp"
#include "luamanagerimp.hpp"
@ -208,6 +209,11 @@ namespace MWLua
};
api["isMouseButtonPressed"]
= [](int button) -> bool { return SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(button); };
api["_isGamepadCursorActive"] = [input]() -> bool { return input->isGamepadGuiCursorEnabled(); };
api["_setGamepadCursorActive"] = [input](bool v) {
input->setGamepadGuiCursorEnabled(v);
MWBase::Environment::get().getWindowManager()->setCursorActive(v);
};
api["getMouseMoveX"] = [input]() { return input->getMouseMoveX(); };
api["getMouseMoveY"] = [input]() { return input->getMouseMoveY(); };
api["getAxisValue"] = [input](int axis) {

@ -4,6 +4,7 @@ paths=(
scripts/omw/ai.lua
scripts/omw/input/playercontrols.lua
scripts/omw/mechanics/animationcontroller.lua
scripts/omw/input/gamepadcontrols.lua
scripts/omw/camera/camera.lua
scripts/omw/mwui/init.lua
scripts/omw/settings/player.lua

@ -39,6 +39,7 @@ Lua API reference
interface_animation
interface_camera
interface_controls
interface_gamepadcontrols
interface_item_usage
interface_mwui
interface_settings

@ -0,0 +1,8 @@
Interface GamepadControls
=========================
.. include:: version.rst
.. raw:: html
:file: generated_html/scripts_omw_input_gamepadcontrols.html

@ -21,6 +21,10 @@
- by player scripts
- | Allows to alter behavior of the built-in script
| that handles player controls.
* - :ref:`Controls <Interface GamepadControls>`
- by player scripts
- | Allows to alter behavior of the built-in script
| that handles player gamepad controls.
* - :ref:`ItemUsage <Interface ItemUsage>`
- by global scripts
- | Allows to extend or override built-in item usage

@ -98,7 +98,8 @@ set(BUILTIN_DATA_FILES
scripts/omw/input/playercontrols.lua
scripts/omw/input/actionbindings.lua
scripts/omw/input/smoothmovement.lua
scripts/omw/input/gamepadcontrols.lua
shaders/adjustments.omwfx
shaders/bloomlinear.omwfx
shaders/debug.omwfx

@ -20,6 +20,7 @@ PLAYER: scripts/omw/input/playercontrols.lua
PLAYER: scripts/omw/camera/camera.lua
PLAYER: scripts/omw/input/actionbindings.lua
PLAYER: scripts/omw/input/smoothmovement.lua
PLAYER: scripts/omw/input/gamepadcontrols.lua
NPC,CREATURE: scripts/omw/ai.lua
# User interface

@ -0,0 +1,29 @@
local input = require('openmw.input')
return {
interfaceName = 'GamepadControls',
---
-- Gamepad control interface
-- @module GamepadControls
interface = {
--- Interface version
-- @field [parent=#GamepadControls] #number version
version = 0,
--- Checks 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] isGamepadCursorActive
-- @return #boolean
isGamepadCursorActive = function()
return input._isGamepadCursorActive()
end,
--- Set 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
setGamepadCursorActive = function(state)
input._setGamepadCursorActive(state)
end,
}
}
Loading…
Cancel
Save