From 552f39ae640de66155ea3c4f099bffb67b9cc9eb Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 19 Jun 2024 19:14:44 -0400
Subject: [PATCH] Fix whitespace to satisfy code policy

---
 indra/newview/alviewermenu.cpp             |   22 +-
 indra/newview/llfloaterjoystick.cpp        |   26 +-
 indra/newview/llfloaterjoystick.h          |    2 +-
 indra/newview/llhudeffectresetskeleton.cpp |  240 ++--
 indra/newview/llhudeffectresetskeleton.h   |   32 +-
 indra/newview/llviewerjoystick.cpp         | 1472 ++++++++++----------
 indra/newview/llviewerjoystick.h           |   80 +-
 indra/newview/pipeline.cpp                 |    2 +-
 8 files changed, 938 insertions(+), 938 deletions(-)

diff --git a/indra/newview/alviewermenu.cpp b/indra/newview/alviewermenu.cpp
index ed8a1d223a4..72a9b9a1104 100644
--- a/indra/newview/alviewermenu.cpp
+++ b/indra/newview/alviewermenu.cpp
@@ -410,20 +410,20 @@ namespace
 
     class ALToggleLocationBar : public view_listener_t
     {
-	    bool handleEvent(const LLSD& userdata) override
-	    {
-		    const U32 val = userdata.asInteger();
-		    gSavedSettings.setU32("NavigationBarStyle", val);
-		    return true;
-	    }
+        bool handleEvent(const LLSD& userdata) override
+        {
+            const U32 val = userdata.asInteger();
+            gSavedSettings.setU32("NavigationBarStyle", val);
+            return true;
+        }
     };
 
     class ALCheckLocationBar : public view_listener_t
     {
-	    bool handleEvent(const LLSD& userdata) override
-	    {
-		    return userdata.asInteger() == (S32)gSavedSettings.getU32("NavigationBarStyle");
-	    }
+        bool handleEvent(const LLSD& userdata) override
+        {
+            return userdata.asInteger() == (S32)gSavedSettings.getU32("NavigationBarStyle");
+        }
     };
 }
 
@@ -461,5 +461,5 @@ void ALViewerMenu::initialize_menus()
     commit.add("View.ToggleCinematicMode", [](LLUICtrl* ctrl, const LLSD& param) { toggle_cinematic_mode(); });
 
     view_listener_t::addMenu(new ALToggleLocationBar(), "ToggleLocationBar");
-	view_listener_t::addMenu(new ALCheckLocationBar(), "CheckLocationBar");
+    view_listener_t::addMenu(new ALCheckLocationBar(), "CheckLocationBar");
 }
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index 03e587e38ee..c3bc8e2f2b3 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -134,15 +134,15 @@ void LLFloaterJoystick::draw()
         }
     }
 
-	for (U32 i = 0; i < 16; i++)
-	{
+    for (U32 i = 0; i < 16; i++)
+    {
         U32 value = joystick->getJoystickButton(i);
-		if (!mAxisButton[i]->getEnabled() && value)
-		{
-			mAxisButton[i]->setEnabled(TRUE);
-		}
-		mAxisButton[i]->setToggleState(value);
-	}
+        if (!mAxisButton[i]->getEnabled() && value)
+        {
+            mAxisButton[i]->setEnabled(TRUE);
+        }
+        mAxisButton[i]->setToggleState(value);
+    }
     LLFloater::draw();
 }
 
@@ -163,11 +163,11 @@ BOOL LLFloaterJoystick::postBuild()
         }
     }
 
-	for (U32 i = 0; i < 16; i++)
-	{
-		std::string btn_name = llformat("btn%d", i);
-		mAxisButton[i] = getChild<LLButton>(btn_name);
-	}
+    for (U32 i = 0; i < 16; i++)
+    {
+        std::string btn_name = llformat("btn%d", i);
+        mAxisButton[i] = getChild<LLButton>(btn_name);
+    }
 
     mJoysticksCombo = getChild<LLComboBox>("joystick_combo");
     childSetCommitCallback("joystick_combo",onCommitJoystickEnabled,this);
diff --git a/indra/newview/llfloaterjoystick.h b/indra/newview/llfloaterjoystick.h
index 5aa0dbd0104..ebc1a26190c 100644
--- a/indra/newview/llfloaterjoystick.h
+++ b/indra/newview/llfloaterjoystick.h
@@ -101,7 +101,7 @@ class LLFloaterJoystick final : public LLFloater
     // stats view
     LLStatBar* mAxisStatsBar[6];
 
-	LLButton* mAxisButton[16];
+    LLButton* mAxisButton[16];
 };
 
 #endif
diff --git a/indra/newview/llhudeffectresetskeleton.cpp b/indra/newview/llhudeffectresetskeleton.cpp
index 8afa231fc53..b7178349bdb 100644
--- a/indra/newview/llhudeffectresetskeleton.cpp
+++ b/indra/newview/llhudeffectresetskeleton.cpp
@@ -1,25 +1,25 @@
-/** 
+/**
  * @file llhudeffectresetskeleton.cpp
  * @brief LLHUDEffectResetSkeleton class implementation
  *
  * $LicenseInfo:firstyear=2024&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2024, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
@@ -41,8 +41,8 @@ const S32 PKT_SIZE = 17;
 //-----------------------------------------------------------------------------
 // LLHUDEffectResetSkeleton()
 //-----------------------------------------------------------------------------
-LLHUDEffectResetSkeleton::LLHUDEffectResetSkeleton(const U8 type) : 
-	LLHUDEffect(type)
+LLHUDEffectResetSkeleton::LLHUDEffectResetSkeleton(const U8 type) :
+    LLHUDEffect(type)
 {
 }
 
@@ -58,28 +58,28 @@ LLHUDEffectResetSkeleton::~LLHUDEffectResetSkeleton()
 //-----------------------------------------------------------------------------
 void LLHUDEffectResetSkeleton::packData(LLMessageSystem *mesgsys)
 {
-	// Pack the default data
-	LLHUDEffect::packData(mesgsys);
-
-	// Pack the type-specific data.  Uses a fun packed binary format.  Whee!
-	U8 packed_data[PKT_SIZE];
-	memset(packed_data, 0, PKT_SIZE);
-
-	// pack both target object and position
-	// position interpreted as offset if target object is non-null
-	if (mTargetObject)
-	{
-		htolememcpy(&(packed_data[TARGET_OBJECT]), mTargetObject->mID.mData, MVT_LLUUID, 16);
-	}
-	else
-	{
-		htolememcpy(&(packed_data[TARGET_OBJECT]), LLUUID::null.mData, MVT_LLUUID, 16);
-	}
-	
-	U8 resetAnimations = (U8)mResetAnimations;
-	htolememcpy(&(packed_data[RESET_ANIMATIONS]), &resetAnimations, MVT_U8, 1);
-
-	mesgsys->addBinaryDataFast(_PREHASH_TypeData, packed_data, PKT_SIZE);
+    // Pack the default data
+    LLHUDEffect::packData(mesgsys);
+
+    // Pack the type-specific data.  Uses a fun packed binary format.  Whee!
+    U8 packed_data[PKT_SIZE];
+    memset(packed_data, 0, PKT_SIZE);
+
+    // pack both target object and position
+    // position interpreted as offset if target object is non-null
+    if (mTargetObject)
+    {
+        htolememcpy(&(packed_data[TARGET_OBJECT]), mTargetObject->mID.mData, MVT_LLUUID, 16);
+    }
+    else
+    {
+        htolememcpy(&(packed_data[TARGET_OBJECT]), LLUUID::null.mData, MVT_LLUUID, 16);
+    }
+
+    U8 resetAnimations = (U8)mResetAnimations;
+    htolememcpy(&(packed_data[RESET_ANIMATIONS]), &resetAnimations, MVT_U8, 1);
+
+    mesgsys->addBinaryDataFast(_PREHASH_TypeData, packed_data, PKT_SIZE);
 }
 
 //-----------------------------------------------------------------------------
@@ -87,58 +87,58 @@ void LLHUDEffectResetSkeleton::packData(LLMessageSystem *mesgsys)
 //-----------------------------------------------------------------------------
 void LLHUDEffectResetSkeleton::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 {
-	LLVector3d new_target;
-	U8 packed_data[PKT_SIZE];
-
-	
-	LLHUDEffect::unpackData(mesgsys, blocknum);
-	
-	LLUUID source_id;
-	mesgsys->getUUIDFast(_PREHASH_Effect, _PREHASH_AgentID, source_id, blocknum);
-	
-	LLViewerObject *objp = gObjectList.findObject(source_id);
-	if (objp && objp->isAvatar())
-	{
-		setSourceObject(objp);
-	}
-	else
-	{
-		//LL_WARNS() << "Could not find source avatar for ResetSkeleton effect" << LL_ENDL;
-		return;
-	}
-	
-	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
-	if (size != PKT_SIZE)
-	{
-		LL_WARNS() << "ResetSkeleton effect with bad size " << size << LL_ENDL;
-		return;
-	}
-	
-	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, PKT_SIZE, blocknum);
-	
-	LLUUID target_id;
-	htolememcpy(target_id.mData, &(packed_data[TARGET_OBJECT]), MVT_LLUUID, 16);
-
-	if (target_id.isNull())
-	{
-		target_id = source_id;
-	}
-	
-	objp = gObjectList.findObject(target_id);
-
-	if (objp)
-	{
-		setTargetObject(objp);
-	}
-	
-	U8 resetAnimations = 0;
-	htolememcpy(&resetAnimations, &(packed_data[RESET_ANIMATIONS]), MVT_U8, 1);
-	
-	// Pre-emptively assume this is going to be flags in the future.
-	// It isn't needed now, but this will assure that only bit 1 is set
-	mResetAnimations = resetAnimations & 1;
-	
-	update();
+    LLVector3d new_target;
+    U8 packed_data[PKT_SIZE];
+
+
+    LLHUDEffect::unpackData(mesgsys, blocknum);
+
+    LLUUID source_id;
+    mesgsys->getUUIDFast(_PREHASH_Effect, _PREHASH_AgentID, source_id, blocknum);
+
+    LLViewerObject *objp = gObjectList.findObject(source_id);
+    if (objp && objp->isAvatar())
+    {
+        setSourceObject(objp);
+    }
+    else
+    {
+        //LL_WARNS() << "Could not find source avatar for ResetSkeleton effect" << LL_ENDL;
+        return;
+    }
+
+    S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
+    if (size != PKT_SIZE)
+    {
+        LL_WARNS() << "ResetSkeleton effect with bad size " << size << LL_ENDL;
+        return;
+    }
+
+    mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, PKT_SIZE, blocknum);
+
+    LLUUID target_id;
+    htolememcpy(target_id.mData, &(packed_data[TARGET_OBJECT]), MVT_LLUUID, 16);
+
+    if (target_id.isNull())
+    {
+        target_id = source_id;
+    }
+
+    objp = gObjectList.findObject(target_id);
+
+    if (objp)
+    {
+        setTargetObject(objp);
+    }
+
+    U8 resetAnimations = 0;
+    htolememcpy(&resetAnimations, &(packed_data[RESET_ANIMATIONS]), MVT_U8, 1);
+
+    // Pre-emptively assume this is going to be flags in the future.
+    // It isn't needed now, but this will assure that only bit 1 is set
+    mResetAnimations = resetAnimations & 1;
+
+    update();
 }
 
 //-----------------------------------------------------------------------------
@@ -146,7 +146,7 @@ void LLHUDEffectResetSkeleton::unpackData(LLMessageSystem *mesgsys, S32 blocknum
 //-----------------------------------------------------------------------------
 void LLHUDEffectResetSkeleton::setTargetObject(LLViewerObject *objp)
 {
-	mTargetObject = objp;
+    mTargetObject = objp;
 }
 
 
@@ -155,16 +155,16 @@ void LLHUDEffectResetSkeleton::setTargetObject(LLViewerObject *objp)
 //-----------------------------------------------------------------------------
 void LLHUDEffectResetSkeleton::markDead()
 {
-	LLHUDEffect::markDead();
+    LLHUDEffect::markDead();
 }
 
 void LLHUDEffectResetSkeleton::setSourceObject(LLViewerObject* objectp)
 {
-	// restrict source objects to avatars
-	if (objectp && objectp->isAvatar())
-	{
-		LLHUDEffect::setSourceObject(objectp);
-	}
+    // restrict source objects to avatars
+    if (objectp && objectp->isAvatar())
+    {
+        LLHUDEffect::setSourceObject(objectp);
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -172,36 +172,36 @@ void LLHUDEffectResetSkeleton::setSourceObject(LLViewerObject* objectp)
 //-----------------------------------------------------------------------------
 void LLHUDEffectResetSkeleton::update()
 {
-	// If the target object is dead, set the target object to NULL
-	if (mTargetObject.isNull() || mTargetObject->isDead())
-	{
-		markDead();
-		return;
-	}
-
-	if (mSourceObject.isNull() || mSourceObject->isDead())
-	{
-		markDead();
-		return;
-	}
-	
-	bool owned = false;
-	if(mTargetObject->isAnimatedObject())
-	{
-		owned = mTargetObject->mOwnerID == mSourceObject->getID();
-	}
-	else
-	{
-		owned = mTargetObject->getID() == mSourceObject->getID();
-	}
-
-	if (owned)
-	{
-		if (mTargetObject->isAvatar() || mTargetObject->isAnimatedObject())
-		{
-			((LLVOAvatar*)(LLViewerObject*)mTargetObject)->resetSkeleton(mResetAnimations);
-		}
-	}
-	
-	markDead();
+    // If the target object is dead, set the target object to NULL
+    if (mTargetObject.isNull() || mTargetObject->isDead())
+    {
+        markDead();
+        return;
+    }
+
+    if (mSourceObject.isNull() || mSourceObject->isDead())
+    {
+        markDead();
+        return;
+    }
+
+    bool owned = false;
+    if(mTargetObject->isAnimatedObject())
+    {
+        owned = mTargetObject->mOwnerID == mSourceObject->getID();
+    }
+    else
+    {
+        owned = mTargetObject->getID() == mSourceObject->getID();
+    }
+
+    if (owned)
+    {
+        if (mTargetObject->isAvatar() || mTargetObject->isAnimatedObject())
+        {
+            ((LLVOAvatar*)(LLViewerObject*)mTargetObject)->resetSkeleton(mResetAnimations);
+        }
+    }
+
+    markDead();
 }
diff --git a/indra/newview/llhudeffectresetskeleton.h b/indra/newview/llhudeffectresetskeleton.h
index ddac84165f3..39a61370548 100644
--- a/indra/newview/llhudeffectresetskeleton.h
+++ b/indra/newview/llhudeffectresetskeleton.h
@@ -1,25 +1,25 @@
-/** 
+/**
  * @file llhudeffectresetskeleton.h
  * @brief LLHUDEffectResetSkeleton class definition
  *
  * $LicenseInfo:firstyear=2024&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2024, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
@@ -36,24 +36,24 @@ class LLVOAvatar;
 class LLHUDEffectResetSkeleton final : public LLHUDEffect
 {
 public:
-	friend class LLHUDObject;
+    friend class LLHUDObject;
 
-	/*virtual*/ void markDead();
-	/*virtual*/ void setSourceObject(LLViewerObject* objectp);
+    /*virtual*/ void markDead();
+    /*virtual*/ void setSourceObject(LLViewerObject* objectp);
 
