diff options
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ed64dce109..cb7606ac2e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1134,7 +1134,11 @@ bool LLAppViewer::init() { LLViewerJoystick::getInstance()->init(false); } - LLGameControl::init(); + + LLGameControl::init(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "gamecontrollerdb.txt")); + LLGameControl::enableSendToServer(gSavedSettings.getBOOL("GameControlToServer")); + LLGameControl::enableControlAgent(gSavedSettings.getBOOL("GameControlToAgent")); + LLGameControl::enableTranslateAgentActions(gSavedSettings.getBOOL("AgentToGameControl")); try { @@ -1458,32 +1462,12 @@ LLGameControl::InputChannel get_active_input_channel(const LLGameControl::State& return input; } -// static -bool packGameControlInput(LLMessageSystem* msg) -{ - if (! LLGameControl::computeFinalStateAndCheckForChanges()) - { - // Note: LLGameControl manages some re-send logic - // so if we get here: nothing changed AND there is no need for a re-send - return false; - } - if (!gSavedSettings.getBOOL("GameControlToServer")) - { - LLGameControl::clearAllState(); - return false; - } +void sendGameControlInput() +{ + LLMessageSystem* msg = gMessageSystem; const LLGameControl::State& state = LLGameControl::getState(); - if (LLPanelPreferenceGameControl::isWaitingForInputChannel()) - { - LLGameControl::InputChannel channel = get_active_input_channel(state); - if (channel.mType != LLGameControl::InputChannel::TYPE_NONE) - { - LLPanelPreferenceGameControl::applyGameControlInput(channel); - } - } - msg->newMessageFast(_PREHASH_GameControlInput); msg->nextBlock("AgentData"); msg->addUUID("AgentID", gAgentID); @@ -1517,7 +1501,7 @@ bool packGameControlInput(LLMessageSystem* msg) } LLGameControl::updateResendPeriod(); - return true; + gAgent.sendMessage(); } @@ -4871,12 +4855,24 @@ void LLAppViewer::idle() // trade flags between gAgent and LLGameControl U32 control_flags = gAgent.getControlFlags(); U32 action_flags = LLGameControl::computeInternalActionFlags(); - LLGameControl::setExternalActionFlags(control_flags); - if (packGameControlInput(gMessageSystem)) + LLGameControl::setExternalInput(control_flags, gAgent.getGameControlButtonsFromKeys()); + + bool should_send_game_control = LLGameControl::computeFinalStateAndCheckForChanges(); + if (LLPanelPreferenceGameControl::isWaitingForInputChannel()) { - // to help minimize lag we send GameInput packets ASAP - gAgent.sendMessage(); + LLGameControl::InputChannel channel = get_active_input_channel(LLGameControl::getState()); + if (channel.mType != LLGameControl::InputChannel::TYPE_NONE) + { + LLPanelPreferenceGameControl::applyGameControlInput(channel); + // skip this send because input is being used to set preferences + should_send_game_control = false; + } } + if (should_send_game_control) + { + sendGameControlInput(); + } + gAgent.setExternalActionFlags(action_flags); // When appropriate, update agent location to the simulator. @@ -5147,7 +5143,7 @@ void LLAppViewer::idle() } else if (gAgent.isUsingFlycam()) { - // TODO: implement this + gAgent.updateFlycam(); } else { |