summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp85
1 files changed, 84 insertions, 1 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6fd58ef1be..75cd189980 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -47,6 +47,7 @@
#include "llagentwearables.h"
#include "lldirpicker.h"
#include "llfloaterimcontainer.h"
+#include "llfloaterpreference.h"
#include "llimprocessing.h"
#include "llwindow.h"
#include "llviewerstats.h"
@@ -64,6 +65,7 @@
#include "llluamanager.h"
#include "llurlfloaterdispatchhandler.h"
#include "llviewerjoystick.h"
+#include "llgamecontrol.h"
#include "llcalc.h"
#include "llconversationlog.h"
#if LL_WINDOWS
@@ -214,6 +216,7 @@
#include "llvosurfacepatch.h"
#include "llviewerfloaterreg.h"
#include "llcommandlineparser.h"
+#include "llfloaterpreference.h"
#include "llfloatermemleak.h"
#include "llfloaterreg.h"
#include "llfloatersimplesnapshot.h"
@@ -1133,6 +1136,15 @@ bool LLAppViewer::init()
LLViewerJoystick::getInstance()->init(false);
}
+ LLGameControl::init(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "gamecontrollerdb.txt"),
+ [&](const std::string& name) -> bool { return gSavedSettings.getBOOL(name); },
+ [&](const std::string& name, bool value) { gSavedSettings.setBOOL(name, value); },
+ [&](const std::string& name) -> std::string { return gSavedSettings.getString(name); },
+ [&](const std::string& name, const std::string& value) { gSavedSettings.setString(name, value); },
+ [&](const std::string& name) -> LLSD { return gSavedSettings.getLLSD(name); },
+ [&](const std::string& name, const LLSD& value) { gSavedSettings.setLLSD(name, value); },
+ [&]() { LLPanelPreferenceGameControl::updateDeviceList(); });
+
try
{
initializeSecHandler();
@@ -1416,6 +1428,48 @@ bool LLAppViewer::frame()
return ret;
}
+void sendGameControlInput()
+{
+ LLMessageSystem* msg = gMessageSystem;
+ const LLGameControl::State& state = LLGameControl::getState();
+
+ msg->newMessageFast(_PREHASH_GameControlInput);
+ msg->nextBlock("AgentData");
+ msg->addUUID("AgentID", gAgentID);
+ msg->addUUID("SessionID", gAgentSessionID);
+
+ size_t num_indices = state.mAxes.size();
+ for (U8 i = 0; i < num_indices; ++i)
+ {
+ if (state.mAxes[i] != state.mPrevAxes[i])
+ {
+ // only pack an axis if it differs from previously packed value
+ msg->nextBlockFast(_PREHASH_AxisData);
+ msg->addU8Fast(_PREHASH_Index, i);
+ msg->addS16Fast(_PREHASH_Value, state.mAxes[i]);
+ }
+ }
+
+ U32 button_flags = state.mButtons;
+ if (button_flags > 0)
+ {
+ std::vector<U8> buttons;
+ for (U8 i = 0; i < 32; i++)
+ {
+ if (button_flags & (0x1 << i))
+ {
+ buttons.push_back(i);
+ }
+ }
+ msg->nextBlockFast(_PREHASH_ButtonData);
+ msg->addBinaryDataFast(_PREHASH_Data, (void*)(buttons.data()), (S32)(buttons.size()));
+ }
+
+ LLGameControl::updateResendPeriod();
+ gAgent.sendMessage();
+}
+
+
bool LLAppViewer::doFrame()
{
LL_RECORD_BLOCK_TIME(FTM_FRAME);
@@ -1477,7 +1531,7 @@ bool LLAppViewer::doFrame()
LL_WARNS() << " Someone took over my signal/exception handler (post messagehandling)!" << LL_ENDL;
}
- gViewerWindow->getWindow()->gatherInput();
+ gViewerWindow->getWindow()->gatherInput(gFocusMgr.getAppHasFocus());
}
//memory leaking simulation
@@ -1961,6 +2015,7 @@ bool LLAppViewer::cleanup()
// Turn off Space Navigator and similar devices
LLViewerJoystick::getInstance()->terminate();
}
+ LLGameControl::terminate();
LL_INFOS() << "Cleaning up Objects" << LL_ENDL;
@@ -4756,6 +4811,30 @@ void LLAppViewer::idle()
gAgent.autoPilot(&yaw);
}
+ // get control flags from each side
+ U32 control_flags = gAgent.getControlFlags();
+ U32 game_control_action_flags = LLGameControl::computeInternalActionFlags();
+
+ // apply to GameControl
+ LLGameControl::setExternalInput(control_flags, gAgent.getGameControlButtonsFromKeys());
+ bool should_send_game_control = LLGameControl::computeFinalStateAndCheckForChanges();
+ if (LLPanelPreferenceGameControl::isWaitingForInputChannel())
+ {
+ LLPanelPreferenceGameControl::applyGameControlInput();
+ // skip this send because input is being used to set preferences
+ should_send_game_control = false;
+ }
+ if (should_send_game_control)
+ {
+ sendGameControlInput();
+ }
+
+ // apply to AvatarControl
+ if (LLGameControl::isEnabled() && LLGameControl::willControlAvatar())
+ {
+ gAgent.applyExternalActionFlags(game_control_action_flags);
+ }
+
send_agent_update(false);
// After calling send_agent_update() in the mainloop we always clear
@@ -5013,6 +5092,10 @@ void LLAppViewer::idle()
{
LLViewerJoystick::getInstance()->moveFlycam();
}
+ else if (gAgent.isUsingFlycam())
+ {
+ gAgent.updateFlycam();
+ }
else
{
if (LLToolMgr::getInstance()->inBuildMode())