diff options
Diffstat (limited to 'indra/newview/llviewerkeyboard.cpp')
| -rw-r--r-- | indra/newview/llviewerkeyboard.cpp | 200 | 
1 files changed, 113 insertions, 87 deletions
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index ab5cdeba44..d7e15e7d6c 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -2,31 +2,25 @@   * @file llviewerkeyboard.cpp   * @brief LLViewerKeyboard class implementation   * - * $LicenseInfo:firstyear=2005&license=viewergpl$ - *  - * Copyright (c) 2005-2009, Linden Research, Inc. - *  + * $LicenseInfo:firstyear=2005&license=viewerlgpl$   * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab.  Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, 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.   *  - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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.   *  - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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   *  - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA   * $/LicenseInfo$   */ @@ -36,7 +30,8 @@  #include "llviewerkeyboard.h"  #include "llmath.h"  #include "llagent.h" -#include "llchatbar.h" +#include "llagentcamera.h" +#include "llnearbychatbar.h"  #include "llviewercontrol.h"  #include "llfocusmgr.h"  #include "llmorphview.h" @@ -44,6 +39,7 @@  #include "lltoolfocus.h"  #include "llviewerwindow.h"  #include "llvoavatarself.h" +#include "llfloatercamera.h"  //  // Constants @@ -98,7 +94,7 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m  			gAgent.sendWalkRun(gAgent.getRunning());  		}  	} -	else if (gAllowTapTapHoldRun && +	else if (gSavedSettings.getBOOL("AllowTapTapHoldRun") &&  		 KEYSTATE_DOWN == s &&  		 !gAgent.getRunning())  	{ @@ -135,14 +131,29 @@ static void agent_push_forwardbackward( EKeystate s, S32 direction, LLAgent::EDo  	}  } +void camera_move_forward( EKeystate s ); +  void agent_push_forward( EKeystate s )  { +	//in free camera control mode we need to intercept keyboard events for avatar movements +	if (LLFloaterCamera::inFreeCameraMode()) +	{ +		camera_move_forward(s); +		return; +	}  	agent_push_forwardbackward(s, 1, LLAgent::DOUBLETAP_FORWARD);  } +void camera_move_backward( EKeystate s );  void agent_push_backward( EKeystate s )  { +	//in free camera control mode we need to intercept keyboard events for avatar movements +	if (LLFloaterCamera::inFreeCameraMode()) +	{ +		camera_move_backward(s); +		return; +	}  	agent_push_forwardbackward(s, -1, LLAgent::DOUBLETAP_BACKWARD);  } @@ -175,8 +186,17 @@ void agent_slide_right( EKeystate s )  	agent_slide_leftright(s, -1, LLAgent::DOUBLETAP_SLIDERIGHT);  } +void camera_spin_around_cw( EKeystate s ); +  void agent_turn_left( EKeystate s )  { +	//in free camera control mode we need to intercept keyboard events for avatar movements +	if (LLFloaterCamera::inFreeCameraMode()) +	{ +		camera_spin_around_cw(s); +		return; +	} +  	if (LLToolCamera::getInstance()->mouseSteerMode())  	{  		agent_slide_left(s); @@ -189,9 +209,17 @@ void agent_turn_left( EKeystate s )  	}  } +void camera_spin_around_ccw( EKeystate s );  void agent_turn_right( EKeystate s )  { +	//in free camera control mode we need to intercept keyboard events for avatar movements +	if (LLFloaterCamera::inFreeCameraMode()) +	{ +		camera_spin_around_ccw(s); +		return; +	} +  	if (LLToolCamera::getInstance()->mouseSteerMode())  	{  		agent_slide_right(s); @@ -246,22 +274,22 @@ F32 get_orbit_rate()  void camera_spin_around_ccw( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitLeftKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitLeftKey( get_orbit_rate() );  }  void camera_spin_around_cw( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitRightKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitRightKey( get_orbit_rate() );  }  void camera_spin_around_ccw_sitting( EKeystate s )  {  	if( KEYSTATE_UP == s ) return; -	if (gAgent.rotateGrabbed() || gAgent.sitCameraEnabled()) +	if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled())  	{  		//send keystrokes, but do not change camera  		agent_turn_right(s); @@ -269,7 +297,7 @@ void camera_spin_around_ccw_sitting( EKeystate s )  	else  	{  		//change camera but do not send keystrokes -		gAgent.setOrbitLeftKey( get_orbit_rate() ); +		gAgentCamera.setOrbitLeftKey( get_orbit_rate() );  	}  } @@ -277,7 +305,7 @@ void camera_spin_around_ccw_sitting( EKeystate s )  void camera_spin_around_cw_sitting( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	if (gAgent.rotateGrabbed() || gAgent.sitCameraEnabled()) +	if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled())  	{  		//send keystrokes, but do not change camera  		agent_turn_left(s); @@ -285,7 +313,7 @@ void camera_spin_around_cw_sitting( EKeystate s )  	else  	{  		//change camera but do not send keystrokes -		gAgent.setOrbitRightKey( get_orbit_rate() ); +		gAgentCamera.setOrbitRightKey( get_orbit_rate() );  	}  } @@ -293,22 +321,22 @@ void camera_spin_around_cw_sitting( EKeystate s )  void camera_spin_over( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitUpKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitUpKey( get_orbit_rate() );  }  void camera_spin_under( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitDownKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitDownKey( get_orbit_rate() );  }  void camera_spin_over_sitting( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	if (gAgent.upGrabbed() || gAgent.sitCameraEnabled()) +	if (gAgent.upGrabbed() || gAgentCamera.sitCameraEnabled())  	{  		//send keystrokes, but do not change camera  		agent_jump(s); @@ -316,7 +344,7 @@ void camera_spin_over_sitting( EKeystate s )  	else  	{  		//change camera but do not send keystrokes -		gAgent.setOrbitUpKey( get_orbit_rate() ); +		gAgentCamera.setOrbitUpKey( get_orbit_rate() );  	}  } @@ -324,7 +352,7 @@ void camera_spin_over_sitting( EKeystate s )  void camera_spin_under_sitting( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	if (gAgent.downGrabbed() || gAgent.sitCameraEnabled()) +	if (gAgent.downGrabbed() || gAgentCamera.sitCameraEnabled())  	{  		//send keystrokes, but do not change camera  		agent_push_down(s); @@ -332,35 +360,35 @@ void camera_spin_under_sitting( EKeystate s )  	else  	{  		//change camera but do not send keystrokes -		gAgent.setOrbitDownKey( get_orbit_rate() ); +		gAgentCamera.setOrbitDownKey( get_orbit_rate() );  	}  }  void camera_move_forward( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitInKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitInKey( get_orbit_rate() );  }  void camera_move_backward( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitOutKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitOutKey( get_orbit_rate() );  }  void camera_move_forward_sitting( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	if (gAgent.forwardGrabbed() || gAgent.sitCameraEnabled()) +	if (gAgent.forwardGrabbed() || gAgentCamera.sitCameraEnabled())  	{  		agent_push_forward(s);  	}  	else  	{ -		gAgent.setOrbitInKey( get_orbit_rate() ); +		gAgentCamera.setOrbitInKey( get_orbit_rate() );  	}  } @@ -369,70 +397,70 @@ void camera_move_backward_sitting( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	if (gAgent.backwardGrabbed() || gAgent.sitCameraEnabled()) +	if (gAgent.backwardGrabbed() || gAgentCamera.sitCameraEnabled())  	{  		agent_push_backward(s);  	}  	else  	{ -		gAgent.setOrbitOutKey( get_orbit_rate() ); +		gAgentCamera.setOrbitOutKey( get_orbit_rate() );  	}  }  void camera_pan_up( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setPanUpKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setPanUpKey( get_orbit_rate() );  }  void camera_pan_down( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setPanDownKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setPanDownKey( get_orbit_rate() );  }  void camera_pan_left( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setPanLeftKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setPanLeftKey( get_orbit_rate() );  }  void camera_pan_right( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setPanRightKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setPanRightKey( get_orbit_rate() );  }  void camera_pan_in( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setPanInKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setPanInKey( get_orbit_rate() );  }  void camera_pan_out( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setPanOutKey( get_orbit_rate() ); +	gAgentCamera.unlockView(); +	gAgentCamera.setPanOutKey( get_orbit_rate() );  }  void camera_move_forward_fast( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitInKey(2.5f); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitInKey(2.5f);  }  void camera_move_backward_fast( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return; -	gAgent.unlockView(); -	gAgent.setOrbitOutKey(2.5f); +	gAgentCamera.unlockView(); +	gAgentCamera.setOrbitOutKey(2.5f);  } @@ -440,7 +468,7 @@ void edit_avatar_spin_ccw( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return;  	gMorphView->setCameraDrivenByKeys( TRUE ); -	gAgent.setOrbitLeftKey( get_orbit_rate() ); +	gAgentCamera.setOrbitLeftKey( get_orbit_rate() );  	//gMorphView->orbitLeft( get_orbit_rate() );  } @@ -449,7 +477,7 @@ void edit_avatar_spin_cw( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return;  	gMorphView->setCameraDrivenByKeys( TRUE ); -	gAgent.setOrbitRightKey( get_orbit_rate() ); +	gAgentCamera.setOrbitRightKey( get_orbit_rate() );  	//gMorphView->orbitRight( get_orbit_rate() );  } @@ -457,7 +485,7 @@ void edit_avatar_spin_over( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return;  	gMorphView->setCameraDrivenByKeys( TRUE ); -	gAgent.setOrbitUpKey( get_orbit_rate() ); +	gAgentCamera.setOrbitUpKey( get_orbit_rate() );  	//gMorphView->orbitUp( get_orbit_rate() );  } @@ -466,7 +494,7 @@ void edit_avatar_spin_under( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return;  	gMorphView->setCameraDrivenByKeys( TRUE ); -	gAgent.setOrbitDownKey( get_orbit_rate() ); +	gAgentCamera.setOrbitDownKey( get_orbit_rate() );  	//gMorphView->orbitDown( get_orbit_rate() );  } @@ -474,7 +502,7 @@ void edit_avatar_move_forward( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return;  	gMorphView->setCameraDrivenByKeys( TRUE ); -	gAgent.setOrbitInKey( get_orbit_rate() ); +	gAgentCamera.setOrbitInKey( get_orbit_rate() );  	//gMorphView->orbitIn();  } @@ -483,7 +511,7 @@ void edit_avatar_move_backward( EKeystate s )  {  	if( KEYSTATE_UP == s  ) return;  	gMorphView->setCameraDrivenByKeys( TRUE ); -	gAgent.setOrbitOutKey( get_orbit_rate() ); +	gAgentCamera.setOrbitOutKey( get_orbit_rate() );  	//gMorphView->orbitOut();  } @@ -500,27 +528,25 @@ void stop_moving( EKeystate s )  void start_chat( EKeystate s )  {  	// start chat -	LLChatBar::startChat(NULL); -//	gChatBar->startChat(NULL); +	LLNearbyChatBar::startChat(NULL);  }  void start_gesture( EKeystate s )  { +	LLUICtrl* focus_ctrlp = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());  	if (KEYSTATE_UP == s && -		!(gFocusMgr.getKeyboardFocus() && gFocusMgr.getKeyboardFocus()->acceptsTextInput())) +		! (focus_ctrlp && focus_ctrlp->acceptsTextInput()))  	{ -		//TODO* remove DUMMY chatbar -		LLChatBar::startChat(NULL); -// 		if (gChatBar->getCurrentChat().empty()) -// 		{ -// 			// No existing chat in chat editor, insert '/' -// 			gChatBar->startChat("/"); -// 		} -// 		else -// 		{ -// 			// Don't overwrite existing text in chat editor -// 			gChatBar->startChat(NULL); -// 		} + 		if (LLNearbyChatBar::getInstance()->getCurrentChat().empty()) + 		{ + 			// No existing chat in chat editor, insert '/' + 			LLNearbyChatBar::startChat("/"); + 		} + 		else + 		{ + 			// Don't overwrite existing text in chat editor + 			LLNearbyChatBar::startChat(NULL); + 		}  	}  } @@ -686,7 +712,7 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c  			if (idx >=2 && idx <= 12)  			{  				U32 keyidx = ((mask<<16)|key); -				(mRemapKeys[mode])[keyidx] = ((0<<16)|KEY_F1+(idx-1)); +				(mRemapKeys[mode])[keyidx] = ((0<<16)|(KEY_F1+(idx-1)));  				return TRUE;  			}  		} @@ -837,7 +863,7 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename)  EKeyboardMode LLViewerKeyboard::getMode()  { -	if ( gAgent.cameraMouselook() ) +	if ( gAgentCamera.cameraMouselook() )  	{  		return MODE_FIRST_PERSON;  	} @@ -845,7 +871,7 @@ EKeyboardMode LLViewerKeyboard::getMode()  	{  		return MODE_EDIT_AVATAR;  	} -	else if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->mIsSitting) +	else if (isAgentAvatarValid() && gAgentAvatarp->isSitting())  	{  		return MODE_SITTING;  	}  | 
