2012-08-11 15:53:39 +00:00
|
|
|
#ifndef GAME_MWBASE_INPUTMANAGER_H
|
|
|
|
#define GAME_MWBASE_INPUTMANAGER_H
|
|
|
|
|
2015-02-02 23:53:30 +00:00
|
|
|
#include <set>
|
2012-08-11 15:53:39 +00:00
|
|
|
#include <string>
|
2015-02-02 23:53:30 +00:00
|
|
|
#include <vector>
|
2012-08-11 15:53:39 +00:00
|
|
|
|
2021-06-26 21:10:24 +00:00
|
|
|
#include <SDL_gamecontroller.h>
|
2022-01-22 21:44:02 +00:00
|
|
|
#include <cstdint>
|
2016-10-20 00:12:01 +00:00
|
|
|
|
|
|
|
namespace Loading
|
|
|
|
{
|
|
|
|
class Listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
}
|
|
|
|
|
2012-08-11 15:53:39 +00:00
|
|
|
namespace MWBase
|
|
|
|
{
|
|
|
|
/// \brief Interface for input manager (implemented in MWInput)
|
|
|
|
class InputManager
|
|
|
|
{
|
|
|
|
InputManager(const InputManager&);
|
|
|
|
///< not implemented
|
|
|
|
|
|
|
|
InputManager& operator=(const InputManager&);
|
|
|
|
///< not implemented
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2012-08-11 15:53:39 +00:00
|
|
|
InputManager() {}
|
|
|
|
|
2014-03-09 02:34:49 +00:00
|
|
|
/// Clear all savegame-specific data
|
|
|
|
virtual void clear() = 0;
|
|
|
|
|
2012-08-11 15:53:39 +00:00
|
|
|
virtual ~InputManager() {}
|
|
|
|
|
2014-03-27 18:51:48 +00:00
|
|
|
virtual void update(float dt, bool disableControls, bool disableEvents = false) = 0;
|
2012-08-11 15:53:39 +00:00
|
|
|
|
|
|
|
virtual void changeInputMode(bool guiMode) = 0;
|
|
|
|
|
2015-02-02 23:53:30 +00:00
|
|
|
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& changed) = 0;
|
2012-08-11 15:53:39 +00:00
|
|
|
|
|
|
|
virtual void setDragDrop(bool dragDrop) = 0;
|
2020-04-08 10:48:23 +00:00
|
|
|
virtual void setGamepadGuiCursorEnabled(bool enabled) = 0;
|
2012-08-11 15:53:39 +00:00
|
|
|
|
2021-11-06 00:25:20 +00:00
|
|
|
virtual void toggleControlSwitch(std::string_view sw, bool value) = 0;
|
|
|
|
virtual bool getControlSwitch(std::string_view sw) = 0;
|
2012-08-12 23:26:15 +00:00
|
|
|
|
2022-08-12 16:42:12 +00:00
|
|
|
virtual std::string_view getActionDescription(int action) const = 0;
|
2021-06-26 21:10:24 +00:00
|
|
|
virtual std::string getActionKeyBindingName(int action) const = 0;
|
|
|
|
virtual std::string getActionControllerBindingName(int action) const = 0;
|
|
|
|
virtual bool actionIsActive(int action) const = 0;
|
|
|
|
|
|
|
|
virtual float getActionValue(int action) const = 0; // returns value in range [0, 1]
|
2021-11-06 00:25:20 +00:00
|
|
|
virtual bool isControllerButtonPressed(SDL_GameControllerButton button) const = 0;
|
2021-06-26 21:10:24 +00:00
|
|
|
virtual float getControllerAxisValue(SDL_GameControllerAxis axis) const = 0; // returns value in range [-1, 1]
|
|
|
|
virtual int getMouseMoveX() const = 0;
|
|
|
|
virtual int getMouseMoveY() const = 0;
|
|
|
|
|
2014-12-09 03:57:32 +00:00
|
|
|
/// Actions available for binding to keyboard buttons
|
2022-08-12 16:42:12 +00:00
|
|
|
virtual const std::initializer_list<int>& getActionKeySorting() = 0;
|
2014-12-09 03:57:32 +00:00
|
|
|
/// Actions available for binding to controller buttons
|
2022-08-12 16:42:12 +00:00
|
|
|
virtual const std::initializer_list<int>& getActionControllerSorting() = 0;
|
2012-08-12 23:26:15 +00:00
|
|
|
virtual int getNumActions() = 0;
|
2014-12-20 20:46:11 +00:00
|
|
|
/// If keyboard is true, only pay attention to keyboard events. If false, only pay attention to controller
|
|
|
|
/// events (excluding esc)
|
2014-12-09 03:57:32 +00:00
|
|
|
virtual void enableDetectingBindingMode(int action, bool keyboard) = 0;
|
|
|
|
virtual void resetToDefaultKeyBindings() = 0;
|
|
|
|
virtual void resetToDefaultControllerBindings() = 0;
|
2014-12-20 20:46:11 +00:00
|
|
|
|
|
|
|
/// Returns if the last used input device was a joystick or a keyboard
|
|
|
|
/// @return true if joystick, false otherwise
|
|
|
|
virtual bool joystickLastUsed() = 0;
|
2020-04-08 10:48:23 +00:00
|
|
|
virtual void setJoystickLastUsed(bool enabled) = 0;
|
2016-10-20 00:12:01 +00:00
|
|
|
|
|
|
|
virtual int countSavedGameRecords() const = 0;
|
|
|
|
virtual void write(ESM::ESMWriter& writer, Loading::Listener& progress) = 0;
|
|
|
|
virtual void readRecord(ESM::ESMReader& reader, uint32_t type) = 0;
|
2020-04-08 10:48:23 +00:00
|
|
|
|
|
|
|
virtual void resetIdleTime() = 0;
|
2021-06-26 21:10:24 +00:00
|
|
|
virtual bool isIdle() const = 0;
|
2020-04-17 11:21:23 +00:00
|
|
|
|
|
|
|
virtual void executeAction(int action) = 0;
|
2020-05-26 06:58:24 +00:00
|
|
|
|
|
|
|
virtual bool controlsDisabled() = 0;
|
2012-08-11 15:53:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|