diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/newview/llviewerkeyboard.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/newview/llviewerkeyboard.cpp')
-rw-r--r-- | linden/indra/newview/llviewerkeyboard.cpp | 114 |
1 files changed, 77 insertions, 37 deletions
diff --git a/linden/indra/newview/llviewerkeyboard.cpp b/linden/indra/newview/llviewerkeyboard.cpp index 6fe1052..1c5d870 100644 --- a/linden/indra/newview/llviewerkeyboard.cpp +++ b/linden/indra/newview/llviewerkeyboard.cpp | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
33 | 33 | ||
34 | #include "llappviewer.h" | ||
34 | #include "llviewerkeyboard.h" | 35 | #include "llviewerkeyboard.h" |
35 | #include "llmath.h" | 36 | #include "llmath.h" |
36 | #include "llagent.h" | 37 | #include "llagent.h" |
@@ -83,82 +84,102 @@ void agent_push_down( EKeystate s ) | |||
83 | gAgent.moveUp(-1); | 84 | gAgent.moveUp(-1); |
84 | } | 85 | } |
85 | 86 | ||
86 | void agent_push_forward( EKeystate s ) | 87 | static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode mode) |
87 | { | 88 | { |
88 | if( KEYSTATE_UP == s ) return; | 89 | if (KEYSTATE_UP == s) |
89 | F32 time = gKeyboard->getCurKeyElapsedTime(); | ||
90 | S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); | ||
91 | |||
92 | if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) | ||
93 | { | 90 | { |
94 | gAgent.moveAtNudge(1); | 91 | // Releasing a walk-key resets the double-tap timer |
92 | gAgent.mDoubleTapRunTimer.reset(); | ||
93 | if (gAgent.mDoubleTapRunMode == mode && | ||
94 | gAgent.getRunning() && | ||
95 | !gAgent.getAlwaysRun()) | ||
96 | { | ||
97 | // Turn off temporary running. | ||
98 | gAgent.clearRunning(); | ||
99 | gAgent.sendWalkRun(gAgent.getRunning()); | ||
100 | } | ||
101 | gAgent.mDoubleTapRunMode = mode; | ||
95 | } | 102 | } |
96 | else | 103 | else if (gAllowTapTapHoldRun && |
104 | KEYSTATE_DOWN == s && | ||
105 | gAgent.mDoubleTapRunMode == mode && | ||
106 | gAgent.mDoubleTapRunTimer.getElapsedTimeF32() < NUDGE_TIME) | ||
97 | { | 107 | { |
98 | gAgent.moveAt(1); | 108 | // Same walk-key was pushed again quickly; this is a double-tap |
109 | // so engage temporary running. | ||
110 | gAgent.setRunning(); | ||
111 | gAgent.sendWalkRun(gAgent.getRunning()); | ||
99 | } | 112 | } |
100 | } | 113 | } |
101 | 114 | ||
102 | 115 | static void agent_push_forwardbackward( EKeystate s, S32 direction, LLAgent::EDoubleTapRunMode mode ) | |
103 | void agent_push_backward( EKeystate s ) | ||
104 | { | 116 | { |
105 | if( KEYSTATE_UP == s ) return; | 117 | agent_handle_doubletap_run(s, mode); |
106 | S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); | 118 | if (KEYSTATE_UP == s) return; |
119 | |||
107 | F32 time = gKeyboard->getCurKeyElapsedTime(); | 120 | F32 time = gKeyboard->getCurKeyElapsedTime(); |
121 | S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); | ||
108 | 122 | ||
109 | if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) | 123 | if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) |
110 | { | 124 | { |
111 | gAgent.moveAtNudge(-1); | 125 | gAgent.moveAtNudge(direction); |
112 | } | 126 | } |
113 | else | 127 | else |
114 | { | 128 | { |
115 | gAgent.moveAt(-1); | 129 | gAgent.moveAt(direction); |
116 | } | 130 | } |
117 | } | 131 | } |
118 | 132 | ||
119 | void agent_slide_left( EKeystate s ) | 133 | void agent_push_forward( EKeystate s ) |
120 | { | 134 | { |
121 | if( KEYSTATE_UP == s ) return; | 135 | agent_push_forwardbackward(s, 1, LLAgent::DOUBLETAP_FORWARD); |
136 | } | ||
137 | |||
138 | |||
139 | void agent_push_backward( EKeystate s ) | ||
140 | { | ||
141 | agent_push_forwardbackward(s, -1, LLAgent::DOUBLETAP_BACKWARD); | ||
142 | } | ||
143 | |||
144 | static void agent_slide_leftright( EKeystate s, S32 direction, LLAgent::EDoubleTapRunMode mode ) | ||
145 | { | ||
146 | agent_handle_doubletap_run(s, mode); | ||
147 | if( KEYSTATE_UP == s ) return; | ||
122 | F32 time = gKeyboard->getCurKeyElapsedTime(); | 148 | F32 time = gKeyboard->getCurKeyElapsedTime(); |
123 | S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); | 149 | S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); |
124 | 150 | ||
125 | if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) | 151 | if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) |
126 | { | 152 | { |
127 | gAgent.moveLeftNudge(1); | 153 | gAgent.moveLeftNudge(direction); |
128 | } | 154 | } |
129 | else | 155 | else |
130 | { | 156 | { |
131 | gAgent.moveLeft(1); | 157 | gAgent.moveLeft(direction); |
132 | } | 158 | } |
133 | } | 159 | } |
134 | 160 | ||
135 | 161 | ||
136 | void agent_slide_right( EKeystate s ) | 162 | void agent_slide_left( EKeystate s ) |
137 | { | 163 | { |
138 | if( KEYSTATE_UP == s ) return; | 164 | agent_slide_leftright(s, 1, LLAgent::DOUBLETAP_SLIDELEFT); |
139 | F32 time = gKeyboard->getCurKeyElapsedTime(); | 165 | } |
140 | S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); | ||
141 | 166 | ||
142 | if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) | 167 | |
143 | { | 168 | void agent_slide_right( EKeystate s ) |
144 | gAgent.moveLeftNudge(-1); | 169 | { |
145 | } | 170 | agent_slide_leftright(s, -1, LLAgent::DOUBLETAP_SLIDERIGHT); |
146 | else | ||
147 | { | ||
148 | gAgent.moveLeft(-1); | ||
149 | } | ||
150 | } | 171 | } |
151 | 172 | ||
152 | void agent_turn_left( EKeystate s ) | 173 | void agent_turn_left( EKeystate s ) |
153 | { | 174 | { |
154 | if( KEYSTATE_UP == s ) return; | 175 | if (LLToolCamera::getInstance()->mouseSteerMode()) |
155 | F32 time = gKeyboard->getCurKeyElapsedTime(); | ||
156 | if (gToolCamera->mouseSteerMode()) | ||
157 | { | 176 | { |
158 | agent_slide_left(s); | 177 | agent_slide_left(s); |
159 | } | 178 | } |
160 | else | 179 | else |
161 | { | 180 | { |
181 | if (KEYSTATE_UP == s) return; | ||
182 | F32 time = gKeyboard->getCurKeyElapsedTime(); | ||
162 | gAgent.moveYaw( LLFloaterMove::getYawRate( time ) ); | 183 | gAgent.moveYaw( LLFloaterMove::getYawRate( time ) ); |
163 | } | 184 | } |
164 | } | 185 | } |
@@ -166,14 +187,14 @@ void agent_turn_left( EKeystate s ) | |||
166 | 187 | ||
167 | void agent_turn_right( EKeystate s ) | 188 | void agent_turn_right( EKeystate s ) |
168 | { | 189 | { |
169 | if( KEYSTATE_UP == s ) return; | 190 | if (LLToolCamera::getInstance()->mouseSteerMode()) |
170 | F32 time = gKeyboard->getCurKeyElapsedTime(); | ||
171 | if (gToolCamera->mouseSteerMode()) | ||
172 | { | 191 | { |
173 | agent_slide_right(s); | 192 | agent_slide_right(s); |
174 | } | 193 | } |
175 | else | 194 | else |
176 | { | 195 | { |
196 | if (KEYSTATE_UP == s) return; | ||
197 | F32 time = gKeyboard->getCurKeyElapsedTime(); | ||
177 | gAgent.moveYaw( -LLFloaterMove::getYawRate( time ) ); | 198 | gAgent.moveYaw( -LLFloaterMove::getYawRate( time ) ); |
178 | } | 199 | } |
179 | } | 200 | } |
@@ -477,6 +498,24 @@ void start_chat( EKeystate s ) | |||
477 | gChatBar->startChat(NULL); | 498 | gChatBar->startChat(NULL); |
478 | } | 499 | } |
479 | 500 | ||
501 | void start_gesture( EKeystate s ) | ||
502 | { | ||
503 | if (KEYSTATE_UP == s && | ||
504 | !(gFocusMgr.getKeyboardFocus() && gFocusMgr.getKeyboardFocus()->acceptsTextInput())) | ||
505 | { | ||
506 | if (gChatBar->getCurrentChat().empty()) | ||
507 | { | ||
508 | // No existing chat in chat editor, insert '/' | ||
509 | gChatBar->startChat("/"); | ||
510 | } | ||
511 | else | ||
512 | { | ||
513 | // Don't overwrite existing text in chat editor | ||
514 | gChatBar->startChat(NULL); | ||
515 | } | ||
516 | } | ||
517 | } | ||
518 | |||
480 | void bind_keyboard_functions() | 519 | void bind_keyboard_functions() |
481 | { | 520 | { |
482 | gViewerKeyboard.bindNamedFunction("jump", agent_jump); | 521 | gViewerKeyboard.bindNamedFunction("jump", agent_jump); |
@@ -518,6 +557,7 @@ void bind_keyboard_functions() | |||
518 | gViewerKeyboard.bindNamedFunction("edit_avatar_move_backward", edit_avatar_move_backward); | 557 | gViewerKeyboard.bindNamedFunction("edit_avatar_move_backward", edit_avatar_move_backward); |
519 | gViewerKeyboard.bindNamedFunction("stop_moving", stop_moving); | 558 | gViewerKeyboard.bindNamedFunction("stop_moving", stop_moving); |
520 | gViewerKeyboard.bindNamedFunction("start_chat", start_chat); | 559 | gViewerKeyboard.bindNamedFunction("start_chat", start_chat); |
560 | gViewerKeyboard.bindNamedFunction("start_gesture", start_gesture); | ||
521 | } | 561 | } |
522 | 562 | ||
523 | LLViewerKeyboard::LLViewerKeyboard() | 563 | LLViewerKeyboard::LLViewerKeyboard() |