1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-12 22:43:07 +00:00

Add bindings for controller cursor mode

This commit is contained in:
Zackhasacat 2023-11-28 19:58:41 -06:00
parent ae3f9f8dcf
commit 4beac9035a
5 changed files with 23 additions and 0 deletions

View file

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

View file

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

View file

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

View file

@ -9,6 +9,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwinput/actions.hpp" #include "../mwinput/actions.hpp"
namespace sol namespace sol
@ -68,6 +69,11 @@ namespace MWLua
}; };
api["isMouseButtonPressed"] api["isMouseButtonPressed"]
= [](int button) -> bool { return SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(button); }; = [](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["getMouseMoveX"] = [input]() { return input->getMouseMoveX(); };
api["getMouseMoveY"] = [input]() { return input->getMouseMoveY(); }; api["getMouseMoveY"] = [input]() { return input->getMouseMoveY(); };
api["getAxisValue"] = [input](int axis) { api["getAxisValue"] = [input](int axis) {

View file

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