diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-09-25 22:23:09 +0300 |
---|---|---|
committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-09-25 22:23:09 +0300 |
commit | 8f35d638fbdbbdcf80ad1e6d826fd6161a0a2387 (patch) | |
tree | 7344bfa754984edd1e97f297f8e9372a44b9bd68 /indra/newview/llviewerkeyboard.cpp | |
parent | 08969001e25397cc947b5aa027522d3cc7aa8c53 (diff) |
SL-6109 LMB DLMB in progress
Diffstat (limited to 'indra/newview/llviewerkeyboard.cpp')
-rw-r--r-- | indra/newview/llviewerkeyboard.cpp | 114 |
1 files changed, 86 insertions, 28 deletions
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index f1a2b037e2..420980ca56 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -38,6 +38,7 @@ #include "llmorphview.h" #include "llmoveview.h" #include "lltoolfocus.h" +#include "lltoolpie.h" #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llfloatercamera.h" @@ -565,7 +566,7 @@ void edit_avatar_move_backward( EKeystate s ) void stop_moving( EKeystate s ) { - if( KEYSTATE_UP == s ) return; + if( KEYSTATE_DOWN != s ) return; // stop agent gAgent.setControlFlags(AGENT_CONTROL_STOP); @@ -579,7 +580,8 @@ void start_chat( EKeystate s ) { return; // can't talk, gotta go, kthxbye! } - + if (KEYSTATE_DOWN != s) return; + // start chat LLFloaterIMNearbyChat::startChat(NULL); } @@ -647,6 +649,19 @@ void toggle_enable_media(EKeystate s) LLViewerMedia::setAllMediaEnabled(!pause); } +void walk_to(EKeystate s) +{ + LL_WARNS() << "processing " << LLSD(s).asString() << LL_ENDL; + if (KEYSTATE_DOWN != s) return; + LLToolPie::getInstance()->walkToClickedLocation(); +} + +void teleport_to(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return; + LLToolPie::getInstance()->teleportToClickedLocation(); +} + #define REGISTER_KEYBOARD_ACTION(KEY, ACTION) LLREGISTER_STATIC(LLKeyboardActionRegistry, KEY, ACTION); REGISTER_KEYBOARD_ACTION("jump", agent_jump); REGISTER_KEYBOARD_ACTION("push_down", agent_push_down); @@ -692,6 +707,8 @@ REGISTER_KEYBOARD_ACTION("toggle_run", toggle_run); REGISTER_KEYBOARD_ACTION("toggle_sit", toggle_sit); REGISTER_KEYBOARD_ACTION("toggle_pause_media", toggle_pause_media); REGISTER_KEYBOARD_ACTION("toggle_enable_media", toggle_enable_media); +REGISTER_KEYBOARD_ACTION("teleport_to", teleport_to); +REGISTER_KEYBOARD_ACTION("walk_to", walk_to); #undef REGISTER_KEYBOARD_ACTION LLViewerKeyboard::LLViewerKeyboard() @@ -754,7 +771,7 @@ BOOL LLViewerKeyboard::mouseFromString(const std::string& string, EMouseClickTyp *mode = CLICK_LEFT; return TRUE; } - else if (string == "DLMB") + else if (string == "Double LMB") { *mode = CLICK_DOUBLELEFT; return TRUE; @@ -1043,24 +1060,44 @@ S32 LLViewerKeyboard::loadBindingMode(const LLViewerKeyboard::KeyMode& keymode, it != end_it; ++it) { + bool processed = false; if (!it->key.getValue().empty()) { KEY key; - MASK mask; - bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; LLKeyboard::keyFromString(it->key, &key); - LLKeyboard::maskFromString(it->mask, &mask); - bindKey(mode, key, mask, ignore, it->command); - binding_count++; + if (key != KEY_NONE) + { + MASK mask; + bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; + LLKeyboard::maskFromString(it->mask, &mask); + bindKey(mode, key, mask, ignore, it->command); + processed = true; + } + else + { + LL_WARNS_ONCE() << "There might be issues in keybindings' file" << LL_ENDL; + } } - else if (it->mouse.isProvided() && !it->mouse.getValue().empty()) + if (!processed && it->mouse.isProvided() && !it->mouse.getValue().empty()) { EMouseClickType mouse; - MASK mask; - bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; mouseFromString(it->mouse.getValue(), &mouse); - LLKeyboard::maskFromString(it->mask, &mask); - bindMouse(mode, mouse, mask, ignore, it->command); + if (mouse != CLICK_NONE) + { + MASK mask; + bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; + LLKeyboard::maskFromString(it->mask, &mask); + bindMouse(mode, mouse, mask, ignore, it->command); + processed = true; + } + else + { + LL_WARNS_ONCE() << "There might be issues in keybindings' file" << LL_ENDL; + } + } + if (processed) + { + // total binding_count++; } } @@ -1259,28 +1296,41 @@ BOOL LLViewerKeyboard::handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK ma if (clicktype != CLICK_NONE) { - // special case - // if UI doesn't handle double click, LMB click is issued, so supres LMB 'down' when doubleclick is set + // Special case + // If UI doesn't handle double click, LMB click is issued, so supres LMB 'down' when doubleclick is set // handle !down as if we are handling doubleclick - bool override_lmb = (clicktype == CLICK_LEFT - && (mMouseLevel[CLICK_DOUBLELEFT] == MOUSE_STATE_DOWN || mMouseLevel[CLICK_DOUBLELEFT] == MOUSE_STATE_LEVEL)); - if (override_lmb && !down) + bool double_click_sp = (clicktype == CLICK_LEFT + && (mMouseLevel[CLICK_DOUBLELEFT] != MOUSE_STATE_SILENT) + && mMouseLevel[CLICK_LEFT] == MOUSE_STATE_SILENT); + if (double_click_sp && !down) { - // process doubleclick instead + // Process doubleclick instead clicktype = CLICK_DOUBLELEFT; } - if (override_lmb && down) + + if (double_click_sp && down) { - // else-supress + // Consume click. + // Due to handling, double click that is not handled will be immediately followed by LMB click } - // if UI handled 'down', it should handle 'up' as well - // if we handle 'down' not by UI, then we should handle 'up'/'level' regardless of UI - else if (handled && mMouseLevel[clicktype] != MOUSE_STATE_SILENT) + // If UI handled 'down', it should handle 'up' as well + // If we handle 'down' not by UI, then we should handle 'up'/'level' regardless of UI + else if (handled) { // UI handled new 'down' so iterupt whatever state we were in. - mMouseLevel[clicktype] = MOUSE_STATE_UP; + if (mMouseLevel[clicktype] != MOUSE_STATE_SILENT) + { + if (mMouseLevel[clicktype] == MOUSE_STATE_DOWN) + { + mMouseLevel[clicktype] = MOUSE_STATE_CLICK; + } + else + { + mMouseLevel[clicktype] = MOUSE_STATE_UP; + } + } } else if (down) { @@ -1295,10 +1345,17 @@ BOOL LLViewerKeyboard::handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK ma mMouseLevel[clicktype] = MOUSE_STATE_DOWN; } } - else + else if (mMouseLevel[clicktype] != MOUSE_STATE_SILENT) { // Released mouse key - mMouseLevel[clicktype] = MOUSE_STATE_UP; + if (mMouseLevel[clicktype] == MOUSE_STATE_DOWN) + { + mMouseLevel[clicktype] = MOUSE_STATE_CLICK; + } + else + { + mMouseLevel[clicktype] = MOUSE_STATE_UP; + } } } @@ -1314,6 +1371,7 @@ bool LLViewerKeyboard::scanMouse(const LLMouseBinding *binding, S32 binding_coun switch (state) { case MOUSE_STATE_DOWN: + case MOUSE_STATE_CLICK: binding[i].mFunction(KEYSTATE_DOWN); break; case MOUSE_STATE_LEVEL: @@ -1358,7 +1416,7 @@ void LLViewerKeyboard::scanMouse() // mouse doesn't support 'continued' state like keyboard does, so after handling, switch to LEVEL mMouseLevel[i] = MOUSE_STATE_LEVEL; } - else if (mMouseLevel[i] == MOUSE_STATE_UP) + else if (mMouseLevel[i] == MOUSE_STATE_UP || mMouseLevel[i] == MOUSE_STATE_CLICK) { mMouseLevel[i] = MOUSE_STATE_SILENT; } |