-	void setTargetObject(LLViewerObject *objp);
-	void setResetAnimations(bool enable){ mResetAnimations = enable; };
+    void setTargetObject(LLViewerObject *objp);
+    void setResetAnimations(bool enable){ mResetAnimations = enable; };
 
 protected:
-	LLHUDEffectResetSkeleton(const U8 type);
-	~LLHUDEffectResetSkeleton();
+    LLHUDEffectResetSkeleton(const U8 type);
+    ~LLHUDEffectResetSkeleton();
 
-	/*virtual*/ void packData(LLMessageSystem *mesgsys);
-	/*virtual*/ void unpackData(LLMessageSystem *mesgsys, S32 blocknum);
+    /*virtual*/ void packData(LLMessageSystem *mesgsys);
+    /*virtual*/ void unpackData(LLMessageSystem *mesgsys, S32 blocknum);
 
-	void update();
+    void update();
 private:
-	bool						mResetAnimations;
+    bool                        mResetAnimations;
 };
 
 #endif // LL_LLHUDEFFECTRESETSKELETON_H
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index dcccd244013..d019200012a 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -620,19 +620,19 @@ void LLViewerJoystick::refreshFromSettings()
     mFlycamFeathering = gSavedSettings.getF32("FlycamFeathering");
 
     mInvertPitch = gSavedSettings.getBOOL("JoystickInvertPitch");
-	
-	mMappedButtons[ROLL_LEFT] = gSavedSettings.getS32("JoystickButtonRollLeft");
-	mMappedButtons[ROLL_RIGHT] = gSavedSettings.getS32("JoystickButtonRollRight");
-	mMappedButtons[ROLL_DEFAULT] = gSavedSettings.getS32("JoystickButtonRollDefault");
-	mMappedButtons[ZOOM_OUT] = gSavedSettings.getS32("JoystickButtonZoomOut");
-	mMappedButtons[ZOOM_IN] = gSavedSettings.getS32("JoystickButtonZoomIn");
-	mMappedButtons[ZOOM_DEFAULT] = gSavedSettings.getS32("JoystickButtonZoomDefault");
-	mMappedButtons[JUMP] = gSavedSettings.getS32("JoystickButtonJump");
-	mMappedButtons[CROUCH] = gSavedSettings.getS32("JoystickButtonCrouch");
-	mMappedButtons[FLY] = gSavedSettings.getS32("JoystickButtonFly");
-	mMappedButtons[MOUSELOOK] = gSavedSettings.getS32("JoystickButtonMouselook");
-	mMappedButtons[FLYCAM] = gSavedSettings.getS32("JoystickButtonFlycam");
-	mMappedButtons[TOGGLE_RUN] = gSavedSettings.getS32("JoystickButtonRunToggle");
+
+    mMappedButtons[ROLL_LEFT] = gSavedSettings.getS32("JoystickButtonRollLeft");
+    mMappedButtons[ROLL_RIGHT] = gSavedSettings.getS32("JoystickButtonRollRight");
+    mMappedButtons[ROLL_DEFAULT] = gSavedSettings.getS32("JoystickButtonRollDefault");
+    mMappedButtons[ZOOM_OUT] = gSavedSettings.getS32("JoystickButtonZoomOut");
+    mMappedButtons[ZOOM_IN] = gSavedSettings.getS32("JoystickButtonZoomIn");
+    mMappedButtons[ZOOM_DEFAULT] = gSavedSettings.getS32("JoystickButtonZoomDefault");
+    mMappedButtons[JUMP] = gSavedSettings.getS32("JoystickButtonJump");
+    mMappedButtons[CROUCH] = gSavedSettings.getS32("JoystickButtonCrouch");
+    mMappedButtons[FLY] = gSavedSettings.getS32("JoystickButtonFly");
+    mMappedButtons[MOUSELOOK] = gSavedSettings.getS32("JoystickButtonMouselook");
+    mMappedButtons[FLYCAM] = gSavedSettings.getS32("JoystickButtonFlycam");
+    mMappedButtons[TOGGLE_RUN] = gSavedSettings.getS32("JoystickButtonRunToggle");
 }
 
 void LLViewerJoystick::initDevice(LLSD &guid)
@@ -987,17 +987,17 @@ void LLViewerJoystick::moveObjects(bool reset)
     bool is_zero = true;
 
     static LLCachedControl<bool> blackdragon(gSavedSettings, "BlackDragonControls", false);
