mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 00:32:49 +00:00
Mouse input engine handlers
This commit is contained in:
parent
3301ebb2cb
commit
c68dee214e
@ -81,6 +81,12 @@ namespace MWBase
|
|||||||
|
|
||||||
struct InputEvent
|
struct InputEvent
|
||||||
{
|
{
|
||||||
|
struct WheelChange
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
KeyPressed,
|
KeyPressed,
|
||||||
@ -91,8 +97,11 @@ namespace MWBase
|
|||||||
TouchPressed,
|
TouchPressed,
|
||||||
TouchReleased,
|
TouchReleased,
|
||||||
TouchMoved,
|
TouchMoved,
|
||||||
|
MouseButtonPressed,
|
||||||
|
MouseButtonReleased,
|
||||||
|
MouseWheel,
|
||||||
} mType;
|
} mType;
|
||||||
std::variant<SDL_Keysym, int, SDLUtil::TouchEvent> mValue;
|
std::variant<SDL_Keysym, int, SDLUtil::TouchEvent, WheelChange> mValue;
|
||||||
};
|
};
|
||||||
virtual void inputEvent(const InputEvent& event) = 0;
|
virtual void inputEvent(const InputEvent& event) = 0;
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/inputmanager.hpp"
|
#include "../mwbase/inputmanager.hpp"
|
||||||
|
#include "../mwbase/luamanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
@ -118,6 +119,8 @@ namespace MWInput
|
|||||||
|
|
||||||
mBindingsManager->setPlayerControlsEnabled(!guiMode);
|
mBindingsManager->setPlayerControlsEnabled(!guiMode);
|
||||||
mBindingsManager->mouseReleased(arg, id);
|
mBindingsManager->mouseReleased(arg, id);
|
||||||
|
MWBase::Environment::get().getLuaManager()->inputEvent(
|
||||||
|
{ MWBase::LuaManager::InputEvent::MouseButtonReleased, arg.button });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +128,11 @@ namespace MWInput
|
|||||||
{
|
{
|
||||||
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
||||||
if (mBindingsManager->isDetectingBindingState() || !input->controlsDisabled())
|
if (mBindingsManager->isDetectingBindingState() || !input->controlsDisabled())
|
||||||
|
{
|
||||||
mBindingsManager->mouseWheelMoved(arg);
|
mBindingsManager->mouseWheelMoved(arg);
|
||||||
|
MWBase::Environment::get().getLuaManager()->inputEvent({ MWBase::LuaManager::InputEvent::MouseWheel,
|
||||||
|
MWBase::LuaManager::InputEvent::WheelChange{ arg.x, arg.y } });
|
||||||
|
}
|
||||||
|
|
||||||
input->setJoystickLastUsed(false);
|
input->setJoystickLastUsed(false);
|
||||||
}
|
}
|
||||||
@ -161,7 +168,11 @@ namespace MWInput
|
|||||||
const MWGui::SettingsWindow* settingsWindow
|
const MWGui::SettingsWindow* settingsWindow
|
||||||
= MWBase::Environment::get().getWindowManager()->getSettingsWindow();
|
= MWBase::Environment::get().getWindowManager()->getSettingsWindow();
|
||||||
if ((!settingsWindow || !settingsWindow->isVisible()) && !input->controlsDisabled())
|
if ((!settingsWindow || !settingsWindow->isVisible()) && !input->controlsDisabled())
|
||||||
|
{
|
||||||
mBindingsManager->mousePressed(arg, id);
|
mBindingsManager->mousePressed(arg, id);
|
||||||
|
MWBase::Environment::get().getLuaManager()->inputEvent(
|
||||||
|
{ MWBase::LuaManager::InputEvent::MouseButtonPressed, arg.button });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseManager::updateCursorMode()
|
void MouseManager::updateCursorMode()
|
||||||
|
@ -18,7 +18,7 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
mScriptsContainer->registerEngineHandlers({ &mKeyPressHandlers, &mKeyReleaseHandlers,
|
mScriptsContainer->registerEngineHandlers({ &mKeyPressHandlers, &mKeyReleaseHandlers,
|
||||||
&mControllerButtonPressHandlers, &mControllerButtonReleaseHandlers, &mActionHandlers, &mTouchpadPressed,
|
&mControllerButtonPressHandlers, &mControllerButtonReleaseHandlers, &mActionHandlers, &mTouchpadPressed,
|
||||||
&mTouchpadReleased, &mTouchpadMoved });
|
&mTouchpadReleased, &mTouchpadMoved, &mMouseButtonPress, &mMouseButtonRelease, &mMouseWheel });
|
||||||
}
|
}
|
||||||
|
|
||||||
void processInputEvent(const MWBase::LuaManager::InputEvent& event)
|
void processInputEvent(const MWBase::LuaManager::InputEvent& event)
|
||||||
@ -53,6 +53,16 @@ namespace MWLua
|
|||||||
case InputEvent::TouchMoved:
|
case InputEvent::TouchMoved:
|
||||||
mScriptsContainer->callEngineHandlers(mTouchpadMoved, std::get<SDLUtil::TouchEvent>(event.mValue));
|
mScriptsContainer->callEngineHandlers(mTouchpadMoved, std::get<SDLUtil::TouchEvent>(event.mValue));
|
||||||
break;
|
break;
|
||||||
|
case InputEvent::MouseButtonPressed:
|
||||||
|
mScriptsContainer->callEngineHandlers(mMouseButtonPress, std::get<int>(event.mValue));
|
||||||
|
break;
|
||||||
|
case InputEvent::MouseButtonReleased:
|
||||||
|
mScriptsContainer->callEngineHandlers(mMouseButtonRelease, std::get<int>(event.mValue));
|
||||||
|
break;
|
||||||
|
case InputEvent::MouseWheel:
|
||||||
|
auto wheelEvent = std::get<MWBase::LuaManager::InputEvent::WheelChange>(event.mValue);
|
||||||
|
mScriptsContainer->callEngineHandlers(mMouseWheel, wheelEvent.y, wheelEvent.x);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +76,9 @@ namespace MWLua
|
|||||||
typename Container::EngineHandlerList mTouchpadPressed{ "onTouchPress" };
|
typename Container::EngineHandlerList mTouchpadPressed{ "onTouchPress" };
|
||||||
typename Container::EngineHandlerList mTouchpadReleased{ "onTouchRelease" };
|
typename Container::EngineHandlerList mTouchpadReleased{ "onTouchRelease" };
|
||||||
typename Container::EngineHandlerList mTouchpadMoved{ "onTouchMove" };
|
typename Container::EngineHandlerList mTouchpadMoved{ "onTouchMove" };
|
||||||
|
typename Container::EngineHandlerList mMouseButtonPress{ "onMouseButtonPress" };
|
||||||
|
typename Container::EngineHandlerList mMouseButtonRelease{ "onMouseButtonRelease" };
|
||||||
|
typename Container::EngineHandlerList mMouseWheel{ "onMouseWheel" };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,15 @@ Engine handler is a function defined by a script, that can be called by the engi
|
|||||||
* - onTouchMove(touchEvent)
|
* - onTouchMove(touchEvent)
|
||||||
- | A finger moved on a touch device.
|
- | A finger moved on a touch device.
|
||||||
| `Touch event <openmw_input.html##(TouchEvent)>`_.
|
| `Touch event <openmw_input.html##(TouchEvent)>`_.
|
||||||
|
* - onMouseButtonPress(button)
|
||||||
|
- | A mouse button was pressed
|
||||||
|
| Button id
|
||||||
|
* - onMouseButtonRelease(button)
|
||||||
|
- | A mouse button was released
|
||||||
|
| Button id
|
||||||
|
* - onMouseWheel(vertical, horizontal)
|
||||||
|
- | Mouse wheel was scrolled
|
||||||
|
| vertical and horizontal mouse wheel change
|
||||||
* - | onConsoleCommand(
|
* - | onConsoleCommand(
|
||||||
| mode, command, selectedObject)
|
| mode, command, selectedObject)
|
||||||
- | User entered `command` in in-game console. Called if either
|
- | User entered `command` in in-game console. Called if either
|
||||||
|
Loading…
x
Reference in New Issue
Block a user