1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00
OpenMW/apps/openmw/mwinput/controllermanager.hpp

68 lines
2.4 KiB
C++
Raw Normal View History

#ifndef MWINPUT_MWCONTROLLERMANAGER_H
#define MWINPUT_MWCONTROLLERMANAGER_H
#include <string>
#include <components/settings/settings.hpp>
#include <components/sdlutil/events.hpp>
namespace MWInput
{
class ActionManager;
class BindingsManager;
class MouseManager;
class ControllerManager : public SDLUtil::ControllerListener
{
public:
ControllerManager(BindingsManager* bindingsManager,
ActionManager* actionManager,
MouseManager* mouseManager,
const std::string& userControllerBindingsFile,
const std::string& controllerBindingsFile);
virtual ~ControllerManager() = default;
2020-05-26 06:58:24 +00:00
bool update(float dt);
void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg) override;
void buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg) override;
void axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg) override;
void controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg) override;
void controllerRemoved(const SDL_ControllerDeviceEvent &arg) override;
void processChangedSettings(const Settings::CategorySettingVector& changed);
void setJoystickLastUsed(bool enabled) { mJoystickLastUsed = enabled; }
2021-11-06 00:25:20 +00:00
bool joystickLastUsed() const { return mJoystickLastUsed; }
void setGuiCursorEnabled(bool enabled) { mGuiCursorEnabled = enabled; }
void setGamepadGuiCursorEnabled(bool enabled) { mGamepadGuiCursorEnabled = enabled; }
2021-11-06 00:25:20 +00:00
bool gamepadGuiCursorEnabled() const { return mGamepadGuiCursorEnabled; }
float getAxisValue(SDL_GameControllerAxis axis) const; // returns value in range [-1, 1]
bool isButtonPressed(SDL_GameControllerButton button) const;
private:
// Return true if GUI consumes input.
bool gamepadToGuiControl(const SDL_ControllerButtonEvent &arg);
bool gamepadToGuiControl(const SDL_ControllerAxisEvent &arg);
BindingsManager* mBindingsManager;
ActionManager* mActionManager;
MouseManager* mMouseManager;
bool mJoystickEnabled;
float mGamepadCursorSpeed;
float mSneakToggleShortcutTimer;
float mGamepadZoom;
bool mGamepadGuiCursorEnabled;
bool mGuiCursorEnabled;
2020-06-18 15:19:57 +00:00
bool mJoystickLastUsed;
bool mSneakGamepadShortcut;
bool mGamepadPreviewMode;
};
}
#endif