From 04b6b6d1ba58ecf5bf70f2e2b9ae80316c4236ae Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 15 Jul 2021 18:37:02 +0300 Subject: SL-443 Keybindings: Do not error on unknown function It is likely be from newer viewer / Preparations for SL-443 deloyment. --- indra/newview/llviewerinput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index c0eaa88f54..f269be035e 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1070,7 +1070,7 @@ BOOL LLViewerInput::bindKey(const S32 mode, const KEY key, const MASK mask, cons if (!function) { - LL_ERRS() << "Can't bind key to function " << function_name << ", no function with this name found" << LL_ENDL; + LL_WARNS() << "Can't bind key to function " << function_name << ", no function with this name found" << LL_ENDL; return FALSE; } @@ -1112,7 +1112,7 @@ BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const if (!function) { - LL_ERRS() << "Can't bind key to function " << function_name << ", no function with this name found" << LL_ENDL; + LL_WARNS() << "Can't bind mouse key to function " << function_name << ", no function with this name found" << LL_ENDL; return FALSE; } -- cgit v1.2.3 From 0814ba33222fa86e73ca3e5351175ba4b7b545e8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 15 Jul 2021 17:34:16 +0300 Subject: SL-443 Keybindings: Support reassigment of script interaction button --- indra/newview/llviewerinput.cpp | 81 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 9 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index f269be035e..f163e871c3 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -61,7 +61,7 @@ const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed const LLKeyData agent_control_lbutton(CLICK_LEFT, KEY_NONE, MASK_NONE, true); struct LLKeyboardActionRegistry -: public LLRegistrySingleton, LLKeyboardActionRegistry> +: public LLRegistrySingleton, LLKeyboardActionRegistry> { LLSINGLETON_EMPTY_CTOR(LLKeyboardActionRegistry); }; @@ -836,7 +836,49 @@ bool voice_follow_key(EKeystate s) return false; } -bool agen_control_lbutton_handle(EKeystate s) +bool sript_trigger_lbutton(EKeystate s) +{ + // Check for script overriding/expecting left mouse button. + // Note that this does not pass event further and depends onto mouselook. + // Checks CONTROL_ML_LBUTTON_DOWN_INDEX for mouselook, + // CONTROL_LBUTTON_DOWN_INDEX for normal camera + if (gAgent.leftButtonGrabbed()) + { + bool mouselook = gAgentCamera.cameraMouselook(); + switch (s) + { + case KEYSTATE_DOWN: + // at the moment sript_trigger_lbutton is only intended for mouselook + // but handling other modes just in case + if (mouselook) + { + gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN); + } + else + { + gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN); + } + return true; + case KEYSTATE_UP: + if (mouselook) + { + gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_UP); + } + else + { + gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP); + } + return true; + default: + break; + } + } + return false; +} + +// Used by scripts, for overriding/handling left mouse button +// see mControlsTakenCount +bool agent_control_lbutton_handle(EKeystate s) { switch (s) { @@ -905,6 +947,7 @@ REGISTER_KEYBOARD_ACTION("teleport_to", teleport_to); REGISTER_KEYBOARD_ACTION("walk_to", walk_to); REGISTER_KEYBOARD_ACTION("toggle_voice", toggle_voice); REGISTER_KEYBOARD_ACTION("voice_follow_key", voice_follow_key); +REGISTER_KEYBOARD_ACTION(script_mouse_handler_name, sript_trigger_lbutton); #undef REGISTER_KEYBOARD_ACTION LLViewerInput::LLViewerInput() @@ -1104,6 +1147,20 @@ BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const typedef boost::function function_t; function_t function = NULL; + if (mouse == CLICK_LEFT + && mask == MASK_NONE + && function_name == script_mouse_handler_name) + { + // Special case + // Left click has script overrides and by default + // is handled via agent_control_lbutton as last option + // In case of mouselook and present overrides it has highest + // priority even over UI and is handled in LLToolCompGun::handleMouseDown + // so just mark it as having default handler + mLMouseDefaultHandling[mode] = true; + return TRUE; + } + function_t* result = LLKeyboardActionRegistry::getValue(function_name); if (result) { @@ -1164,6 +1221,7 @@ void LLViewerInput::resetBindings() { mKeyBindings[i].clear(); mMouseBindings[i].clear(); + mLMouseDefaultHandling[i] = false; } } @@ -1355,13 +1413,14 @@ bool LLViewerInput::scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) if (!res && agent_control_lbutton.canHandle(CLICK_NONE, key, mask)) { + // pass mouse left button press to script if (key_down && !repeat) { - res = agen_control_lbutton_handle(KEYSTATE_DOWN); + res = agent_control_lbutton_handle(KEYSTATE_DOWN); } if (key_up) { - res = agen_control_lbutton_handle(KEYSTATE_UP); + res = agent_control_lbutton_handle(KEYSTATE_UP); } } return res; @@ -1481,24 +1540,28 @@ bool LLViewerInput::scanMouse(EMouseClickType click, EMouseState state) const S32 mode = getMode(); MASK mask = gKeyboard->currentMask(TRUE); res = scanMouse(mMouseBindings[mode], mMouseBindings[mode].size(), click, mask, state); + // no user defined actions found or those actions can't handle the key/button, handle control if nessesary - if (!res && agent_control_lbutton.canHandle(click, KEY_NONE, mask)) + // This will pass AGENT_CONTROL_LBUTTON_DOWN to server, no idea why it doesn't do mouselook variant _ML_ + // but it was set this way forever (moved as is from LLTool::handleMouseDown) so lots of scripts probably + // rely on this. + if (!res && mLMouseDefaultHandling[mode] && agent_control_lbutton.canHandle(click, KEY_NONE, mask)) { switch (state) { case MOUSE_STATE_DOWN: - agen_control_lbutton_handle(KEYSTATE_DOWN); + agent_control_lbutton_handle(KEYSTATE_DOWN); res = true; break; case MOUSE_STATE_CLICK: // might not work best with some functions, // but some function need specific states too specifically - agen_control_lbutton_handle(KEYSTATE_DOWN); - agen_control_lbutton_handle(KEYSTATE_UP); + agent_control_lbutton_handle(KEYSTATE_DOWN); + agent_control_lbutton_handle(KEYSTATE_UP); res = true; break; case MOUSE_STATE_UP: - agen_control_lbutton_handle(KEYSTATE_UP); + agent_control_lbutton_handle(KEYSTATE_UP); res = true; break; default: -- cgit v1.2.3 From 48921a62322bd4eae17d1085256693aa66041dbd Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 15 Jul 2021 20:22:53 +0300 Subject: SL-443 Keybindings: Backward compatibility --- indra/newview/llviewerinput.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index f163e871c3..dff199d791 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1212,7 +1212,8 @@ LLViewerInput::Keys::Keys() : first_person("first_person"), third_person("third_person"), sitting("sitting"), - edit_avatar("edit_avatar") + edit_avatar("edit_avatar"), + version("version", 0) {} void LLViewerInput::resetBindings() @@ -1240,6 +1241,16 @@ S32 LLViewerInput::loadBindingsXML(const std::string& filename) binding_count += loadBindingMode(keys.third_person, MODE_THIRD_PERSON); binding_count += loadBindingMode(keys.sitting, MODE_SITTING); binding_count += loadBindingMode(keys.edit_avatar, MODE_EDIT_AVATAR); + + // verify version + if (keys.version < 1) + { + // updating from a version that was not aware of LMouse bindings + for (S32 i = 0; i < MODE_COUNT; i++) + { + mLMouseDefaultHandling[i] = true; + } + } } return binding_count; } -- cgit v1.2.3 From e7563ff13fe1e6e77a0c6de5dcf0c1b67a6d2e2c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 15 Jul 2021 20:28:26 +0300 Subject: SL-443 Keybindings: Backward compatibility #2 --- indra/newview/llviewerinput.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index dff199d791..1ca7d8024a 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -836,7 +836,7 @@ bool voice_follow_key(EKeystate s) return false; } -bool sript_trigger_lbutton(EKeystate s) +bool script_trigger_lbutton(EKeystate s) { // Check for script overriding/expecting left mouse button. // Note that this does not pass event further and depends onto mouselook. @@ -848,8 +848,6 @@ bool sript_trigger_lbutton(EKeystate s) switch (s) { case KEYSTATE_DOWN: - // at the moment sript_trigger_lbutton is only intended for mouselook - // but handling other modes just in case if (mouselook) { gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN); @@ -947,7 +945,7 @@ REGISTER_KEYBOARD_ACTION("teleport_to", teleport_to); REGISTER_KEYBOARD_ACTION("walk_to", walk_to); REGISTER_KEYBOARD_ACTION("toggle_voice", toggle_voice); REGISTER_KEYBOARD_ACTION("voice_follow_key", voice_follow_key); -REGISTER_KEYBOARD_ACTION(script_mouse_handler_name, sript_trigger_lbutton); +REGISTER_KEYBOARD_ACTION(script_mouse_handler_name, script_trigger_lbutton); #undef REGISTER_KEYBOARD_ACTION LLViewerInput::LLViewerInput() @@ -1213,7 +1211,7 @@ LLViewerInput::Keys::Keys() third_person("third_person"), sitting("sitting"), edit_avatar("edit_avatar"), - version("version", 0) + xml_version("xml_version", 0) {} void LLViewerInput::resetBindings() @@ -1243,7 +1241,7 @@ S32 LLViewerInput::loadBindingsXML(const std::string& filename) binding_count += loadBindingMode(keys.edit_avatar, MODE_EDIT_AVATAR); // verify version - if (keys.version < 1) + if (keys.xml_version < 1) { // updating from a version that was not aware of LMouse bindings for (S32 i = 0; i < MODE_COUNT; i++) @@ -1602,7 +1600,7 @@ void LLViewerInput::scanMouse() } } -bool LLViewerInput::isMouseBindUsed(const EMouseClickType mouse, const MASK mask, const S32 mode) +bool LLViewerInput::isMouseBindUsed(const EMouseClickType mouse, const MASK mask, const S32 mode) const { S32 size = mMouseBindings[mode].size(); for (S32 index = 0; index < size; index++) -- cgit v1.2.3 From f55821a6daad638110a7eb5b6b824f9f06220b51 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 11 Aug 2021 00:52:34 +0300 Subject: SL-15791 CONTROL_ML_LBUTTON and CONTROL_LBUTTON were triggered simultaneously --- indra/newview/llviewerinput.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index 1ca7d8024a..15cf0b05db 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1550,11 +1550,16 @@ bool LLViewerInput::scanMouse(EMouseClickType click, EMouseState state) const MASK mask = gKeyboard->currentMask(TRUE); res = scanMouse(mMouseBindings[mode], mMouseBindings[mode].size(), click, mask, state); - // no user defined actions found or those actions can't handle the key/button, handle control if nessesary - // This will pass AGENT_CONTROL_LBUTTON_DOWN to server, no idea why it doesn't do mouselook variant _ML_ - // but it was set this way forever (moved as is from LLTool::handleMouseDown) so lots of scripts probably - // rely on this. - if (!res && mLMouseDefaultHandling[mode] && agent_control_lbutton.canHandle(click, KEY_NONE, mask)) + // No user defined actions found or those actions can't handle the key/button, handle control if nessesary + // + // Default handling for MODE_FIRST_PERSON is in LLToolCompGun::handleMouseDown, but only if + // leftButtonGrabbed() + // + // If not grabbed or not in mouse look, should pass AGENT_CONTROL_LBUTTON_DOWN to server + if (!res + && (mode != MODE_FIRST_PERSON || !gAgent.leftButtonGrabbed()) + && mLMouseDefaultHandling[mode] + && agent_control_lbutton.canHandle(click, KEY_NONE, mask)) { switch (state) { -- cgit v1.2.3 From 10ba971b586ff2d12f58a1ad7d5eed8264584398 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 11 Aug 2021 20:07:51 +0300 Subject: SL-15791 Double click was not causing CONTROL_LBUTTON_DOWN --- indra/newview/llviewerinput.cpp | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index 15cf0b05db..976d7d9c6b 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -58,8 +58,6 @@ const F32 NUDGE_TIME = 0.25f; // in seconds const S32 NUDGE_FRAMES = 2; const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed -const LLKeyData agent_control_lbutton(CLICK_LEFT, KEY_NONE, MASK_NONE, true); - struct LLKeyboardActionRegistry : public LLRegistrySingleton, LLKeyboardActionRegistry> { @@ -1420,18 +1418,6 @@ bool LLViewerInput::scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) bool res = scanKey(mKeyBindings[mode], mKeyBindings[mode].size(), key, mask, key_down, key_up, key_level, repeat); - if (!res && agent_control_lbutton.canHandle(CLICK_NONE, key, mask)) - { - // pass mouse left button press to script - if (key_down && !repeat) - { - res = agent_control_lbutton_handle(KEYSTATE_DOWN); - } - if (key_up) - { - res = agent_control_lbutton_handle(KEYSTATE_UP); - } - } return res; } @@ -1550,16 +1536,18 @@ bool LLViewerInput::scanMouse(EMouseClickType click, EMouseState state) const MASK mask = gKeyboard->currentMask(TRUE); res = scanMouse(mMouseBindings[mode], mMouseBindings[mode].size(), click, mask, state); - // No user defined actions found or those actions can't handle the key/button, handle control if nessesary + // No user defined actions found or those actions can't handle the key/button, + // so handle CONTROL_LBUTTON if nessesary. // - // Default handling for MODE_FIRST_PERSON is in LLToolCompGun::handleMouseDown, but only if - // leftButtonGrabbed() - // - // If not grabbed or not in mouse look, should pass AGENT_CONTROL_LBUTTON_DOWN to server + // Default handling for MODE_FIRST_PERSON is in LLToolCompGun::handleMouseDown, + // and sends AGENT_CONTROL_ML_LBUTTON_DOWN, but it only applies if ML controls + // are leftButtonGrabbed(), send a normal click otherwise. + if (!res - && (mode != MODE_FIRST_PERSON || !gAgent.leftButtonGrabbed()) && mLMouseDefaultHandling[mode] - && agent_control_lbutton.canHandle(click, KEY_NONE, mask)) + && (mode != MODE_FIRST_PERSON || !gAgent.leftButtonGrabbed()) + && (click == CLICK_LEFT || click == CLICK_DOUBLELEFT) + ) { switch (state) { -- cgit v1.2.3 From 6d05c44d712991815e991ba2c61ddc7370b66ead Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 11 Aug 2021 21:29:59 +0300 Subject: SL-15791 Assigned walk_to or teleport_to sometimes prevents controls from triggering --- indra/newview/llviewerinput.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index 976d7d9c6b..bb8617735f 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -800,13 +800,20 @@ bool toggle_enable_media(EKeystate s) bool walk_to(EKeystate s) { - if (KEYSTATE_DOWN != s) return true; + if (KEYSTATE_DOWN != s) + { + // teleport/walk is usually on mouseclick, mouseclick needs + // to let AGENT_CONTROL_LBUTTON_UP happen if teleport didn't, + // so return false, but if it causes issues, do some kind of + // "return !has_teleported" + return false; + } return LLToolPie::getInstance()->walkToClickedLocation(); } bool teleport_to(EKeystate s) { - if (KEYSTATE_DOWN != s) return true; + if (KEYSTATE_DOWN != s) return false; return LLToolPie::getInstance()->teleportToClickedLocation(); } -- cgit v1.2.3 From 0dd4577013a48289f84dcb3cc8b673fb1f733b7d Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 19 Nov 2021 05:53:20 +0200 Subject: DRTVWR-540 Post-merge build fix --- indra/newview/llviewerinput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index c900d0f6bf..e76b8c0fcf 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1255,7 +1255,7 @@ BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const return TRUE; } - function_t* result = LLKeyboardActionRegistry::getValue(function_name); + LLKeybindFunctionData* result = LLKeyboardActionRegistry::getValue(function_name); if (result) { function = result->mFunction; @@ -1666,7 +1666,7 @@ bool LLViewerInput::scanMouse(EMouseClickType click, EMouseState state) const bool res = false; S32 mode = getMode(); MASK mask = gKeyboard->currentMask(TRUE); - res = scanMouse(mMouseBindings[mode], mMouseBindings[mode].size(), click, mask, state); + res = scanMouse(mMouseBindings[mode], mMouseBindings[mode].size(), click, mask, state, false); // No user defined actions found or those actions can't handle the key/button, // so handle CONTROL_LBUTTON if nessesary. -- cgit v1.2.3 From 93262cf286baba47d271ee0aa700c6c40afaa132 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 19 Nov 2021 13:00:36 +0200 Subject: DRTVWR-540 Merge follow up fix --- indra/newview/llviewerinput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index e76b8c0fcf..1a08b1a56c 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -967,8 +967,8 @@ 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); -REGISTER_KEYBOARD_ACTION("toggle_voice", toggle_voice); -REGISTER_KEYBOARD_ACTION("voice_follow_key", voice_follow_key); +REGISTER_KEYBOARD_GLOBAL_ACTION("toggle_voice", toggle_voice); +REGISTER_KEYBOARD_GLOBAL_ACTION("voice_follow_key", voice_follow_key); REGISTER_KEYBOARD_ACTION(script_mouse_handler_name, script_trigger_lbutton); #undef REGISTER_KEYBOARD_ACTION -- cgit v1.2.3 From fc90fee5087c91bb8c4c93b5e9508706e46bd409 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 4 Mar 2022 22:24:59 +0200 Subject: SL-16976 SL-443 Keybindings: Backward compatibility #3 --- indra/newview/llviewerinput.cpp | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index 1a08b1a56c..43b9cd90bd 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1371,6 +1371,55 @@ S32 LLViewerInput::loadBindingsXML(const std::string& filename) { mLMouseDefaultHandling[i] = true; } + + // fix missing values + KeyBinding mouse_binding; + mouse_binding.key = ""; + mouse_binding.mask = "NONE"; + mouse_binding.mouse = "LMB"; + mouse_binding.command = script_mouse_handler_name; + + if (keys.third_person.isProvided()) + { + keys.third_person.bindings.add(mouse_binding); + } + + if (keys.first_person.isProvided()) + { + keys.first_person.bindings.add(mouse_binding); + } + + if (keys.sitting.isProvided()) + { + keys.sitting.bindings.add(mouse_binding); + } + + if (keys.edit_avatar.isProvided()) + { + keys.edit_avatar.bindings.add(mouse_binding); + } + + // fix version + keys.xml_version.set(keybindings_xml_version, true); + + // Write the resulting XML to file + LLXMLNodePtr output_node = new LLXMLNode("keys", false); + LLXUIParser write_parser; + write_parser.writeXUI(output_node, keys); + + if (!output_node->isNull()) + { + // file in app_settings is supposed to be up to date + // this is only for the file from user_settings + LL_INFOS("ViewerInput") << "Updating file " << filename << " to a newer version" << LL_ENDL; + LLFILE *fp = LLFile::fopen(filename, "w"); + if (fp != NULL) + { + LLXMLNode::writeHeaderToFile(fp); + output_node->writeToFile(fp); + fclose(fp); + } + } } } return binding_count; -- cgit v1.2.3