2014-01-05 17:22:29 +00:00
|
|
|
#ifndef MWINPUT_MWINPUTMANAGERIMP_H
|
|
|
|
#define MWINPUT_MWINPUTMANAGERIMP_H
|
2010-06-08 11:53:34 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
#include <osg/ref_ptr>
|
2017-11-09 17:26:27 +00:00
|
|
|
#include <osgViewer/ViewerEventHandlers>
|
2015-05-13 14:50:47 +00:00
|
|
|
|
2012-05-28 07:19:25 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
2015-05-13 14:50:47 +00:00
|
|
|
#include <components/sdlutil/events.hpp>
|
2012-05-28 07:19:25 +00:00
|
|
|
|
2012-08-11 15:53:39 +00:00
|
|
|
#include "../mwbase/inputmanager.hpp"
|
2015-05-13 14:50:47 +00:00
|
|
|
|
2020-04-17 11:59:37 +00:00
|
|
|
#include "../mwgui/mode.hpp"
|
|
|
|
|
2020-04-08 07:10:17 +00:00
|
|
|
#include "actions.hpp"
|
|
|
|
|
2011-01-04 14:58:22 +00:00
|
|
|
namespace MWWorld
|
2010-07-17 17:58:15 +00:00
|
|
|
{
|
2012-08-12 18:45:02 +00:00
|
|
|
class Player;
|
2010-07-17 17:58:15 +00:00
|
|
|
}
|
2010-07-16 12:26:46 +00:00
|
|
|
|
2012-08-12 16:11:09 +00:00
|
|
|
namespace MWBase
|
2010-07-17 17:58:15 +00:00
|
|
|
{
|
2012-08-12 18:45:02 +00:00
|
|
|
class WindowManager;
|
2010-07-17 17:58:15 +00:00
|
|
|
}
|
2010-07-16 12:26:46 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
namespace SDLUtil
|
|
|
|
{
|
|
|
|
class InputWrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SDL_Window;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
namespace MWInput
|
|
|
|
{
|
2020-04-17 12:51:47 +00:00
|
|
|
class ControlSwitch;
|
|
|
|
class ActionManager;
|
|
|
|
class BindingsManager;
|
|
|
|
class ControllerManager;
|
|
|
|
class KeyboardManager;
|
|
|
|
class MouseManager;
|
|
|
|
class SensorManager;
|
|
|
|
|
2012-08-12 18:45:02 +00:00
|
|
|
/**
|
2020-04-17 12:51:47 +00:00
|
|
|
* @brief Class that provides a high-level API for game input
|
2012-08-12 18:45:02 +00:00
|
|
|
*/
|
2020-04-17 12:51:47 +00:00
|
|
|
class InputManager : public MWBase::InputManager
|
2012-08-12 18:45:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-05-03 15:24:35 +00:00
|
|
|
InputManager(
|
2015-05-13 14:50:47 +00:00
|
|
|
SDL_Window* window,
|
|
|
|
osg::ref_ptr<osgViewer::Viewer> viewer,
|
2015-11-14 01:43:24 +00:00
|
|
|
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
|
2017-11-09 17:26:27 +00:00
|
|
|
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
|
2015-01-20 00:55:17 +00:00
|
|
|
const std::string& userFile, bool userFileExists,
|
2019-08-03 19:55:58 +00:00
|
|
|
const std::string& userControllerBindingsFile,
|
2015-01-20 00:55:17 +00:00
|
|
|
const std::string& controllerBindingsFile, bool grab);
|
2012-08-12 18:45:02 +00:00
|
|
|
|
|
|
|
virtual ~InputManager();
|
|
|
|
|
2014-03-09 02:34:49 +00:00
|
|
|
/// Clear all savegame-specific data
|
2020-10-16 18:18:54 +00:00
|
|
|
void clear() override;
|
2014-03-09 02:34:49 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void update(float dt, bool disableControls=false, bool disableEvents=false) override;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void changeInputMode(bool guiMode) override;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& changed) override;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void setDragDrop(bool dragDrop) override;
|
|
|
|
void setGamepadGuiCursorEnabled(bool enabled) override;
|
|
|
|
void setAttemptJump(bool jumping) override;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void toggleControlSwitch (const std::string& sw, bool value) override;
|
|
|
|
bool getControlSwitch (const std::string& sw) override;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
std::string getActionDescription (int action) override;
|
|
|
|
std::string getActionKeyBindingName (int action) override;
|
|
|
|
std::string getActionControllerBindingName (int action) 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-12 23:26:15 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void setJoystickLastUsed(bool enabled) override;
|
|
|
|
bool joystickLastUsed() override;
|
2014-12-20 20:46:11 +00:00
|
|
|
|
2020-10-16 18:18:54 +00: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 00:12:01 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void resetIdleTime() override;
|
2020-04-08 10:48:23 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void executeAction(int action) override;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool controlsDisabled() override { return mControlsDisabled; }
|
2020-05-26 06:58:24 +00:00
|
|
|
|
2020-04-17 11:21:23 +00:00
|
|
|
private:
|
2020-04-17 12:51:47 +00: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);
|
|
|
|
|
2020-04-15 08:48:18 +00:00
|
|
|
SDLUtil::InputWrapper* mInputWrapper;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-05-26 06:58:24 +00:00
|
|
|
bool mControlsDisabled;
|
2013-12-28 23:58:48 +00:00
|
|
|
|
2020-04-16 14:08:55 +00:00
|
|
|
ControlSwitch* mControlSwitch;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2020-04-08 15:33:07 +00:00
|
|
|
ActionManager* mActionManager;
|
2020-04-17 11:21:23 +00:00
|
|
|
BindingsManager* mBindingsManager;
|
2020-04-08 18:02:53 +00:00
|
|
|
ControllerManager* mControllerManager;
|
2020-04-16 07:03:34 +00:00
|
|
|
KeyboardManager* mKeyboardManager;
|
2020-04-08 10:48:23 +00:00
|
|
|
MouseManager* mMouseManager;
|
2020-04-08 06:55:35 +00:00
|
|
|
SensorManager* mSensorManager;
|
2012-08-12 18:45:02 +00:00
|
|
|
};
|
2010-06-08 11:53:34 +00:00
|
|
|
}
|
|
|
|
#endif
|