mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-12 22:36:43 +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);
|
||||
}
|
||||
|
||||
void ActionManager::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void ActionManager::handleGuiArrowKey(int action)
|
||||
{
|
||||
bool joystickUsed = MWBase::Environment::get().getInputManager()->joystickLastUsed();
|
||||
|
|
|
@ -23,8 +23,6 @@ namespace MWInput
|
|||
osg::ref_ptr<osgViewer::Viewer> viewer,
|
||||
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler);
|
||||
|
||||
void clear();
|
||||
|
||||
void update(float dt, bool triedToMove);
|
||||
|
||||
void executeAction(int action);
|
||||
|
|
|
@ -220,8 +220,8 @@ namespace MWInput
|
|||
A_QuickKey7, A_QuickKey8, A_QuickKey9, A_QuickKey10,
|
||||
A_Use, A_Journal};
|
||||
|
||||
for(size_t i = 0; i < sizeof(playerChannels)/sizeof(playerChannels[0]); i++) {
|
||||
int pc = playerChannels[i];
|
||||
for(int pc : playerChannels)
|
||||
{
|
||||
mInputBinder->getChannel(pc)->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
@ -308,8 +308,7 @@ namespace MWInput
|
|||
if (!controlExists || force ||
|
||||
(mInputBinder->getKeyBinding(control, ICS::Control::INCREASE) == SDL_SCANCODE_UNKNOWN
|
||||
&& 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);
|
||||
|
||||
|
@ -395,7 +394,8 @@ namespace MWInput
|
|||
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);
|
||||
|
||||
|
@ -464,8 +464,8 @@ namespace MWInput
|
|||
descriptions[A_QuickSave] = "sQuickSaveCmd";
|
||||
descriptions[A_QuickLoad] = "sQuickLoadCmd";
|
||||
|
||||
if (descriptions[action] == "")
|
||||
return ""; // not configurable
|
||||
if (descriptions[action].empty())
|
||||
return std::string(); // not configurable
|
||||
|
||||
return "#{" + descriptions[action] + "}";
|
||||
}
|
||||
|
@ -685,12 +685,12 @@ namespace MWInput
|
|||
//Is a normal button press, so don't change it at all
|
||||
}
|
||||
//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;
|
||||
previousValue = 1.0;
|
||||
}
|
||||
else if(previousValue <= .6 && currentValue > .6)
|
||||
else if (previousValue <= 0.6 && currentValue > 0.6)
|
||||
{
|
||||
currentValue = 1.0;
|
||||
previousValue = 0.0;
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace MWInput
|
|||
{
|
||||
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
|
||||
}
|
||||
|
||||
if (!userControllerBindingsFile.empty())
|
||||
{
|
||||
SDL_GameControllerAddMappingsFromFile(userControllerBindingsFile.c_str());
|
||||
|
@ -73,10 +74,6 @@ namespace MWInput
|
|||
mInvUiScalingFactor = 1.f / uiScale;
|
||||
}
|
||||
|
||||
void ControllerManager::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void ControllerManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
||||
{
|
||||
for (const auto& setting : changed)
|
||||
|
@ -131,13 +128,13 @@ namespace MWInput
|
|||
{
|
||||
float xAxis = mBindingsManager->getActionValue(A_MoveLeftRight);
|
||||
float yAxis = mBindingsManager->getActionValue(A_MoveForwardBackward);
|
||||
if (xAxis != .5)
|
||||
if (xAxis != 0.5)
|
||||
{
|
||||
triedToMove = true;
|
||||
player.setLeftRight((xAxis - 0.5f) * 2);
|
||||
}
|
||||
|
||||
if (yAxis != .5)
|
||||
if (yAxis != 0.5)
|
||||
{
|
||||
triedToMove = true;
|
||||
player.setAutoMove (false);
|
||||
|
@ -210,6 +207,7 @@ namespace MWInput
|
|||
{
|
||||
if (gamepadToGuiControl(arg))
|
||||
return;
|
||||
|
||||
if (mGamepadGuiCursorEnabled)
|
||||
{
|
||||
// Temporary mouse binding until keyboard controls are available:
|
||||
|
@ -245,6 +243,7 @@ namespace MWInput
|
|||
mBindingsManager->controllerButtonReleased(deviceID, arg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mJoystickEnabled || mControlsDisabled)
|
||||
return;
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ namespace MWInput
|
|||
|
||||
virtual ~ControllerManager() = default;
|
||||
|
||||
void clear();
|
||||
|
||||
bool update(float dt, bool disableControls);
|
||||
|
||||
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg);
|
||||
|
|
|
@ -58,11 +58,6 @@ namespace MWInput
|
|||
{
|
||||
// Enable all controls
|
||||
mControlSwitch->clear();
|
||||
|
||||
mActionManager->clear();
|
||||
mControllerManager->clear();
|
||||
mSensorManager->clear();
|
||||
mMouseManager->clear();
|
||||
}
|
||||
|
||||
InputManager::~InputManager()
|
||||
|
@ -90,19 +85,19 @@ namespace MWInput
|
|||
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
||||
&& !MWBase::Environment::get().getWindowManager()->isConsoleMode();
|
||||
|
||||
bool was_relative = mInputWrapper->getMouseRelative();
|
||||
bool is_relative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
bool wasRelative = mInputWrapper->getMouseRelative();
|
||||
bool isRelative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
|
||||
// don't keep the pointer away from the window edge in gui mode
|
||||
// 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
|
||||
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
|
||||
//cursor is
|
||||
if(!is_relative && was_relative != is_relative)
|
||||
if (!isRelative && wasRelative != isRelative)
|
||||
{
|
||||
mMouseManager->warpMouse();
|
||||
}
|
||||
|
@ -148,7 +143,9 @@ namespace MWInput
|
|||
mMouseManager->setMouseLookEnabled(!guiMode);
|
||||
if (guiMode)
|
||||
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.
|
||||
}
|
||||
|
||||
|
|
|
@ -13,17 +13,6 @@
|
|||
|
||||
#include "actions.hpp"
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
class ControlSwitch;
|
||||
class ActionManager;
|
||||
class BindingsManager;
|
||||
class ControllerManager;
|
||||
class KeyboardManager;
|
||||
class MouseManager;
|
||||
class SensorManager;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Player;
|
||||
|
@ -43,11 +32,18 @@ struct SDL_Window;
|
|||
|
||||
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 :
|
||||
public MWBase::InputManager
|
||||
class InputManager : public MWBase::InputManager
|
||||
{
|
||||
public:
|
||||
InputManager(
|
||||
|
@ -99,6 +95,18 @@ namespace MWInput
|
|||
virtual void executeAction(int action);
|
||||
|
||||
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;
|
||||
|
||||
bool mGrabCursor;
|
||||
|
@ -111,18 +119,6 @@ namespace MWInput
|
|||
KeyboardManager* mKeyboardManager;
|
||||
MouseManager* mMouseManager;
|
||||
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
|
||||
|
|
|
@ -47,11 +47,13 @@ namespace MWInput
|
|||
consumed = true;
|
||||
mBindingsManager->setPlayerControlsEnabled(!consumed);
|
||||
}
|
||||
|
||||
if (arg.repeat)
|
||||
return;
|
||||
|
||||
if (!mControlsDisabled && !consumed)
|
||||
mBindingsManager->keyPressed(arg);
|
||||
|
||||
MWBase::Environment::get().getInputManager()->setJoystickLastUsed(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,10 +47,6 @@ namespace MWInput
|
|||
mGuiCursorY = mInvUiScalingFactor * h / 2.f;
|
||||
}
|
||||
|
||||
void MouseManager::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void MouseManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
||||
{
|
||||
for (const auto& setting : changed)
|
||||
|
@ -130,7 +126,8 @@ namespace MWInput
|
|||
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
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->mouseReleased(arg, id);
|
||||
|
|
|
@ -20,8 +20,6 @@ namespace MWInput
|
|||
|
||||
virtual ~MouseManager() = default;
|
||||
|
||||
void clear();
|
||||
|
||||
void update(float dt, bool disableControls);
|
||||
|
||||
virtual void mouseMoved(const SDLUtil::MouseMotionEvent &arg);
|
||||
|
|
|
@ -206,12 +206,9 @@ namespace MWInput
|
|||
{
|
||||
static std::map<SDL_Keycode, MyGUI::KeyCode> keyMap;
|
||||
if (keyMap.empty())
|
||||
{
|
||||
initKeyMap(keyMap);
|
||||
}
|
||||
|
||||
MyGUI::KeyCode kc = MyGUI::KeyCode::None;
|
||||
|
||||
auto foundKey = keyMap.find(code);
|
||||
if (foundKey != keyMap.end())
|
||||
kc = foundKey->second;
|
||||
|
|
|
@ -33,13 +33,6 @@ namespace MWInput
|
|||
updateSensors();
|
||||
}
|
||||
|
||||
void SensorManager::clear()
|
||||
{
|
||||
mGyroXSpeed = 0.f;
|
||||
mGyroYSpeed = 0.f;
|
||||
mGyroUpdateTimer = 0.f;
|
||||
}
|
||||
|
||||
SensorManager::~SensorManager()
|
||||
{
|
||||
if (mGyroscope != nullptr)
|
||||
|
@ -246,7 +239,8 @@ namespace MWInput
|
|||
// More than half of second passed since the last gyroscope update.
|
||||
// A device more likely was disconnected or switched to the sleep mode.
|
||||
// Reset current rotation speed and wait for update.
|
||||
clear();
|
||||
mGyroXSpeed = 0.f;
|
||||
mGyroYSpeed = 0.f;
|
||||
mGyroUpdateTimer = 0.f;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace MWInput
|
|||
|
||||
void init();
|
||||
|
||||
void clear();
|
||||
|
||||
void update(float dt);
|
||||
|
||||
virtual void sensorUpdated(const SDL_SensorEvent &arg);
|
||||
|
|
Loading…
Reference in a new issue