mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Formatting changes
This commit is contained in:
parent
85f91a7de8
commit
b575712cb1
13 changed files with 114 additions and 144 deletions
|
@ -579,10 +579,6 @@ namespace MWInput
|
||||||
player.setSneak(mSneaking);
|
player.setSneak(mSneaking);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManager::clear()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionManager::handleGuiArrowKey(int action)
|
void ActionManager::handleGuiArrowKey(int action)
|
||||||
{
|
{
|
||||||
bool joystickUsed = MWBase::Environment::get().getInputManager()->joystickLastUsed();
|
bool joystickUsed = MWBase::Environment::get().getInputManager()->joystickLastUsed();
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace MWInput
|
||||||
osg::ref_ptr<osgViewer::Viewer> viewer,
|
osg::ref_ptr<osgViewer::Viewer> viewer,
|
||||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler);
|
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler);
|
||||||
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
void update(float dt, bool triedToMove);
|
void update(float dt, bool triedToMove);
|
||||||
|
|
||||||
void executeAction(int action);
|
void executeAction(int action);
|
||||||
|
|
|
@ -220,8 +220,8 @@ namespace MWInput
|
||||||
A_QuickKey7, A_QuickKey8, A_QuickKey9, A_QuickKey10,
|
A_QuickKey7, A_QuickKey8, A_QuickKey9, A_QuickKey10,
|
||||||
A_Use, A_Journal};
|
A_Use, A_Journal};
|
||||||
|
|
||||||
for(size_t i = 0; i < sizeof(playerChannels)/sizeof(playerChannels[0]); i++) {
|
for(int pc : playerChannels)
|
||||||
int pc = playerChannels[i];
|
{
|
||||||
mInputBinder->getChannel(pc)->setEnabled(enabled);
|
mInputBinder->getChannel(pc)->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,8 +308,7 @@ namespace MWInput
|
||||||
if (!controlExists || force ||
|
if (!controlExists || force ||
|
||||||
(mInputBinder->getKeyBinding(control, ICS::Control::INCREASE) == SDL_SCANCODE_UNKNOWN
|
(mInputBinder->getKeyBinding(control, ICS::Control::INCREASE) == SDL_SCANCODE_UNKNOWN
|
||||||
&& mInputBinder->getMouseButtonBinding(control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS
|
&& mInputBinder->getMouseButtonBinding(control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS
|
||||||
&& mInputBinder->getMouseWheelBinding(control, ICS::Control::INCREASE) == ICS::InputControlSystem::MouseWheelClick::UNASSIGNED
|
&& mInputBinder->getMouseWheelBinding(control, ICS::Control::INCREASE) == ICS::InputControlSystem::MouseWheelClick::UNASSIGNED))
|
||||||
))
|
|
||||||
{
|
{
|
||||||
clearAllKeyBindings(mInputBinder, control);
|
clearAllKeyBindings(mInputBinder, control);
|
||||||
|
|
||||||
|
@ -395,7 +394,8 @@ namespace MWInput
|
||||||
control = mInputBinder->getChannel(i)->getAttachedControls().front().control;
|
control = mInputBinder->getChannel(i)->getAttachedControls().front().control;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!controlExists || force || ( mInputBinder->getJoystickAxisBinding (control, sFakeDeviceId, ICS::Control::INCREASE) == ICS::InputControlSystem::UNASSIGNED && mInputBinder->getJoystickButtonBinding (control, sFakeDeviceId, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS ))
|
if (!controlExists || force || (mInputBinder->getJoystickAxisBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS::InputControlSystem::UNASSIGNED &&
|
||||||
|
mInputBinder->getJoystickButtonBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS))
|
||||||
{
|
{
|
||||||
clearAllControllerBindings(mInputBinder, control);
|
clearAllControllerBindings(mInputBinder, control);
|
||||||
|
|
||||||
|
@ -464,8 +464,8 @@ namespace MWInput
|
||||||
descriptions[A_QuickSave] = "sQuickSaveCmd";
|
descriptions[A_QuickSave] = "sQuickSaveCmd";
|
||||||
descriptions[A_QuickLoad] = "sQuickLoadCmd";
|
descriptions[A_QuickLoad] = "sQuickLoadCmd";
|
||||||
|
|
||||||
if (descriptions[action] == "")
|
if (descriptions[action].empty())
|
||||||
return ""; // not configurable
|
return std::string(); // not configurable
|
||||||
|
|
||||||
return "#{" + descriptions[action] + "}";
|
return "#{" + descriptions[action] + "}";
|
||||||
}
|
}
|
||||||
|
@ -685,12 +685,12 @@ namespace MWInput
|
||||||
//Is a normal button press, so don't change it at all
|
//Is a normal button press, so don't change it at all
|
||||||
}
|
}
|
||||||
//Otherwise only trigger button presses as they go through specific points
|
//Otherwise only trigger button presses as they go through specific points
|
||||||
else if(previousValue >= .8 && currentValue < .8)
|
else if (previousValue >= 0.8 && currentValue < 0.8)
|
||||||
{
|
{
|
||||||
currentValue = 0.0;
|
currentValue = 0.0;
|
||||||
previousValue = 1.0;
|
previousValue = 1.0;
|
||||||
}
|
}
|
||||||
else if(previousValue <= .6 && currentValue > .6)
|
else if (previousValue <= 0.6 && currentValue > 0.6)
|
||||||
{
|
{
|
||||||
currentValue = 1.0;
|
currentValue = 1.0;
|
||||||
previousValue = 0.0;
|
previousValue = 0.0;
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
|
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userControllerBindingsFile.empty())
|
if (!userControllerBindingsFile.empty())
|
||||||
{
|
{
|
||||||
SDL_GameControllerAddMappingsFromFile(userControllerBindingsFile.c_str());
|
SDL_GameControllerAddMappingsFromFile(userControllerBindingsFile.c_str());
|
||||||
|
@ -73,10 +74,6 @@ namespace MWInput
|
||||||
mInvUiScalingFactor = 1.f / uiScale;
|
mInvUiScalingFactor = 1.f / uiScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerManager::clear()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ControllerManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
void ControllerManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
||||||
{
|
{
|
||||||
for (const auto& setting : changed)
|
for (const auto& setting : changed)
|
||||||
|
@ -131,13 +128,13 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
float xAxis = mBindingsManager->getActionValue(A_MoveLeftRight);
|
float xAxis = mBindingsManager->getActionValue(A_MoveLeftRight);
|
||||||
float yAxis = mBindingsManager->getActionValue(A_MoveForwardBackward);
|
float yAxis = mBindingsManager->getActionValue(A_MoveForwardBackward);
|
||||||
if (xAxis != .5)
|
if (xAxis != 0.5)
|
||||||
{
|
{
|
||||||
triedToMove = true;
|
triedToMove = true;
|
||||||
player.setLeftRight((xAxis - 0.5f) * 2);
|
player.setLeftRight((xAxis - 0.5f) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yAxis != .5)
|
if (yAxis != 0.5)
|
||||||
{
|
{
|
||||||
triedToMove = true;
|
triedToMove = true;
|
||||||
player.setAutoMove (false);
|
player.setAutoMove (false);
|
||||||
|
@ -210,6 +207,7 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
if (gamepadToGuiControl(arg))
|
if (gamepadToGuiControl(arg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mGamepadGuiCursorEnabled)
|
if (mGamepadGuiCursorEnabled)
|
||||||
{
|
{
|
||||||
// Temporary mouse binding until keyboard controls are available:
|
// Temporary mouse binding until keyboard controls are available:
|
||||||
|
@ -245,6 +243,7 @@ namespace MWInput
|
||||||
mBindingsManager->controllerButtonReleased(deviceID, arg);
|
mBindingsManager->controllerButtonReleased(deviceID, arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mJoystickEnabled || mControlsDisabled)
|
if (!mJoystickEnabled || mControlsDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace MWInput
|
||||||
|
|
||||||
virtual ~ControllerManager() = default;
|
virtual ~ControllerManager() = default;
|
||||||
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
bool update(float dt, bool disableControls);
|
bool update(float dt, bool disableControls);
|
||||||
|
|
||||||
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg);
|
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg);
|
||||||
|
|
|
@ -58,11 +58,6 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
// Enable all controls
|
// Enable all controls
|
||||||
mControlSwitch->clear();
|
mControlSwitch->clear();
|
||||||
|
|
||||||
mActionManager->clear();
|
|
||||||
mControllerManager->clear();
|
|
||||||
mSensorManager->clear();
|
|
||||||
mMouseManager->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputManager::~InputManager()
|
InputManager::~InputManager()
|
||||||
|
@ -90,19 +85,19 @@ namespace MWInput
|
||||||
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
||||||
&& !MWBase::Environment::get().getWindowManager()->isConsoleMode();
|
&& !MWBase::Environment::get().getWindowManager()->isConsoleMode();
|
||||||
|
|
||||||
bool was_relative = mInputWrapper->getMouseRelative();
|
bool wasRelative = mInputWrapper->getMouseRelative();
|
||||||
bool is_relative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
|
bool isRelative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||||
|
|
||||||
// don't keep the pointer away from the window edge in gui mode
|
// don't keep the pointer away from the window edge in gui mode
|
||||||
// stop using raw mouse motions and switch to system cursor movements
|
// stop using raw mouse motions and switch to system cursor movements
|
||||||
mInputWrapper->setMouseRelative(is_relative);
|
mInputWrapper->setMouseRelative(isRelative);
|
||||||
|
|
||||||
//we let the mouse escape in the main menu
|
//we let the mouse escape in the main menu
|
||||||
mInputWrapper->setGrabPointer(grab && (mGrabCursor || is_relative));
|
mInputWrapper->setGrabPointer(grab && (mGrabCursor || isRelative));
|
||||||
|
|
||||||
//we switched to non-relative mode, move our cursor to where the in-game
|
//we switched to non-relative mode, move our cursor to where the in-game
|
||||||
//cursor is
|
//cursor is
|
||||||
if(!is_relative && was_relative != is_relative)
|
if (!isRelative && wasRelative != isRelative)
|
||||||
{
|
{
|
||||||
mMouseManager->warpMouse();
|
mMouseManager->warpMouse();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +143,9 @@ namespace MWInput
|
||||||
mMouseManager->setMouseLookEnabled(!guiMode);
|
mMouseManager->setMouseLookEnabled(!guiMode);
|
||||||
if (guiMode)
|
if (guiMode)
|
||||||
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
|
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
|
||||||
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode && (!mControllerManager->joystickLastUsed() || mControllerManager->gamepadGuiCursorEnabled()));
|
|
||||||
|
bool isCursorVisible = guiMode && (!mControllerManager->joystickLastUsed() || mControllerManager->gamepadGuiCursorEnabled());
|
||||||
|
MWBase::Environment::get().getWindowManager()->setCursorVisible(isCursorVisible);
|
||||||
// if not in gui mode, the camera decides whether to show crosshair or not.
|
// if not in gui mode, the camera decides whether to show crosshair or not.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,6 @@
|
||||||
|
|
||||||
#include "actions.hpp"
|
#include "actions.hpp"
|
||||||
|
|
||||||
namespace MWInput
|
|
||||||
{
|
|
||||||
class ControlSwitch;
|
|
||||||
class ActionManager;
|
|
||||||
class BindingsManager;
|
|
||||||
class ControllerManager;
|
|
||||||
class KeyboardManager;
|
|
||||||
class MouseManager;
|
|
||||||
class SensorManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Player;
|
class Player;
|
||||||
|
@ -43,11 +32,18 @@ struct SDL_Window;
|
||||||
|
|
||||||
namespace MWInput
|
namespace MWInput
|
||||||
{
|
{
|
||||||
|
class ControlSwitch;
|
||||||
|
class ActionManager;
|
||||||
|
class BindingsManager;
|
||||||
|
class ControllerManager;
|
||||||
|
class KeyboardManager;
|
||||||
|
class MouseManager;
|
||||||
|
class SensorManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Class that handles all input and key bindings for OpenMW.
|
* @brief Class that provides a high-level API for game input
|
||||||
*/
|
*/
|
||||||
class InputManager :
|
class InputManager : public MWBase::InputManager
|
||||||
public MWBase::InputManager
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputManager(
|
InputManager(
|
||||||
|
@ -99,6 +95,18 @@ namespace MWInput
|
||||||
virtual void executeAction(int action);
|
virtual void executeAction(int action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void convertMousePosForMyGUI(int& x, int& y);
|
||||||
|
|
||||||
|
void handleGuiArrowKey(int action);
|
||||||
|
|
||||||
|
void updateCursorMode();
|
||||||
|
|
||||||
|
void quickKey(int index);
|
||||||
|
void showQuickKeysMenu();
|
||||||
|
|
||||||
|
void loadKeyDefaults(bool force = false);
|
||||||
|
void loadControllerDefaults(bool force = false);
|
||||||
|
|
||||||
SDLUtil::InputWrapper* mInputWrapper;
|
SDLUtil::InputWrapper* mInputWrapper;
|
||||||
|
|
||||||
bool mGrabCursor;
|
bool mGrabCursor;
|
||||||
|
@ -111,18 +119,6 @@ namespace MWInput
|
||||||
KeyboardManager* mKeyboardManager;
|
KeyboardManager* mKeyboardManager;
|
||||||
MouseManager* mMouseManager;
|
MouseManager* mMouseManager;
|
||||||
SensorManager* mSensorManager;
|
SensorManager* mSensorManager;
|
||||||
|
|
||||||
void convertMousePosForMyGUI(int& x, int& y);
|
|
||||||
|
|
||||||
void handleGuiArrowKey(int action);
|
|
||||||
|
|
||||||
void updateCursorMode();
|
|
||||||
|
|
||||||
void quickKey(int index);
|
|
||||||
void showQuickKeysMenu();
|
|
||||||
|
|
||||||
void loadKeyDefaults(bool force = false);
|
|
||||||
void loadControllerDefaults(bool force = false);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,11 +47,13 @@ namespace MWInput
|
||||||
consumed = true;
|
consumed = true;
|
||||||
mBindingsManager->setPlayerControlsEnabled(!consumed);
|
mBindingsManager->setPlayerControlsEnabled(!consumed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.repeat)
|
if (arg.repeat)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!mControlsDisabled && !consumed)
|
if (!mControlsDisabled && !consumed)
|
||||||
mBindingsManager->keyPressed(arg);
|
mBindingsManager->keyPressed(arg);
|
||||||
|
|
||||||
MWBase::Environment::get().getInputManager()->setJoystickLastUsed(false);
|
MWBase::Environment::get().getInputManager()->setJoystickLastUsed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,6 @@ namespace MWInput
|
||||||
mGuiCursorY = mInvUiScalingFactor * h / 2.f;
|
mGuiCursorY = mInvUiScalingFactor * h / 2.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseManager::clear()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void MouseManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
void MouseManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
||||||
{
|
{
|
||||||
for (const auto& setting : changed)
|
for (const auto& setting : changed)
|
||||||
|
@ -130,7 +126,8 @@ namespace MWInput
|
||||||
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||||
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI(id)) && guiMode;
|
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), sdlButtonToMyGUI(id)) && guiMode;
|
||||||
|
|
||||||
if(mBindingsManager->isDetectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
|
if (mBindingsManager->isDetectingBindingState())
|
||||||
|
return; // don't allow same mouseup to bind as initiated bind
|
||||||
|
|
||||||
mBindingsManager->setPlayerControlsEnabled(!guiMode);
|
mBindingsManager->setPlayerControlsEnabled(!guiMode);
|
||||||
mBindingsManager->mouseReleased(arg, id);
|
mBindingsManager->mouseReleased(arg, id);
|
||||||
|
|
|
@ -20,8 +20,6 @@ namespace MWInput
|
||||||
|
|
||||||
virtual ~MouseManager() = default;
|
virtual ~MouseManager() = default;
|
||||||
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
void update(float dt, bool disableControls);
|
void update(float dt, bool disableControls);
|
||||||
|
|
||||||
virtual void mouseMoved(const SDLUtil::MouseMotionEvent &arg);
|
virtual void mouseMoved(const SDLUtil::MouseMotionEvent &arg);
|
||||||
|
|
|
@ -206,12 +206,9 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
static std::map<SDL_Keycode, MyGUI::KeyCode> keyMap;
|
static std::map<SDL_Keycode, MyGUI::KeyCode> keyMap;
|
||||||
if (keyMap.empty())
|
if (keyMap.empty())
|
||||||
{
|
|
||||||
initKeyMap(keyMap);
|
initKeyMap(keyMap);
|
||||||
}
|
|
||||||
|
|
||||||
MyGUI::KeyCode kc = MyGUI::KeyCode::None;
|
MyGUI::KeyCode kc = MyGUI::KeyCode::None;
|
||||||
|
|
||||||
auto foundKey = keyMap.find(code);
|
auto foundKey = keyMap.find(code);
|
||||||
if (foundKey != keyMap.end())
|
if (foundKey != keyMap.end())
|
||||||
kc = foundKey->second;
|
kc = foundKey->second;
|
||||||
|
|
|
@ -33,13 +33,6 @@ namespace MWInput
|
||||||
updateSensors();
|
updateSensors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorManager::clear()
|
|
||||||
{
|
|
||||||
mGyroXSpeed = 0.f;
|
|
||||||
mGyroYSpeed = 0.f;
|
|
||||||
mGyroUpdateTimer = 0.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
SensorManager::~SensorManager()
|
SensorManager::~SensorManager()
|
||||||
{
|
{
|
||||||
if (mGyroscope != nullptr)
|
if (mGyroscope != nullptr)
|
||||||
|
@ -246,7 +239,8 @@ namespace MWInput
|
||||||
// More than half of second passed since the last gyroscope update.
|
// More than half of second passed since the last gyroscope update.
|
||||||
// A device more likely was disconnected or switched to the sleep mode.
|
// A device more likely was disconnected or switched to the sleep mode.
|
||||||
// Reset current rotation speed and wait for update.
|
// Reset current rotation speed and wait for update.
|
||||||
clear();
|
mGyroXSpeed = 0.f;
|
||||||
|
mGyroYSpeed = 0.f;
|
||||||
mGyroUpdateTimer = 0.f;
|
mGyroUpdateTimer = 0.f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,6 @@ namespace MWInput
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
||||||
virtual void sensorUpdated(const SDL_SensorEvent &arg);
|
virtual void sensorUpdated(const SDL_SensorEvent &arg);
|
||||||
|
|
Loading…
Reference in a new issue