summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-06-15 18:13:46 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-06-23 14:51:30 +0300
commit6092e2ffab9ec76bdd8821e188db9cb785456eee (patch)
treea23c465a2a9ebe328c0f97d759a55fe231951178 /indra/newview/llappviewer.cpp
parentc604b274fb4ab218a89fc03a4ea5cc1b739ad65f (diff)
SL-13418 Added converter from old mouse binding settings to new ones
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 4c2de27f42..911cc224a1 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -49,6 +49,7 @@
#include "llwindow.h"
#include "llviewerstats.h"
#include "llviewerstatsrecorder.h"
+#include "llkeyconflict.h" // for legacy keybinding support, remove later
#include "llmarketplacefunctions.h"
#include "llmarketplacenotifications.h"
#include "llmd5.h"
@@ -1004,6 +1005,104 @@ bool LLAppViewer::init()
// Load User's bindings
std::string key_bindings_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "key_bindings.xml");
+#if 1
+ // Legacy support
+ // Remove #if-#endif section half a year after DRTVWR-501 releases.
+ // Mouse actions are part of keybinding file since DRTVWR-501 instead of being stored in
+ // settings.xml. To support legacy viewers that were storing in settings.xml we need to
+ // transfer old variables to new format.
+ // Also part of backward compatibility is present in LLKeyConflictHandler to modify
+ // legacy variables on changes in new system (to make sure we won't enforce
+ // legacy values again if user dropped to defaults in new system)
+ if (mIsFirstRun
+ && !gDirUtilp->fileExists(key_bindings_file)) // if file is missing, assume that there were no changes by user yet
+ {
+ // copy mouse actions and voice key changes to new file
+ LL_INFOS("InitInfo") << "Converting legacy mouse bindings to new format" << LL_ENDL;
+ // Load settings from file
+ LLKeyConflictHandler third_person_view(LLKeyConflictHandler::MODE_THIRD_PERSON);
+
+ // Since we are only modifying keybindings if personal file doesn't exist yet,
+ // it should be safe to just overwrite the value
+ // If key is already in use somewhere by default, LLKeyConflictHandler should resolve it.
+ BOOL value = gSavedSettings.getBOOL("DoubleClickAutoPilot");
+ third_person_view.registerControl("walk_to",
+ 0,
+ value ? EMouseClickType::CLICK_DOUBLELEFT : EMouseClickType::CLICK_NONE,
+ KEY_NONE,
+ MASK_NONE,
+ value);
+
+ U32 index = value ? 1 : 0; // we can store multiple combinations per action, so if first is in use by doubleclick, go to second
+ value = gSavedSettings.getBOOL("ClickToWalk");
+ third_person_view.registerControl("walk_to",
+ index,
+ value ? EMouseClickType::CLICK_LEFT : EMouseClickType::CLICK_NONE,
+ KEY_NONE,
+ MASK_NONE,
+ value);
+
+ value = gSavedSettings.getBOOL("DoubleClickTeleport");
+ third_person_view.registerControl("teleport_to",
+ 0,
+ value ? EMouseClickType::CLICK_DOUBLELEFT : EMouseClickType::CLICK_NONE,
+ KEY_NONE,
+ MASK_NONE,
+ value);
+
+ std::string key_string = gSavedSettings.getString("PushToTalkButton");
+ EMouseClickType mouse = EMouseClickType::CLICK_NONE;
+ KEY key = KEY_NONE;
+ if (key_string == "MiddleMouse")
+ {
+ mouse = EMouseClickType::CLICK_MIDDLE;
+ }
+ else if (key_string == "MouseButton4")
+ {
+ mouse = EMouseClickType::CLICK_BUTTON4;
+ }
+ else if (key_string == "MouseButton5")
+ {
+ mouse = EMouseClickType::CLICK_BUTTON5;
+ }
+ else
+ {
+ LLKeyboard::keyFromString(key_string, &key);
+ }
+
+ value = gSavedSettings.getBOOL("PushToTalkToggle");
+ std::string control_name = value ? "toggle_voice" : "voice_follow_key";
+ third_person_view.registerControl(control_name, 0, mouse, key, MASK_NONE, true);
+
+ if (third_person_view.hasUnsavedChanges())
+ {
+ // calls loadBindingsXML()
+ third_person_view.saveToSettings();
+ }
+
+ // in case of voice we need to repeat this in other modes (teleports and
+ // autopilot are not entirely practical when sitting or editing)
+
+ for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i)
+ {
+ if (i != LLKeyConflictHandler::MODE_THIRD_PERSON)
+ {
+ LLKeyConflictHandler handler((LLKeyConflictHandler::ESourceMode)i);
+
+ handler.registerControl(control_name, 0, mouse, key, MASK_NONE, true);
+
+ if (handler.hasUnsavedChanges())
+ {
+ // calls loadBindingsXML()
+ handler.saveToSettings();
+ }
+ }
+ }
+ }
+ // since something might have gone wrong or there might have been nothing to save
+ // (and because otherwise following code will have to be encased in else{}),
+ // load everything one last time
+#endif
if (!gDirUtilp->fileExists(key_bindings_file) || !gViewerInput.loadBindingsXML(key_bindings_file))
{
// Failed to load custom bindings, try default ones