diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-10-03 22:45:29 +0300 |
---|---|---|
committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-10-03 22:45:29 +0300 |
commit | 6aab234105d6eed022afbea388ae21530c7e99dd (patch) | |
tree | ba193253fe1902967e1fff56321b512a9c5b7f20 /indra/newview | |
parent | b8c5ae8d8fcf9219112c4ab48233615732737e44 (diff) |
SL-6109 Remade 'ignore' list processing, renamed and reformed keybindings
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/key_bindings.xml (renamed from indra/newview/app_settings/keys.xml) | 79 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 20 | ||||
-rw-r--r-- | indra/newview/llfloaterpreference.h | 8 | ||||
-rw-r--r-- | indra/newview/llkeyconflict.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llpanelpresetspulldown.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llsetkeybinddialog.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llsetkeybinddialog.h | 18 | ||||
-rw-r--r-- | indra/newview/llviewerinput.cpp | 164 | ||||
-rw-r--r-- | indra/newview/llviewerinput.h | 28 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/control_table_contents.xml | 14 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_select_key.xml | 15 |
13 files changed, 146 insertions, 243 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 8345d5c445..cbd2dd8b2f 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1666,7 +1666,7 @@ set(viewer_APPSETTINGS_FILES app_settings/grass.xml app_settings/high_graphics.xml app_settings/ignorable_dialogs.xml - app_settings/keys.xml + app_settings/key_bindings.xml app_settings/keywords_lsl_default.xml app_settings/logcontrol.xml app_settings/low_graphics.xml diff --git a/indra/newview/app_settings/keys.xml b/indra/newview/app_settings/key_bindings.xml index a8037fec05..0c90ef26df 100644 --- a/indra/newview/app_settings/keys.xml +++ b/indra/newview/app_settings/key_bindings.xml @@ -28,34 +28,9 @@ <binding key="PAD_ENTER" mask="NONE" command="start_chat"/> <binding key="PAD_DIVIDE" mask="NONE" command="start_gesture"/> - <binding key="A" mask="SHIFT" command="slide_left"/> - <binding key="D" mask="SHIFT" command="slide_right"/> - <binding key="W" mask="SHIFT" command="push_forward"/> - <binding key="S" mask="SHIFT" command="push_backward"/> - <binding key="E" mask="SHIFT" command="jump"/> - <binding key="C" mask="SHIFT" command="push_down"/> - <binding key="F" mask="SHIFT" command="toggle_fly"/> - <binding key="SPACE" mask="NONE" command="stop_moving"/> <binding key="ENTER" mask="NONE" command="start_chat"/> <binding key="DIVIDE" mask="NONE" command="start_gesture"/> - - <binding key="LEFT" mask="SHIFT" command="slide_left"/> - <binding key="RIGHT" mask="SHIFT" command="slide_right"/> - <binding key="UP" mask="SHIFT" command="push_forward"/> - <binding key="DOWN" mask="SHIFT" command="push_backward"/> - <binding key="PGUP" mask="SHIFT" command="jump"/> - <binding key="PGDN" mask="SHIFT" command="push_down"/> - - <binding key="PAD_LEFT" mask="SHIFT" command="slide_left"/> - <binding key="PAD_RIGHT" mask="SHIFT" command="slide_right"/> - <binding key="PAD_UP" mask="SHIFT" command="push_forward"/> - <binding key="PAD_DOWN" mask="SHIFT" command="push_backward"/> - <binding key="PAD_PGUP" mask="SHIFT" command="jump"/> - <binding key="PAD_PGDN" mask="SHIFT" command="push_down"/> - <binding key="PAD_HOME" mask="SHIFT" command="toggle_fly"/> - <binding key="PAD_ENTER" mask="SHIFT" command="start_chat"/> - <binding key="PAD_DIVIDE" mask="SHIFT" command="start_gesture"/> </first_person> <third_person> <binding key="A" mask="NONE" command="turn_left"/> @@ -64,15 +39,10 @@ <binding key="D" mask="SHIFT" command="slide_right"/> <binding key="W" mask="NONE" command="push_forward"/> <binding key="S" mask="NONE" command="push_backward"/> - <binding key="W" mask="SHIFT" command="push_forward"/> - <binding key="S" mask="SHIFT" command="push_backward"/> <binding key="E" mask="NONE" command="jump"/> <binding key="C" mask="NONE" command="push_down"/> - <binding key="E" mask="SHIFT" command="jump"/> - <binding key="C" mask="SHIFT" command="push_down"/> <binding key="F" mask="NONE" command="toggle_fly"/> - <binding key="F" mask="SHIFT" command="toggle_fly"/> <binding key="SPACE" mask="NONE" command="stop_moving"/> <binding key="ENTER" mask="NONE" command="start_chat"/> @@ -84,13 +54,8 @@ <binding key="RIGHT" mask="SHIFT" command="slide_right"/> <binding key="UP" mask="NONE" command="push_forward"/> <binding key="DOWN" mask="NONE" command="push_backward"/> - <binding key="UP" mask="SHIFT" command="push_forward"/> - <binding key="DOWN" mask="SHIFT" command="push_backward"/> <binding key="PGUP" mask="NONE" command="jump"/> <binding key="PGDN" mask="NONE" command="push_down"/> - <binding key="PGUP" mask="SHIFT" command="jump"/> - <binding key="PGDN" mask="SHIFT" command="push_down"/> - <binding key="HOME" mask="SHIFT" command="toggle_fly"/> <binding key="HOME" mask="NONE" command="toggle_fly"/> <binding key="PAD_LEFT" mask="NONE" command="turn_left"/> @@ -99,20 +64,12 @@ <binding key="PAD_RIGHT" mask="SHIFT" command="slide_right"/> <binding key="PAD_UP" mask="NONE" command="push_forward"/> <binding key="PAD_DOWN" mask="NONE" command="push_backward"/> - <binding key="PAD_UP" mask="SHIFT" command="push_forward"/> - <binding key="PAD_DOWN" mask="SHIFT" command="push_backward"/> <binding key="PAD_PGUP" mask="NONE" command="jump"/> <binding key="PAD_PGDN" mask="NONE" command="push_down"/> - <binding key="PAD_PGUP" mask="SHIFT" command="jump"/> - <binding key="PAD_PGDN" mask="SHIFT" command="push_down"/> <binding key="PAD_HOME" mask="NONE" command="toggle_fly"/> - <binding key="PAD_HOME" mask="SHIFT" command="toggle_fly"/> <binding key="PAD_CENTER" mask="NONE" command="stop_moving"/> - <binding key="PAD_CENTER" mask="SHIFT" command="stop_moving"/> <binding key="PAD_ENTER" mask="NONE" command="start_chat"/> - <binding key="PAD_ENTER" mask="SHIFT" command="start_chat"/> <binding key="PAD_DIVIDE" mask="NONE" command="start_gesture"/> - <binding key="PAD_DIVIDE" mask="SHIFT" command="start_gesture"/> <!--Camera controls in third person on Alt--> <binding key="LEFT" mask="ALT" command="spin_around_cw"/> @@ -139,28 +96,14 @@ <binding key="PAD_DIVIDE" mask="ALT" command="start_gesture"/> <!--mimic alt zoom behavior with keyboard only--> - <binding key="A" mask="CTL_ALT" command="spin_around_cw"/> - <binding key="D" mask="CTL_ALT" command="spin_around_ccw"/> <binding key="W" mask="CTL_ALT" command="spin_over"/> <binding key="S" mask="CTL_ALT" command="spin_under"/> - <binding key="E" mask="CTL_ALT" command="spin_over"/> - <binding key="C" mask="CTL_ALT" command="spin_under"/> - <binding key="LEFT" mask="CTL_ALT" command="spin_around_cw"/> - <binding key="RIGHT" mask="CTL_ALT" command="spin_around_ccw"/> <binding key="UP" mask="CTL_ALT" command="spin_over"/> <binding key="DOWN" mask="CTL_ALT" command="spin_under"/> - <binding key="PGUP" mask="CTL_ALT" command="spin_over"/> - <binding key="PGDN" mask="CTL_ALT" command="spin_under"/> - <binding key="PAD_LEFT" mask="CTL_ALT" command="spin_around_cw"/> - <binding key="PAD_RIGHT" mask="CTL_ALT" command="spin_around_ccw"/> <binding key="PAD_UP" mask="CTL_ALT" command="spin_over"/> <binding key="PAD_DOWN" mask="CTL_ALT" command="spin_under"/> - <binding key="PAD_PGUP" mask="CTL_ALT" command="spin_over"/> - <binding key="PAD_PGDN" mask="CTL_ALT" command="spin_under"/> - <binding key="PAD_ENTER" mask="CTL_ALT" command="start_chat"/> - <binding key="PAD_DIVIDE" mask="CTL_ALT" command="start_gesture"/> <!--Therefore pan on Alt-Shift--> <binding key="A" mask="CTL_ALT_SHIFT" command="pan_left"/> @@ -251,15 +194,11 @@ <binding key="PGUP" mask="ALT" command="spin_over"/> <binding key="PGDN" mask="ALT" command="spin_under"/> - <binding key="A" mask="CTL_ALT" command="spin_around_cw"/> - <binding key="D" mask="CTL_ALT" command="spin_around_ccw"/> <binding key="W" mask="CTL_ALT" command="spin_over"/> <binding key="S" mask="CTL_ALT" command="spin_under"/> <binding key="E" mask="CTL_ALT" command="spin_over"/> <binding key="C" mask="CTL_ALT" command="spin_under"/> - <binding key="LEFT" mask="CTL_ALT" command="spin_around_cw"/> - <binding key="RIGHT" mask="CTL_ALT" command="spin_around_ccw"/> <binding key="UP" mask="CTL_ALT" command="spin_over"/> <binding key="DOWN" mask="CTL_ALT" command="spin_under"/> <binding key="PGUP" mask="CTL_ALT" command="spin_over"/> @@ -294,23 +233,23 @@ <binding key="A" mask="SHIFT" command="slide_left"/> <binding key="D" mask="SHIFT" command="slide_right"/> <binding key="W" mask="SHIFT" command="move_forward_sitting"/> - <binding key="S" mask="SHIFT" command="move_backward_sitting"/> - <binding key="E" mask="SHIFT" command="spin_over_sitting"/> - <binding key="C" mask="SHIFT" command="spin_under_sitting"/> + <binding key="S" mask="SHIFT" command="move_backward_sitting"/> + <binding key="E" mask="SHIFT" command="spin_over_sitting"/> + <binding key="C" mask="SHIFT" command="spin_under_sitting"/> <binding key="LEFT" mask="SHIFT" command="slide_left"/> <binding key="RIGHT" mask="SHIFT" command="slide_right"/> <binding key="UP" mask="SHIFT" command="move_forward_sitting"/> - <binding key="DOWN" mask="SHIFT" command="move_backward_sitting"/> - <binding key="PGUP" mask="SHIFT" command="spin_over_sitting"/> - <binding key="PGDN" mask="SHIFT" command="spin_under_sitting"/> + <binding key="DOWN" mask="SHIFT" command="move_backward_sitting"/> + <binding key="PGUP" mask="SHIFT" command="spin_over_sitting"/> + <binding key="PGDN" mask="SHIFT" command="spin_under_sitting"/> <binding key="PAD_LEFT" mask="SHIFT" command="slide_left"/> <binding key="PAD_RIGHT" mask="SHIFT" command="slide_right"/> <binding key="PAD_UP" mask="SHIFT" command="move_forward_sitting"/> - <binding key="PAD_DOWN" mask="SHIFT" command="move_backward_sitting"/> - <binding key="PAD_PGUP" mask="SHIFT" command="spin_over_sitting"/> - <binding key="PAD_PGDN" mask="SHIFT" command="spin_under_sitting"/> + <binding key="PAD_DOWN" mask="SHIFT" command="move_backward_sitting"/> + <binding key="PAD_PGUP" mask="SHIFT" command="spin_over_sitting"/> + <binding key="PAD_PGDN" mask="SHIFT" command="spin_under_sitting"/> <binding key="PAD_ENTER" mask="SHIFT" command="start_chat"/> <binding key="PAD_DIVIDE" mask="SHIFT" command="start_gesture"/> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 1023a553f8..96e77410c3 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1005,11 +1005,11 @@ bool LLAppViewer::init() gGLManager.printGLInfoString(); // Load User's bindings - std::string key_bindings_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "keys.xml"); + std::string key_bindings_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "key_bindings.xml"); if (!gDirUtilp->fileExists(key_bindings_file) || !gViewerInput.loadBindingsXML(key_bindings_file)) { // Failed to load custom bindings, try default ones - key_bindings_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "keys.xml"); + key_bindings_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "key_bindings.xml"); if (!gViewerInput.loadBindingsXML(key_bindings_file)) { LL_ERRS("InitInfo") << "Unable to open default key bindings from" << key_bindings_file << LL_ENDL; diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 6ee1bbee1a..61fd13f219 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2926,7 +2926,7 @@ void LLPanelPreferenceControls::onListCommit() { mEditingControl = control; mEditingColumn = cell_ind; - dialog->setParent(this, DEFAULT_KEY_FILTER); + dialog->setParent(this, pControlsTable, DEFAULT_KEY_FILTER); LLFloater* root_floater = gFloaterView->getParentFloater(this); if (root_floater) @@ -2946,6 +2946,14 @@ void LLPanelPreferenceControls::onModeCommit() regenerateControls(); } +void LLPanelPreferenceControls::onRestoreDefaults() +{ + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) + { + mConflictHandler[mEditingMode].resetToDefaults(); + } +} + // todo: copy onSetKeyBind to interface and inherit from interface bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) { @@ -2956,21 +2964,13 @@ bool LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS if ( mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, ignore_mask); + mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, true); } updateTable(); return true; } -void LLPanelPreferenceControls::onRestoreDefaults() -{ - for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT - 1; ++i) - { - mConflictHandler[mEditingMode].resetToDefaults(); - } -} - void LLPanelPreferenceControls::onDefaultKeyBind() { if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 9734ea30a2..bc19564bf6 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -291,7 +291,7 @@ class LLPanelPreferenceControls : public LLPanelPreference, public LLKeyBindResp LOG_CLASS(LLPanelPreferenceControls); public: LLPanelPreferenceControls(); - ~LLPanelPreferenceControls(); + virtual ~LLPanelPreferenceControls(); BOOL postBuild(); @@ -302,10 +302,10 @@ public: void onListCommit(); void onModeCommit(); - bool onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask); void onRestoreDefaults(); - void onDefaultKeyBind(); - void onCancelKeyBind(); + /*virtual*/ bool onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask); + /*virtual*/ void onDefaultKeyBind(); + /*virtual*/ void onCancelKeyBind(); private: void regenerateControls(); diff --git a/indra/newview/llkeyconflict.cpp b/indra/newview/llkeyconflict.cpp index bad4e4a2d8..0b9aaea478 100644 --- a/indra/newview/llkeyconflict.cpp +++ b/indra/newview/llkeyconflict.cpp @@ -243,10 +243,6 @@ std::string LLKeyConflictHandler::getStringFromKeyData(const LLKeyData& keydata) { result = LLKeyboard::stringFromAccelerator(keydata.mMask); } - else if (keydata.mIgnoreMasks) - { - result = "acc+"; - } result += string_from_mouse(keydata.mMouse); @@ -283,7 +279,6 @@ void LLKeyConflictHandler::loadFromSettings(const LLViewerInput::KeyMode& keymod KEY key; MASK mask; EMouseClickType mouse = it->mouse.isProvided() ? mouse_from_string(it->mouse) : CLICK_NONE; - bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; if (it->key.getValue().empty()) { key = KEY_NONE; @@ -297,7 +292,7 @@ void LLKeyConflictHandler::loadFromSettings(const LLViewerInput::KeyMode& keymod // might not know all the commands, so UI will have to know what to fill by its own LLKeyConflict &type_data = (*destination)[it->command]; type_data.mAssignable = true; - type_data.mKeyBind.addKeyData(mouse, key, mask, ignore); + type_data.mKeyBind.addKeyData(mouse, key, mask, true); } } @@ -380,7 +375,7 @@ void LLKeyConflictHandler::loadFromSettings(ESourceMode load_mode) else { // load defaults - std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "keys.xml"); + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "key_bindings.xml"); if (!loadFromSettings(load_mode, filename, &mDefaultsMap)) { LL_WARNS() << "Failed to load default settings, aborting" << LL_ENDL; @@ -388,7 +383,7 @@ void LLKeyConflictHandler::loadFromSettings(ESourceMode load_mode) } // load user's - filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "keys.xml"); + filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "key_bindings.xml"); if (!gDirUtilp->fileExists(filename) || loadFromSettings(load_mode, filename, &mControlsMap)) { // mind placeholders @@ -440,7 +435,7 @@ void LLKeyConflictHandler::saveToSettings() else { // loaded full copy of original file - std::string filename = gDirUtilp->findFile("keys.xml", + std::string filename = gDirUtilp->findFile("key_bindings.xml", gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, ""), gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "")); @@ -494,7 +489,6 @@ void LLKeyConflictHandler::saveToSettings() } binding.mask = string_from_mask(data.mMask); binding.mouse.set(string_from_mouse(data.mMouse), true); //set() because 'optional', for compatibility purposes - binding.ignore.set(data.mIgnoreMasks, true); binding.command = iter->first; mode.bindings.add(binding); } @@ -537,7 +531,7 @@ void LLKeyConflictHandler::saveToSettings() } // write back to user's xml; - std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "keys.xml"); + std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "key_bindings.xml"); LLXMLNodePtr output_node = new LLXMLNode("keys", false); LLXUIParser parser; @@ -708,7 +702,7 @@ void LLKeyConflictHandler::clear() void LLKeyConflictHandler::resetKeyboardBindings() { - std::string filename = gDirUtilp->findFile("keys.xml", + std::string filename = gDirUtilp->findFile("key_bindings.xml", gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, ""), gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "")); diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp index 1a49cbc250..0ca4a83779 100644 --- a/indra/newview/llpanelpresetspulldown.cpp +++ b/indra/newview/llpanelpresetspulldown.cpp @@ -33,6 +33,7 @@ #include "llbutton.h" #include "lltabcontainer.h" +#include "llfloater.h" #include "llfloaterreg.h" #include "llpresetsmanager.h" #include "llsliderctrl.h" diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index 0ad71cb372..320f1f297d 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -34,6 +34,7 @@ #include "llcheckboxctrl.h" #include "lleventtimer.h" #include "llfocusmgr.h" +#include "llkeyconflict.h" class LLSetKeyBindDialog::Updater : public LLEventTimer { @@ -85,6 +86,7 @@ BOOL LLSetKeyBindDialog::postBuild() getChild<LLUICtrl>("Cancel")->setFocus(TRUE); pCheckBox = getChild<LLCheckBoxCtrl>("ignore_masks"); + pDesription = getChild<LLTextBase>("descritption"); gFocusMgr.setKeystrokesOnly(TRUE); @@ -116,14 +118,12 @@ void LLSetKeyBindDialog::draw() LLModalDialog::draw(); } -void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) +void LLSetKeyBindDialog::setParent(LLKeyBindResponderInterface* parent, LLView* frustum_origin, U32 key_mask) { pParent = parent; - setFrustumOrigin(parent); + setFrustumOrigin(frustum_origin); mKeyFilterMask = key_mask; - LLTextBase *text_ctrl = getChild<LLTextBase>("descritption"); - std::string input; if ((key_mask & ALLOW_MOUSE) != 0) { @@ -137,7 +137,8 @@ void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_ma } input += getString("keyboard"); } - text_ctrl->setTextArg("[INPUT]", input); + pDesription->setText(getString("basic_description")); + pDesription->setTextArg("[INPUT]", input); bool can_ignore_masks = (key_mask & CAN_IGNORE_MASKS) != 0; pCheckBox->setVisible(can_ignore_masks); @@ -185,6 +186,13 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) return FALSE; } + if (LLKeyConflictHandler::isReservedByMenu(key, mask)) + { + pDesription->setText(getString("reserved_by_menu")); + pDesription->setTextArg("[KEYSTR]", LLKeyboard::stringFromAccelerator(mask,key)); + return TRUE; + } + setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); closeFloater(); return TRUE; diff --git a/indra/newview/llsetkeybinddialog.h b/indra/newview/llsetkeybinddialog.h index fb3b2a2269..8faa2cc363 100644 --- a/indra/newview/llsetkeybinddialog.h +++ b/indra/newview/llsetkeybinddialog.h @@ -32,6 +32,7 @@ #include "lldrawfrustum.h" class LLCheckBoxCtrl; +class LLTextBase; // Filters for LLSetKeyBindDialog static const U32 ALLOW_MOUSE = 1; @@ -40,18 +41,18 @@ static const U32 ALLOW_KEYS = 4; //keyboard static const U32 ALLOW_MASK_KEYS = 8; static const U32 ALLOW_MASKS = 16; static const U32 CAN_IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed -static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS | CAN_IGNORE_MASKS; +static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS; class LLKeyBindResponderInterface { public: - virtual ~LLKeyBindResponderInterface(); + virtual ~LLKeyBindResponderInterface() {}; - virtual void onCancelKeyBind(); - virtual void onDefaultKeyBind(); + virtual void onCancelKeyBind() = 0; + virtual void onDefaultKeyBind() = 0; // returns true if parent failed to set key due to key being in use - virtual bool onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore); + virtual bool onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore) = 0; }; class LLSetKeyBindDialog : public LLModalDialog, public LLDrawFrustum @@ -64,7 +65,7 @@ public: /*virtual*/ void onClose(bool app_quiting); /*virtual*/ void draw(); - void setParent(LLKeyBindResponderInterface* parent, U32 key_mask = DEFAULT_KEY_FILTER); + void setParent(LLKeyBindResponderInterface* parent, LLView* frustum_origin, U32 key_mask = DEFAULT_KEY_FILTER); BOOL handleKeyHere(KEY key, MASK mask); BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); @@ -77,8 +78,9 @@ public: private: void setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore); - LLKeyBindResponderInterface* pParent; - LLCheckBoxCtrl* pCheckBox; + LLKeyBindResponderInterface *pParent; + LLCheckBoxCtrl *pCheckBox; + LLTextBase *pDesription; U32 mKeyFilterMask; Updater *pUpdater; diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index eff578cf26..95c26cdde2 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1005,7 +1005,7 @@ BOOL LLViewerInput::handleKeyUp(KEY translated_key, MASK translated_mask) return gViewerWindow->handleKeyUp(translated_key, translated_mask); } -BOOL LLViewerInput::bindKey(const S32 mode, const KEY key, const MASK mask, const bool ignore, const std::string& function_name) +BOOL LLViewerInput::bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name) { S32 index; typedef boost::function<bool(EKeystate)> function_t; @@ -1046,57 +1046,30 @@ BOOL LLViewerInput::bindKey(const S32 mode, const KEY key, const MASK mask, cons } // check for duplicate first and overwrite - if (ignore) + S32 size = mKeyBindings[mode].size(); + for (index = 0; index < size; index++) { - for (index = 0; index < mKeyIgnoreMaskCount[mode]; index++) - { - if (key == mKeyIgnoreMask[mode][index].mKey) - break; - } - } - else - { - for (index = 0; index < mKeyBindingCount[mode]; index++) - { - if (key == mKeyBindings[mode][index].mKey && mask == mKeyBindings[mode][index].mMask) - break; - } + if (key == mKeyBindings[mode][index].mKey && mask == mKeyBindings[mode][index].mMask) + break; } - if (index >= MAX_KEY_BINDINGS) - { - LL_ERRS() << "LLKeyboard::bindKey() - too many keys for mode " << mode << LL_ENDL; - return FALSE; - } - if (mode >= MODE_COUNT) { LL_ERRS() << "LLKeyboard::bindKey() - unknown mode passed" << mode << LL_ENDL; return FALSE; } - if (ignore) - { - mKeyIgnoreMask[mode][index].mKey = key; - mKeyIgnoreMask[mode][index].mFunction = function; - - if (index == mKeyIgnoreMaskCount[mode]) - mKeyIgnoreMaskCount[mode]++; - } - else - { - mKeyBindings[mode][index].mKey = key; - mKeyBindings[mode][index].mMask = mask; - mKeyBindings[mode][index].mFunction = function; + LLKeyboardBinding bind; + bind.mKey = key; + bind.mMask = mask; + bind.mFunction = function; - if (index == mKeyBindingCount[mode]) - mKeyBindingCount[mode]++; - } + mKeyBindings[mode].push_back(bind); return TRUE; } -BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const MASK mask, const bool ignore, const std::string& function_name) +BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const MASK mask, const std::string& function_name) { S32 index; typedef boost::function<bool(EKeystate)> function_t; @@ -1115,27 +1088,11 @@ BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const } // check for duplicate first and overwrite - if (ignore) - { - for (index = 0; index < mMouseIgnoreMaskCount[mode]; index++) - { - if (mouse == mMouseIgnoreMask[mode][index].mMouse) - break; - } - } - else - { - for (index = 0; index < mMouseBindingCount[mode]; index++) - { - if (mouse == mMouseBindings[mode][index].mMouse && mask == mMouseBindings[mode][index].mMask) - break; - } - } - - if (index >= MAX_KEY_BINDINGS) + S32 size = mMouseBindings[mode].size(); + for (index = 0; index < size; index++) { - LL_ERRS() << "LLKeyboard::bindKey() - too many keys for mode " << mode << LL_ENDL; - return FALSE; + if (mouse == mMouseBindings[mode][index].mMouse && mask == mMouseBindings[mode][index].mMask) + break; } if (mode >= MODE_COUNT) @@ -1144,23 +1101,12 @@ BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const return FALSE; } - if (ignore) - { - mMouseIgnoreMask[mode][index].mMouse = mouse; - mMouseIgnoreMask[mode][index].mFunction = function; - - if (index == mMouseIgnoreMaskCount[mode]) - mMouseIgnoreMaskCount[mode]++; - } - else - { - mMouseBindings[mode][index].mMouse = mouse; - mMouseBindings[mode][index].mMask = mask; - mMouseBindings[mode][index].mFunction = function; + LLMouseBinding bind; + bind.mMouse = mouse; + bind.mMask = mask; + bind.mFunction = function; - if (index == mMouseBindingCount[mode]) - mMouseBindingCount[mode]++; - } + mMouseBindings[mode].push_back(bind); return TRUE; } @@ -1169,8 +1115,7 @@ LLViewerInput::KeyBinding::KeyBinding() : key("key"), mouse("mouse"), mask("mask"), - command("command"), - ignore("ignore", false) + command("command") {} LLViewerInput::KeyMode::KeyMode() @@ -1189,10 +1134,8 @@ void LLViewerInput::resetBindings() { for (S32 i = 0; i < MODE_COUNT; i++) { - mKeyBindingCount[i] = 0; - mKeyIgnoreMaskCount[i] = 0; - mMouseBindingCount[i] = 0; - mMouseIgnoreMaskCount[i] = 0; + mKeyBindings[i].clear(); + mMouseBindings[i].clear(); } } @@ -1216,6 +1159,34 @@ S32 LLViewerInput::loadBindingsXML(const std::string& filename) return binding_count; } +S32 count_masks(const MASK &mask) +{ + S32 res = 0; + if (mask & MASK_CONTROL) + { + res++; + } + if (mask & MASK_SHIFT) + { + res++; + } + if (mask & MASK_ALT) + { + res++; + } + return res; +} + +bool compare_key_by_mask(LLKeyboardBinding i1, LLKeyboardBinding i2) +{ + return (count_masks(i1.mMask) > count_masks(i2.mMask)); +} + +bool compare_mouse_by_mask(LLMouseBinding i1, LLMouseBinding i2) +{ + return (count_masks(i1.mMask) > count_masks(i2.mMask)); +} + S32 LLViewerInput::loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mode) { S32 binding_count = 0; @@ -1232,9 +1203,8 @@ S32 LLViewerInput::loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mo 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); + bindKey(mode, key, mask, it->command); processed = true; } else @@ -1249,9 +1219,8 @@ S32 LLViewerInput::loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mo 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); + bindMouse(mode, mouse, mask, it->command); processed = true; } else @@ -1264,7 +1233,11 @@ S32 LLViewerInput::loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mo // total binding_count++; } - } + } + + // sort lists by mask (so that Shift+W is executed before W, if both are assigned, but if Shift+W is not assigned W should be executed) + std::sort(mKeyBindings[mode].begin(), mKeyBindings[mode].end(), compare_key_by_mask); + std::sort(mMouseBindings[mode].begin(), mMouseBindings[mode].end(), compare_mouse_by_mask); return binding_count; } @@ -1289,7 +1262,7 @@ EKeyboardMode LLViewerInput::getMode() const } } -bool LLViewerInput::scanKey(const LLKeyboardBinding* binding, +bool LLViewerInput::scanKey(const std::vector<LLKeyboardBinding> &binding, S32 binding_count, KEY key, MASK mask, @@ -1302,7 +1275,7 @@ bool LLViewerInput::scanKey(const LLKeyboardBinding* binding, { if (binding[i].mKey == key) { - if (binding[i].mMask == mask) + if ((binding[i].mMask & mask) == binding[i].mMask) { bool res = false; if (key_down && !repeat) @@ -1350,12 +1323,7 @@ bool LLViewerInput::scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) // don't process key down on repeated keys BOOL repeat = gKeyboard->getKeyRepeated(key); - bool res = scanKey(mKeyBindings[mode], mKeyBindingCount[mode], key, mask, key_down, key_up, key_level, repeat); - if (!res) - { - // Nothing found, try ignore list - res = scanKey(mKeyIgnoreMask[mode], mKeyIgnoreMaskCount[mode], key, MASK_NONE, key_down, key_up, key_level, repeat); - } + 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)) { @@ -1443,11 +1411,11 @@ BOOL LLViewerInput::handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK mask, return handled; } -bool LLViewerInput::scanMouse(const LLMouseBinding *binding, S32 binding_count, EMouseClickType mouse, MASK mask, EMouseState state) const +bool LLViewerInput::scanMouse(const std::vector<LLMouseBinding> &binding, S32 binding_count, EMouseClickType mouse, MASK mask, EMouseState state) const { for (S32 i = 0; i < binding_count; i++) { - if (binding[i].mMouse == mouse && binding[i].mMask == mask) + if (binding[i].mMouse == mouse && (binding[i].mMask & mask) == binding[i].mMask) { bool res = false; switch (state) @@ -1484,11 +1452,7 @@ bool LLViewerInput::scanMouse(EMouseClickType click, EMouseState state) const bool res = false; S32 mode = getMode(); MASK mask = gKeyboard->currentMask(TRUE); - res = scanMouse(mMouseBindings[mode], mMouseBindingCount[mode], click, mask, state); - if (!res) - { - res = scanMouse(mMouseIgnoreMask[mode], mMouseIgnoreMaskCount[mode], click, MASK_NONE, state); - } + 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)) { diff --git a/indra/newview/llviewerinput.h b/indra/newview/llviewerinput.h index d18a61eaf0..b7124a54b2 100644 --- a/indra/newview/llviewerinput.h +++ b/indra/newview/llviewerinput.h @@ -30,7 +30,6 @@ #include "llkeyboard.h" // For EKeystate #include "llinitparam.h" -const S32 MAX_NAMED_FUNCTIONS = 100; const S32 MAX_KEY_BINDINGS = 128; // was 60 class LLNamedFunction @@ -48,7 +47,6 @@ class LLKeyboardBinding public: KEY mKey; MASK mMask; - bool mIgnoreMask; // whether CTRL/ALT/SHIFT should be checked LLKeyFunc mFunction; }; @@ -58,7 +56,6 @@ class LLMouseBinding public: EMouseClickType mMouse; MASK mMask; - bool mIgnoreMask; // whether CTRL/ALT/SHIFT should be checked LLKeyFunc mFunction; }; @@ -86,8 +83,7 @@ public: Mandatory<std::string> key, mask, command; - Optional<std::string> mouse; // Note, not mandatory for the sake of backward campatibility - Optional<bool> ignore; + Optional<std::string> mouse; // Note, not mandatory for the sake of backward campatibility with keys.xml KeyBinding(); }; @@ -131,7 +127,7 @@ public: void scanMouse(); private: - bool scanKey(const LLKeyboardBinding* binding, + bool scanKey(const std::vector<LLKeyboardBinding> &binding, S32 binding_count, KEY key, MASK mask, @@ -149,34 +145,24 @@ private: MOUSE_STATE_SILENT // notified about 'up', do not notify again }; bool scanMouse(EMouseClickType click, EMouseState state) const; - bool scanMouse(const LLMouseBinding *binding, + bool scanMouse(const std::vector<LLMouseBinding> &binding, S32 binding_count, EMouseClickType mouse, MASK mask, EMouseState state) const; S32 loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mode); - BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const bool ignore, const std::string& function_name); - BOOL bindMouse(const S32 mode, const EMouseClickType mouse, const MASK mask, const bool ignore, const std::string& function_name); + BOOL bindKey(const S32 mode, const KEY key, const MASK mask, const std::string& function_name); + BOOL bindMouse(const S32 mode, const EMouseClickType mouse, const MASK mask, const std::string& function_name); void resetBindings(); // Hold all the ugly stuff torn out to make LLKeyboard non-viewer-specific here - // We process specific keys first, then keys that should ignore mask. - // This way with W+ignore defined to 'forward' and with ctrl+W tied to camera, - // pressing undefined Shift+W will do 'forward', yet ctrl+W will do 'camera forward' - // With A defined to 'turn', shift+A defined to strafe, pressing Shift+W+A will do strafe+forward // TODO: at some point it is better to remake this, especially keyaboard part // would be much better to send to functions actual state of the button than // to send what we think function wants based on collection of bools (mKeyRepeated, mKeyLevel, mKeyDown) - S32 mKeyBindingCount[MODE_COUNT]; - S32 mKeyIgnoreMaskCount[MODE_COUNT]; - S32 mMouseBindingCount[MODE_COUNT]; - S32 mMouseIgnoreMaskCount[MODE_COUNT]; - LLKeyboardBinding mKeyBindings[MODE_COUNT][MAX_KEY_BINDINGS]; - LLKeyboardBinding mKeyIgnoreMask[MODE_COUNT][MAX_KEY_BINDINGS]; - LLMouseBinding mMouseBindings[MODE_COUNT][MAX_KEY_BINDINGS]; - LLMouseBinding mMouseIgnoreMask[MODE_COUNT][MAX_KEY_BINDINGS]; + std::vector<LLKeyboardBinding> mKeyBindings[MODE_COUNT]; + std::vector<LLMouseBinding> mMouseBindings[MODE_COUNT]; typedef std::map<U32, U32> key_remap_t; key_remap_t mRemapKeys[MODE_COUNT]; diff --git a/indra/newview/skins/default/xui/en/control_table_contents.xml b/indra/newview/skins/default/xui/en/control_table_contents.xml index 00c2d27124..7d4b9be894 100644 --- a/indra/newview/skins/default/xui/en/control_table_contents.xml +++ b/indra/newview/skins/default/xui/en/control_table_contents.xml @@ -20,7 +20,7 @@ enabled="false"
value="">
<columns
- cell_type="icontext"
+ type="icontext"
column="lst_action"
font="SansSerif"
halign="left"
@@ -195,7 +195,7 @@ <rows
enabled="false">
<columns
- cell_type="icon"
+ type="icon"
color="0 0 0 0.7"
halign="center"
value="menu_separator" />
@@ -204,7 +204,7 @@ enabled="false"
value="">
<columns
- cell_type="icontext"
+ type="icontext"
column="lst_action"
font="SansSerif"
halign="left"
@@ -417,7 +417,7 @@ <rows
enabled="false">
<columns
- cell_type="icon"
+ type="icon"
color="0 0 0 0.7"
halign="center"
value="menu_separator" />
@@ -426,7 +426,7 @@ enabled="false"
value="">
<columns
- cell_type="icontext"
+ type="icontext"
column="lst_action"
font="SansSerif"
halign="left"
@@ -495,7 +495,7 @@ <rows
enabled="false">
<columns
- cell_type="icon"
+ type="icon"
color="0 0 0 0.7"
halign="center"
value="menu_separator" />
@@ -504,7 +504,7 @@ enabled="false"
value="">
<columns
- cell_type="icontext"
+ type="icontext"
column="lst_action"
font="SansSerif"
halign="left"
diff --git a/indra/newview/skins/default/xui/en/floater_select_key.xml b/indra/newview/skins/default/xui/en/floater_select_key.xml index 32f091938e..255de60d00 100644 --- a/indra/newview/skins/default/xui/en/floater_select_key.xml +++ b/indra/newview/skins/default/xui/en/floater_select_key.xml @@ -16,6 +16,15 @@ name="mouse"> Mouse Buttons </floater.string> + <floater.string + name="basic_description"> +Press a key to set your trigger. +Allowed input: [INPUT]. + </floater.string> + <floater.string + name="reserved_by_menu"> +Combination [KEYSTR] is reserved by menu. + </floater.string> <text type="string" halign="center" @@ -35,11 +44,11 @@ Allowed input: [INPUT]. follows="top|left" height="20" initial_value="false" - label="Ignore accelerator keys" + label="Ignore extra accelerator keys" layout="topleft" - left="8" + left="28" name="ignore_masks" - tool_tip="Ignore Shift, Alt and Ctrl keys. Example: This allows to hold W (forward, ignores shift) and Shift+A (slide left) simultaneously and agent will both move forward and slide left." + tool_tip="Ignore extra Shift, Alt and Ctrl keys. Example: This allows to hold W (forward, ignores shift) and Shift+A (slide left) simultaneously and agent will both move forward and slide left." top_pad="8" width="160" /> |