summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerkeyboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerkeyboard.cpp')
-rw-r--r--indra/newview/llviewerkeyboard.cpp89
1 files changed, 54 insertions, 35 deletions
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index 8a5a5e99c9..db0da19927 100644
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -83,82 +83,101 @@ void agent_push_down( EKeystate s )
gAgent.moveUp(-1);
}
-void agent_push_forward( EKeystate s )
+static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode mode)
{
- if( KEYSTATE_UP == s ) return;
- F32 time = gKeyboard->getCurKeyElapsedTime();
- S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount());
-
- if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES)
+ if (KEYSTATE_UP == s)
{
- gAgent.moveAtNudge(1);
+ // Releasing a walk-key resets the double-tap timer
+ gAgent.mDoubleTapRunTimer.reset();
+ if (gAgent.mDoubleTapRunMode == mode &&
+ gAgent.getRunning() &&
+ !gAgent.getAlwaysRun())
+ {
+ // Turn off temporary running.
+ gAgent.clearRunning();
+ gAgent.sendWalkRun(gAgent.getRunning());
+ }
+ gAgent.mDoubleTapRunMode = mode;
}
- else
+ else if (KEYSTATE_DOWN == s &&
+ gAgent.mDoubleTapRunMode == mode &&
+ gAgent.mDoubleTapRunTimer.getElapsedTimeF32() < NUDGE_TIME)
{
- gAgent.moveAt(1);
+ // Same walk-key was pushed again quickly; this is a double-tap
+ // so engage temporary running.
+ gAgent.setRunning();
+ gAgent.sendWalkRun(gAgent.getRunning());
}
}
-
-void agent_push_backward( EKeystate s )
+static void agent_push_forwardbackward( EKeystate s, S32 direction, LLAgent::EDoubleTapRunMode mode )
{
- if( KEYSTATE_UP == s ) return;
- S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount());
+ agent_handle_doubletap_run(s, mode);
+ if (KEYSTATE_UP == s) return;
+
F32 time = gKeyboard->getCurKeyElapsedTime();
+ S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount());
if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES)
{
- gAgent.moveAtNudge(-1);
+ gAgent.moveAtNudge(direction);
}
else
{
- gAgent.moveAt(-1);
+ gAgent.moveAt(direction);
}
}
-void agent_slide_left( EKeystate s )
+void agent_push_forward( EKeystate s )
{
- if( KEYSTATE_UP == s ) return;
+ agent_push_forwardbackward(s, 1, LLAgent::DOUBLETAP_FORWARD);
+}
+
+
+void agent_push_backward( EKeystate s )
+{
+ agent_push_forwardbackward(s, -1, LLAgent::DOUBLETAP_BACKWARD);
+}
+
+static void agent_slide_leftright( EKeystate s, S32 direction, LLAgent::EDoubleTapRunMode mode )
+{
+ agent_handle_doubletap_run(s, mode);
+ if( KEYSTATE_UP == s ) return;
F32 time = gKeyboard->getCurKeyElapsedTime();
S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount());
if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES)
{
- gAgent.moveLeftNudge(1);
+ gAgent.moveLeftNudge(direction);
}
else
{
- gAgent.moveLeft(1);
+ gAgent.moveLeft(direction);
}
}
-void agent_slide_right( EKeystate s )
+void agent_slide_left( EKeystate s )
{
- if( KEYSTATE_UP == s ) return;
- F32 time = gKeyboard->getCurKeyElapsedTime();
- S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount());
+ agent_slide_leftright(s, 1, LLAgent::DOUBLETAP_SLIDELEFT);
+}
- if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES)
- {
- gAgent.moveLeftNudge(-1);
- }
- else
- {
- gAgent.moveLeft(-1);
- }
+
+void agent_slide_right( EKeystate s )
+{
+ agent_slide_leftright(s, -1, LLAgent::DOUBLETAP_SLIDERIGHT);
}
void agent_turn_left( EKeystate s )
{
- if( KEYSTATE_UP == s ) return;
- F32 time = gKeyboard->getCurKeyElapsedTime();
if (gToolCamera->mouseSteerMode())
{
agent_slide_left(s);
}
else
{
+ if (KEYSTATE_UP == s) return;
+ F32 time = gKeyboard->getCurKeyElapsedTime();
gAgent.moveYaw( LLFloaterMove::getYawRate( time ) );
}
}
@@ -166,14 +185,14 @@ void agent_turn_left( EKeystate s )
void agent_turn_right( EKeystate s )
{
- if( KEYSTATE_UP == s ) return;
- F32 time = gKeyboard->getCurKeyElapsedTime();
if (gToolCamera->mouseSteerMode())
{
agent_slide_right(s);
}
else
{
+ if (KEYSTATE_UP == s) return;
+ F32 time = gKeyboard->getCurKeyElapsedTime();
gAgent.moveYaw( -LLFloaterMove::getYawRate( time ) );
}
}