diff options
author | Josh Bell <josh@lindenlab.com> | 2008-03-14 19:27:38 +0000 |
---|---|---|
committer | Josh Bell <josh@lindenlab.com> | 2008-03-14 19:27:38 +0000 |
commit | 133a7b5fe2bcaaec8389b209cb5bd774ebc2ab63 (patch) | |
tree | d7a8f7846af7dc948d9e11c5a75dd830fb12465c /indra/newview/llviewerkeyboard.cpp | |
parent | a1cde743e755d826c86aeb006d2027ad2e5c8ce3 (diff) |
svn merge -r 82272:82277 svn+ssh://svn.lindenlab.com/svn/linden/branches/maint-ui-9-merge-2 --> release
QAR-364 - merge of maint-ui-9
Diffstat (limited to 'indra/newview/llviewerkeyboard.cpp')
-rw-r--r-- | indra/newview/llviewerkeyboard.cpp | 89 |
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 ) ); } } |