-	if(blackdragon)
-	{
-		//BD - Avoid making ridicously big movements if there's a big drop in fps 
-		time = llclamp(time, 0.016f, 0.033f);
+    if(blackdragon)
+    {
+        //BD - Avoid making ridicously big movements if there's a big drop in fps
+        time = llclamp(time, 0.016f, 0.033f);
 
-	//	//BD - Remappable Joystick Controls
+    //  //BD - Remappable Joystick Controls
 
-	
-		for (U32 i = 0; i < 6; i++)
-		{
-			cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
+
+        for (U32 i = 0; i < 6; i++)
+        {
+            cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
 
             if (i == CAM_X_AXIS)
             {
@@ -1010,89 +1010,89 @@ void LLViewerJoystick::moveObjects(bool reset)
                 cur_delta[i] -= (F32)getJoystickButton(mMappedButtons[CROUCH]);
             }
 
-	//		//BD - Invertable Pitch Controls
+    //      //BD - Invertable Pitch Controls
             if (mInvertPitch && i == 4)
-				cur_delta[4] *= -1.f;
-
-			F32 tmp = cur_delta[i];
-			F32 axis_deadzone = mBuildAxisDeadZone[i];
-			if (m3DCursor || llabs(cur_delta[i]) < axis_deadzone)
-			{
-				cur_delta[i] = cur_delta[i] - sLastDelta[i];
-			}
-			sLastDelta[i] = tmp;
-			is_zero = is_zero && (cur_delta[i] == 0.f);
-			
-			//BD - We assume that delta 1.0 is the maximum.
-			if (llabs(cur_delta[i]) > axis_deadzone)
-			{
-				//BD - Clamp the delta between 1 and -1 while taking the deadzone into account.
-				if (cur_delta[i] > 0)
-				{
-					cur_delta[i] = llclamp(cur_delta[i] - axis_deadzone, 0.f, 1.f - axis_deadzone);
-				}
-				else
-				{
-					cur_delta[i] = llclamp(cur_delta[i] + axis_deadzone, -1.f + axis_deadzone, 0.f);
-				}
-				//BD - Rescale the remaining delta to match the maximum to get a new clean 0 to 1 range.
-				cur_delta[i] = cur_delta[i] / (1.f - axis_deadzone);
-			}
-			cur_delta[i] *= mBuildAxisScale[i];
-		
-			if (!m3DCursor)
-			{
-				cur_delta[i] *= time;
-			}
-
-			sDelta[i] = sDelta[i] + (cur_delta[i] - sDelta[i]) * time * mBuildFeathering;
-		}
-	}
-	else
-	{
-	    // avoid making ridicously big movements if there's a big drop in fps
-	    if (time > .2f)
-	    {
-	        time = .2f;
-	    }
-
-	    // max feather is 32
-	    F32 feather = mBuildFeathering;
-	    bool absolute = m3DCursor;
-
-	    for (U32 i = 0; i < 6; i++)
-	    {
-	        cur_delta[i] = -mAxes[mJoystickAxis[i]];
-	//      //BD - Invertable Pitch Controls
-	        if (!mInvertPitch && i == 4)
-	            cur_delta[i] = -cur_delta[i];
-
-	        F32 tmp = cur_delta[i];
-	        if (absolute)
-	        {
-	            cur_delta[i] = cur_delta[i] - sLastDelta[i];
-	        }
-	        sLastDelta[i] = tmp;
-	        is_zero = is_zero && (cur_delta[i] == 0.f);
-
-	        if (cur_delta[i] > 0)
-	        {
-	            cur_delta[i] = llmax(cur_delta[i]- mBuildAxisDeadZone[i], 0.f);
-	        }
-	        else
-	        {
-	            cur_delta[i] = llmin(cur_delta[i]+ mBuildAxisDeadZone[i], 0.f);
-	        }
-	        cur_delta[i] *= mBuildAxisScale[i];
-
-	        if (!absolute)
-	        {
-	            cur_delta[i] *= time;
-	        }
-
-	        sDelta[i] = sDelta[i] + (cur_delta[i]-sDelta[i])*time*feather;
-	    }
-	}
+                cur_delta[4] *= -1.f;
+
+            F32 tmp = cur_delta[i];
+            F32 axis_deadzone = mBuildAxisDeadZone[i];
+            if (m3DCursor || llabs(cur_delta[i]) < axis_deadzone)
+            {
+                cur_delta[i] = cur_delta[i] - sLastDelta[i];
+            }
+            sLastDelta[i] = tmp;
+            is_zero = is_zero && (cur_delta[i] == 0.f);
+
+            //BD - We assume that delta 1.0 is the maximum.
+            if (llabs(cur_delta[i]) > axis_deadzone)
+            {
+                //BD - Clamp the delta between 1 and -1 while taking the deadzone into account.
+                if (cur_delta[i] > 0)
+                {
+                    cur_delta[i] = llclamp(cur_delta[i] - axis_deadzone, 0.f, 1.f - axis_deadzone);
+                }
+                else
+                {
+                    cur_delta[i] = llclamp(cur_delta[i] + axis_deadzone, -1.f + axis_deadzone, 0.f);
+                }
+                //BD - Rescale the remaining delta to match the maximum to get a new clean 0 to 1 range.
+                cur_delta[i] = cur_delta[i] / (1.f - axis_deadzone);
+            }
+            cur_delta[i] *= mBuildAxisScale[i];
+
+            if (!m3DCursor)
+            {
+                cur_delta[i] *= time;
+            }
+
+            sDelta[i] = sDelta[i] + (cur_delta[i] - sDelta[i]) * time * mBuildFeathering;
+        }
+    }
+    else
+    {
+        // avoid making ridicously big movements if there's a big drop in fps
+        if (time > .2f)
+        {
+            time = .2f;
+        }
+
+        // max feather is 32
+        F32 feather = mBuildFeathering;
+        bool absolute = m3DCursor;
+
+        for (U32 i = 0; i < 6; i++)
+        {
+            cur_delta[i] = -mAxes[mJoystickAxis[i]];
+    //      //BD - Invertable Pitch Controls
+            if (!mInvertPitch && i == 4)
+                cur_delta[i] = -cur_delta[i];
+
+            F32 tmp = cur_delta[i];
+            if (absolute)
+            {
+                cur_delta[i] = cur_delta[i] - sLastDelta[i];
+            }
+            sLastDelta[i] = tmp;
+            is_zero = is_zero && (cur_delta[i] == 0.f);
+
+            if (cur_delta[i] > 0)
+            {
+                cur_delta[i] = llmax(cur_delta[i]- mBuildAxisDeadZone[i], 0.f);
+            }
+            else
+            {
+                cur_delta[i] = llmin(cur_delta[i]+ mBuildAxisDeadZone[i], 0.f);
+            }
+            cur_delta[i] *= mBuildAxisScale[i];
+
+            if (!absolute)
+            {
+                cur_delta[i] *= time;
+            }
+
+            sDelta[i] = sDelta[i] + (cur_delta[i]-sDelta[i])*time*feather;
+        }
+    }
 
     U32 upd_type = UPD_NONE;
     LLVector3 v;
@@ -1152,81 +1152,81 @@ void LLViewerJoystick::moveAvatar(bool reset)
 
     static LLCachedControl<bool> blackdragon(gSavedSettings, "BlackDragonControls", false);
     if (blackdragon)
