2014-01-05 17:22:29 +00:00
|
|
|
#ifndef MWINPUT_MWINPUTMANAGERIMP_H
|
|
|
|
#define MWINPUT_MWINPUTMANAGERIMP_H
|
2010-06-08 11:53:34 +00:00
|
|
|
|
2010-09-15 12:48:19 +00:00
|
|
|
#include "../mwgui/mode.hpp"
|
|
|
|
|
2020-03-14 18:24:36 +00:00
|
|
|
#include <SDL_sensor.h>
|
|
|
|
|
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
|
|
|
|
|
|
|
#include <extern/oics/ICSChannelListener.h>
|
|
|
|
#include <extern/oics/ICSInputControlSystem.h>
|
|
|
|
|
2012-05-28 07:19:25 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
2014-12-20 20:46:11 +00:00
|
|
|
#include <components/files/configurationmanager.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-08 07:10:17 +00:00
|
|
|
#include "actions.hpp"
|
|
|
|
|
2020-04-08 06:55:35 +00:00
|
|
|
namespace MWInput
|
|
|
|
{
|
2020-04-08 15:33:07 +00:00
|
|
|
class ActionManager;
|
2020-04-08 18:02:53 +00:00
|
|
|
class ControllerManager;
|
2020-04-08 10:48:23 +00:00
|
|
|
class MouseManager;
|
2020-04-08 06:55:35 +00:00
|
|
|
class SensorManager;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-08-12 18:45:02 +00:00
|
|
|
namespace ICS
|
|
|
|
{
|
|
|
|
class InputControlSystem;
|
|
|
|
}
|
|
|
|
|
2014-12-20 20:46:11 +00:00
|
|
|
namespace Files
|
|
|
|
{
|
|
|
|
struct ConfigurationManager;
|
|
|
|
}
|
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
namespace SDLUtil
|
|
|
|
{
|
|
|
|
class InputWrapper;
|
2015-05-14 18:31:16 +00:00
|
|
|
class VideoWrapper;
|
2015-05-13 14:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct SDL_Window;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2010-06-08 11:53:34 +00:00
|
|
|
namespace MWInput
|
|
|
|
{
|
2012-08-12 18:45:02 +00:00
|
|
|
/**
|
|
|
|
* @brief Class that handles all input and key bindings for OpenMW.
|
|
|
|
*/
|
2013-01-08 10:19:05 +00:00
|
|
|
class InputManager :
|
|
|
|
public MWBase::InputManager,
|
2015-05-13 14:50:47 +00:00
|
|
|
public SDLUtil::KeyListener,
|
|
|
|
public SDLUtil::WindowListener,
|
2013-01-08 10:19:05 +00:00
|
|
|
public ICS::ChannelListener,
|
|
|
|
public ICS::DetectingBindingListener
|
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();
|
|
|
|
|
2015-09-04 01:44:14 +00:00
|
|
|
virtual bool isWindowVisible();
|
|
|
|
|
2014-03-09 02:34:49 +00:00
|
|
|
/// Clear all savegame-specific data
|
|
|
|
virtual void clear();
|
|
|
|
|
2014-04-26 12:33:45 +00:00
|
|
|
virtual void update(float dt, bool disableControls=false, bool disableEvents=false);
|
2012-08-12 18:45:02 +00:00
|
|
|
|
|
|
|
virtual void changeInputMode(bool guiMode);
|
|
|
|
|
|
|
|
virtual void processChangedSettings(const Settings::CategorySettingVector& changed);
|
|
|
|
|
|
|
|
virtual void setDragDrop(bool dragDrop);
|
2020-04-08 10:48:23 +00:00
|
|
|
virtual void setGamepadGuiCursorEnabled(bool enabled);
|
2012-08-12 18:45:02 +00:00
|
|
|
|
|
|
|
virtual void toggleControlSwitch (const std::string& sw, bool value);
|
2012-09-10 16:44:59 +00:00
|
|
|
virtual bool getControlSwitch (const std::string& sw);
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2012-08-12 23:26:15 +00:00
|
|
|
virtual std::string getActionDescription (int action);
|
2014-12-09 03:57:32 +00:00
|
|
|
virtual std::string getActionKeyBindingName (int action);
|
|
|
|
virtual std::string getActionControllerBindingName (int action);
|
2012-08-12 23:26:15 +00:00
|
|
|
virtual int getNumActions() { return A_Last; }
|
2014-12-09 03:57:32 +00:00
|
|
|
virtual std::vector<int> getActionKeySorting();
|
|
|
|
virtual std::vector<int> getActionControllerSorting();
|
|
|
|
virtual void enableDetectingBindingMode (int action, bool keyboard);
|
|
|
|
virtual void resetToDefaultKeyBindings();
|
|
|
|
virtual void resetToDefaultControllerBindings();
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2020-04-08 18:02:53 +00:00
|
|
|
virtual void setJoystickLastUsed(bool enabled);
|
|
|
|
virtual bool joystickLastUsed();
|
2014-12-20 20:46:11 +00:00
|
|
|
|
2014-02-13 14:08:40 +00:00
|
|
|
virtual void keyPressed(const SDL_KeyboardEvent &arg );
|
|
|
|
virtual void keyReleased( const SDL_KeyboardEvent &arg );
|
2013-06-16 17:43:59 +00:00
|
|
|
virtual void textInput (const SDL_TextInputEvent &arg);
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2013-07-29 00:32:08 +00:00
|
|
|
virtual void windowVisibilityChange( bool visible );
|
|
|
|
virtual void windowFocusChange( bool have_focus );
|
|
|
|
virtual void windowResized (int x, int y);
|
2013-11-05 02:02:28 +00:00
|
|
|
virtual void windowClosed ();
|
2013-01-09 10:10:05 +00:00
|
|
|
|
2012-08-12 18:45:02 +00:00
|
|
|
virtual void channelChanged(ICS::Channel* channel, float currentValue, float previousValue);
|
|
|
|
|
2012-08-12 23:26:15 +00:00
|
|
|
virtual void keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
2014-09-13 18:39:32 +00:00
|
|
|
, SDL_Scancode key, ICS::Control::ControlChangingDirection direction);
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2019-10-30 11:22:24 +00:00
|
|
|
virtual void mouseAxisBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
|
|
|
, ICS::InputControlSystem::NamedAxis axis, ICS::Control::ControlChangingDirection direction);
|
|
|
|
|
2012-08-12 23:26:15 +00:00
|
|
|
virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
|
|
|
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
|
|
|
|
2019-10-30 11:22:24 +00:00
|
|
|
virtual void mouseWheelBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
|
|
|
, ICS::InputControlSystem::MouseWheelClick click, ICS::Control::ControlChangingDirection direction);
|
|
|
|
|
2015-01-19 21:36:15 +00:00
|
|
|
virtual void joystickAxisBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
2014-12-09 03:57:32 +00:00
|
|
|
, int axis, ICS::Control::ControlChangingDirection direction);
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2015-01-19 21:36:15 +00:00
|
|
|
virtual void joystickButtonBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
2014-12-09 03:57:32 +00:00
|
|
|
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2014-12-09 03:57:32 +00:00
|
|
|
void clearAllKeyBindings (ICS::Control* control);
|
|
|
|
void clearAllControllerBindings (ICS::Control* control);
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2016-10-20 00:12:01 +00:00
|
|
|
virtual int countSavedGameRecords() const;
|
|
|
|
virtual void write(ESM::ESMWriter& writer, Loading::Listener& progress);
|
|
|
|
virtual void readRecord(ESM::ESMReader& reader, uint32_t type);
|
|
|
|
|
2020-04-08 10:48:23 +00:00
|
|
|
virtual void setPlayerControlsEnabled(bool enabled);
|
|
|
|
|
|
|
|
virtual void resetIdleTime();
|
|
|
|
|
2012-08-12 18:45:02 +00:00
|
|
|
private:
|
2015-05-14 18:31:16 +00:00
|
|
|
SDL_Window* mWindow;
|
2015-09-04 01:44:14 +00:00
|
|
|
bool mWindowVisible;
|
2015-05-14 18:31:16 +00:00
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
ICS::InputControlSystem* mInputBinder;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
SDLUtil::InputWrapper* mInputManager;
|
2015-05-14 18:31:16 +00:00
|
|
|
SDLUtil::VideoWrapper* mVideoWrapper;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
|
|
|
std::string mUserFile;
|
|
|
|
|
|
|
|
bool mDragDrop;
|
|
|
|
|
2013-12-28 23:58:48 +00:00
|
|
|
bool mGrabCursor;
|
|
|
|
|
2014-04-26 12:33:45 +00:00
|
|
|
bool mControlsDisabled;
|
|
|
|
|
2012-08-17 12:42:42 +00:00
|
|
|
float mPreviewPOVDelay;
|
2012-08-17 21:31:57 +00:00
|
|
|
float mTimeIdle;
|
2012-08-13 16:48:50 +00:00
|
|
|
|
2012-08-12 18:45:02 +00:00
|
|
|
bool mGuiCursorEnabled;
|
|
|
|
|
2014-12-09 03:57:32 +00:00
|
|
|
bool mDetectingKeyboard;
|
|
|
|
|
2013-02-25 15:31:48 +00:00
|
|
|
float mOverencumberedMessageDelay;
|
|
|
|
|
2014-05-27 17:12:27 +00:00
|
|
|
bool mAttemptJump;
|
2012-08-12 18:45:02 +00:00
|
|
|
|
|
|
|
std::map<std::string, bool> mControlSwitch;
|
|
|
|
|
2020-04-08 15:33:07 +00:00
|
|
|
ActionManager* mActionManager;
|
2020-04-08 18:02:53 +00:00
|
|
|
ControllerManager* mControllerManager;
|
2020-04-08 10:48:23 +00:00
|
|
|
MouseManager* mMouseManager;
|
2020-04-08 06:55:35 +00:00
|
|
|
SensorManager* mSensorManager;
|
2020-03-14 18:24:36 +00:00
|
|
|
|
2015-05-14 22:41:21 +00:00
|
|
|
void convertMousePosForMyGUI(int& x, int& y);
|
|
|
|
|
2012-08-17 21:31:57 +00:00
|
|
|
void updateIdleTime(float dt);
|
|
|
|
|
2017-09-27 11:14:26 +00:00
|
|
|
void handleGuiArrowKey(int action);
|
2014-05-31 23:51:21 +00:00
|
|
|
|
2015-01-13 03:53:49 +00:00
|
|
|
void updateCursorMode();
|
|
|
|
|
2012-08-26 08:52:06 +00:00
|
|
|
void quickKey (int index);
|
|
|
|
void showQuickKeysMenu();
|
|
|
|
|
2012-08-12 18:45:02 +00:00
|
|
|
bool actionIsActive (int id);
|
|
|
|
|
2012-08-13 00:55:22 +00:00
|
|
|
void loadKeyDefaults(bool force = false);
|
2014-12-09 03:57:32 +00:00
|
|
|
void loadControllerDefaults(bool force = false);
|
2012-08-12 20:59:58 +00:00
|
|
|
|
2015-01-19 21:36:15 +00:00
|
|
|
int mFakeDeviceID; //As we only support one controller at a time, use a fake deviceID so we don't lose bindings when switching controllers
|
2012-08-12 18:45:02 +00:00
|
|
|
};
|
2010-06-08 11:53:34 +00:00
|
|
|
}
|
|
|
|
#endif
|