2014-01-05 18:22:29 +01:00
|
|
|
#ifndef MWINPUT_MWINPUTMANAGERIMP_H
|
|
|
|
#define MWINPUT_MWINPUTMANAGERIMP_H
|
2010-06-08 13:53:34 +02:00
|
|
|
|
2010-09-15 14:48:19 +02:00
|
|
|
#include "../mwgui/mode.hpp"
|
|
|
|
|
2012-05-28 09:19:25 +02:00
|
|
|
#include <components/settings/settings.hpp>
|
2014-12-20 14:46:11 -06:00
|
|
|
#include <components/files/configurationmanager.hpp>
|
2012-05-28 09:19:25 +02:00
|
|
|
|
2012-08-11 17:53:39 +02:00
|
|
|
#include "../mwbase/inputmanager.hpp"
|
2013-01-10 17:21:47 -04:00
|
|
|
#include <extern/sdl4ogre/sdlinputwrapper.hpp>
|
2012-08-11 17:53:39 +02:00
|
|
|
|
2010-07-17 19:58:15 +02:00
|
|
|
namespace OEngine
|
|
|
|
{
|
2012-08-12 20:45:02 +02:00
|
|
|
namespace Render
|
|
|
|
{
|
|
|
|
class OgreRenderer;
|
|
|
|
}
|
2010-07-17 19:58:15 +02:00
|
|
|
}
|
2010-06-08 13:53:34 +02:00
|
|
|
|
2011-01-04 15:58:22 +01:00
|
|
|
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
|
|
|
}
|
2010-07-16 14:26:46 +02:00
|
|
|
|
2012-08-12 18:11:09 +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
|
|
|
}
|
2010-07-16 14:26:46 +02:00
|
|
|
|
2010-08-05 13:36:33 +02:00
|
|
|
namespace OMW
|
|
|
|
{
|
|
|
|
class Engine;
|
|
|
|
}
|
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
namespace ICS
|
|
|
|
{
|
|
|
|
class InputControlSystem;
|
|
|
|
}
|
|
|
|
|
2013-01-08 22:14:30 -04:00
|
|
|
namespace MyGUI
|
|
|
|
{
|
2015-03-06 21:36:42 +13:00
|
|
|
struct MouseButton;
|
2013-01-08 22:14:30 -04:00
|
|
|
}
|
|
|
|
|
2014-12-20 14:46:11 -06:00
|
|
|
namespace Files
|
|
|
|
{
|
|
|
|
struct ConfigurationManager;
|
|
|
|
}
|
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
#include <extern/oics/ICSChannelListener.h>
|
2012-08-13 01:26:15 +02:00
|
|
|
#include <extern/oics/ICSInputControlSystem.h>
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2010-06-08 13:53:34 +02:00
|
|
|
namespace MWInput
|
|
|
|
{
|
2010-06-22 16:02:58 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
/**
|
|
|
|
* @brief Class that handles all input and key bindings for OpenMW.
|
|
|
|
*/
|
2013-01-08 06:19:05 -04:00
|
|
|
class InputManager :
|
|
|
|
public MWBase::InputManager,
|
2013-01-10 17:21:47 -04:00
|
|
|
public SFO::KeyListener,
|
|
|
|
public SFO::MouseListener,
|
|
|
|
public SFO::WindowListener,
|
2014-12-08 21:57:32 -06:00
|
|
|
public SFO::ControllerListener,
|
2013-01-08 06:19:05 -04:00
|
|
|
public ICS::ChannelListener,
|
|
|
|
public ICS::DetectingBindingListener
|
2012-08-12 20:45:02 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
InputManager(OEngine::Render::OgreRenderer &_ogre,
|
|
|
|
OMW::Engine& engine,
|
2015-01-19 18:55:17 -06:00
|
|
|
const std::string& userFile, bool userFileExists,
|
|
|
|
const std::string& controllerBindingsFile, bool grab);
|
2012-08-12 20:45:02 +02:00
|
|
|
|
|
|
|
virtual ~InputManager();
|
|
|
|
|
2014-03-09 03:34:49 +01:00
|
|
|
/// Clear all savegame-specific data
|
|
|
|
virtual void clear();
|
|
|
|
|
2014-04-26 14:33:45 +02:00
|
|
|
virtual void update(float dt, bool disableControls=false, bool disableEvents=false);
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2013-08-27 15:48:13 +02:00
|
|
|
void setPlayer (MWWorld::Player* player) { mPlayer = player; }
|
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
virtual void changeInputMode(bool guiMode);
|
|
|
|
|
|
|
|
virtual void processChangedSettings(const Settings::CategorySettingVector& changed);
|
|
|
|
|
|
|
|
virtual void setDragDrop(bool dragDrop);
|
|
|
|
|
|
|
|
virtual void toggleControlSwitch (const std::string& sw, bool value);
|
2012-09-10 18:44:59 +02:00
|
|
|
virtual bool getControlSwitch (const std::string& sw);
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2012-08-13 01:26:15 +02:00
|
|
|
virtual std::string getActionDescription (int action);
|
2014-12-08 21:57:32 -06:00
|
|
|
virtual std::string getActionKeyBindingName (int action);
|
|
|
|
virtual std::string getActionControllerBindingName (int action);
|
2012-08-13 01:26:15 +02:00
|
|
|
virtual int getNumActions() { return A_Last; }
|
2014-12-08 21:57:32 -06: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-13 01:26:15 +02:00
|
|
|
|
2014-12-20 14:46:11 -06:00
|
|
|
virtual bool joystickLastUsed() {return mJoystickLastUsed;}
|
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
public:
|
2014-02-13 15:08:40 +01:00
|
|
|
virtual void keyPressed(const SDL_KeyboardEvent &arg );
|
|
|
|
virtual void keyReleased( const SDL_KeyboardEvent &arg );
|
2013-06-16 19:43:59 +02:00
|
|
|
virtual void textInput (const SDL_TextInputEvent &arg);
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2014-02-13 15:08:40 +01:00
|
|
|
virtual void mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id );
|
|
|
|
virtual void mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id );
|
|
|
|
virtual void mouseMoved( const SFO::MouseMotionEvent &arg );
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2015-01-19 15:36:15 -06:00
|
|
|
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg);
|
|
|
|
virtual void buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg);
|
|
|
|
virtual void axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg);
|
|
|
|
virtual void controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg);
|
|
|
|
virtual void controllerRemoved(const SDL_ControllerDeviceEvent &arg);
|
2014-12-08 21:57:32 -06:00
|
|
|
|
2013-07-29 02:32:08 +02:00
|
|
|
virtual void windowVisibilityChange( bool visible );
|
|
|
|
virtual void windowFocusChange( bool have_focus );
|
|
|
|
virtual void windowResized (int x, int y);
|
2013-11-05 03:02:28 +01:00
|
|
|
virtual void windowClosed ();
|
2013-01-09 06:10:05 -04:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
virtual void channelChanged(ICS::Channel* channel, float currentValue, float previousValue);
|
|
|
|
|
2012-08-13 01:26:15 +02:00
|
|
|
virtual void mouseAxisBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
|
|
|
, ICS::InputControlSystem::NamedAxis axis, ICS::Control::ControlChangingDirection direction);
|
|
|
|
|
|
|
|
virtual void keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
2014-09-13 20:39:32 +02:00
|
|
|
, SDL_Scancode key, ICS::Control::ControlChangingDirection direction);
|
2012-08-13 01:26:15 +02:00
|
|
|
|
|
|
|
virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
|
|
|
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
|
|
|
|
2015-01-19 15:36:15 -06:00
|
|
|
virtual void joystickAxisBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
2014-12-08 21:57:32 -06:00
|
|
|
, int axis, ICS::Control::ControlChangingDirection direction);
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2015-01-19 15:36:15 -06:00
|
|
|
virtual void joystickButtonBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
2014-12-08 21:57:32 -06:00
|
|
|
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
void clearAllKeyBindings (ICS::Control* control);
|
|
|
|
void clearAllControllerBindings (ICS::Control* control);
|
2012-08-13 01:26:15 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
private:
|
2014-12-08 21:57:32 -06:00
|
|
|
bool mJoystickLastUsed;
|
2012-08-12 20:45:02 +02:00
|
|
|
OEngine::Render::OgreRenderer &mOgre;
|
2013-08-27 15:48:13 +02:00
|
|
|
MWWorld::Player* mPlayer;
|
2012-08-12 20:45:02 +02:00
|
|
|
OMW::Engine& mEngine;
|
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
ICS::InputControlSystem* mInputBinder;
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2013-01-08 06:19:05 -04:00
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
SFO::InputWrapper* mInputManager;
|
2012-08-12 20:45:02 +02:00
|
|
|
|
|
|
|
std::string mUserFile;
|
|
|
|
|
|
|
|
bool mDragDrop;
|
|
|
|
|
2013-12-29 00:58:48 +01:00
|
|
|
bool mGrabCursor;
|
|
|
|
|
2012-08-13 02:55:22 +02:00
|
|
|
bool mInvertY;
|
|
|
|
|
2014-04-26 14:33:45 +02:00
|
|
|
bool mControlsDisabled;
|
|
|
|
|
2012-08-13 18:48:50 +02:00
|
|
|
float mCameraSensitivity;
|
|
|
|
float mUISensitivity;
|
|
|
|
float mCameraYMultiplier;
|
2012-08-17 16:42:42 +04:00
|
|
|
float mPreviewPOVDelay;
|
2012-08-18 01:31:57 +04:00
|
|
|
float mTimeIdle;
|
2012-08-13 18:48:50 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
bool mMouseLookEnabled;
|
|
|
|
bool mGuiCursorEnabled;
|
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
bool mDetectingKeyboard;
|
|
|
|
|
2013-02-25 16:31:48 +01:00
|
|
|
float mOverencumberedMessageDelay;
|
|
|
|
|
2012-08-13 21:33:53 +02:00
|
|
|
float mMouseX;
|
|
|
|
float mMouseY;
|
2013-01-03 01:07:17 +01:00
|
|
|
int mMouseWheel;
|
2013-02-05 19:22:08 +01:00
|
|
|
bool mUserFileExists;
|
2013-03-14 21:08:19 +01:00
|
|
|
bool mAlwaysRunActive;
|
2014-05-27 13:12:27 -04:00
|
|
|
bool mAttemptJump;
|
2012-08-12 20:45:02 +02:00
|
|
|
|
|
|
|
std::map<std::string, bool> mControlSwitch;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void adjustMouseRegion(int width, int height);
|
2013-01-08 22:14:30 -04:00
|
|
|
MyGUI::MouseButton sdlButtonToMyGUI(Uint8 button);
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2014-12-20 14:46:11 -06:00
|
|
|
virtual std::string sdlControllerAxisToString(int axis);
|
|
|
|
virtual std::string sdlControllerButtonToString(int button);
|
|
|
|
|
2012-08-18 01:31:57 +04:00
|
|
|
void resetIdleTime();
|
|
|
|
void updateIdleTime(float dt);
|
|
|
|
|
2014-05-31 19:51:21 -04:00
|
|
|
void setPlayerControlsEnabled(bool enabled);
|
|
|
|
|
2015-01-13 04:53:49 +01:00
|
|
|
void updateCursorMode();
|
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
private:
|
|
|
|
void toggleMainMenu();
|
|
|
|
void toggleSpell();
|
|
|
|
void toggleWeapon();
|
|
|
|
void toggleInventory();
|
|
|
|
void toggleConsole();
|
|
|
|
void screenshot();
|
|
|
|
void toggleJournal();
|
|
|
|
void activate();
|
|
|
|
void toggleWalking();
|
|
|
|
void toggleAutoMove();
|
2012-09-15 17:12:42 +02:00
|
|
|
void rest();
|
2014-04-23 21:02:09 -04:00
|
|
|
void quickLoad();
|
|
|
|
void quickSave();
|
2012-08-12 20:45:02 +02:00
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
void quickKey (int index);
|
|
|
|
void showQuickKeysMenu();
|
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
bool actionIsActive (int id);
|
|
|
|
|
2012-08-13 02:55:22 +02:00
|
|
|
void loadKeyDefaults(bool force = false);
|
2014-12-08 21:57:32 -06:00
|
|
|
void loadControllerDefaults(bool force = false);
|
2012-08-12 22:59:58 +02:00
|
|
|
|
2015-01-19 15:36:15 -06: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 20:45:02 +02:00
|
|
|
private:
|
|
|
|
enum Actions
|
|
|
|
{
|
|
|
|
// please add new actions at the bottom, in order to preserve the channel IDs in the key configuration files
|
|
|
|
|
|
|
|
A_GameMenu,
|
|
|
|
|
2013-10-30 13:05:28 +01:00
|
|
|
A_Unused,
|
2012-08-12 20:45:02 +02:00
|
|
|
|
|
|
|
A_Screenshot, // Take a screenshot
|
|
|
|
|
|
|
|
A_Inventory, // Toggle inventory screen
|
|
|
|
|
|
|
|
A_Console, // Toggle console screen
|
2010-07-17 14:01:47 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
A_MoveLeft, // Move player left / right
|
|
|
|
A_MoveRight,
|
|
|
|
A_MoveForward, // Forward / Backward
|
|
|
|
A_MoveBackward,
|
2010-07-17 14:01:47 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
A_Activate,
|
2010-09-15 14:48:19 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
A_Use, //Use weapon, spell, etc.
|
|
|
|
A_Jump,
|
|
|
|
A_AutoMove, //Toggle Auto-move forward
|
|
|
|
A_Rest, //Rest
|
|
|
|
A_Journal, //Journal
|
|
|
|
A_Weapon, //Draw/Sheath weapon
|
|
|
|
A_Spell, //Ready/Unready Casting
|
2013-02-06 18:22:16 -08:00
|
|
|
A_Run, //Run when held
|
2012-08-12 20:45:02 +02:00
|
|
|
A_CycleSpellLeft, //cycling through spells
|
|
|
|
A_CycleSpellRight,
|
|
|
|
A_CycleWeaponLeft,//Cycling through weapons
|
|
|
|
A_CycleWeaponRight,
|
2013-03-06 16:58:56 +01:00
|
|
|
A_ToggleSneak, //Toggles Sneak
|
2013-03-14 20:27:16 +01:00
|
|
|
A_AlwaysRun, //Toggle Walking/Running
|
2013-03-06 16:58:56 +01:00
|
|
|
A_Sneak,
|
2012-04-05 21:16:51 +02:00
|
|
|
|
2012-08-12 20:45:02 +02:00
|
|
|
A_QuickSave,
|
|
|
|
A_QuickLoad,
|
|
|
|
A_QuickMenu,
|
|
|
|
A_ToggleWeapon,
|
|
|
|
A_ToggleSpell,
|
2012-05-13 10:18:17 +02:00
|
|
|
|
2012-08-19 22:09:22 +02:00
|
|
|
A_TogglePOV,
|
2012-08-17 23:25:29 +04:00
|
|
|
|
2012-08-26 10:52:06 +02:00
|
|
|
A_QuickKey1,
|
|
|
|
A_QuickKey2,
|
|
|
|
A_QuickKey3,
|
|
|
|
A_QuickKey4,
|
|
|
|
A_QuickKey5,
|
|
|
|
A_QuickKey6,
|
|
|
|
A_QuickKey7,
|
|
|
|
A_QuickKey8,
|
|
|
|
A_QuickKey9,
|
|
|
|
A_QuickKey10,
|
|
|
|
|
|
|
|
A_QuickKeysMenu,
|
|
|
|
|
2012-08-30 20:47:39 +02:00
|
|
|
A_ToggleHUD,
|
|
|
|
|
2014-09-28 17:57:14 +02:00
|
|
|
A_ToggleDebug,
|
|
|
|
|
2014-12-08 21:57:32 -06:00
|
|
|
A_LookUpDown, //Joystick look
|
|
|
|
A_LookLeftRight,
|
|
|
|
A_MoveForwardBackward,
|
|
|
|
A_MoveLeftRight,
|
|
|
|
|
2012-08-13 01:26:15 +02:00
|
|
|
A_Last // Marker for the last item
|
2012-08-12 20:45:02 +02:00
|
|
|
};
|
|
|
|
};
|
2010-06-08 13:53:34 +02:00
|
|
|
}
|
|
|
|
#endif
|