-	{
-		bool is_zero = true;
-		static bool button_held = false;
-		//BD
-		static bool w_button_held = false;
-		static bool m_button_held = false;
-
-	//	//BD - Remappable Joystick Controls
-		if (getJoystickButton(mMappedButtons[FLY]) == 1 && !button_held)
-		{
-			button_held = true;
-			if (gAgent.getFlying())
-			{
-				gAgent.setFlying(FALSE);
-			}
-			else
-			{
-				gAgent.setFlying(TRUE);
-			}
-		}
-		else if (getJoystickButton(mMappedButtons[FLY]) == 0 && button_held)
-		{
-			button_held = false;
-		}
-
-		if (getJoystickButton(mMappedButtons[TOGGLE_RUN]) == 1 && !w_button_held)
-		{
-			w_button_held = true;
-			if (gAgent.getAlwaysRun())
-			{
-				gAgent.clearAlwaysRun();
-			}
-			else
-			{
-				gAgent.setAlwaysRun();
-			}
-		}
-		else if (getJoystickButton(mMappedButtons[TOGGLE_RUN]) == 0 && w_button_held)
-		{
-			w_button_held = false;
-		}
-
-		if (getJoystickButton(mMappedButtons[MOUSELOOK]) == 1 && !m_button_held)
-		{
-			m_button_held = true;
-			if (gAgentCamera.cameraMouselook())
-			{
-				gAgentCamera.changeCameraToDefault();
-			}
-			else
-			{
-				gAgentCamera.changeCameraToMouselook();
-			}
-		}
-		else if (getJoystickButton(mMappedButtons[MOUSELOOK]) == 0 && m_button_held)
-		{
-			m_button_held = false;
-		}
-
-		// time interval in seconds between this frame and the previous
-		F32 time = gFrameIntervalSeconds.value();
-
-		//BD - Avoid making ridicously big movements if there's a big drop in fps 
-		time = llclamp(time, 0.016f, 0.033f);
-
-		// note: max feather is 32.0
-	
+    {
+        bool is_zero = true;
+        static bool button_held = false;
+        //BD
+        static bool w_button_held = false;
+        static bool m_button_held = false;
+
+    //  //BD - Remappable Joystick Controls
+        if (getJoystickButton(mMappedButtons[FLY]) == 1 && !button_held)
+        {
+            button_held = true;
+            if (gAgent.getFlying())
+            {
+                gAgent.setFlying(FALSE);
+            }
+            else
+            {
+                gAgent.setFlying(TRUE);
+            }
+        }
+        else if (getJoystickButton(mMappedButtons[FLY]) == 0 && button_held)
+        {
+            button_held = false;
+        }
+
+        if (getJoystickButton(mMappedButtons[TOGGLE_RUN]) == 1 && !w_button_held)
+        {
+            w_button_held = true;
+            if (gAgent.getAlwaysRun())
+            {
+                gAgent.clearAlwaysRun();
+            }
+            else
+            {
+                gAgent.setAlwaysRun();
+            }
+        }
+        else if (getJoystickButton(mMappedButtons[TOGGLE_RUN]) == 0 && w_button_held)
+        {
+            w_button_held = false;
+        }
+
+        if (getJoystickButton(mMappedButtons[MOUSELOOK]) == 1 && !m_button_held)
+        {
+            m_button_held = true;
+            if (gAgentCamera.cameraMouselook())
+            {
+                gAgentCamera.changeCameraToDefault();
+            }
+            else
+            {
+                gAgentCamera.changeCameraToMouselook();
+            }
+        }
+        else if (getJoystickButton(mMappedButtons[MOUSELOOK]) == 0 && m_button_held)
+        {
+            m_button_held = false;
+        }
+
+        // time interval in seconds between this frame and the previous
+        F32 time = gFrameIntervalSeconds.value();
+
+        //BD - Avoid making ridicously big movements if there's a big drop in fps
+        time = llclamp(time, 0.016f, 0.033f);
+
+        // note: max feather is 32.0
+
         F32 cur_delta[6] = {};
-		F32 val, dom_mov = 0.f;
-		U32 dom_axis = Z_I;
+        F32 val, dom_mov = 0.f;
+        U32 dom_axis = Z_I;
 
-		// remove dead zones and determine biggest movement on the joystick 
-		for (U32 i = 0; i < 6; i++)
-		{
-			cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
+        // remove dead zones and determine biggest movement on the joystick
+        for (U32 i = 0; i < 6; i++)
+        {
+            cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
 
             if(i == Z_AXIS)
             {
@@ -1234,289 +1234,289 @@ void LLViewerJoystick::moveAvatar(bool reset)
                 cur_delta[i] -= (F32)getJoystickButton(mMappedButtons[CROUCH]);
             }
 
-			F32 axis_deadzone = mAvatarAxisDeadZone[i];
-
-			//BD - We assume that delta 1.0 is the maximum.
-			if (llabs(cur_delta[i]) > axis_deadzone)
-			{
-				//BD - Clamp the delta between 1 and -1 while taking the deadzone into account.
-				if (cur_delta[i] > 0)
-				{
-					cur_delta[i] = llclamp(cur_delta[i] - axis_deadzone, 0.f, 1.f - axis_deadzone);
-				}
-				else
-				{
-					cur_delta[i] = llclamp(cur_delta[i] + axis_deadzone, -1.f + axis_deadzone, 0.f);
-				}
-				//BD - Rescale the remaining delta to match the maximum to get a new clean 0 to 1 range.
-				cur_delta[i] = cur_delta[i] / (1.f - axis_deadzone);
-			}
-			else
-			{
-				cur_delta[i] = 0.f;
-			}
-
-			// we don't care about Roll (RZ) and Z is calculated after the loop
-	        if (i != Z_I && i != RZ_I)
-			{
-				// find out the axis with the biggest joystick motion
-				val = fabs(cur_delta[i]);
-				if (val > dom_mov)
-				{
-					dom_axis = i;
-					dom_mov = val;
-				}
-			}
-		
-			cur_delta[i] *= mAvatarAxisScale[i] * time;
-
-			//sDelta[i] = sDelta[i] + (cur_delta[i] - sDelta[i]) * time;
-			is_zero = is_zero && (cur_delta[i] == 0.f);
-		}
-
-		if (!is_zero)
-		{
-			// Clear AFK state if moved beyond the deadzone
-			if (gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
-			{
-				gAgent.clearAFK();
-			}
-		
-			setCameraNeedsUpdate(true);
-		}
-
-	//	//BD - Invertable Pitch Controls
-		if (!mInvertPitch)
-			cur_delta[RX_I] = -cur_delta[RX_I];
-
-		// forward|backward movements overrule the real dominant movement if 
-		// they're bigger than its 20%. This is what you want 'cos moving forward
-		// is what you do most. We also added a special (even more lenient) case 
-		// for RX|RY to allow walking while pitching and turning
-		if (fabs(cur_delta[Z_I]) > .2f * dom_mov
-		    || ((dom_axis == RX_I || dom_axis == RY_I) 
-			&& fabs(cur_delta[Z_I]) > .05f * dom_mov))
-		{
-			dom_axis = Z_I;
-		}
-
-		sDelta[X_I] = -cur_delta[X_I];
-		sDelta[Y_I] = -cur_delta[Y_I];
-		sDelta[Z_I] = -cur_delta[Z_I];
-		cur_delta[RX_I] *= -mAvatarAxisScale[RX_I];
-		cur_delta[RY_I] *= -mAvatarAxisScale[RY_I];
-		
-		sDelta[RX_I] += (cur_delta[RX_I] - sDelta[RX_I]) * time * mAvatarFeathering;
-		sDelta[RY_I] += (cur_delta[RY_I] - sDelta[RY_I]) * time * mAvatarFeathering;
-	
-		handleRun((F32) sqrt(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I]));
-	
-	//	//BD - Xbox360 Controller Support
-		//     Use raw deltas, do not add any stupid limitations or extra dead zones
-		//     otherwise alot controllers will cry and camera movement will bug out
-		//     or be completely ignored on some controllers. Especially fixes Xbox 360
-		//     controller avatar movement.
-		agentSlide(sDelta[X_I]);		// move sideways
-		agentFly(sDelta[Y_I]);			// up/down & crouch
-		agentPush(sDelta[Z_I]);			// forward/back
-		agentPitch(sDelta[RX_I]);		// pitch
-		agentYaw(sDelta[RY_I]);			// turn
-	}
-	else
-	{
-	    bool is_zero = true;
-	    static bool button_held = false;
-
-	    if (mBtn[1] == 1)
-	    {
-	        // If AutomaticFly is enabled, then button1 merely causes a
-	        // jump (as the up/down axis already controls flying) if on the
-	        // ground, or cease flight if already flying.
-	        // If AutomaticFly is disabled, then button1 toggles flying.
-	        if (ALControlCache::AutomaticFly)
-	        {
-	            if (!gAgent.getFlying())
-	            {
-	                gAgent.moveUp(1);
-	            }
-	            else if (!button_held)
-	            {
-	                button_held = true;
-	                gAgent.setFlying(FALSE);
-	            }
-	        }
-	        else if (!button_held)
-	        {
-	            button_held = true;
-	            gAgent.setFlying(!gAgent.getFlying());
-	        }
-
-	        is_zero = false;
-	    }
-	    else
-	    {
-	        button_held = false;
-	    }
-
-	    // time interval in seconds between this frame and the previous
-	    F32 time = gFrameIntervalSeconds.value();
-
-	    // avoid making ridicously big movements if there's a big drop in fps
-	    if (time > .2f)
-	    {
-	        time = .2f;
-	    }
-
-	    // note: max feather is 32.0
-	    F32 feather = mAvatarFeathering;
-
-	    F32 cur_delta[6];
-	    F32 val, dom_mov = 0.f;
-	    U32 dom_axis = Z_I;
-	#if LIB_NDOF
-	    bool absolute = (m3DCursor && mNdofDev->absolute);
-	#else
-	    bool absolute = false;
-	#endif
-	    // remove dead zones and determine biggest movement on the joystick
-	    for (U32 i = 0; i < 6; i++)
-	    {
-	        cur_delta[i] = -mAxes[mJoystickAxis[i]];
-
-	        if (!mInvertPitch && i == 4)
-	            cur_delta[i] = -cur_delta[i];
-
-	        if (absolute)
-	        {
-	            F32 tmp = cur_delta[i];
-	            cur_delta[i] = cur_delta[i] - sLastDelta[i];
-	            sLastDelta[i] = tmp;
-	        }
-
-	        if (cur_delta[i] > 0)
-	        {
-	            cur_delta[i] = llmax(cur_delta[i]- mAvatarAxisDeadZone[i], 0.f);
-	        }
-	        else
-	        {
-	            cur_delta[i] = llmin(cur_delta[i]+ mAvatarAxisDeadZone[i], 0.f);
-	        }
-
-	        // we don't care about Roll (RZ) and Z is calculated after the loop
-	        if (i != Z_I && i != RZ_I)
-	        {
-	            // find out the axis with the biggest joystick motion
-	            val = fabs(cur_delta[i]);
-	            if (val > dom_mov)
-	            {
-	                dom_axis = i;
-	                dom_mov = val;
-	            }
-	        }
-
-	        is_zero = is_zero && (cur_delta[i] == 0.f);
-	    }
-
-	    if (!is_zero)
-	    {
-	        // Clear AFK state if moved beyond the deadzone
-	        if (gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
-	        {
-	            gAgent.clearAFK();
-	        }
-
-	        setCameraNeedsUpdate(true);
-	    }
-
-	    // forward|backward movements overrule the real dominant movement if
-	    // they're bigger than its 20%. This is what you want 'cos moving forward
-	    // is what you do most. We also added a special (even more lenient) case
-	    // for RX|RY to allow walking while pitching and turning
-	    if (fabs(cur_delta[Z_I]) > .2f * dom_mov
-	        || ((dom_axis == RX_I || dom_axis == RY_I)
-	        && fabs(cur_delta[Z_I]) > .05f * dom_mov))
-	    {
-	        dom_axis = Z_I;
-	    }
-
-	    sDelta[X_I] = -cur_delta[X_I] * mAvatarAxisScale[X_I];
-	    sDelta[Y_I] = -cur_delta[Y_I] * mAvatarAxisScale[Y_I];
-	    sDelta[Z_I] = -cur_delta[Z_I] * mAvatarAxisScale[Z_I];
-	    cur_delta[RX_I] *= -mAvatarAxisScale[RX_I] * mPerfScale;
-	    cur_delta[RY_I] *= -mAvatarAxisScale[RY_I] * mPerfScale;
-
-	    if (!absolute)
-	    {
-	        cur_delta[RX_I] *= time;
-	        cur_delta[RY_I] *= time;
-	    }
-	    sDelta[RX_I] += (cur_delta[RX_I] - sDelta[RX_I]) * time * feather;
-	    sDelta[RY_I] += (cur_delta[RY_I] - sDelta[RY_I]) * time * feather;
-
-	    handleRun((F32) sqrt(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I]));
-
-	    // Allow forward/backward movement some priority
-	    if (dom_axis == Z_I)
-	    {
-	        agentPush(sDelta[Z_I]);         // forward/back
-
-	        if (fabs(sDelta[X_I])  > .1f)
-	        {
-	            agentSlide(sDelta[X_I]);    // move sideways
-	        }
-
-	        if (fabs(sDelta[Y_I])  > .1f)
-	        {
-	            agentFly(sDelta[Y_I]);      // up/down & crouch
-	        }
-
-	        // too many rotations during walking can be confusing, so apply
-	        // the deadzones one more time (quick & dirty), at 50%|30% power
-	        F32 eff_rx = .3f * mAvatarAxisDeadZone[RX_I];
-	        F32 eff_ry = .3f * mAvatarAxisDeadZone[RY_I];
-
-	        if (sDelta[RX_I] > 0)
-	        {
-	            eff_rx = llmax(sDelta[RX_I] - eff_rx, 0.f);
-	        }
-	        else
-	        {
-	            eff_rx = llmin(sDelta[RX_I] + eff_rx, 0.f);
-	        }
-
-	        if (sDelta[RY_I] > 0)
-	        {
-	            eff_ry = llmax(sDelta[RY_I] - eff_ry, 0.f);
-	        }
-	        else
-	        {
-	            eff_ry = llmin(sDelta[RY_I] + eff_ry, 0.f);
-	        }
-
-
-	        if (fabs(eff_rx) > 0.f || fabs(eff_ry) > 0.f)
-	        {
-	            if (gAgent.getFlying())
-	            {
-	                agentPitch(eff_rx);
-	                agentYaw(eff_ry);
-	            }
-	            else
-	            {
-	                agentPitch(eff_rx);
-	                agentYaw(2.f * eff_ry);
-	            }
-	        }
-	    }
-	    else
-	    {
-	        agentSlide(sDelta[X_I]);        // move sideways
-	        agentFly(sDelta[Y_I]);          // up/down & crouch
-	        agentPush(sDelta[Z_I]);         // forward/back
-	        agentPitch(sDelta[RX_I]);       // pitch
-	        agentYaw(sDelta[RY_I]);         // turn
-	    }
-	}
+            F32 axis_deadzone = mAvatarAxisDeadZone[i];
+
+            //BD - We assume that delta 1.0 is the maximum.
+            if (llabs(cur_delta[i]) > axis_deadzone)
+            {
+                //BD - Clamp the delta between 1 and -1 while taking the deadzone into account.
+                if (cur_delta[i] > 0)
+                {
+                    cur_delta[i] = llclamp(cur_delta[i] - axis_deadzone, 0.f, 1.f - axis_deadzone);
+                }
+                else
+                {
+                    cur_delta[i] = llclamp(cur_delta[i] + axis_deadzone, -1.f + axis_deadzone, 0.f);
+                }
+                //BD - Rescale the remaining delta to match the maximum to get a new clean 0 to 1 range.
+                cur_delta[i] = cur_delta[i] / (1.f - axis_deadzone);
+            }
+            else
+            {
+                cur_delta[i] = 0.f;
+            }
+
+            // we don't care about Roll (RZ) and Z is calculated after the loop
+            if (i != Z_I && i != RZ_I)
+            {
+                // find out the axis with the biggest joystick motion
+                val = fabs(cur_delta[i]);
+                if (val > dom_mov)
+                {
+                    dom_axis = i;
+                    dom_mov = val;
+                }
+            }
+
+            cur_delta[i] *= mAvatarAxisScale[i] * time;
+
+            //sDelta[i] = sDelta[i] + (cur_delta[i] - sDelta[i]) * time;
+            is_zero = is_zero && (cur_delta[i] == 0.f);
+        }
+
+        if (!is_zero)
+        {
+            // Clear AFK state if moved beyond the deadzone
+            if (gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
+            {
+                gAgent.clearAFK();
+            }
+
+            setCameraNeedsUpdate(true);
+        }
+
+    //  //BD - Invertable Pitch Controls
+        if (!mInvertPitch)
+            cur_delta[RX_I] = -cur_delta[RX_I];
+
+        // forward|backward movements overrule the real dominant movement if
+        // they're bigger than its 20%. This is what you want 'cos moving forward
+        // is what you do most. We also added a special (even more lenient) case
+        // for RX|RY to allow walking while pitching and turning
+        if (fabs(cur_delta[Z_I]) > .2f * dom_mov
+            || ((dom_axis == RX_I || dom_axis == RY_I)
+            && fabs(cur_delta[Z_I]) > .05f * dom_mov))
+        {
+            dom_axis = Z_I;
+        }
+
+        sDelta[X_I] = -cur_delta[X_I];
+        sDelta[Y_I] = -cur_delta[Y_I];
+        sDelta[Z_I] = -cur_delta[Z_I];
+        cur_delta[RX_I] *= -mAvatarAxisScale[RX_I];
+        cur_delta[RY_I] *= -mAvatarAxisScale[RY_I];
+
+        sDelta[RX_I] += (cur_delta[RX_I] - sDelta[RX_I]) * time * mAvatarFeathering;
+        sDelta[RY_I] += (cur_delta[RY_I] - sDelta[RY_I]) * time * mAvatarFeathering;
+
+        handleRun((F32) sqrt(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I]));
+
+    //  //BD - Xbox360 Controller Support
+        //     Use raw deltas, do not add any stupid limitations or extra dead zones
+        //     otherwise alot controllers will cry and camera movement will bug out
+        //     or be completely ignored on some controllers. Especially fixes Xbox 360
+        //     controller avatar movement.
+        agentSlide(sDelta[X_I]);        // move sideways
+        agentFly(sDelta[Y_I]);          // up/down & crouch
+        agentPush(sDelta[Z_I]);         // forward/back
+        agentPitch(sDelta[RX_I]);       // pitch
+        agentYaw(sDelta[RY_I]);         // turn
+    }
+    else
+    {
+        bool is_zero = true;
+        static bool button_held = false;
+
+        if (mBtn[1] == 1)
+        {
+            // If AutomaticFly is enabled, then button1 merely causes a
+            // jump (as the up/down axis already controls flying) if on the
+            // ground, or cease flight if already flying.
+            // If AutomaticFly is disabled, then button1 toggles flying.
+            if (ALControlCache::AutomaticFly)
+            {
+                if (!gAgent.getFlying())
+                {
+                    gAgent.moveUp(1);
+                }
+                else if (!button_held)
+                {
+                    button_held = true;
+                    gAgent.setFlying(FALSE);
+                }
+            }
+            else if (!button_held)
+            {
+                button_held = true;
+                gAgent.setFlying(!gAgent.getFlying());
+            }
+
+            is_zero = false;
+        }
+        else
+        {
+            button_held = false;
+        }
+
+        // time interval in seconds between this frame and the previous
+        F32 time = gFrameIntervalSeconds.value();
+
+        // avoid making ridicously big movements if there's a big drop in fps
+        if (time > .2f)
+        {
+            time = .2f;
+        }
+
+        // note: max feather is 32.0
+        F32 feather = mAvatarFeathering;
+
+        F32 cur_delta[6];
+        F32 val, dom_mov = 0.f;
+        U32 dom_axis = Z_I;
+    #if LIB_NDOF
+        bool absolute = (m3DCursor && mNdofDev->absolute);
+    #else
+        bool absolute = false;
+    #endif
+        // remove dead zones and determine biggest movement on the joystick
+        for (U32 i = 0; i < 6; i++)
+        {
+            cur_delta[i] = -mAxes[mJoystickAxis[i]];
+
+            if (!mInvertPitch && i == 4)
+                cur_delta[i] = -cur_delta[i];
+
+            if (absolute)
+            {
+                F32 tmp = cur_delta[i];
+                cur_delta[i] = cur_delta[i] - sLastDelta[i];
+                sLastDelta[i] = tmp;
+            }
+
+            if (cur_delta[i] > 0)
+            {
+                cur_delta[i] = llmax(cur_delta[i]- mAvatarAxisDeadZone[i], 0.f);
+            }
+            else
+            {
+                cur_delta[i] = llmin(cur_delta[i]+ mAvatarAxisDeadZone[i], 0.f);
+            }
+
+            // we don't care about Roll (RZ) and Z is calculated after the loop
+            if (i != Z_I && i != RZ_I)
+            {
+                // find out the axis with the biggest joystick motion
+                val = fabs(cur_delta[i]);
+                if (val > dom_mov)
+                {
+                    dom_axis = i;
+                    dom_mov = val;
+                }
+            }
+
+            is_zero = is_zero && (cur_delta[i] == 0.f);
+        }
+
+        if (!is_zero)
+        {
+            // Clear AFK state if moved beyond the deadzone
+            if (gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
+            {
+                gAgent.clearAFK();
+            }
+
+            setCameraNeedsUpdate(true);
+        }
+
+        // forward|backward movements overrule the real dominant movement if
+        // they're bigger than its 20%. This is what you want 'cos moving forward
+        // is what you do most. We also added a special (even more lenient) case
+        // for RX|RY to allow walking while pitching and turning
+        if (fabs(cur_delta[Z_I]) > .2f * dom_mov
+            || ((dom_axis == RX_I || dom_axis == RY_I)
+            && fabs(cur_delta[Z_I]) > .05f * dom_mov))
+        {
+            dom_axis = Z_I;
+        }
+
+        sDelta[X_I] = -cur_delta[X_I] * mAvatarAxisScale[X_I];
+        sDelta[Y_I] = -cur_delta[Y_I] * mAvatarAxisScale[Y_I];
+        sDelta[Z_I] = -cur_delta[Z_I] * mAvatarAxisScale[Z_I];
+        cur_delta[RX_I] *= -mAvatarAxisScale[RX_I] * mPerfScale;
+        cur_delta[RY_I] *= -mAvatarAxisScale[RY_I] * mPerfScale;
+
+        if (!absolute)
+        {
+            cur_delta[RX_I] *= time;
+            cur_delta[RY_I] *= time;
+        }
+        sDelta[RX_I] += (cur_delta[RX_I] - sDelta[RX_I]) * time * feather;
+        sDelta[RY_I] += (cur_delta[RY_I] - sDelta[RY_I]) * time * feather;
+
+        handleRun((F32) sqrt(sDelta[Z_I]*sDelta[Z_I] + sDelta[X_I]*sDelta[X_I]));
+
+        // Allow forward/backward movement some priority
+        if (dom_axis == Z_I)
+        {
+            agentPush(sDelta[Z_I]);         // forward/back
+
+            if (fabs(sDelta[X_I])  > .1f)
+            {
+                agentSlide(sDelta[X_I]);    // move sideways
+            }
+
+            if (fabs(sDelta[Y_I])  > .1f)
+            {
+                agentFly(sDelta[Y_I]);      // up/down & crouch
+            }
+
+            // too many rotations during walking can be confusing, so apply
+            // the deadzones one more time (quick & dirty), at 50%|30% power
+            F32 eff_rx = .3f * mAvatarAxisDeadZone[RX_I];
+            F32 eff_ry = .3f * mAvatarAxisDeadZone[RY_I];
+
+            if (sDelta[RX_I] > 0)
+            {
+                eff_rx = llmax(sDelta[RX_I] - eff_rx, 0.f);
+            }
+            else
+            {
+                eff_rx = llmin(sDelta[RX_I] + eff_rx, 0.f);
+            }
+
+            if (sDelta[RY_I] > 0)
+            {
+                eff_ry = llmax(sDelta[RY_I] - eff_ry, 0.f);
+            }
+            else
+            {
+                eff_ry = llmin(sDelta[RY_I] + eff_ry, 0.f);
+            }
+
+
+            if (fabs(eff_rx) > 0.f || fabs(eff_ry) > 0.f)
+            {
+                if (gAgent.getFlying())
+                {
+                    agentPitch(eff_rx);
+                    agentYaw(eff_ry);
+                }
+                else
+                {
+                    agentPitch(eff_rx);
+                    agentYaw(2.f * eff_ry);
+                }
+            }
+        }
+        else
+        {
+            agentSlide(sDelta[X_I]);        // move sideways
+            agentFly(sDelta[Y_I]);          // up/down & crouch
+            agentPush(sDelta[Z_I]);         // forward/back
+            agentPitch(sDelta[RX_I]);       // pitch
+            agentYaw(sDelta[RY_I]);         // turn
+        }
+    }
 }
 
 // -----------------------------------------------------------------------------
