1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-18 13:12:50 +00:00
OpenMW/apps/openmw/mwinput/inputmanagerimp.hpp

136 lines
4.0 KiB
C++
Raw Normal View History

#ifndef MWINPUT_MWINPUTMANAGERIMP_H
#define MWINPUT_MWINPUTMANAGERIMP_H
2015-05-13 16:50:47 +02:00
#include <osg/ref_ptr>
2017-11-09 18:26:27 +01:00
#include <osgViewer/ViewerEventHandlers>
2015-05-13 16:50:47 +02:00
#include <components/settings/settings.hpp>
2015-05-13 16:50:47 +02:00
#include <components/sdlutil/events.hpp>
#include "../mwbase/inputmanager.hpp"
2015-05-13 16:50:47 +02:00
2020-04-17 15:59:37 +04:00
#include "../mwgui/mode.hpp"
#include "actions.hpp"
namespace MWWorld
2010-07-17 19:58:15 +02:00
{
2012-08-12 20:45:02 +02:00
class Player;
2010-07-17 19:58:15 +02:00
}
namespace MWBase
2010-07-17 19:58:15 +02:00
{
2012-08-12 20:45:02 +02:00
class WindowManager;
2010-07-17 19:58:15 +02:00
}
2015-05-13 16:50:47 +02:00
namespace SDLUtil
{
class InputWrapper;
}
struct SDL_Window;
2012-08-12 20:45:02 +02:00
namespace MWInput
{
2020-04-17 16:51:47 +04:00
class ControlSwitch;
class ActionManager;
class BindingsManager;
class ControllerManager;
class KeyboardManager;
class MouseManager;
class SensorManager;
2022-01-18 22:47:49 +01:00
class GyroManager;
2020-04-17 16:51:47 +04:00
2012-08-12 20:45:02 +02:00
/**
2020-04-17 16:51:47 +04:00
* @brief Class that provides a high-level API for game input
2012-08-12 20:45:02 +02:00
*/
2020-04-17 16:51:47 +04:00
class InputManager : public MWBase::InputManager
2012-08-12 20:45:02 +02:00
{
public:
2015-05-03 17:24:35 +02:00
InputManager(
2015-05-13 16:50:47 +02:00
SDL_Window* window,
osg::ref_ptr<osgViewer::Viewer> viewer,
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
2017-11-09 18:26:27 +01:00
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
const std::string& userFile, bool userFileExists,
2019-08-03 19:55:58 +00:00
const std::string& userControllerBindingsFile,
const std::string& controllerBindingsFile, bool grab);
2012-08-12 20:45:02 +02:00
virtual ~InputManager();
/// Clear all savegame-specific data
void clear() override;
void update(float dt, bool disableControls, bool disableEvents=false) override;
2012-08-12 20:45:02 +02:00
void changeInputMode(bool guiMode) override;
2012-08-12 20:45:02 +02:00
void processChangedSettings(const Settings::CategorySettingVector& changed) override;
2012-08-12 20:45:02 +02:00
void setDragDrop(bool dragDrop) override;
void setGamepadGuiCursorEnabled(bool enabled) override;
void setAttemptJump(bool jumping) override;
2012-08-12 20:45:02 +02:00
2021-11-06 01:25:20 +01:00
void toggleControlSwitch(std::string_view sw, bool value) override;
bool getControlSwitch(std::string_view sw) override;
2012-08-12 20:45:02 +02:00
2021-06-26 23:10:24 +02:00
std::string getActionDescription (int action) const override;
std::string getActionKeyBindingName (int action) const override;
std::string getActionControllerBindingName (int action) const override;
bool actionIsActive(int action) const override;
float getActionValue(int action) const override;
2021-11-06 01:25:20 +01:00
bool isControllerButtonPressed(SDL_GameControllerButton button) const override;
2021-06-26 23:10:24 +02:00
float getControllerAxisValue(SDL_GameControllerAxis axis) const override;
int getMouseMoveX() const override;
int getMouseMoveY() const override;
int getNumActions() override { return A_Last; }
std::vector<int> getActionKeySorting() override;
std::vector<int> getActionControllerSorting() override;
void enableDetectingBindingMode (int action, bool keyboard) override;
void resetToDefaultKeyBindings() override;
void resetToDefaultControllerBindings() override;
2012-08-13 01:26:15 +02:00
void setJoystickLastUsed(bool enabled) override;
bool joystickLastUsed() override;
2014-12-20 14:46:11 -06:00
int countSavedGameRecords() const override;
void write(ESM::ESMWriter& writer, Loading::Listener& progress) override;
void readRecord(ESM::ESMReader& reader, uint32_t type) override;
2016-10-20 02:12:01 +02:00
void resetIdleTime() override;
2021-06-26 23:10:24 +02:00
bool isIdle() const override;
void executeAction(int action) override;
2012-08-12 20:45:02 +02:00
bool controlsDisabled() override { return mControlsDisabled; }
2020-05-26 10:58:24 +04:00
private:
2020-04-17 16:51:47 +04:00
void convertMousePosForMyGUI(int& x, int& y);
void handleGuiArrowKey(int action);
void quickKey(int index);
void showQuickKeysMenu();
void loadKeyDefaults(bool force = false);
void loadControllerDefaults(bool force = false);
SDLUtil::InputWrapper* mInputWrapper;
2012-08-12 20:45:02 +02:00
2020-05-26 10:58:24 +04:00
bool mControlsDisabled;
ControlSwitch* mControlSwitch;
2012-08-12 20:45:02 +02:00
ActionManager* mActionManager;
BindingsManager* mBindingsManager;
ControllerManager* mControllerManager;
KeyboardManager* mKeyboardManager;
MouseManager* mMouseManager;
SensorManager* mSensorManager;
2022-01-18 22:47:49 +01:00
GyroManager* mGyroManager;
2012-08-12 20:45:02 +02:00
};
}
#endif