1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 09:55:35 +00:00
OpenMW/apps/openmw/mwinput/bindingsmanager.hpp
AnyOldName3 28131fd62b Fixes for a whole bunch of warnings
These warnings were always enabled, but we didn't see them due to https://gitlab.com/OpenMW/openmw/-/issues/7882.
I do not fully understand the cause of 7822 as I can't repro it in a minimal CMake project.

Some of these fixes are thought through.
Some are sensible best guesses.
Some are kind of a stab in the dark as I don't know whether there was a
possible bug the warning was telling me about that I've done nothing to
help by introducing a static_cast.

Nearly all of these warnings were about some kind of narrowing
conversion, so I'm not sure why they weren't firing with GCC and Clang,
which have -Wall -Wextra -pedantic set, which should imply -Wnarrowing,
and they can't have been affected by 7882.

There were also some warnings being triggered from Boost code.
The vast majority of library headers that do questionable things weren't
firing warnings off, but for some reason, /external:I wasn't putting
these Boost headers into external mode.

We need these warnings dealt with one way or another so we can switch
the default Windows CI from MSBuild (which doesn't do ccache) to Ninja
(which does).
I have the necessary magic for that on a branch, but the branch won't
build because of these warnings.
2024-03-14 23:39:33 +00:00

80 lines
2.5 KiB
C++

#ifndef MWINPUT_MWBINDINGSMANAGER_H
#define MWINPUT_MWBINDINGSMANAGER_H
#include <filesystem>
#include <memory>
#include <string>
#include <vector>
#include <components/sdlutil/events.hpp>
namespace MWInput
{
class BindingsListener;
class InputControlSystem;
class BindingsManager
{
public:
BindingsManager(const std::filesystem::path& userFile, bool userFileExists);
virtual ~BindingsManager();
std::string_view getActionDescription(int action);
std::string getActionKeyBindingName(int action);
std::string getActionControllerBindingName(int action);
const std::initializer_list<int>& getActionKeySorting();
const std::initializer_list<int>& getActionControllerSorting();
void enableDetectingBindingMode(int action, bool keyboard);
bool isDetectingBindingState() const;
void loadKeyDefaults(bool force = false);
void loadControllerDefaults(bool force = false);
void setDragDrop(bool dragDrop);
void update(float dt);
void setPlayerControlsEnabled(bool enabled);
void setJoystickDeadZone(float deadZone);
bool isLeftOrRightButton(int action, bool joystick) const;
bool actionIsActive(int id) const;
float getActionValue(int id) const; // returns value in range [0, 1]
SDL_GameController* getControllerOrNull() const;
void mousePressed(const SDL_MouseButtonEvent& evt, Uint8 deviceID);
void mouseReleased(const SDL_MouseButtonEvent& arg, Uint8 deviceID);
void mouseMoved(const SDLUtil::MouseMotionEvent& arg);
void mouseWheelMoved(const SDL_MouseWheelEvent& arg);
void keyPressed(const SDL_KeyboardEvent& arg);
void keyReleased(const SDL_KeyboardEvent& arg);
void controllerAdded(int deviceID, const SDL_ControllerDeviceEvent& arg);
void controllerRemoved(const SDL_ControllerDeviceEvent& arg);
void controllerButtonPressed(int deviceID, const SDL_ControllerButtonEvent& arg);
void controllerButtonReleased(int deviceID, const SDL_ControllerButtonEvent& arg);
void controllerAxisMoved(int deviceID, const SDL_ControllerAxisEvent& arg);
SDL_Scancode getKeyBinding(int actionId);
void actionValueChanged(int action, float currentValue, float previousValue);
private:
void setupSDLKeyMappings();
std::unique_ptr<InputControlSystem> mInputBinder;
std::unique_ptr<BindingsListener> mListener;
std::filesystem::path mUserFile;
bool mDragDrop;
};
}
#endif