@@ -1548,37 +1548,37 @@ void LLViewerJoystick::moveFlycam(bool reset)
 
     static LLCachedControl<bool> blackdragon(gSavedSettings, "BlackDragonControls", false);
     if (blackdragon)
-	{
-		F32 time = gFrameIntervalSeconds.value();
-
-		//BD - Avoid making ridiculously big movements if there's a big drop in fps 
-		time = llclamp(time, 0.016f, 0.033f);
-
-		F32 flycam_feather = mFlycamFeathering;
-		F32 cur_delta[MAX_AXES];
-		F32 max_angle = LLViewerCamera::getInstance()->getMaxView();
-		F32 min_angle = LLViewerCamera::getInstance()->getMinView();
-
-		//BD - Slam zoom back to default and kill any delta we might have.
-		if (getJoystickButton(mMappedButtons[ZOOM_DEFAULT]) == 1)
-		{
-			sFlycamZoom = gSavedSettings.getF32("CameraAngle");
-			sDelta[CAM_W_AXIS] = 0.0f;
-		}
-
-		//BD - Only smooth flycam zoom if we are not capping at the min/max otherwise the feathering
-		//     ends up working against previous input, delaying zoom in movement when we just zoomed
-		//     out beyond capped max for a bit and vise versa.
-		if ((sFlycamZoom <= min_angle
-			|| sFlycamZoom >= max_angle))
-		{
-			flycam_feather = 3.0f;
-		}
-
-		bool is_zero = true;
-		for (U32 i = 0; i < 7; i++)
-		{
-			cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
+    {
+        F32 time = gFrameIntervalSeconds.value();
+
+        //BD - Avoid making ridiculously big movements if there's a big drop in fps
+        time = llclamp(time, 0.016f, 0.033f);
+
+        F32 flycam_feather = mFlycamFeathering;
+        F32 cur_delta[MAX_AXES];
+        F32 max_angle = LLViewerCamera::getInstance()->getMaxView();
+        F32 min_angle = LLViewerCamera::getInstance()->getMinView();
+
+        //BD - Slam zoom back to default and kill any delta we might have.
+        if (getJoystickButton(mMappedButtons[ZOOM_DEFAULT]) == 1)
+        {
+            sFlycamZoom = gSavedSettings.getF32("CameraAngle");
+            sDelta[CAM_W_AXIS] = 0.0f;
+        }
+
+        //BD - Only smooth flycam zoom if we are not capping at the min/max otherwise the feathering
+        //     ends up working against previous input, delaying zoom in movement when we just zoomed
+        //     out beyond capped max for a bit and vise versa.
+        if ((sFlycamZoom <= min_angle
+            || sFlycamZoom >= max_angle))
+        {
+            flycam_feather = 3.0f;
+        }
+
+        bool is_zero = true;
+        for (U32 i = 0; i < 7; i++)
+        {
+            cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
 
             if (i == CAM_W_AXIS)
             {
@@ -1596,198 +1596,198 @@ void LLViewerJoystick::moveFlycam(bool reset)
                 cur_delta[i] += (F32)getJoystickButton(mMappedButtons[ROLL_RIGHT]);
             }
 
-			F32 tmp = cur_delta[i];
-			F32 axis_deadzone = mFlycamAxisDeadZone[i];
-			if (m3DCursor || llabs(cur_delta[i]) < axis_deadzone)
-			{
-				cur_delta[i] = cur_delta[i] - sLastDelta[i];
-			}
-			sLastDelta[i] = tmp;
-
-			//BD - We assume that delta 1.0 is the maximum.
-			if (llabs(cur_delta[i]) > axis_deadzone)
-			{
-				//BD - Clamp the delta between 1 and -1 while taking the deadzone into account.
-				if (cur_delta[i] > 0)
-				{
-					cur_delta[i] = llclamp(cur_delta[i] - axis_deadzone, 0.f, 1.f - axis_deadzone);
-				}
-				else
-				{
-					cur_delta[i] = llclamp(cur_delta[i] + axis_deadzone, -1.f + axis_deadzone, 0.f);
-				}
-				//BD - Rescale the remaining delta to match the maximum to get a new clean 0 to 1 range.
-				cur_delta[i] = cur_delta[i] / (1.f - axis_deadzone);
-			}
-
-			// We may want to scale camera movements up or down in build mode.
-			// NOTE: this needs to remain after the deadzone calculation, otherwise
-			// we have issues with flycam "jumping" when the build dialog is opened/closed  -Nyx
-			if (LLToolMgr::getInstance()->inBuildMode())
-			{
-				if (i == X_I || i == Y_I || i == Z_I)
-				{
-					cur_delta[i] *= build_mode_scale;
-				}
-			}
-
-			cur_delta[i] *= mFlycamAxisScale[i];
-
-			if (!m3DCursor)
-			{
-				cur_delta[i] *= time;
-			}
-
-			sDelta[i] = sDelta[i] + (cur_delta[i] - sDelta[i]) * time * flycam_feather;
-			is_zero = is_zero && (cur_delta[i] == 0.f);
-		}
-
-	//	//BD - Invertable Pitch Controls
-		if (mInvertPitch)
-			cur_delta[CAM_Y_AXIS] = -cur_delta[CAM_Y_AXIS];
-	
-		// Clear AFK state if moved beyond the deadzone
-		if (!is_zero && gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
-		{
-			gAgent.clearAFK();
-		}
-
-		sFlycamPosition += LLVector3(sDelta.data()) * sFlycamRotation;
-		LLMatrix3 rot_mat(sDelta[CAM_X_AXIS], sDelta[CAM_Y_AXIS], sDelta[CAM_Z_AXIS]);
-		sFlycamRotation = LLQuaternion(rot_mat)*sFlycamRotation;
-
-		if (mAutoLeveling || getJoystickButton(mMappedButtons[ROLL_DEFAULT]) == 1)
-		{
-			LLMatrix3 level(sFlycamRotation);
-
-			LLVector3 x = LLVector3(level.mMatrix[0]);
-			LLVector3 y = LLVector3(level.mMatrix[1]);
-			LLVector3 z = LLVector3(level.mMatrix[2]);
-
-			y.mV[2] = 0.f;
-			y.normVec();
-
-			level.setRows(x,y,z);
-			level.orthogonalize();
-				
-			LLQuaternion quat(level);
-			LLQuaternion lerp = nlerp(llmin(flycam_feather * time, 1.f), sFlycamRotation, quat);
-			sFlycamRotation = getJoystickButton(mMappedButtons[ROLL_DEFAULT]) == 1 ? quat : lerp;
-		}
-
-		if (mZoomDirect)
-		{
-			sFlycamZoom = sLastDelta[CAM_W_AXIS] * mFlycamAxisScale[FLYCAM_AXIS_6] + mFlycamAxisScale[FLYCAM_AXIS_6];
-		}
-		else
-		{
-			//BD - We need to cap zoom otherwise it internally counts higher causing
-			//     the zoom level to not react until that extra has been removed first.
-			sFlycamZoom = llclamp(sFlycamZoom + sDelta[CAM_W_AXIS], LLViewerCamera::getInstance()->getMinView(), LLViewerCamera::getInstance()->getMaxView());
-		}
-	}
-	else
-	{
-	    F32 time = gFrameIntervalSeconds.value();
-
-	    // avoid making ridiculously big movements if there's a big drop in fps
-	    if (time > .2f)
-	    {
-	        time = .2f;
-	    }
-
-	    F32 cur_delta[7];
-	    F32 feather = mFlycamFeathering;
-	    bool absolute = m3DCursor;
-	    bool is_zero = true;
-
-	    for (U32 i = 0; i < 7; i++)
-	    {
-	        cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
-
-	        if (!mInvertPitch && i == 4)
-	            cur_delta[i] = -cur_delta[i];
-
-	        F32 tmp = cur_delta[i];
-	        if (absolute)
-	        {
-	            cur_delta[i] = cur_delta[i] - sLastDelta[i];
-	        }
-	        sLastDelta[i] = tmp;
-
-	        if (cur_delta[i] > 0)
-	        {
-	            cur_delta[i] = llmax(cur_delta[i]- mFlycamAxisDeadZone[i], 0.f);
-	        }
-	        else
-	        {
-	            cur_delta[i] = llmin(cur_delta[i]+ mFlycamAxisDeadZone[i], 0.f);
-	        }
-
-	        // We may want to scale camera movements up or down in build mode.
-	        // NOTE: this needs to remain after the deadzone calculation, otherwise
-	        // we have issues with flycam "jumping" when the build dialog is opened/closed  -Nyx
-	        if (in_build_mode)
-	        {
-	            if (i == X_I || i == Y_I || i == Z_I)
-	            {
-	                cur_delta[i] *= build_mode_scale;
-	            }
-	        }
-
-	        cur_delta[i] *= mFlycamAxisScale[i];
-
-	        if (!absolute)
-	        {
-	            cur_delta[i] *= time;
-	        }
-
-	        sDelta[i] = sDelta[i] + (cur_delta[i]-sDelta[i])*time*feather;
-
-	        is_zero = is_zero && (cur_delta[i] == 0.f);
-
-	    }
-
-	    // Clear AFK state if moved beyond the deadzone
-	    if (!is_zero && gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
-	    {
-	        gAgent.clearAFK();
-	    }
-
-	    sFlycamPosition += LLVector3(sDelta.data()) * sFlycamRotation;
-
-	    LLMatrix3 rot_mat(sDelta[3], sDelta[4], sDelta[5]);
-	    sFlycamRotation = LLQuaternion(rot_mat)*sFlycamRotation;
-
-	    if (mAutoLeveling)
-	    {
-	        LLMatrix3 level(sFlycamRotation);
-
-	        LLVector3 x = LLVector3(level.mMatrix[0]);
-	        LLVector3 y = LLVector3(level.mMatrix[1]);
-	        LLVector3 z = LLVector3(level.mMatrix[2]);
-
-	        y.mV[2] = 0.f;
-	        y.normVec();
-
-	        level.setRows(x,y,z);
-	        level.orthogonalize();
-
-	        LLQuaternion quat(level);
-	        sFlycamRotation = nlerp(llmin(feather*time,1.f), sFlycamRotation, quat);
-	    }
-
-	    if (mZoomDirect)
-	    {
-	        sFlycamZoom = sLastDelta[6]* mFlycamAxisScale[6]+ mFlycamAxisDeadZone[6];
-	    }
-	    else
-	    {
-	        //BD - We need to cap zoom otherwise it internally counts higher causing
-	        //     the zoom level to not react until that extra has been removed first.
-	        sFlycamZoom = llclamp(sFlycamZoom + sDelta[6], LLViewerCamera::getInstance()->getMinView(), LLViewerCamera::getInstance()->getMaxView());
-	    }
-	}
+            F32 tmp = cur_delta[i];
+            F32 axis_deadzone = mFlycamAxisDeadZone[i];
+            if (m3DCursor || llabs(cur_delta[i]) < axis_deadzone)
+            {
+                cur_delta[i] = cur_delta[i] - sLastDelta[i];
+            }
+            sLastDelta[i] = tmp;
+
+            //BD - We assume that delta 1.0 is the maximum.
+            if (llabs(cur_delta[i]) > axis_deadzone)
+            {
+                //BD - Clamp the delta between 1 and -1 while taking the deadzone into account.
+                if (cur_delta[i] > 0)
+                {
+                    cur_delta[i] = llclamp(cur_delta[i] - axis_deadzone, 0.f, 1.f - axis_deadzone);
+                }
+                else
+                {
+                    cur_delta[i] = llclamp(cur_delta[i] + axis_deadzone, -1.f + axis_deadzone, 0.f);
+                }
+                //BD - Rescale the remaining delta to match the maximum to get a new clean 0 to 1 range.
+                cur_delta[i] = cur_delta[i] / (1.f - axis_deadzone);
+            }
+
+            // We may want to scale camera movements up or down in build mode.
+            // NOTE: this needs to remain after the deadzone calculation, otherwise
+            // we have issues with flycam "jumping" when the build dialog is opened/closed  -Nyx
+            if (LLToolMgr::getInstance()->inBuildMode())
+            {
+                if (i == X_I || i == Y_I || i == Z_I)
+                {
+                    cur_delta[i] *= build_mode_scale;
+                }
+            }
+
+            cur_delta[i] *= mFlycamAxisScale[i];
+
+            if (!m3DCursor)
+            {
+                cur_delta[i] *= time;
+            }
+
+            sDelta[i] = sDelta[i] + (cur_delta[i] - sDelta[i]) * time * flycam_feather;
+            is_zero = is_zero && (cur_delta[i] == 0.f);
+        }
+
+    //  //BD - Invertable Pitch Controls
+        if (mInvertPitch)
+            cur_delta[CAM_Y_AXIS] = -cur_delta[CAM_Y_AXIS];
+
+        // Clear AFK state if moved beyond the deadzone
+        if (!is_zero && gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
+        {
+            gAgent.clearAFK();
+        }
+
+        sFlycamPosition += LLVector3(sDelta.data()) * sFlycamRotation;
+        LLMatrix3 rot_mat(sDelta[CAM_X_AXIS], sDelta[CAM_Y_AXIS], sDelta[CAM_Z_AXIS]);
+        sFlycamRotation = LLQuaternion(rot_mat)*sFlycamRotation;
+
+        if (mAutoLeveling || getJoystickButton(mMappedButtons[ROLL_DEFAULT]) == 1)
+        {
+            LLMatrix3 level(sFlycamRotation);
+
+            LLVector3 x = LLVector3(level.mMatrix[0]);
+            LLVector3 y = LLVector3(level.mMatrix[1]);
+            LLVector3 z = LLVector3(level.mMatrix[2]);
+
+            y.mV[2] = 0.f;
+            y.normVec();
+
+            level.setRows(x,y,z);
+            level.orthogonalize();
+
+            LLQuaternion quat(level);
+            LLQuaternion lerp = nlerp(llmin(flycam_feather * time, 1.f), sFlycamRotation, quat);
+            sFlycamRotation = getJoystickButton(mMappedButtons[ROLL_DEFAULT]) == 1 ? quat : lerp;
+        }
+
+        if (mZoomDirect)
+        {
+            sFlycamZoom = sLastDelta[CAM_W_AXIS] * mFlycamAxisScale[FLYCAM_AXIS_6] + mFlycamAxisScale[FLYCAM_AXIS_6];
+        }
+        else
+        {
+            //BD - We need to cap zoom otherwise it internally counts higher causing
+            //     the zoom level to not react until that extra has been removed first.
+            sFlycamZoom = llclamp(sFlycamZoom + sDelta[CAM_W_AXIS], LLViewerCamera::getInstance()->getMinView(), LLViewerCamera::getInstance()->getMaxView());
+        }
+    }
+    else
+    {
+        F32 time = gFrameIntervalSeconds.value();
+
+        // avoid making ridiculously big movements if there's a big drop in fps
+        if (time > .2f)
+        {
+            time = .2f;
+        }
+
+        F32 cur_delta[7];
+        F32 feather = mFlycamFeathering;
+        bool absolute = m3DCursor;
+        bool is_zero = true;
+
+        for (U32 i = 0; i < 7; i++)
+        {
+            cur_delta[i] = -getJoystickAxis(mJoystickAxis[i]);
+
+            if (!mInvertPitch && i == 4)
+                cur_delta[i] = -cur_delta[i];
+
+            F32 tmp = cur_delta[i];
+            if (absolute)
+            {
+                cur_delta[i] = cur_delta[i] - sLastDelta[i];
+            }
+            sLastDelta[i] = tmp;
+
+            if (cur_delta[i] > 0)
+            {
+                cur_delta[i] = llmax(cur_delta[i]- mFlycamAxisDeadZone[i], 0.f);
+            }
+            else
+            {
+                cur_delta[i] = llmin(cur_delta[i]+ mFlycamAxisDeadZone[i], 0.f);
+            }
+
+            // We may want to scale camera movements up or down in build mode.
+            // NOTE: this needs to remain after the deadzone calculation, otherwise
+            // we have issues with flycam "jumping" when the build dialog is opened/closed  -Nyx
+            if (in_build_mode)
+            {
+                if (i == X_I || i == Y_I || i == Z_I)
+                {
+                    cur_delta[i] *= build_mode_scale;
+                }
+            }
+
+            cur_delta[i] *= mFlycamAxisScale[i];
+
+            if (!absolute)
+            {
+                cur_delta[i] *= time;
+            }
+
+            sDelta[i] = sDelta[i] + (cur_delta[i]-sDelta[i])*time*feather;
+
+            is_zero = is_zero && (cur_delta[i] == 0.f);
+
+        }
+
+        // Clear AFK state if moved beyond the deadzone
+        if (!is_zero && gAwayTimer.getElapsedTimeF32() > LLAgent::MIN_AFK_TIME)
+        {
+            gAgent.clearAFK();
+        }
+
+        sFlycamPosition += LLVector3(sDelta.data()) * sFlycamRotation;
+
+        LLMatrix3 rot_mat(sDelta[3], sDelta[4], sDelta[5]);
+        sFlycamRotation = LLQuaternion(rot_mat)*sFlycamRotation;
+
+        if (mAutoLeveling)
+        {
+            LLMatrix3 level(sFlycamRotation);
+
+            LLVector3 x = LLVector3(level.mMatrix[0]);
+            LLVector3 y = LLVector3(level.mMatrix[1]);
+            LLVector3 z = LLVector3(level.mMatrix[2]);
+
+            y.mV[2] = 0.f;
+            y.normVec();
+
+            level.setRows(x,y,z);
+            level.orthogonalize();
+
+            LLQuaternion quat(level);
+            sFlycamRotation = nlerp(llmin(feather*time,1.f), sFlycamRotation, quat);
+        }
+
+        if (mZoomDirect)
+        {
+            sFlycamZoom = sLastDelta[6]* mFlycamAxisScale[6]+ mFlycamAxisDeadZone[6];
+        }
+        else
+        {
+            //BD - We need to cap zoom otherwise it internally counts higher causing
+            //     the zoom level to not react until that extra has been removed first.
+            sFlycamZoom = llclamp(sFlycamZoom + sDelta[6], LLViewerCamera::getInstance()->getMinView(), LLViewerCamera::getInstance()->getMaxView());
+        }
+    }
 
     LLMatrix3 mat(sFlycamRotation);
 
@@ -1858,33 +1858,33 @@ void LLViewerJoystick::scanJoystick()
 
     static LLCachedControl<bool> blackdragon(gSavedSettings, "BlackDragonControls", false);
     if (blackdragon)
-	{
-		if (getJoystickButton(mMappedButtons[FLYCAM]) == 1)
-		{
-			if (getJoystickButton(mMappedButtons[FLYCAM]) != toggle_flycam)
-			{
-				toggle_flycam = toggleFlycam() ? 1 : 0;
-			}
-		}
-		else
-		{
-			toggle_flycam = 0;
-		}
-	}
-	else
-	{
-	    if (mBtn[0] == 1)
-	    {
-	        if (mBtn[0] != toggle_flycam)
-	        {
-	            toggle_flycam = toggleFlycam() ? 1 : 0;
-	        }
-	    }
-	    else
-	    {
-	        toggle_flycam = 0;
-	    }
-	}
+    {
+        if (getJoystickButton(mMappedButtons[FLYCAM]) == 1)
+        {
+            if (getJoystickButton(mMappedButtons[FLYCAM]) != toggle_flycam)
+            {
+                toggle_flycam = toggleFlycam() ? 1 : 0;
+            }
+        }
+        else
+        {
+            toggle_flycam = 0;
+        }
+    }
+    else
+    {
+        if (mBtn[0] == 1)
+        {
+            if (mBtn[0] != toggle_flycam)
+            {
+                toggle_flycam = toggleFlycam() ? 1 : 0;
+            }
+        }
+        else
+        {
+            toggle_flycam = 0;
+        }
+    }
 
     if (!mOverrideCamera && !(LLToolMgr::getInstance()->inBuildMode() && mBuildEnabled))
     {
@@ -2056,19 +2056,19 @@ void LLViewerJoystick::setSNDefaults()
     gSavedSettings.setS32("JoystickAxis5", 5); // yaw
     gSavedSettings.setS32("JoystickAxis6", -1);
 
-	gSavedSettings.setS32("JoystickButtonJump", -1);
-	gSavedSettings.setS32("JoystickButtonCrouch", -1);
-	gSavedSettings.setS32("JoystickButtonFly", -1);
-	gSavedSettings.setS32("JoystickButtonRunToggle", -1);
-	gSavedSettings.setS32("JoystickButtonMouselook", -1);
-	gSavedSettings.setS32("JoystickButtonZoomDefault", -1);
-	gSavedSettings.setS32("JoystickButtonFlycam", 0);
-	gSavedSettings.setS32("JoystickButtonZoomOut", -1);
-	gSavedSettings.setS32("JoystickButtonZoomIn", -1);
-	gSavedSettings.setS32("JoystickButtonRollLeft", -1);
-	gSavedSettings.setS32("JoystickButtonRollRight", -1);
-	gSavedSettings.setS32("JoystickButtonRollDefault", -1);
-	
+    gSavedSettings.setS32("JoystickButtonJump", -1);
+    gSavedSettings.setS32("JoystickButtonCrouch", -1);
+    gSavedSettings.setS32("JoystickButtonFly", -1);
+    gSavedSettings.setS32("JoystickButtonRunToggle", -1);
+    gSavedSettings.setS32("JoystickButtonMouselook", -1);
+    gSavedSettings.setS32("JoystickButtonZoomDefault", -1);
+    gSavedSettings.setS32("JoystickButtonFlycam", 0);
+    gSavedSettings.setS32("JoystickButtonZoomOut", -1);
+    gSavedSettings.setS32("JoystickButtonZoomIn", -1);
+    gSavedSettings.setS32("JoystickButtonRollLeft", -1);
+    gSavedSettings.setS32("JoystickButtonRollRight", -1);
+    gSavedSettings.setS32("JoystickButtonRollDefault", -1);
+
     gSavedSettings.setBOOL("Cursor3D", is_3d_cursor);
     gSavedSettings.setBOOL("AutoLeveling", true);
     gSavedSettings.setBOOL("ZoomDirect", false);
@@ -2133,19 +2133,19 @@ void LLViewerJoystick::setXboxDefaults()
     gSavedSettings.setS32("JoystickAxis5", 3);  // Yaw
     gSavedSettings.setS32("JoystickAxis6", -1); // Zoom
 
-	gSavedSettings.setS32("JoystickButtonJump", 0);
-	gSavedSettings.setS32("JoystickButtonCrouch", 1);
-	gSavedSettings.setS32("JoystickButtonFly", 2);
-	gSavedSettings.setS32("JoystickButtonRunToggle", 8);
-	gSavedSettings.setS32("JoystickButtonMouselook", 9);
-	gSavedSettings.setS32("JoystickButtonZoomDefault", 6);
-	gSavedSettings.setS32("JoystickButtonFlycam", 7);
-	gSavedSettings.setS32("JoystickButtonZoomOut", 5);
-	gSavedSettings.setS32("JoystickButtonZoomIn", 4);
-	gSavedSettings.setS32("JoystickButtonRollLeft", -1);
-	gSavedSettings.setS32("JoystickButtonRollRight", -1);
-	gSavedSettings.setS32("JoystickButtonRollDefault", -1);
-	
+    gSavedSettings.setS32("JoystickButtonJump", 0);
+    gSavedSettings.setS32("JoystickButtonCrouch", 1);
+    gSavedSettings.setS32("JoystickButtonFly", 2);
+    gSavedSettings.setS32("JoystickButtonRunToggle", 8);
+    gSavedSettings.setS32("JoystickButtonMouselook", 9);
+    gSavedSettings.setS32("JoystickButtonZoomDefault", 6);
+    gSavedSettings.setS32("JoystickButtonFlycam", 7);
+    gSavedSettings.setS32("JoystickButtonZoomOut", 5);
+    gSavedSettings.setS32("JoystickButtonZoomIn", 4);
+    gSavedSettings.setS32("JoystickButtonRollLeft", -1);
+    gSavedSettings.setS32("JoystickButtonRollRight", -1);
+    gSavedSettings.setS32("JoystickButtonRollDefault", -1);
+
     gSavedSettings.setBOOL("Cursor3D", false); // Xbox Gamepad, not 3D Mouse
     gSavedSettings.setBOOL("AutoLeveling", false);
     gSavedSettings.setBOOL("ZoomDirect", false);
diff --git a/indra/newview/llviewerjoystick.h b/indra/newview/llviewerjoystick.h
index 19e544f7da7..43338e9be30 100644
--- a/indra/newview/llviewerjoystick.h
+++ b/indra/newview/llviewerjoystick.h
@@ -48,62 +48,62 @@ typedef enum e_joystick_driver_state
 
 typedef enum E_Buttons
 {
-	ROLL_LEFT = 0,
-	ROLL_RIGHT,
-	ROLL_DEFAULT ,
-	ZOOM_IN,
-	ZOOM_OUT,
-	ZOOM_DEFAULT,
-	JUMP,
-	CROUCH,
-	FLY,
-	MOUSELOOK,
-	FLYCAM,
-	TOGGLE_RUN,
-	MAX_BUTTONS
+    ROLL_LEFT = 0,
+    ROLL_RIGHT,
+    ROLL_DEFAULT ,
+    ZOOM_IN,
+    ZOOM_OUT,
+    ZOOM_DEFAULT,
+    JUMP,
+    CROUCH,
+    FLY,
+    MOUSELOOK,
+    FLYCAM,
+    TOGGLE_RUN,
+    MAX_BUTTONS
 } E_buttons;
 
 typedef enum E_Axes
 {
-	X_AXIS = 0,
-	Y_AXIS = 1,
-	Z_AXIS = 2,
-	CAM_X_AXIS = 3,
-	CAM_Y_AXIS = 4,
-	CAM_Z_AXIS = 5,
-	CAM_W_AXIS = 6,
-	MAX_AXES = 7
+    X_AXIS = 0,
+    Y_AXIS = 1,
+    Z_AXIS = 2,
+    CAM_X_AXIS = 3,
+    CAM_Y_AXIS = 4,
+    CAM_Z_AXIS = 5,
+    CAM_W_AXIS = 6,
+    MAX_AXES = 7
 } E_Axes;
 
 typedef enum E_AVScalings
 {
-	AV_AXIS_0 = 0,
-	AV_AXIS_1,
-	AV_AXIS_2,
-	AV_AXIS_3,
-	AV_AXIS_4,
-	AV_AXIS_5,
+    AV_AXIS_0 = 0,
+    AV_AXIS_1,
+    AV_AXIS_2,
+    AV_AXIS_3,
+    AV_AXIS_4,
+    AV_AXIS_5,
 } E_AVScalings;
 
 typedef enum E_BuildScalings
 {
-	BUILD_AXIS_0 = 0,
-	BUILD_AXIS_1,
-	BUILD_AXIS_2,
-	BUILD_AXIS_3,
-	BUILD_AXIS_4,
-	BUILD_AXIS_5,
+    BUILD_AXIS_0 = 0,
+    BUILD_AXIS_1,
+    BUILD_AXIS_2,
+    BUILD_AXIS_3,
+    BUILD_AXIS_4,
+    BUILD_AXIS_5,
 } E_BuildScalings;
 
 typedef enum E_FlycamScalings
 {
-	FLYCAM_AXIS_0 = 0,
-	FLYCAM_AXIS_1,
-	FLYCAM_AXIS_2,
-	FLYCAM_AXIS_3,
-	FLYCAM_AXIS_4,
-	FLYCAM_AXIS_5,
-	FLYCAM_AXIS_6,
+    FLYCAM_AXIS_0 = 0,
+    FLYCAM_AXIS_1,
+    FLYCAM_AXIS_2,
+    FLYCAM_AXIS_3,
+    FLYCAM_AXIS_4,
+    FLYCAM_AXIS_5,
+    FLYCAM_AXIS_6,
 } E_FlycamScalings;
 
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 55073d0f71f..312398e54a7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2022,7 +2022,7 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list)
 {
     LL_PROFILE_ZONE_SCOPED;
     LLDrawable::drawable_vector_t newList; // removing elements in the middle of a vector is a really bad idea. I'll just create a new one and swap it at the end.
-	
+
     for (LLDrawable::drawable_vector_t::iterator iter = moved_list.begin();
          iter != moved_list.end(); )
     {
-- 
GitLab