Move gamepad controls to lua interface

pull/3235/head
Zackhasacat 3 months ago
parent c2782426fc
commit 873877795a

@ -202,8 +202,8 @@ 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) {
api["_isGamepadCursorActive"] = [input]() -> bool { return input->isGamepadGuiCursorEnabled(); };
api["_setGamepadCursorActive"] = [input](bool v) {
input->setGamepadGuiCursorEnabled(v);
MWBase::Environment::get().getWindowManager()->setCursorActive(v);
};

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

@ -37,6 +37,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

@ -95,7 +95,8 @@ set(BUILTIN_DATA_FILES
scripts/omw/worldeventhandlers.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

@ -16,6 +16,7 @@ PLAYER: scripts/omw/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,
}
}

@ -28,16 +28,6 @@
-- @param #number buttonId Button index (see @{openmw.input#CONTROLLER_BUTTON})
-- @return #boolean
---
-- 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=#input] isGamepadCursorActive
-- @return #boolean
---
-- 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=#input] setGamepadCursorActive
-- @param #boolean value
---
-- Is `Shift` key pressed.
-- @function [parent=#input] isShiftPressed

Loading…
Cancel
Save