summaryrefslogtreecommitdiff
path: root/indra/llwindow/llgamecontrol.cpp
diff options
context:
space:
mode:
authorleviathan <leviathan@lindenlab.com>2024-06-27 00:18:42 -0700
committerAndrew Meadows <andrew.l.meadows@gmail.com>2024-10-03 09:03:28 -0700
commit9c986bef6704ac07112e18dc82b870acf1847e41 (patch)
treed24a8ce4b0c63dd2e0304340ec33464ee19dd845 /indra/llwindow/llgamecontrol.cpp
parent2daf175650cdda7cc8f820b6cb17b1475496e7ac (diff)
put GameControl behind a feature flag
Diffstat (limited to 'indra/llwindow/llgamecontrol.cpp')
-rw-r--r--indra/llwindow/llgamecontrol.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/indra/llwindow/llgamecontrol.cpp b/indra/llwindow/llgamecontrol.cpp
index 23849aca66..0e3782a10e 100644
--- a/indra/llwindow/llgamecontrol.cpp
+++ b/indra/llwindow/llgamecontrol.cpp
@@ -443,6 +443,7 @@ namespace
U64 g_lastSend = 0;
U64 g_nextResendPeriod = FIRST_RESEND_PERIOD;
+ bool g_enabled = false;
bool g_sendToServer = false;
bool g_controlAgent = false;
bool g_translateAgentActions = false;
@@ -457,6 +458,7 @@ namespace
std::function<LLSD(const std::string&)> s_loadObject;
std::function<void(const std::string&, LLSD&)> s_saveObject;
+ std::string SETTING_ENABLE("EnableGameControl");
std::string SETTING_SENDTOSERVER("GameControlToServer");
std::string SETTING_CONTROLAGENT("GameControlToAgent");
std::string SETTING_TRANSLATEACTIONS("AgentToGameControl");
@@ -1490,6 +1492,21 @@ void onControllerAxis(const SDL_Event& event)
}
// static
+bool LLGameControl::isEnabled()
+{
+ return g_enabled;
+}
+
+void LLGameControl::setEnabled(bool enable)
+{
+ if (enable != g_enabled)
+ {
+ g_enabled = enable;
+ s_saveBoolean(SETTING_ENABLE, g_enabled);
+ }
+}
+
+// static
bool LLGameControl::isInitialized()
{
return g_gameControl != nullptr;
@@ -1593,7 +1610,7 @@ bool LLGameControl::computeFinalStateAndCheckForChanges()
// g_lastSend has "expired"
// either because g_nextResendPeriod has been zeroed
// or the last send really has expired.
- return g_sendToServer && (g_lastSend + g_nextResendPeriod < get_now_nsec());
+ return g_enabled && g_sendToServer && (g_lastSend + g_nextResendPeriod < get_now_nsec());
}
// static
@@ -1762,7 +1779,7 @@ LLGameControl::ActionNameType LLGameControl::getActionNameType(const std::string
// static
bool LLGameControl::willControlAvatar()
{
- return g_controlAgent && g_agentControlMode == CONTROL_MODE_AVATAR;
+ return g_enabled && g_controlAgent && g_agentControlMode == CONTROL_MODE_AVATAR;
}
// static
@@ -2040,6 +2057,7 @@ void LLGameControl::initByDefault()
void LLGameControl::loadFromSettings()
{
// In case of absence of the required setting the default value is assigned
+ g_enabled = s_loadBoolean(SETTING_ENABLE);
g_sendToServer = s_loadBoolean(SETTING_SENDTOSERVER);
g_controlAgent = s_loadBoolean(SETTING_CONTROLAGENT);
g_translateAgentActions = s_loadBoolean(SETTING_TRANSLATEACTIONS);
@@ -2068,6 +2086,7 @@ void LLGameControl::loadFromSettings()
// static
void LLGameControl::saveToSettings()
{
+ s_saveBoolean(SETTING_ENABLE, g_enabled);
s_saveBoolean(SETTING_SENDTOSERVER, g_sendToServer);
s_saveBoolean(SETTING_CONTROLAGENT, g_controlAgent);
s_saveBoolean(SETTING_TRANSLATEACTIONS, g_translateAgentActions);