From b12cf6696348520556cf70f96e0562776479fe70 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 27 Sep 2019 15:25:47 +0300 Subject: SL-6109 Small reorganisation --- indra/newview/llviewerinput.cpp | 1463 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 1463 insertions(+) create mode 100644 indra/newview/llviewerinput.cpp (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp new file mode 100644 index 0000000000..fb405fd225 --- /dev/null +++ b/indra/newview/llviewerinput.cpp @@ -0,0 +1,1463 @@ +/** + * @file llviewerinput.cpp + * @brief LLViewerInput class implementation + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llviewerinput.h" + +#include "llappviewer.h" +#include "llfloaterreg.h" +#include "llmath.h" +#include "llagent.h" +#include "llagentcamera.h" +#include "llfloaterimnearbychat.h" +#include "llfocusmgr.h" +#include "llkeybind.h" // LLKeyData +#include "llmorphview.h" +#include "llmoveview.h" +#include "lltoolfocus.h" +#include "lltoolpie.h" +#include "llviewercontrol.h" +#include "llviewerwindow.h" +#include "llvoavatarself.h" +#include "llfloatercamera.h" +#include "llinitparam.h" + +// +// Constants +// + +const F32 FLY_TIME = 0.5f; +const F32 FLY_FRAMES = 4; + +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> +{ + LLSINGLETON_EMPTY_CTOR(LLKeyboardActionRegistry); +}; + +LLViewerInput gViewerInput; + +bool agent_jump( EKeystate s ) +{ + static BOOL first_fly_attempt(TRUE); + if (KEYSTATE_UP == s) + { + first_fly_attempt = TRUE; + return true; + } + F32 time = gKeyboard->getCurKeyElapsedTime(); + S32 frame_count = ll_round(gKeyboard->getCurKeyElapsedFrameCount()); + + if( time < FLY_TIME + || frame_count <= FLY_FRAMES + || gAgent.upGrabbed() + || !gSavedSettings.getBOOL("AutomaticFly")) + { + gAgent.moveUp(1); + } + else + { + gAgent.setFlying(TRUE, first_fly_attempt); + first_fly_attempt = FALSE; + gAgent.moveUp(1); + } + return true; +} + +bool agent_push_down( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgent.moveUp(-1); + return true; +} + +static void agent_check_temporary_run(LLAgent::EDoubleTapRunMode mode) +{ + if (gAgent.mDoubleTapRunMode == mode && + gAgent.getRunning() && + !gAgent.getAlwaysRun()) + { + // Turn off temporary running. + gAgent.clearRunning(); + gAgent.sendWalkRun(gAgent.getRunning()); + } +} + +static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode mode) +{ + if (KEYSTATE_UP == s) + { + // Note: in case shift is already released, slide left/right run + // will be released in agent_turn_left()/agent_turn_right() + agent_check_temporary_run(mode); + } + else if (gSavedSettings.getBOOL("AllowTapTapHoldRun") && + KEYSTATE_DOWN == s && + !gAgent.getRunning()) + { + if (gAgent.mDoubleTapRunMode == mode && + gAgent.mDoubleTapRunTimer.getElapsedTimeF32() < NUDGE_TIME) + { + // Same walk-key was pushed again quickly; this is a + // double-tap so engage temporary running. + gAgent.setRunning(); + gAgent.sendWalkRun(gAgent.getRunning()); + } + + // Pressing any walk-key resets the double-tap timer + gAgent.mDoubleTapRunTimer.reset(); + gAgent.mDoubleTapRunMode = mode; + } +} + +static void agent_push_forwardbackward( 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 = ll_round(gKeyboard->getCurKeyElapsedFrameCount()); + + if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) + { + gAgent.moveAtNudge(direction); + } + else + { + gAgent.moveAt(direction); + } +} + +bool camera_move_forward( EKeystate s ); + +bool agent_push_forward( EKeystate s ) +{ + if(gAgent.isMovementLocked()) return true; + + //in free camera control mode we need to intercept keyboard events for avatar movements + if (LLFloaterCamera::inFreeCameraMode()) + { + camera_move_forward(s); + } + else + { + agent_push_forwardbackward(s, 1, LLAgent::DOUBLETAP_FORWARD); + } + return true; +} + +bool camera_move_backward( EKeystate s ); + +bool agent_push_backward( EKeystate s ) +{ + if(gAgent.isMovementLocked()) return true; + + //in free camera control mode we need to intercept keyboard events for avatar movements + if (LLFloaterCamera::inFreeCameraMode()) + { + camera_move_backward(s); + } + else if (!gAgent.backwardGrabbed() && gAgentAvatarp->isSitting() && gSavedSettings.getBOOL("LeaveMouselook")) + { + gAgentCamera.changeCameraToThirdPerson(); + } + else + { + agent_push_forwardbackward(s, -1, LLAgent::DOUBLETAP_BACKWARD); + } + return true; +} + +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 = ll_round(gKeyboard->getCurKeyElapsedFrameCount()); + + if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) + { + gAgent.moveLeftNudge(direction); + } + else + { + gAgent.moveLeft(direction); + } +} + + +bool agent_slide_left( EKeystate s ) +{ + if(gAgent.isMovementLocked()) return true; + agent_slide_leftright(s, 1, LLAgent::DOUBLETAP_SLIDELEFT); + return true; +} + + +bool agent_slide_right( EKeystate s ) +{ + if(gAgent.isMovementLocked()) return true; + agent_slide_leftright(s, -1, LLAgent::DOUBLETAP_SLIDERIGHT); + return true; +} + +bool camera_spin_around_cw( EKeystate s ); + +bool agent_turn_left(EKeystate s) +{ + //in free camera control mode we need to intercept keyboard events for avatar movements + if (LLFloaterCamera::inFreeCameraMode()) + { + camera_spin_around_cw(s); + return true; + } + + if(gAgent.isMovementLocked()) return false; + + if (LLToolCamera::getInstance()->mouseSteerMode()) + { + agent_slide_left(s); + } + else + { + if (KEYSTATE_UP == s) + { + // Check temporary running. In case user released 'left' key with shift already released. + agent_check_temporary_run(LLAgent::DOUBLETAP_SLIDELEFT); + return true; + } + F32 time = gKeyboard->getCurKeyElapsedTime(); + gAgent.moveYaw( LLFloaterMove::getYawRate( time ) ); + } + return true; +} + +bool camera_spin_around_ccw( EKeystate s ); + +bool agent_turn_right( EKeystate s ) +{ + //in free camera control mode we need to intercept keyboard events for avatar movements + if (LLFloaterCamera::inFreeCameraMode()) + { + camera_spin_around_ccw(s); + return true; + } + + if(gAgent.isMovementLocked()) return false; + + if (LLToolCamera::getInstance()->mouseSteerMode()) + { + agent_slide_right(s); + } + else + { + if (KEYSTATE_UP == s) + { + // Check temporary running. In case user released 'right' key with shift already released. + agent_check_temporary_run(LLAgent::DOUBLETAP_SLIDERIGHT); + return true; + } + F32 time = gKeyboard->getCurKeyElapsedTime(); + gAgent.moveYaw( -LLFloaterMove::getYawRate( time ) ); + } + return true; +} + +bool agent_look_up( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgent.movePitch(-1); + //gAgent.rotate(-2.f * DEG_TO_RAD, gAgent.getFrame().getLeftAxis() ); + return true; +} + + +bool agent_look_down( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgent.movePitch(1); + //gAgent.rotate(2.f * DEG_TO_RAD, gAgent.getFrame().getLeftAxis() ); + return true; +} + +bool agent_toggle_fly( EKeystate s ) +{ + // Only catch the edge + if (KEYSTATE_DOWN == s ) + { + LLAgent::toggleFlying(); + } + return true; +} + +F32 get_orbit_rate() +{ + F32 time = gKeyboard->getCurKeyElapsedTime(); + if( time < NUDGE_TIME ) + { + F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME; + //LL_INFOS() << rate << LL_ENDL; + return rate; + } + else + { + return 1; + } +} + +bool camera_spin_around_ccw( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); + return true; +} + + +bool camera_spin_around_cw( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitRightKey( get_orbit_rate() ); + return true; +} + +bool camera_spin_around_ccw_sitting( EKeystate s ) +{ + if( KEYSTATE_UP == s && gAgent.mDoubleTapRunMode != LLAgent::DOUBLETAP_SLIDERIGHT ) return true; + if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled() || gAgent.getRunning()) + { + //send keystrokes, but do not change camera + agent_turn_right(s); + } + else + { + //change camera but do not send keystrokes + gAgentCamera.unlockView(); + gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); + } + return true; +} + + +bool camera_spin_around_cw_sitting( EKeystate s ) +{ + if( KEYSTATE_UP == s && gAgent.mDoubleTapRunMode != LLAgent::DOUBLETAP_SLIDELEFT ) return true; + if (gAgent.rotateGrabbed() || gAgentCamera.sitCameraEnabled() || gAgent.getRunning()) + { + //send keystrokes, but do not change camera + agent_turn_left(s); + } + else + { + //change camera but do not send keystrokes + gAgentCamera.unlockView(); + gAgentCamera.setOrbitRightKey( get_orbit_rate() ); + } + return true; +} + + +bool camera_spin_over( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitUpKey( get_orbit_rate() ); + return true; +} + + +bool camera_spin_under( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitDownKey( get_orbit_rate() ); + return true; +} + +bool camera_spin_over_sitting( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + if (gAgent.upGrabbed() || gAgentCamera.sitCameraEnabled()) + { + //send keystrokes, but do not change camera + agent_jump(s); + } + else + { + //change camera but do not send keystrokes + gAgentCamera.setOrbitUpKey( get_orbit_rate() ); + } + return true; +} + + +bool camera_spin_under_sitting( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + if (gAgent.downGrabbed() || gAgentCamera.sitCameraEnabled()) + { + //send keystrokes, but do not change camera + agent_push_down(s); + } + else + { + //change camera but do not send keystrokes + gAgentCamera.setOrbitDownKey( get_orbit_rate() ); + } + return true; +} + +bool camera_move_forward( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitInKey( get_orbit_rate() ); + return true; +} + + +bool camera_move_backward( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitOutKey( get_orbit_rate() ); + return true; +} + +bool camera_move_forward_sitting( EKeystate s ) +{ + if( KEYSTATE_UP == s && gAgent.mDoubleTapRunMode != LLAgent::DOUBLETAP_FORWARD ) return true; + if (gAgent.forwardGrabbed() || gAgentCamera.sitCameraEnabled() || (gAgent.getRunning() && !gAgent.getAlwaysRun())) + { + agent_push_forward(s); + } + else + { + gAgentCamera.setOrbitInKey( get_orbit_rate() ); + } + return true; +} + +bool camera_move_backward_sitting( EKeystate s ) +{ + if( KEYSTATE_UP == s && gAgent.mDoubleTapRunMode != LLAgent::DOUBLETAP_BACKWARD ) return true; + + if (gAgent.backwardGrabbed() || gAgentCamera.sitCameraEnabled() || (gAgent.getRunning() && !gAgent.getAlwaysRun())) + { + agent_push_backward(s); + } + else + { + gAgentCamera.setOrbitOutKey( get_orbit_rate() ); + } + return true; +} + +bool camera_pan_up( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setPanUpKey( get_orbit_rate() ); + return true; +} + +bool camera_pan_down( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setPanDownKey( get_orbit_rate() ); + return true; +} + +bool camera_pan_left( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setPanLeftKey( get_orbit_rate() ); + return true; +} + +bool camera_pan_right( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setPanRightKey( get_orbit_rate() ); + return true; +} + +bool camera_pan_in( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setPanInKey( get_orbit_rate() ); + return true; +} + +bool camera_pan_out( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setPanOutKey( get_orbit_rate() ); + return true; +} + +bool camera_move_forward_fast( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitInKey(2.5f); + return true; +} + +bool camera_move_backward_fast( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gAgentCamera.unlockView(); + gAgentCamera.setOrbitOutKey(2.5f); + return true; +} + + +bool edit_avatar_spin_ccw( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gMorphView->setCameraDrivenByKeys( TRUE ); + gAgentCamera.setOrbitLeftKey( get_orbit_rate() ); + //gMorphView->orbitLeft( get_orbit_rate() ); + return true; +} + + +bool edit_avatar_spin_cw( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gMorphView->setCameraDrivenByKeys( TRUE ); + gAgentCamera.setOrbitRightKey( get_orbit_rate() ); + //gMorphView->orbitRight( get_orbit_rate() ); + return true; +} + +bool edit_avatar_spin_over( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gMorphView->setCameraDrivenByKeys( TRUE ); + gAgentCamera.setOrbitUpKey( get_orbit_rate() ); + //gMorphView->orbitUp( get_orbit_rate() ); + return true; +} + + +bool edit_avatar_spin_under( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gMorphView->setCameraDrivenByKeys( TRUE ); + gAgentCamera.setOrbitDownKey( get_orbit_rate() ); + //gMorphView->orbitDown( get_orbit_rate() ); + return true; +} + +bool edit_avatar_move_forward( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gMorphView->setCameraDrivenByKeys( TRUE ); + gAgentCamera.setOrbitInKey( get_orbit_rate() ); + //gMorphView->orbitIn(); + return true; +} + + +bool edit_avatar_move_backward( EKeystate s ) +{ + if( KEYSTATE_UP == s ) return true; + gMorphView->setCameraDrivenByKeys( TRUE ); + gAgentCamera.setOrbitOutKey( get_orbit_rate() ); + //gMorphView->orbitOut(); + return true; +} + +bool stop_moving( EKeystate s ) +{ + if( KEYSTATE_DOWN != s ) return true; + // stop agent + gAgent.setControlFlags(AGENT_CONTROL_STOP); + + // cancel autopilot + gAgent.stopAutoPilot(); + return true; +} + +bool start_chat( EKeystate s ) +{ + if (LLAppViewer::instance()->quitRequested()) + { + return true; // can't talk, gotta go, kthxbye! + } + if (KEYSTATE_DOWN != s) return true; + + // start chat + LLFloaterIMNearbyChat::startChat(NULL); + return true; +} + +bool start_gesture( EKeystate s ) +{ + LLUICtrl* focus_ctrlp = dynamic_cast(gFocusMgr.getKeyboardFocus()); + if (KEYSTATE_UP == s && + ! (focus_ctrlp && focus_ctrlp->acceptsTextInput())) + { + if ((LLFloaterReg::getTypedInstance("nearby_chat"))->getCurrentChat().empty()) + { + // No existing chat in chat editor, insert '/' + LLFloaterIMNearbyChat::startChat("/"); + } + else + { + // Don't overwrite existing text in chat editor + LLFloaterIMNearbyChat::startChat(NULL); + } + } + return true; +} + +bool toggle_run(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return true; + bool run = gAgent.getAlwaysRun(); + if (run) + { + gAgent.clearAlwaysRun(); + gAgent.clearRunning(); + } + else + { + gAgent.setAlwaysRun(); + gAgent.setRunning(); + } + gAgent.sendWalkRun(!run); + return true; +} + +bool toggle_sit(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return true; + if (gAgent.isSitting()) + { + gAgent.standUp(); + } + else + { + gAgent.sitDown(); + } + return true; +} + +bool toggle_pause_media(EKeystate s) // analogue of play/pause button in top bar +{ + if (KEYSTATE_DOWN != s) return true; + bool pause = LLViewerMedia::isAnyMediaPlaying(); + LLViewerMedia::setAllMediaPaused(pause); + return true; +} + +bool toggle_enable_media(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return true; + bool pause = LLViewerMedia::isAnyMediaPlaying() || LLViewerMedia::isAnyMediaShowing(); + LLViewerMedia::setAllMediaEnabled(!pause); + return true; +} + +bool walk_to(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return true; + return LLToolPie::getInstance()->walkToClickedLocation(); +} + +bool teleport_to(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return true; + return LLToolPie::getInstance()->teleportToClickedLocation(); +} + +bool toggle_voice(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return true; + if (!LLAgent::isActionAllowed("speak")) return false; + LLVoiceClient::getInstance()->toggleUserPTTState(); + return true; +} + +bool voice_follow_key(EKeystate s) +{ + if (KEYSTATE_DOWN == s) + { + if (!LLAgent::isActionAllowed("speak")) return false; + LLVoiceClient::getInstance()->setUserPTTState(true); + return true; + } + else if (KEYSTATE_UP == s && LLVoiceClient::getInstance()->getUserPTTState()) + { + LLVoiceClient::getInstance()->setUserPTTState(false); + return true; + } + return false; +} + +bool agen_control_lbutton_handle(EKeystate s) +{ + switch (s) + { + case KEYSTATE_DOWN: + gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN); + break; + case KEYSTATE_UP: + gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP); + break; + default: + break; + } + return true; +} + +#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); +REGISTER_KEYBOARD_ACTION("push_forward", agent_push_forward); +REGISTER_KEYBOARD_ACTION("push_backward", agent_push_backward); +REGISTER_KEYBOARD_ACTION("look_up", agent_look_up); +REGISTER_KEYBOARD_ACTION("look_down", agent_look_down); +REGISTER_KEYBOARD_ACTION("toggle_fly", agent_toggle_fly); +REGISTER_KEYBOARD_ACTION("turn_left", agent_turn_left); +REGISTER_KEYBOARD_ACTION("turn_right", agent_turn_right); +REGISTER_KEYBOARD_ACTION("slide_left", agent_slide_left); +REGISTER_KEYBOARD_ACTION("slide_right", agent_slide_right); +REGISTER_KEYBOARD_ACTION("spin_around_ccw", camera_spin_around_ccw); +REGISTER_KEYBOARD_ACTION("spin_around_cw", camera_spin_around_cw); +REGISTER_KEYBOARD_ACTION("spin_around_ccw_sitting", camera_spin_around_ccw_sitting); +REGISTER_KEYBOARD_ACTION("spin_around_cw_sitting", camera_spin_around_cw_sitting); +REGISTER_KEYBOARD_ACTION("spin_over", camera_spin_over); +REGISTER_KEYBOARD_ACTION("spin_under", camera_spin_under); +REGISTER_KEYBOARD_ACTION("spin_over_sitting", camera_spin_over_sitting); +REGISTER_KEYBOARD_ACTION("spin_under_sitting", camera_spin_under_sitting); +REGISTER_KEYBOARD_ACTION("move_forward", camera_move_forward); +REGISTER_KEYBOARD_ACTION("move_backward", camera_move_backward); +REGISTER_KEYBOARD_ACTION("move_forward_sitting", camera_move_forward_sitting); +REGISTER_KEYBOARD_ACTION("move_backward_sitting", camera_move_backward_sitting); +REGISTER_KEYBOARD_ACTION("pan_up", camera_pan_up); +REGISTER_KEYBOARD_ACTION("pan_down", camera_pan_down); +REGISTER_KEYBOARD_ACTION("pan_left", camera_pan_left); +REGISTER_KEYBOARD_ACTION("pan_right", camera_pan_right); +REGISTER_KEYBOARD_ACTION("pan_in", camera_pan_in); +REGISTER_KEYBOARD_ACTION("pan_out", camera_pan_out); +REGISTER_KEYBOARD_ACTION("move_forward_fast", camera_move_forward_fast); +REGISTER_KEYBOARD_ACTION("move_backward_fast", camera_move_backward_fast); +REGISTER_KEYBOARD_ACTION("edit_avatar_spin_ccw", edit_avatar_spin_ccw); +REGISTER_KEYBOARD_ACTION("edit_avatar_spin_cw", edit_avatar_spin_cw); +REGISTER_KEYBOARD_ACTION("edit_avatar_spin_over", edit_avatar_spin_over); +REGISTER_KEYBOARD_ACTION("edit_avatar_spin_under", edit_avatar_spin_under); +REGISTER_KEYBOARD_ACTION("edit_avatar_move_forward", edit_avatar_move_forward); +REGISTER_KEYBOARD_ACTION("edit_avatar_move_backward", edit_avatar_move_backward); +REGISTER_KEYBOARD_ACTION("stop_moving", stop_moving); +REGISTER_KEYBOARD_ACTION("start_chat", start_chat); +REGISTER_KEYBOARD_ACTION("start_gesture", start_gesture); +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); +REGISTER_KEYBOARD_ACTION("toggle_voice", toggle_voice); +REGISTER_KEYBOARD_ACTION("voice_follow_key", voice_follow_key); +#undef REGISTER_KEYBOARD_ACTION + +LLViewerInput::LLViewerInput() +{ + resetBindings(); + + for (S32 i = 0; i < KEY_COUNT; i++) + { + mKeyHandledByUI[i] = FALSE; + } + for (S32 i = 0; i < CLICK_COUNT; i++) + { + mMouseLevel[i] = MOUSE_STATE_SILENT; + } + // we want the UI to never see these keys so that they can always control the avatar/camera + for(KEY k = KEY_PAD_UP; k <= KEY_PAD_DIVIDE; k++) + { + mKeysSkippedByUI.insert(k); + } +} + +BOOL LLViewerInput::modeFromString(const std::string& string, S32 *mode) const +{ + if (string == "FIRST_PERSON") + { + *mode = MODE_FIRST_PERSON; + return TRUE; + } + else if (string == "THIRD_PERSON") + { + *mode = MODE_THIRD_PERSON; + return TRUE; + } + else if (string == "EDIT") + { + *mode = MODE_EDIT; + return TRUE; + } + else if (string == "EDIT_AVATAR") + { + *mode = MODE_EDIT_AVATAR; + return TRUE; + } + else if (string == "SITTING") + { + *mode = MODE_SITTING; + return TRUE; + } + else + { + *mode = MODE_THIRD_PERSON; + return FALSE; + } +} + +BOOL LLViewerInput::mouseFromString(const std::string& string, EMouseClickType *mode) const +{ + if (string == "LMB") + { + *mode = CLICK_LEFT; + return TRUE; + } + else if (string == "Double LMB") + { + *mode = CLICK_DOUBLELEFT; + return TRUE; + } + else if (string == "MMB") + { + *mode = CLICK_MIDDLE; + return TRUE; + } + else if (string == "MB4") + { + *mode = CLICK_BUTTON4; + return TRUE; + } + else if (string == "MB5") + { + *mode = CLICK_BUTTON5; + return TRUE; + } + else + { + *mode = CLICK_NONE; + return FALSE; + } +} + +BOOL LLViewerInput::handleKey(KEY translated_key, MASK translated_mask, BOOL repeated) +{ + // check for re-map + EKeyboardMode mode = gViewerInput.getMode(); + U32 keyidx = (translated_mask<<16) | translated_key; + key_remap_t::iterator iter = mRemapKeys[mode].find(keyidx); + if (iter != mRemapKeys[mode].end()) + { + translated_key = (iter->second) & 0xff; + translated_mask = (iter->second)>>16; + } + + // No repeats of F-keys + BOOL repeatable_key = (translated_key < KEY_F1 || translated_key > KEY_F12); + if (!repeatable_key && repeated) + { + return FALSE; + } + + LL_DEBUGS("UserInput") << "keydown -" << translated_key << "-" << LL_ENDL; + // skip skipped keys + if(mKeysSkippedByUI.find(translated_key) != mKeysSkippedByUI.end()) + { + mKeyHandledByUI[translated_key] = FALSE; + LL_INFOS("KeyboardHandling") << "Key wasn't handled by UI!" << LL_ENDL; + } + else + { + // it is sufficient to set this value once per call to handlekey + // without clearing it, as it is only used in the subsequent call to scanKey + mKeyHandledByUI[translated_key] = gViewerWindow->handleKey(translated_key, translated_mask); + // mKeyHandledByUI is not what you think ... this indicates whether the UI has handled this keypress yet (any keypress) + // NOT whether some UI shortcut wishes to handle the keypress + + } + return mKeyHandledByUI[translated_key]; +} + +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) +{ + S32 index; + typedef boost::function function_t; + function_t function = NULL; + std::string name; + + // Allow remapping of F2-F12 + if (function_name[0] == 'F') + { + int c1 = function_name[1] - '0'; + int c2 = function_name[2] ? function_name[2] - '0' : -1; + if (c1 >= 0 && c1 <= 9 && c2 >= -1 && c2 <= 9) + { + int idx = c1; + if (c2 >= 0) + idx = idx*10 + c2; + if (idx >=2 && idx <= 12) + { + U32 keyidx = ((mask<<16)|key); + (mRemapKeys[mode])[keyidx] = ((0<<16)|(KEY_F1+(idx-1))); + return TRUE; + } + } + } + + // Not remapped, look for a function + + function_t* result = LLKeyboardActionRegistry::getValue(function_name); + if (result) + { + function = *result; + } + + if (!function) + { + LL_ERRS() << "Can't bind key to function " << function_name << ", no function with this name found" << LL_ENDL; + return FALSE; + } + + // check for duplicate first and overwrite + if (ignore) + { + 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 (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; + + if (index == mKeyBindingCount[mode]) + mKeyBindingCount[mode]++; + } + + return TRUE; +} + +BOOL LLViewerInput::bindMouse(const S32 mode, const EMouseClickType mouse, const MASK mask, const bool ignore, const std::string& function_name) +{ + S32 index; + typedef boost::function function_t; + function_t function = NULL; + + function_t* result = LLKeyboardActionRegistry::getValue(function_name); + if (result) + { + function = *result; + } + + if (!function) + { + LL_ERRS() << "Can't bind key to function " << function_name << ", no function with this name found" << LL_ENDL; + return FALSE; + } + + // 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) + { + 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) + { + 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; + + if (index == mMouseBindingCount[mode]) + mMouseBindingCount[mode]++; + } + + return TRUE; +} + +LLViewerInput::KeyBinding::KeyBinding() +: key("key"), + mouse("mouse"), + mask("mask"), + command("command"), + ignore("ignore", false) +{} + +LLViewerInput::KeyMode::KeyMode() +: bindings("binding") +{} + +LLViewerInput::Keys::Keys() +: first_person("first_person"), + third_person("third_person"), + edit("edit"), + sitting("sitting"), + edit_avatar("edit_avatar") +{} + +void LLViewerInput::resetBindings() +{ + for (S32 i = 0; i < MODE_COUNT; i++) + { + mKeyBindingCount[i] = 0; + mKeyIgnoreMaskCount[i] = 0; + mMouseBindingCount[i] = 0; + mMouseIgnoreMaskCount[i] = 0; + } +} + +S32 LLViewerInput::loadBindingsXML(const std::string& filename) +{ + resetBindings(); + + S32 binding_count = 0; + Keys keys; + LLSimpleXUIParser parser; + + if (parser.readXUI(filename, keys) + && keys.validateBlock()) + { + binding_count += loadBindingMode(keys.first_person, MODE_FIRST_PERSON); + binding_count += loadBindingMode(keys.third_person, MODE_THIRD_PERSON); + binding_count += loadBindingMode(keys.edit, MODE_EDIT); + binding_count += loadBindingMode(keys.sitting, MODE_SITTING); + binding_count += loadBindingMode(keys.edit_avatar, MODE_EDIT_AVATAR); + } + return binding_count; +} + +S32 LLViewerInput::loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mode) +{ + S32 binding_count = 0; + for (LLInitParam::ParamIterator::const_iterator it = keymode.bindings.begin(), + end_it = keymode.bindings.end(); + it != end_it; + ++it) + { + bool processed = false; + if (!it->key.getValue().empty()) + { + KEY key; + LLKeyboard::keyFromString(it->key, &key); + 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; + } + } + if (!processed && it->mouse.isProvided() && !it->mouse.getValue().empty()) + { + EMouseClickType mouse; + mouseFromString(it->mouse.getValue(), &mouse); + 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++; + } + } + + return binding_count; +} + +EKeyboardMode LLViewerInput::getMode() const +{ + if ( gAgentCamera.cameraMouselook() ) + { + return MODE_FIRST_PERSON; + } + else if ( gMorphView && gMorphView->getVisible()) + { + return MODE_EDIT_AVATAR; + } + else if (isAgentAvatarValid() && gAgentAvatarp->isSitting()) + { + return MODE_SITTING; + } + else + { + return MODE_THIRD_PERSON; + } +} + +bool LLViewerInput::scanKey(const LLKeyboardBinding* binding, + S32 binding_count, + KEY key, + MASK mask, + BOOL key_down, + BOOL key_up, + BOOL key_level, + bool repeat) const +{ + for (S32 i = 0; i < binding_count; i++) + { + if (binding[i].mKey == key) + { + if (binding[i].mMask == mask) + { + bool res = false; + if (key_down && !repeat) + { + // ...key went down this frame, call function + res = binding[i].mFunction( KEYSTATE_DOWN ); + return true; + } + else if (key_up) + { + // ...key went down this frame, call function + res = binding[i].mFunction( KEYSTATE_UP ); + } + else if (key_level) + { + // ...key held down from previous frame + // Not windows, just call the function. + res = binding[i].mFunction( KEYSTATE_LEVEL ); + }//if + // Key+Mask combinations are supposed to be unique, so we won't find anything else + return res; + }//if + }//if + }//for + return false; +} + +// Called from scanKeyboard. +bool LLViewerInput::scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) const +{ + if (LLApp::isExiting()) + { + return; + } + + S32 mode = getMode(); + // Consider keyboard scanning as NOT mouse event. JC + MASK mask = gKeyboard->currentMask(FALSE); + + if (mKeyHandledByUI[key]) + { + return false; + } + + // 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); + } + + if (!res && agent_control_lbutton.canHandle(CLICK_NONE, key, mask)) + { + if (key_down && !repeat) + { + res = agen_control_lbutton_handle(KEYSTATE_DOWN); + } + if (key_up) + { + res = agen_control_lbutton_handle(KEYSTATE_UP); + } + } + return res; +} + +BOOL LLViewerInput::handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK mask, EMouseClickType clicktype, BOOL down) +{ + BOOL handled = gViewerWindow->handleAnyMouseClick(window_impl, pos, mask, clicktype, down); + + 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 + // handle !down as if we are handling doubleclick + + 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 + clicktype = CLICK_DOUBLELEFT; + } + + + if (double_click_sp && down) + { + // 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) + { + // UI handled new 'down' so iterupt whatever state we were in. + 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) + { + if (mMouseLevel[clicktype] == MOUSE_STATE_DOWN) + { + // this is repeated hit (mouse does not repeat event until release) + // for now treat rapid clicking like mouse being held + mMouseLevel[clicktype] = MOUSE_STATE_LEVEL; + } + else + { + mMouseLevel[clicktype] = MOUSE_STATE_DOWN; + } + } + else if (mMouseLevel[clicktype] != MOUSE_STATE_SILENT) + { + // Released mouse key + if (mMouseLevel[clicktype] == MOUSE_STATE_DOWN) + { + mMouseLevel[clicktype] = MOUSE_STATE_CLICK; + } + else + { + mMouseLevel[clicktype] = MOUSE_STATE_UP; + } + } + } + + return handled; +} + +bool LLViewerInput::scanMouse(const 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) + { + bool res = false; + switch (state) + { + case MOUSE_STATE_DOWN: + res = binding[i].mFunction(KEYSTATE_DOWN); + break; + case MOUSE_STATE_CLICK: + // Button went down and up in scope of single frame + // might not work best with some functions, + // but some function need specific states specifically + res = binding[i].mFunction(KEYSTATE_DOWN); + res |= binding[i].mFunction(KEYSTATE_UP); + break; + case MOUSE_STATE_LEVEL: + res = binding[i].mFunction(KEYSTATE_LEVEL); + break; + case MOUSE_STATE_UP: + res = binding[i].mFunction(KEYSTATE_UP); + break; + default: + break; + } + // Key+Mask combinations are supposed to be unique, no need to continue + return res; + } + } + return false; +} + +// todo: this recods key, scanMouse() triggers functions with EKeystate +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); + } + // 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)) + { + switch (state) + { + case MOUSE_STATE_DOWN: + agen_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); + res = true; + break; + case MOUSE_STATE_UP: + agen_control_lbutton_handle(KEYSTATE_UP); + res = true; + break; + default: + break; + } + } + return res; +} + +void LLViewerInput::scanMouse() +{ + for (S32 i = 0; i < CLICK_COUNT; i++) + { + if (mMouseLevel[i] != MOUSE_STATE_SILENT) + { + scanMouse((EMouseClickType)i, mMouseLevel[i]); + if (mMouseLevel[i] == MOUSE_STATE_DOWN) + { + // mouse doesn't support 'continued' state, so after handling, switch to LEVEL + mMouseLevel[i] = MOUSE_STATE_LEVEL; + } + else if (mMouseLevel[i] == MOUSE_STATE_UP || mMouseLevel[i] == MOUSE_STATE_CLICK) + { + mMouseLevel[i] = MOUSE_STATE_SILENT; + } + } + } +} -- cgit v1.3 From 0b8021870335ff9b9684fb193c6e0fe2f02b4091 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 27 Sep 2019 19:53:33 +0300 Subject: SL-6109 Cleanup, run commands, and preparation for tooltip support --- indra/newview/llfloaterpreference.cpp | 369 +++++++++++------- indra/newview/llfloaterpreference.h | 4 +- indra/newview/llkeyconflict.cpp | 426 ++++++++------------- indra/newview/llkeyconflict.h | 117 +----- indra/newview/llviewerinput.cpp | 76 ++++ indra/newview/llviewerwindow.cpp | 2 + .../default/xui/en/panel_preferences_controls.xml | 55 +-- 7 files changed, 510 insertions(+), 539 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 4852a9d93e..f94a52a232 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -185,18 +185,53 @@ public: static void onCancel(void* user_data); static void onBlank(void* user_data); static void onDefault(void* user_data); + static void onClickTimeout(void* user_data, MASK mask); + + class Updater; private: + void setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore); LLPanelPreferenceControls* pParent; LLCheckBoxCtrl* pCheckBox; - U32 mKeyMask; + U32 mKeyFilterMask; + Updater *pUpdater; +}; + +class LLSetKeyBindDialog::Updater : public LLEventTimer +{ +public: + + typedef boost::function callback_t; + + Updater(callback_t cb, F32 period, MASK mask) + :LLEventTimer(period), + mMask(mask), + mCallback(cb) + { + mEventTimer.start(); + } + + virtual ~Updater(){} + +protected: + BOOL tick() + { + mCallback(mMask); + // Deletes itseft after execution + return TRUE; + } + +private: + MASK mMask; + callback_t mCallback; }; LLSetKeyBindDialog::LLSetKeyBindDialog(const LLSD& key) : LLModalDialog(key), pParent(NULL), - mKeyMask(DEFAULT_KEY_FILTER) + mKeyFilterMask(DEFAULT_KEY_FILTER), + pUpdater(NULL) { } @@ -227,13 +262,19 @@ void LLSetKeyBindDialog::onClose(bool app_quiting) pParent->onCancelKeyBind(); pParent = NULL; } + if (pUpdater) + { + // Doubleclick timer has't fired, delete it + delete pUpdater; + pUpdater = NULL; + } LLModalDialog::onClose(app_quiting); } void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_mask) { pParent = parent; - mKeyMask = key_mask; + mKeyFilterMask = key_mask; LLTextBase *text_ctrl = getChild("descritption"); @@ -259,24 +300,18 @@ void LLSetKeyBindDialog::setParent(LLPanelPreferenceControls* parent, U32 key_ma BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) { - BOOL result = TRUE; - if ((key == 'Q' && mask == MASK_CONTROL) || key == KEY_ESCAPE) { closeFloater(); - return true; + return TRUE; } if (key == KEY_DELETE) { - if (pParent) - { - pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); - pParent = NULL; - } + setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); closeFloater(); - return true; + return FALSE; } // forbidden keys @@ -284,40 +319,41 @@ BOOL LLSetKeyBindDialog::handleKeyHere(KEY key, MASK mask) || key == KEY_RETURN || key == KEY_BACKSPACE) { - return false; + return FALSE; } - if ((mKeyMask & ALLOW_MASKS) == 0 + if ((mKeyFilterMask & ALLOW_MASKS) == 0 && (key == KEY_CONTROL || key == KEY_SHIFT || key == KEY_ALT)) { // mask by themself are not allowed - return false; + return FALSE; } - else if ((mKeyMask & ALLOW_KEYS) == 0) + else if ((mKeyFilterMask & ALLOW_KEYS) == 0) { // basic keys not allowed - return false; + return FALSE; } - else if ((mKeyMask & ALLOW_MASK_KEYS) == 0 && mask != 0) + else if ((mKeyFilterMask & ALLOW_MASK_KEYS) == 0 && mask != 0) { // masked keys not allowed - return false; + return FALSE; } - if (pParent) - { - pParent->onSetKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); - pParent = NULL; - } - closeFloater(); - return result; + setKeyBind(CLICK_NONE, key, mask, pCheckBox->getValue().asBoolean()); + closeFloater(); + return TRUE; } BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) { BOOL result = FALSE; - - if (clicktype == CLICK_LEFT) + if (!pParent) + { + // we already processed 'down' event, this is 'up', consume + closeFloater(); + result = TRUE; + } + if (!result && clicktype == CLICK_LEFT) { // try handling buttons first if (down) @@ -328,25 +364,38 @@ BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClic { result = LLView::handleMouseUp(x, y, mask); } + if (result) + { + setFocus(TRUE); + gFocusMgr.setKeystrokesOnly(TRUE); + } + // ignore selection related combinations + else if (down && (mask & (MASK_SHIFT | MASK_CONTROL)) == 0) + { + // this can be a double click, wait a bit; + if (!pUpdater) + { + // Note: default doubleclick time is 500ms, but can stretch up to 5s + pUpdater = new Updater(boost::bind(&onClickTimeout, this, _1), 0.7f, mask); + result = TRUE; + } + } } if (!result - && ((mKeyMask & ALLOW_MOUSE) != 0) + && (clicktype != CLICK_LEFT) // subcases were handled above + && ((mKeyFilterMask & ALLOW_MOUSE) != 0) && (clicktype != CLICK_RIGHT || mask != 0) // reassigning menu button is not supported - && ((mKeyMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) + && ((mKeyFilterMask & ALLOW_MASK_MOUSE) != 0 || mask == 0)) // reserved for selection { - if (pParent) + setKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); + result = TRUE; + if (!down) { - pParent->onSetKeyBind(clicktype, KEY_NONE, mask, pCheckBox->getValue().asBoolean()); - pParent = NULL; + // wait for 'up' event before closing + // alternative: set pUpdater + closeFloater(); } - result = TRUE; - closeFloater(); - } - - if (!result) - { - result = LLMouseHandler::handleAnyMouseClick(x, y, mask, clicktype, down); } return result; @@ -356,7 +405,7 @@ BOOL LLSetKeyBindDialog::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClic void LLSetKeyBindDialog::onCancel(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - self->closeFloater(); + self->closeFloater(); } //static @@ -364,11 +413,7 @@ void LLSetKeyBindDialog::onBlank(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; // tmp needs 'no key' button - if (self->pParent) - { - self->pParent->onSetKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); - self->pParent = NULL; - } + self->setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); self->closeFloater(); } @@ -376,7 +421,6 @@ void LLSetKeyBindDialog::onBlank(void* user_data) void LLSetKeyBindDialog::onDefault(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - // tmp needs 'no key' button if (self->pParent) { self->pParent->onDefaultKeyBind(); @@ -385,6 +429,27 @@ void LLSetKeyBindDialog::onDefault(void* user_data) self->closeFloater(); } +//static +void LLSetKeyBindDialog::onClickTimeout(void* user_data, MASK mask) +{ + LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; + + // timer will delete itself after timeout + self->pUpdater = NULL; + + self->setKeyBind(CLICK_LEFT, KEY_NONE, mask, self->pCheckBox->getValue().asBoolean()); + self->closeFloater(); +} + +void LLSetKeyBindDialog::setKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore) +{ + if (pParent) + { + pParent->onSetKeyBind(click, key, mask, ignore); + pParent = NULL; + } +} + // global functions @@ -2921,9 +2986,72 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() //------------------------LLPanelPreferenceControls-------------------------------- static LLPanelInjector t_pref_contrls("panel_preference_controls"); +//name of control and name of icon if it is a group, likely 'TEMP' until xml gets properly populated +typedef std::vector > controls_to_icon_t; +static const controls_to_icon_t commands_and_headers = +{ + //{ "control_view_actions", "Search_Icon" }, + //{ "control_interactions", "Command_Gestures_Icon" }, + { "control_movements", "Move_Walk_Off" }, + { "walk_to", "" }, + { "teleport_to", "" }, + { "push_forward", "" }, + { "push_backward", "" }, + { "turn_left", "" }, + { "turn_right", "" }, + { "slide_left", "" }, + { "slide_right", "" }, + { "jump", "" }, + { "push_down", "" }, + { "run_forward", "" }, + { "run_backward", "" }, + { "run_left", "" }, + { "run_right", "" }, + { "toggle_run", "" }, + { "toggle_fly", "" }, + { "toggle_sit", "" }, + { "stop_moving", "" }, + { "control_camera", "Cam_FreeCam_Off" }, + { "look_up", "" }, + { "look_down", "" }, + { "move_forward", "" }, + { "move_backward", "" }, + { "move_forward_fast", "" }, + { "move_backward_fast", "" }, + { "move_forward_sitting", "" }, + { "move_backward_sitting", "" }, + { "spin_over", "" }, + { "spin_under", "" }, + { "spin_over_sitting", "" }, + { "spin_under_sitting", "" }, + { "pan_up", "" }, + { "pan_down", "" }, + { "pan_left", "" }, + { "pan_right", "" }, + { "pan_in", "" }, + { "pan_out", "" }, + { "spin_around_ccw", "" }, + { "spin_around_cw", "" }, + { "spin_around_ccw_sitting", "" }, + { "spin_around_cw_sitting", "" }, + { "control_edit_title", "Tool_Dozer" }, + { "edit_avatar_spin_ccw", "" }, + { "edit_avatar_spin_cw", "" }, + { "edit_avatar_spin_over", "" }, + { "edit_avatar_spin_under", "" }, + { "edit_avatar_move_forward", "" }, + { "edit_avatar_move_backward", "" }, + { "control_mediacontent", "Audio_Press" }, + { "toggle_pause_media", "" }, + { "toggle_enable_media", "" }, + { "voice_follow_key", "" }, + { "toggle_voice", "" }, + { "start_chat", "" }, + { "start_gesture", "" }, +}; + LLPanelPreferenceControls::LLPanelPreferenceControls() :LLPanelPreference(), - mEditingIndex(-1), mEditingColumn(-1), mEditingMode(0), mShowKeyDialog(false), @@ -2962,8 +3090,8 @@ BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) if (mShowKeyDialog) { mShowKeyDialog = false; - if (mEditingIndex > 0 - && mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)mEditingIndex)) + if (!mEditingControl.empty() + && mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { LLScrollListItem* item = pControlsTable->getFirstSelected(); // don't use pControlsTable->hitItem(x, y) dur to drift; if (item) @@ -2991,10 +3119,10 @@ BOOL LLPanelPreferenceControls::handleHover(S32 x, S32 y, MASK mask) return LLPanelPreference::handleHover(x, y, mask); } -void LLPanelPreferenceControls::addGroupRow(const std::string &icon, S32 index) +void LLPanelPreferenceControls::addGroupRow(const std::string &control_name, const std::string &icon) { LLScrollListItem::Params item_params; - item_params.value = LLSD::Integer(-1); + item_params.value = ""; LLScrollListCell::Params icon_cell_params; icon_cell_params.font = LLFontGL::getFontSansSerif(); @@ -3006,7 +3134,6 @@ void LLPanelPreferenceControls::addGroupRow(const std::string &icon, S32 index) cell_params.font = LLFontGL::getFontSansSerif(); cell_params.font_halign = LLFontGL::LEFT; - std::string control_name = LLKeyConflictHandler::getControlName((LLKeyConflictHandler::EControlTypes)index); std::string label; if (hasString(control_name)) { @@ -3059,76 +3186,48 @@ void LLPanelPreferenceControls::populateControlTable() cell_params.column = ""; cell_params.value = label; - S32 start = mEditingMode == LLKeyConflictHandler::MODE_GENERAL ? LLKeyConflictHandler::CONTROL_VIEW_ACTIONS : LLKeyConflictHandler::CONTROL_MOVEMENTS; - S32 end = mEditingMode == LLKeyConflictHandler::MODE_GENERAL ? LLKeyConflictHandler::CONTROL_NUM_INDICES : LLKeyConflictHandler::CONTROL_RESERVED; - for (S32 i = start; i < end; i++) + controls_to_icon_t::const_iterator iter = commands_and_headers.begin(); + controls_to_icon_t::const_iterator end = commands_and_headers.end(); + for (; iter != end; ++iter) { - LLKeyConflictHandler::EControlTypes type = (LLKeyConflictHandler::EControlTypes)i; - switch (type) + if (iter->second.empty()) { - case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: - addSeparator(); - addGroupRow("Search_Icon", i); - break; - case LLKeyConflictHandler::CONTROL_INTERACTIONS: - addSeparator(); - addGroupRow("Command_Gestures_Icon", i); - break; - case LLKeyConflictHandler::CONTROL_MOVEMENTS: - addSeparator(); - addGroupRow("Move_Walk_Off", i); - break; - case LLKeyConflictHandler::CONTROL_MEDIACONTENT: - addSeparator(); - addGroupRow("Audio_Press", i); - break; - case LLKeyConflictHandler::CONTROL_CAMERA: - addSeparator(); - addGroupRow("Cam_FreeCam_Off", i); - break; - case LLKeyConflictHandler::CONTROL_EDIT_TITLE: - addSeparator(); - addGroupRow("Tool_Dozer", i); - break; - case LLKeyConflictHandler::CONTROL_RESERVED: - addSeparator(); - addGroupRow("Info_Small", i); - break; - default: + // general control + LLScrollListItem::Params item_params; + item_params.value = LLSD(iter->first); + + cell_params.column = "lst_action"; + bool enabled = mConflictHandler[mEditingMode].canAssignControl(iter->first); + if (hasString(iter->first)) { - //default insert - LLScrollListItem::Params item_params; - item_params.value = LLSD::Integer(i); - - cell_params.column = "lst_action"; - bool enabled = mConflictHandler[mEditingMode].canAssignControl(type); - control_name = LLKeyConflictHandler::getControlName(type); - if (hasString(control_name)) - { - label = getString(control_name); - } - else - { - label = control_name; - } - cell_params.value = label; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl1"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 0); - cell_params.enabled = enabled; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl2"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 1); - cell_params.enabled = enabled; - item_params.columns.add(cell_params); - cell_params.column = "lst_ctrl3"; - cell_params.value = mConflictHandler[mEditingMode].getControlString(type, 2); - cell_params.enabled = enabled; - item_params.columns.add(cell_params); - - pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); - break; + label = getString(iter->first); } + else + { + label = iter->first; + } + cell_params.value = label; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl1"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 0); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl2"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 1); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + cell_params.column = "lst_ctrl3"; + cell_params.value = mConflictHandler[mEditingMode].getControlString(iter->first, 2); + cell_params.enabled = enabled; + item_params.columns.add(cell_params); + + pControlsTable->addRow(item_params, EAddPosition::ADD_BOTTOM); + } + else + { + // header + addSeparator(); + addGroupRow(iter->first, iter->second); } } } @@ -3144,13 +3243,13 @@ void LLPanelPreferenceControls::addSeparator() void LLPanelPreferenceControls::updateTable() { + mEditingControl.clear(); std::vector list = pControlsTable->getAllData(); for (S32 i = 0; i < list.size(); ++i) { - S32 value = list[i]->getValue().asInteger(); - if (value > 0) + std::string control = list[i]->getValue(); + if (!control.empty()) { - LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)value; LLScrollListCell* cell = list[i]->getColumn(1); cell->setValue(mConflictHandler[mEditingMode].getControlString(control, 0)); cell = list[i]->getColumn(2); @@ -3207,6 +3306,7 @@ void LLPanelPreferenceControls::saveSettings() if (mConflictHandler[i].hasUnsavedChanges()) { mConflictHandler[i].saveToSettings(); + mConflictHandler[i].clear(); } } @@ -3229,20 +3329,21 @@ void LLPanelPreferenceControls::resetDirtyChilds() void LLPanelPreferenceControls::onListCommit() { + mShowKeyDialog = false; LLScrollListItem* item = pControlsTable->getFirstSelected(); if (item == NULL) { return; } - S32 control = item->getValue().asInteger(); + std::string control = item->getValue(); - if (control <= 0) + if (control.empty()) { return; } - if (!mConflictHandler[mEditingMode].canAssignControl((LLKeyConflictHandler::EControlTypes)control)) + if (!mConflictHandler[mEditingMode].canAssignControl(control)) { return; } @@ -3251,7 +3352,7 @@ void LLPanelPreferenceControls::onListCommit() // fresh mouse coordinates are not yet accessible during onCommit() and there are other issues, // so we cheat: remember item user clicked at, trigger 'key dialog' on hover that comes next, // use coordinates from hover to calculate cell - mEditingIndex = control; + mEditingControl = control; mShowKeyDialog = true; if (mHighlightedCell) @@ -3269,18 +3370,16 @@ void LLPanelPreferenceControls::onModeCommit() // todo: copy onSetKeyBind to interface and inherit from interface void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MASK mask, bool ignore_mask) { - LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; - - if (!mConflictHandler[mEditingMode].canAssignControl(control)) + if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { return; } pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingIndex); + pControlsTable->selectByValue(mEditingControl); if ( mEditingColumn > 0) { - mConflictHandler[mEditingMode].registerControl(control, mEditingColumn - 1, click, key, mask, ignore_mask); + mConflictHandler[mEditingMode].registerControl(mEditingControl, mEditingColumn - 1, click, key, mask, ignore_mask); } updateTable(); @@ -3296,19 +3395,17 @@ void LLPanelPreferenceControls::onRestoreDefaults() void LLPanelPreferenceControls::onDefaultKeyBind() { - LLKeyConflictHandler::EControlTypes control = (LLKeyConflictHandler::EControlTypes)mEditingIndex; - - if (!mConflictHandler[mEditingMode].canAssignControl(control)) + if (!mConflictHandler[mEditingMode].canAssignControl(mEditingControl)) { return; } pControlsTable->deselectAllItems(); - pControlsTable->selectByValue(mEditingIndex); + pControlsTable->selectByValue(mEditingControl); if (mEditingColumn > 0) { - mConflictHandler[mEditingMode].resetToDefault(control, mEditingColumn - 1); + mConflictHandler[mEditingMode].resetToDefault(mEditingControl, mEditingColumn - 1); } updateTable(); } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 9178927e74..e07ead7e18 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -318,7 +318,7 @@ public: void onCancelKeyBind(); private: - void addGroupRow(const std::string &icon, S32 index); + void addGroupRow(const std::string &control_name, const std::string &icon); void regenerateControls(); void populateControlTable(); void addSeparator(); @@ -328,7 +328,7 @@ private: LLComboBox *pKeyModeBox; LLScrollListCell *mHighlightedCell; LLKeyConflictHandler mConflictHandler[LLKeyConflictHandler::MODE_COUNT]; - S32 mEditingIndex; + std::string mEditingControl; S32 mEditingColumn; S32 mEditingMode; bool mShowKeyDialog; diff --git a/indra/newview/llkeyconflict.cpp b/indra/newview/llkeyconflict.cpp index e81d121e3b..c74eea6e47 100644 --- a/indra/newview/llkeyconflict.cpp +++ b/indra/newview/llkeyconflict.cpp @@ -41,135 +41,7 @@ #include "llxuiparser.h" //#include "llstring.h" -static const std::string typetostring[LLKeyConflictHandler::CONTROL_NUM_INDICES] = { - "control_view_actions", - "control_about", - "control_orbit", - "control_pan", - "control_world_map", - "control_zoom", - "control_interactions", - "control_build", - //"control_drag", - "control_edit", - //"control_menu", - "control_open", - "control_touch", - "control_wear", - "control_movements", - "walk_to", - "teleport_to", - "push_forward", - "push_backward", - "turn_left", - "turn_right", - "slide_left", - "slide_right", - "jump", - "push_down", - //"control_run", - "toggle_run", - "toggle_fly", - "toggle_sit", - "stop_moving", - "control_camera", - "look_up", - "look_down", - "move_forward", - "move_backward", - "move_forward_fast", - "move_backward_fast", - "move_forward_sitting", - "move_backward_sitting", - "spin_over", - "spin_under", - "spin_over_sitting", - "spin_under_sitting", - "pan_up", - "pan_down", - "pan_left", - "pan_right", - "pan_in", - "pan_out", - "spin_around_ccw", - "spin_around_cw", - "spin_around_ccw_sitting", - "spin_around_cw_sitting", - "control_edit_title", - "edit_avatar_spin_ccw", - "edit_avatar_spin_cw", - "edit_avatar_spin_over", - "edit_avatar_spin_under", - "edit_avatar_move_forward", - "edit_avatar_move_backward", - "control_mediacontent", - "toggle_pause_media", - "toggle_enable_media", - "voice_follow_key", - "toggle_voice", - "start_chat", - "start_gesture", - "control_reserved", - "control_delete", - "control_menu", - "control_reserved_select", - "control_shift_select", - "control_cntrl_select" -}; - -// note, a solution is needed that will keep this up to date with llviewerinput -typedef std::map control_enum_t; -static const control_enum_t command_to_key = -{ - { "jump", LLKeyConflictHandler::CONTROL_JUMP }, - { "push_down", LLKeyConflictHandler::CONTROL_DOWN }, - { "push_forward", LLKeyConflictHandler::CONTROL_FORWARD }, - { "push_backward", LLKeyConflictHandler::CONTROL_BACKWARD }, - { "look_up", LLKeyConflictHandler::CONTROL_LOOK_UP }, - { "look_down", LLKeyConflictHandler::CONTROL_LOOK_DOWN }, - { "toggle_fly", LLKeyConflictHandler::CONTROL_TOGGLE_FLY }, - { "turn_left", LLKeyConflictHandler::CONTROL_LEFT }, - { "turn_right", LLKeyConflictHandler::CONTROL_RIGHT }, - { "slide_left", LLKeyConflictHandler::CONTROL_LSTRAFE }, - { "slide_right", LLKeyConflictHandler::CONTROL_RSTRAFE }, - { "spin_around_ccw", LLKeyConflictHandler::CONTROL_CAMERA_SPIN_CCW }, // todo, no idea what these spins are - { "spin_around_cw", LLKeyConflictHandler::CONTROL_CAMERA_SPIN_CW }, - { "spin_around_ccw_sitting", LLKeyConflictHandler::CONTROL_CAMERA_SPIN_CCW_SITTING }, - { "spin_around_cw_sitting", LLKeyConflictHandler::CONTROL_CAMERA_SPIN_CCW_SITTING }, - { "spin_over", LLKeyConflictHandler::CONTROL_CAMERA_SOVER }, - { "spin_under", LLKeyConflictHandler::CONTROL_CAMERA_SUNDER }, - { "spin_over_sitting", LLKeyConflictHandler::CONTROL_CAMERA_SOVER_SITTING }, - { "spin_under_sitting", LLKeyConflictHandler::CONTROL_CAMERA_SUNDER_SITTING }, - { "move_forward", LLKeyConflictHandler::CONTROL_CAMERA_FORWARD }, - { "move_backward", LLKeyConflictHandler::CONTROL_CAMERA_BACKWARD }, - { "move_forward_sitting", LLKeyConflictHandler::CONTROL_CAMERA_FSITTING }, - { "move_backward_sitting", LLKeyConflictHandler::CONTROL_CAMERA_BSITTING }, - { "pan_up", LLKeyConflictHandler::CONTROL_CAMERA_PANUP }, - { "pan_down", LLKeyConflictHandler::CONTROL_CAMERA_PANDOWN }, - { "pan_left", LLKeyConflictHandler::CONTROL_CAMERA_PANLEFT }, - { "pan_right", LLKeyConflictHandler::CONTROL_CAMERA_PANRIGHT }, - { "pan_in", LLKeyConflictHandler::CONTROL_CAMERA_PANIN }, - { "pan_out", LLKeyConflictHandler::CONTROL_CAMERA_PANOUT }, - { "move_forward_fast", LLKeyConflictHandler::CONTROL_CAMERA_FFORWARD }, - { "move_backward_fast", LLKeyConflictHandler::CONTROL_CAMERA_FBACKWARD }, - { "edit_avatar_spin_ccw", LLKeyConflictHandler::CONTROL_EDIT_AV_SPIN_CCW }, - { "edit_avatar_spin_cw", LLKeyConflictHandler::CONTROL_EDIT_AV_SPIN_CW }, - { "edit_avatar_spin_over", LLKeyConflictHandler::CONTROL_EDIT_AV_SPIN_OVER }, - { "edit_avatar_spin_under", LLKeyConflictHandler::CONTROL_EDIT_AV_SPIN_UNDER }, - { "edit_avatar_move_forward", LLKeyConflictHandler::CONTROL_EDIT_AV_MV_FORWARD }, - { "edit_avatar_move_backward", LLKeyConflictHandler::CONTROL_EDIT_AV_MV_BACKWARD }, - { "stop_moving", LLKeyConflictHandler::CONTROL_STOP }, - { "start_chat", LLKeyConflictHandler::CONTROL_START_CHAT }, - { "start_gesture", LLKeyConflictHandler::CONTROL_START_GESTURE }, - { "toggle_run", LLKeyConflictHandler::CONTROL_TOGGLE_RUN }, - { "toggle_sit", LLKeyConflictHandler::CONTROL_SIT }, - { "toggle_parcel_media", LLKeyConflictHandler::CONTROL_PAUSE_MEDIA }, - { "toggle_enable_media", LLKeyConflictHandler::CONTROL_ENABLE_MEDIA }, - { "walk_to", LLKeyConflictHandler::CONTROL_MOVETO }, - { "teleport_to", LLKeyConflictHandler::CONTROL_TELEPORTTO }, - { "toggle_voice", LLKeyConflictHandler::CONTROL_TOGGLE_VOICE }, - { "voice_follow_key", LLKeyConflictHandler::CONTROL_VOICE }, -}; +static const std::string saved_settings_key_controls[] = { "placeholder" }; // LLKeyboard::stringFromMask is meant for UI and is OS dependent, @@ -267,29 +139,29 @@ LLKeyConflictHandler::LLKeyConflictHandler(ESourceMode mode) loadFromSettings(mode); } -bool LLKeyConflictHandler::canHandleControl(LLKeyConflictHandler::EControlTypes control_type, EMouseClickType mouse_ind, KEY key, MASK mask) +bool LLKeyConflictHandler::canHandleControl(const std::string &control_name, EMouseClickType mouse_ind, KEY key, MASK mask) { - return mControlsMap[control_type].canHandle(mouse_ind, key, mask); + return mControlsMap[control_name].canHandle(mouse_ind, key, mask); } -bool LLKeyConflictHandler::canHandleKey(EControlTypes control_type, KEY key, MASK mask) +bool LLKeyConflictHandler::canHandleKey(const std::string &control_name, KEY key, MASK mask) { - return canHandleControl(control_type, CLICK_NONE, key, mask); + return canHandleControl(control_name, CLICK_NONE, key, mask); } -bool LLKeyConflictHandler::canHandleMouse(LLKeyConflictHandler::EControlTypes control_type, EMouseClickType mouse_ind, MASK mask) +bool LLKeyConflictHandler::canHandleMouse(const std::string &control_name, EMouseClickType mouse_ind, MASK mask) { - return canHandleControl(control_type, mouse_ind, KEY_NONE, mask); + return canHandleControl(control_name, mouse_ind, KEY_NONE, mask); } -bool LLKeyConflictHandler::canHandleMouse(EControlTypes control_type, S32 mouse_ind, MASK mask) +bool LLKeyConflictHandler::canHandleMouse(const std::string &control_name, S32 mouse_ind, MASK mask) { - return canHandleControl(control_type, (EMouseClickType)mouse_ind, KEY_NONE, mask); + return canHandleControl(control_name, (EMouseClickType)mouse_ind, KEY_NONE, mask); } -bool LLKeyConflictHandler::canAssignControl(EControlTypes control_type) +bool LLKeyConflictHandler::canAssignControl(const std::string &control_name) { - std::map::iterator iter = mControlsMap.find(control_type); + control_map_t::iterator iter = mControlsMap.find(control_name); if (iter != mControlsMap.end()) { return iter->second.mAssignable; @@ -297,9 +169,13 @@ bool LLKeyConflictHandler::canAssignControl(EControlTypes control_type) return false; } -bool LLKeyConflictHandler::registerControl(EControlTypes control_type, U32 index, EMouseClickType mouse, KEY key, MASK mask, bool ignore_mask) +bool LLKeyConflictHandler::registerControl(const std::string &control_name, U32 index, EMouseClickType mouse, KEY key, MASK mask, bool ignore_mask) { - LLKeyConflict &type_data = mControlsMap[control_type]; + if (control_name.empty()) + { + return false; + } + LLKeyConflict &type_data = mControlsMap[control_name]; if (!type_data.mAssignable) { LL_ERRS() << "Error in code, user or system should not be able to change certain controls" << LL_ENDL; @@ -319,9 +195,13 @@ bool LLKeyConflictHandler::registerControl(EControlTypes control_type, U32 index return false; } -LLKeyData LLKeyConflictHandler::getControl(EControlTypes control_type, U32 index) +LLKeyData LLKeyConflictHandler::getControl(const std::string &control_name, U32 index) { - return mControlsMap[control_type].getKeyData(index); + if (control_name.empty()) + { + return LLKeyData(); + } + return mControlsMap[control_name].getKeyData(index); } // static @@ -341,24 +221,37 @@ std::string LLKeyConflictHandler::getStringFromKeyData(const LLKeyData& keydata) { result = LLKeyboard::stringFromAccelerator(keydata.mMask); } + else if (keydata.mIgnoreMasks) + { + result = "acc+"; + } result += string_from_mouse(keydata.mMouse); return result; } -// static -std::string LLKeyConflictHandler::getControlName(EControlTypes control_type) +std::string LLKeyConflictHandler::getControlString(const std::string &control_name, U32 index) { - return typetostring[control_type]; + if (control_name.empty()) + { + return ""; + } + return getStringFromKeyData(mControlsMap[control_name].getKeyData(index)); } -std::string LLKeyConflictHandler::getControlString(EControlTypes control_type, U32 index) +void LLKeyConflictHandler::loadFromControlSettings(const std::string &name) { - return getStringFromKeyData(mControlsMap[control_type].getKeyData(index)); + LLControlVariablePtr var = gSavedSettings.getControl(name); + if (var) + { + LLKeyBind bind(var->getValue()); + LLKeyConflict key(bind, true, 0); + mControlsMap[name] = key; + } } -void LLKeyConflictHandler::loadFromSettings(const LLViewerInput::KeyMode& keymode, control_map_t *destination) +void LLKeyConflictHandler::loadFromSettings(const LLViewerInput::KeyMode& keymode, control_map_t *destination) { for (LLInitParam::ParamIterator::const_iterator it = keymode.bindings.begin(), end_it = keymode.bindings.end(); @@ -378,28 +271,23 @@ void LLKeyConflictHandler::loadFromSettings(const LLViewerInput::KeyMode& keymo LLKeyboard::keyFromString(it->key, &key); } LLKeyboard::maskFromString(it->mask, &mask); - std::string command_name = it->command; - // it->command - // It might be better to have map, but at the moment enum is easier to iterate through. - // Besides keys.xml might not contain all commands - control_enum_t::const_iterator iter = command_to_key.find(command_name); - if (iter != command_to_key.end()) - { - LLKeyConflict &type_data = (*destination)[iter->second]; - type_data.mAssignable = true; - // Don't care about conflict level, all movement and view commands already account for it - type_data.mKeyBind.addKeyData(mouse, key, mask, ignore); - } + // Note: it->command is also the name of UI element, howhever xml we are loading from + // 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); } } -void LLKeyConflictHandler::loadFromSettings(const ESourceMode &load_mode, const std::string &filename, control_map_t *destination) +bool LLKeyConflictHandler::loadFromSettings(const ESourceMode &load_mode, const std::string &filename, control_map_t *destination) { if (filename.empty()) { - return; + return false; } + bool res = false; + LLViewerInput::Keys keys; LLSimpleXUIParser parser; @@ -412,39 +300,45 @@ void LLKeyConflictHandler::loadFromSettings(const ESourceMode &load_mode, const if (keys.first_person.isProvided()) { loadFromSettings(keys.first_person, destination); + res = true; } break; case MODE_THIRD_PERSON: if (keys.third_person.isProvided()) { loadFromSettings(keys.third_person, destination); + res = true; } break; case MODE_EDIT: if (keys.edit.isProvided()) { loadFromSettings(keys.edit, destination); + res = true; } break; case MODE_EDIT_AVATAR: if (keys.edit_avatar.isProvided()) { loadFromSettings(keys.edit_avatar, destination); + res = true; } break; case MODE_SITTING: if (keys.sitting.isProvided()) { loadFromSettings(keys.sitting, destination); + res = true; } break; default: break; } } + return res; } -void LLKeyConflictHandler::loadFromSettings(ESourceMode load_mode) +void LLKeyConflictHandler::loadFromSettings(ESourceMode load_mode) { mControlsMap.clear(); mDefaultsMap.clear(); @@ -454,48 +348,26 @@ void LLKeyConflictHandler::loadFromSettings(ESourceMode load_mode) if (load_mode == MODE_GENERAL) { - for (U32 i = 0; i < CONTROL_NUM_INDICES; i++) + // load settings clss knows about, but it also possible to load settings by name separately + const S32 size = std::extent::value; + for (U32 i = 0; i < size; i++) { - EControlTypes type = (EControlTypes)i; - switch (type) - { - case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: - case LLKeyConflictHandler::CONTROL_INTERACTIONS: - case LLKeyConflictHandler::CONTROL_MOVEMENTS: - case LLKeyConflictHandler::CONTROL_MEDIACONTENT: - case LLKeyConflictHandler::CONTROL_CAMERA: - case LLKeyConflictHandler::CONTROL_EDIT_TITLE: - case LLKeyConflictHandler::CONTROL_RESERVED: - // ignore 'headers', they are for representation and organization purposes - break; - default: - { - std::string name = getControlName(type); - LLControlVariablePtr var = gSavedSettings.getControl(name); - if (var) - { - LLKeyBind bind(var->getValue()); - LLKeyConflict key(bind, true, 0); - mControlsMap[type] = key; - } - break; - } - } + loadFromControlSettings(saved_settings_key_controls[i]); } } else { // load defaults std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "keys.xml"); - loadFromSettings(load_mode, filename, &mDefaultsMap); + if (!loadFromSettings(load_mode, filename, &mDefaultsMap)) + { + LL_WARNS() << "Failed to load default settings, aborting" << LL_ENDL; + return; + } // load user's filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "keys.xml"); - if (gDirUtilp->fileExists(filename)) - { - loadFromSettings(load_mode, filename, &mControlsMap); - } - else + if (!gDirUtilp->fileExists(filename) || loadFromSettings(load_mode, filename, &mControlsMap)) { // mind placeholders mControlsMap.insert(mDefaultsMap.begin(), mDefaultsMap.end()); @@ -504,7 +376,7 @@ void LLKeyConflictHandler::loadFromSettings(ESourceMode load_mode) mLoadMode = load_mode; } -void LLKeyConflictHandler::saveToSettings() +void LLKeyConflictHandler::saveToSettings() { if (mControlsMap.empty()) { @@ -513,39 +385,33 @@ void LLKeyConflictHandler::saveToSettings() if (mLoadMode == MODE_GENERAL) { - for (U32 i = 0; i < CONTROL_NUM_INDICES; i++) + control_map_t::iterator iter = mControlsMap.begin(); + control_map_t::iterator end = mControlsMap.end(); + + for (; iter != end; ++iter) { - EControlTypes type = (EControlTypes)i; - switch (type) + if (iter->first.empty()) { - case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: - case LLKeyConflictHandler::CONTROL_INTERACTIONS: - case LLKeyConflictHandler::CONTROL_MOVEMENTS: - case LLKeyConflictHandler::CONTROL_MEDIACONTENT: - case LLKeyConflictHandler::CONTROL_CAMERA: - case LLKeyConflictHandler::CONTROL_EDIT_TITLE: - case LLKeyConflictHandler::CONTROL_RESERVED: - // ignore 'headers', they are for representation and organization purposes - break; - default: + continue; + } + + LLKeyConflict &key = iter->second; + key.mKeyBind.trimEmpty(); + if (!key.mAssignable) { - if (mControlsMap[type].mAssignable) - { - std::string name = getControlName(type); - if (gSavedSettings.controlExists(name)) - { - gSavedSettings.setLLSD(name, mControlsMap[type].mKeyBind.asLLSD()); - } - else if (!mControlsMap[type].mKeyBind.empty()) - { - // shouldn't happen user side since all settings are supposed to be declared already, but handy when creating new ones - // (just don't forget to change comment and to copy them from user's folder) - LL_INFOS() << "Creating new keybinding " << name << LL_ENDL; - gSavedSettings.declareLLSD(name, mControlsMap[type].mKeyBind.asLLSD(), "comment", LLControlVariable::PERSIST_ALWAYS); - } - } - break; + continue; + } + + if (gSavedSettings.controlExists(iter->first)) + { + gSavedSettings.setLLSD(iter->first, key.mKeyBind.asLLSD()); } + else if (!key.mKeyBind.empty()) + { + // Note: this is currently not in use, might be better for load mechanics to ask for and retain control group + // otherwise settings loaded from other control groups will end in this one + LL_INFOS() << "Creating new keybinding " << iter->first << LL_ENDL; + gSavedSettings.declareLLSD(iter->first, key.mKeyBind.asLLSD(), "comment", LLControlVariable::PERSIST_ALWAYS); } } } @@ -564,8 +430,8 @@ void LLKeyConflictHandler::saveToSettings() { // replace category we edited - // todo: fix this - // workaround to avoid doing own param container + // mode is a HACK to correctly reset bindings without reparsing whole file and avoid doing + // own param container (which will face issues with inasseesible members of LLInitParam) LLViewerInput::KeyMode mode; LLViewerInput::KeyBinding binding; @@ -581,8 +447,20 @@ void LLKeyConflictHandler::saveToSettings() U32 size = iter->second.mKeyBind.getDataCount(); for (U32 i = 0; i < size; ++i) { - // Still write empty keys to make sure we will maintain UI position - LLKeyData data = iter->second.mKeyBind.getKeyData(i); + if (iter->first.empty()) + { + continue; + } + + LLKeyConflict &key = iter->second; + key.mKeyBind.trimEmpty(); + if (key.mKeyBind.empty() || !key.mAssignable) + { + continue; + } + + LLKeyData data = key.mKeyBind.getKeyData(i); + // Still write empty LLKeyData to make sure we will maintain UI position if (data.mKey == KEY_NONE) { binding.key = ""; @@ -595,7 +473,7 @@ 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 = getControlName(iter->first); + binding.command = iter->first; mode.bindings.add(binding); } } @@ -664,12 +542,15 @@ void LLKeyConflictHandler::saveToSettings() mHasUnsavedChanges = false; } -LLKeyData LLKeyConflictHandler::getDefaultControl(EControlTypes control_type, U32 index) +LLKeyData LLKeyConflictHandler::getDefaultControl(const std::string &control_name, U32 index) { + if (control_name.empty()) + { + return LLKeyData(); + } if (mLoadMode == MODE_GENERAL) { - std::string name = getControlName(control_type); - LLControlVariablePtr var = gSavedSettings.getControl(name); + LLControlVariablePtr var = gSavedSettings.getControl(control_name); if (var) { return LLKeyBind(var->getDefault()).getKeyData(index); @@ -678,7 +559,7 @@ LLKeyData LLKeyConflictHandler::getDefaultControl(EControlTypes control_type, U3 } else { - control_map_t::iterator iter = mDefaultsMap.find(control_type); + control_map_t::iterator iter = mDefaultsMap.find(control_name); if (iter != mDefaultsMap.end()) { return iter->second.mKeyBind.getKeyData(index); @@ -687,24 +568,31 @@ LLKeyData LLKeyConflictHandler::getDefaultControl(EControlTypes control_type, U3 } } -void LLKeyConflictHandler::resetToDefault(EControlTypes control_type, U32 index) +void LLKeyConflictHandler::resetToDefault(const std::string &control_name, U32 index) { - LLKeyData data = getDefaultControl(control_type, index); + if (control_name.empty()) + { + return; + } + LLKeyData data = getDefaultControl(control_name, index); - if (data != mControlsMap[control_type].getKeyData(index)) + if (data != mControlsMap[control_name].getKeyData(index)) { // reset controls that might have been switched to our current control - removeConflicts(data, mControlsMap[control_type].mConflictMask); - mControlsMap[control_type].setKeyData(data, index); + removeConflicts(data, mControlsMap[control_name].mConflictMask); + mControlsMap[control_name].setKeyData(data, index); } } -void LLKeyConflictHandler::resetToDefaultAndResolve(EControlTypes control_type, bool ignore_conflicts) +void LLKeyConflictHandler::resetToDefaultAndResolve(const std::string &control_name, bool ignore_conflicts) { + if (control_name.empty()) + { + return; + } if (mLoadMode == MODE_GENERAL) { - std::string name = getControlName(control_type); - LLControlVariablePtr var = gSavedSettings.getControl(name); + LLControlVariablePtr var = gSavedSettings.getControl(control_name); if (var) { LLKeyBind bind(var->getDefault()); @@ -712,67 +600,53 @@ void LLKeyConflictHandler::resetToDefaultAndResolve(EControlTypes control_type, { for (S32 i = 0; i < bind.getDataCount(); ++i) { - removeConflicts(bind.getKeyData(i), mControlsMap[control_type].mConflictMask); + removeConflicts(bind.getKeyData(i), mControlsMap[control_name].mConflictMask); } } - mControlsMap[control_type].mKeyBind = bind; + mControlsMap[control_name].mKeyBind = bind; } else { - mControlsMap[control_type].mKeyBind.clear(); + mControlsMap[control_name].mKeyBind.clear(); } } else { - control_map_t::iterator iter = mDefaultsMap.find(control_type); + control_map_t::iterator iter = mDefaultsMap.find(control_name); if (iter != mDefaultsMap.end()) { if (!ignore_conflicts) { for (S32 i = 0; i < iter->second.mKeyBind.getDataCount(); ++i) { - removeConflicts(iter->second.mKeyBind.getKeyData(i), mControlsMap[control_type].mConflictMask); + removeConflicts(iter->second.mKeyBind.getKeyData(i), mControlsMap[control_name].mConflictMask); } } - mControlsMap[control_type].mKeyBind = iter->second.mKeyBind; + mControlsMap[control_name].mKeyBind = iter->second.mKeyBind; } else { - mControlsMap[control_type].mKeyBind.clear(); + mControlsMap[control_name].mKeyBind.clear(); } } } -void LLKeyConflictHandler::resetToDefault(EControlTypes control_type) +void LLKeyConflictHandler::resetToDefault(const std::string &control_name) { // reset specific binding without ignoring conflicts - resetToDefaultAndResolve(control_type, false); + resetToDefaultAndResolve(control_name, false); } void LLKeyConflictHandler::resetToDefaults(ESourceMode mode) { if (mode == MODE_GENERAL) { - for (U32 i = 0; i < CONTROL_NUM_INDICES; i++) + control_map_t::iterator iter = mControlsMap.begin(); + control_map_t::iterator end = mControlsMap.end(); + + for (; iter != end; ++iter) { - EControlTypes type = (EControlTypes)i; - switch (type) - { - case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: - case LLKeyConflictHandler::CONTROL_INTERACTIONS: - case LLKeyConflictHandler::CONTROL_MOVEMENTS: - case LLKeyConflictHandler::CONTROL_MEDIACONTENT: - case LLKeyConflictHandler::CONTROL_CAMERA: - case LLKeyConflictHandler::CONTROL_EDIT_TITLE: - case LLKeyConflictHandler::CONTROL_RESERVED: - // ignore 'headers', they are for representation and organization purposes - break; - default: - { - resetToDefaultAndResolve(type, true); - break; - } - } + resetToDefaultAndResolve(iter->first, true); } } else @@ -834,7 +708,7 @@ bool LLKeyConflictHandler::removeConflicts(const LLKeyData &data, const U32 &con // Can't conflict return true; } - std::map conflict_list; + std::map conflict_list; control_map_t::iterator cntrl_iter = mControlsMap.begin(); control_map_t::iterator cntrl_end = mControlsMap.end(); for (; cntrl_iter != cntrl_end; ++cntrl_iter) @@ -859,8 +733,8 @@ bool LLKeyConflictHandler::removeConflicts(const LLKeyData &data, const U32 &con } } - std::map::iterator cnflct_iter = conflict_list.begin(); - std::map::iterator cnflct_end = conflict_list.end(); + std::map::iterator cnflct_iter = conflict_list.begin(); + std::map::iterator cnflct_end = conflict_list.end(); for (; cnflct_iter != cnflct_end; ++cnflct_iter) { mControlsMap[cnflct_iter->first].mKeyBind.resetKeyData(cnflct_iter->second); @@ -868,9 +742,9 @@ bool LLKeyConflictHandler::removeConflicts(const LLKeyData &data, const U32 &con return true; } -void LLKeyConflictHandler::registerTemporaryControl(EControlTypes control_type, EMouseClickType mouse, KEY key, MASK mask, U32 conflict_mask) +void LLKeyConflictHandler::registerTemporaryControl(const std::string &control_name, EMouseClickType mouse, KEY key, MASK mask, U32 conflict_mask) { - LLKeyConflict *type_data = &mControlsMap[control_type]; + LLKeyConflict *type_data = &mControlsMap[control_name]; type_data->mAssignable = false; type_data->mConflictMask = conflict_mask; type_data->mKeyBind.addKeyData(mouse, key, mask, false); diff --git a/indra/newview/llkeyconflict.h b/indra/newview/llkeyconflict.h index e4a6da30d0..a0886bedce 100644 --- a/indra/newview/llkeyconflict.h +++ b/indra/newview/llkeyconflict.h @@ -70,114 +70,35 @@ public: // at the moment this just means that key will conflict with everything that is identical const U32 CONFLICT_ANY = U32_MAX; - // todo, unfortunately will have to remove this and use map/array of strings - enum EControlTypes - { - CONTROL_VIEW_ACTIONS = 0, // Group control, for visual representation in view, not for use - CONTROL_ABOUT, - CONTROL_ORBIT, - CONTROL_PAN, - CONTROL_WORLD_MAP, - CONTROL_ZOOM, - CONTROL_INTERACTIONS, // Group control, for visual representation - CONTROL_BUILD, - //CONTROL_DRAG, - CONTROL_EDIT, - //CONTROL_MENU, - CONTROL_OPEN, - CONTROL_TOUCH, - CONTROL_WEAR, - CONTROL_MOVEMENTS, // Group control, for visual representation - CONTROL_MOVETO, - CONTROL_TELEPORTTO, - CONTROL_FORWARD, - CONTROL_BACKWARD, - CONTROL_LEFT, // Check and sinc name with real movement names - CONTROL_RIGHT, - CONTROL_LSTRAFE, - CONTROL_RSTRAFE, - CONTROL_JUMP, - CONTROL_DOWN, - //CONTROL_RUN, - CONTROL_TOGGLE_RUN, - CONTROL_TOGGLE_FLY, - CONTROL_SIT, - CONTROL_STOP, - CONTROL_CAMERA, // Group control, for visual representation - CONTROL_LOOK_UP, - CONTROL_LOOK_DOWN, - CONTROL_CAMERA_FORWARD, - CONTROL_CAMERA_BACKWARD, - CONTROL_CAMERA_FFORWARD, - CONTROL_CAMERA_FBACKWARD, - CONTROL_CAMERA_FSITTING, - CONTROL_CAMERA_BSITTING, - CONTROL_CAMERA_SOVER, - CONTROL_CAMERA_SUNDER, - CONTROL_CAMERA_SOVER_SITTING, - CONTROL_CAMERA_SUNDER_SITTING, - CONTROL_CAMERA_PANUP, - CONTROL_CAMERA_PANDOWN, - CONTROL_CAMERA_PANLEFT, - CONTROL_CAMERA_PANRIGHT, - CONTROL_CAMERA_PANIN, - CONTROL_CAMERA_PANOUT, - CONTROL_CAMERA_SPIN_CCW, - CONTROL_CAMERA_SPIN_CW, - CONTROL_CAMERA_SPIN_CCW_SITTING, - CONTROL_CAMERA_SPIN_CW_SITTING, - CONTROL_EDIT_TITLE, // Group control, for visual representation - CONTROL_EDIT_AV_SPIN_CCW, - CONTROL_EDIT_AV_SPIN_CW, - CONTROL_EDIT_AV_SPIN_OVER, - CONTROL_EDIT_AV_SPIN_UNDER, - CONTROL_EDIT_AV_MV_FORWARD, - CONTROL_EDIT_AV_MV_BACKWARD, - CONTROL_MEDIACONTENT, // Group control, for visual representation - CONTROL_PAUSE_MEDIA, // Play pause - CONTROL_ENABLE_MEDIA, // Play stop - CONTROL_VOICE, // Keep pressing for voice to be ON - CONTROL_TOGGLE_VOICE, // Press once to ON/OFF - CONTROL_START_CHAT, // Press once to ON/OFF - CONTROL_START_GESTURE, // Press once to ON/OFF - CONTROL_RESERVED, // Special group control, controls that are disabled by default and not meant to be changed - CONTROL_DELETE, - CONTROL_RESERVED_MENU, - CONTROL_RESERVED_SELECT, - CONTROL_SHIFT_SELECT, - CONTROL_CNTRL_SELECT, - CONTROL_NUM_INDICES // Size, always should be last - }; - // Note: missed selection and edition commands (would be really nice to go through selection via MB4/5 or wheel) LLKeyConflictHandler(); LLKeyConflictHandler(ESourceMode mode); - bool canHandleControl(EControlTypes control_type, EMouseClickType mouse_ind, KEY key, MASK mask); - bool canHandleKey(EControlTypes control_type, KEY key, MASK mask); - bool canHandleMouse(EControlTypes control_type, EMouseClickType mouse_ind, MASK mask); - bool canHandleMouse(EControlTypes control_type, S32 mouse_ind, MASK mask); //Just for convinience - bool canAssignControl(EControlTypes control_type); - bool registerControl(EControlTypes control_type, U32 data_index, EMouseClickType mouse_ind, KEY key, MASK mask, bool ignore_mask); //todo: return conflicts? - - LLKeyData getControl(EControlTypes control_type, U32 data_index); + bool canHandleControl(const std::string &control_name, EMouseClickType mouse_ind, KEY key, MASK mask); + bool canHandleKey(const std::string &control_name, KEY key, MASK mask); + bool canHandleMouse(const std::string &control_name, EMouseClickType mouse_ind, MASK mask); + bool canHandleMouse(const std::string &control_name, S32 mouse_ind, MASK mask); //Just for convinience + bool canAssignControl(const std::string &control_name); + bool registerControl(const std::string &control_name, U32 data_index, EMouseClickType mouse_ind, KEY key, MASK mask, bool ignore_mask); //todo: return conflicts? - static std::string LLKeyConflictHandler::getStringFromKeyData(const LLKeyData& keydata); - static std::string getControlName(EControlTypes control_type); - std::string getControlString(EControlTypes control_type, U32 data_index); + LLKeyData getControl(const std::string &control_name, U32 data_index); + static std::string getStringFromKeyData(const LLKeyData& keydata); + std::string getControlString(const std::string &control_name, U32 data_index); + // Load single control, overrides existing one if names match + void loadFromControlSettings(const std::string &name); // Drops any changes loads controls with ones from 'saved settings' or from xml void loadFromSettings(ESourceMode load_mode); // Saves settings to 'saved settings' or to xml void saveToSettings(); - LLKeyData getDefaultControl(EControlTypes control_type, U32 data_index); + LLKeyData getDefaultControl(const std::string &control_name, U32 data_index); // Resets keybinding to default variant from 'saved settings' or xml - void resetToDefault(EControlTypes control_type, U32 index); - void resetToDefault(EControlTypes control_type); - // resets current mode to defaults, + void resetToDefault(const std::string &control_name, U32 index); + void resetToDefault(const std::string &control_name); + // resets current mode to defaults void resetToDefaults(); bool empty() { return mControlsMap.empty(); } @@ -188,15 +109,15 @@ public: ESourceMode getLoadMode() { return mLoadMode; } private: - void resetToDefaultAndResolve(EControlTypes control_type, bool ignore_conflicts); + void resetToDefaultAndResolve(const std::string &control_name, bool ignore_conflicts); void resetToDefaults(ESourceMode mode); // at the moment these kind of control is not savable, but takes part will take part in conflict resolution - void registerTemporaryControl(EControlTypes control_type, EMouseClickType mouse_ind, KEY key, MASK mask, U32 conflict_mask); + void registerTemporaryControl(const std::string &control_name, EMouseClickType mouse_ind, KEY key, MASK mask, U32 conflict_mask); - typedef std::map control_map_t; + typedef std::map control_map_t; void loadFromSettings(const LLViewerInput::KeyMode& keymode, control_map_t *destination); - void loadFromSettings(const ESourceMode &load_mode, const std::string &filename, control_map_t *destination); + bool loadFromSettings(const ESourceMode &load_mode, const std::string &filename, control_map_t *destination); void resetKeyboardBindings(); void generatePlaceholders(ESourceMode load_mode); //E.x. non-assignable values // returns false in case user is trying to reuse control that can't be reassigned diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index fb405fd225..4a06a2012f 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -650,6 +650,78 @@ bool start_gesture( EKeystate s ) return true; } +bool run_forward(EKeystate s) +{ + if (KEYSTATE_DOWN == s) + { + gAgent.setAlwaysRun(); + gAgent.setRunning(); + gAgent.sendWalkRun(true); + } + else if(KEYSTATE_UP == s) + { + gAgent.clearAlwaysRun(); + gAgent.clearRunning(); + gAgent.sendWalkRun(false); + } + agent_push_forward(s); + return true; +} + +bool run_backward(EKeystate s) +{ + if (KEYSTATE_DOWN == s) + { + gAgent.setAlwaysRun(); + gAgent.setRunning(); + gAgent.sendWalkRun(true); + } + else if (KEYSTATE_UP == s) + { + gAgent.clearAlwaysRun(); + gAgent.clearRunning(); + gAgent.sendWalkRun(false); + } + agent_push_backward(s); + return true; +} + +bool run_left(EKeystate s) +{ + if (KEYSTATE_DOWN == s) + { + gAgent.setAlwaysRun(); + gAgent.setRunning(); + gAgent.sendWalkRun(true); + } + else if (KEYSTATE_UP == s) + { + gAgent.clearAlwaysRun(); + gAgent.clearRunning(); + gAgent.sendWalkRun(false); + } + agent_slide_left(s); + return true; +} + +bool run_right(EKeystate s) +{ + if (KEYSTATE_DOWN == s) + { + gAgent.setAlwaysRun(); + gAgent.setRunning(); + gAgent.sendWalkRun(true); + } + else if (KEYSTATE_UP == s) + { + gAgent.clearAlwaysRun(); + gAgent.clearRunning(); + gAgent.sendWalkRun(false); + } + agent_slide_right(s); + return true; +} + bool toggle_run(EKeystate s) { if (KEYSTATE_DOWN != s) return true; @@ -791,6 +863,10 @@ REGISTER_KEYBOARD_ACTION("edit_avatar_move_backward", edit_avatar_move_backward) REGISTER_KEYBOARD_ACTION("stop_moving", stop_moving); REGISTER_KEYBOARD_ACTION("start_chat", start_chat); REGISTER_KEYBOARD_ACTION("start_gesture", start_gesture); +REGISTER_KEYBOARD_ACTION("run_forward", run_forward); +REGISTER_KEYBOARD_ACTION("run_backward", run_backward); +REGISTER_KEYBOARD_ACTION("run_left", run_left); +REGISTER_KEYBOARD_ACTION("run_right", run_right); REGISTER_KEYBOARD_ACTION("toggle_run", toggle_run); REGISTER_KEYBOARD_ACTION("toggle_sit", toggle_sit); REGISTER_KEYBOARD_ACTION("toggle_pause_media", toggle_pause_media); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 28adc2b7ab..091fc720c1 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -971,6 +971,8 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window, LLCoordGL pos, MASK m case CLICK_BUTTON5: buttonname = "Button 5"; break; + default: + break; // COUNT and NONE } LLView::sMouseHandlerMessage.clear(); diff --git a/indra/newview/skins/default/xui/en/panel_preferences_controls.xml b/indra/newview/skins/default/xui/en/panel_preferences_controls.xml index 62267dce8a..385d4796a0 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_controls.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_controls.xml @@ -9,6 +9,10 @@ name="controls" top="1" width="517"> + + Walk to + View Actions @@ -70,8 +74,8 @@ Move Actions - Move To + name="teleport_to"> + Teleport to @@ -118,6 +122,22 @@ name="control_run"> Run + + Run Forward + + + Run Backward + + + Run Left + + + Run Right + Toggle Run @@ -126,6 +146,10 @@ name="toggle_fly"> Fly/Stop flying + + Stop Moving + Camera @@ -215,36 +239,13 @@ Play/Stop All Media + name="voice_follow_key"> Voice + name="toggle_voice"> Toggle Voice - - Reserved Controls - - - Delete - - - - Select - - - Multi-Select - - - Add to Selection - Date: Thu, 3 Oct 2019 22:45:29 +0300 Subject: SL-6109 Remade 'ignore' list processing, renamed and reformed keybindings --- indra/llcommon/llkeybind.cpp | 9 +- indra/llcommon/llkeybind.h | 3 +- indra/llui/llscrolllistcell.h | 2 +- indra/newview/CMakeLists.txt | 2 +- indra/newview/app_settings/key_bindings.xml | 302 +++++++++++++++++ indra/newview/app_settings/keys.xml | 363 --------------------- indra/newview/llappviewer.cpp | 4 +- indra/newview/llfloaterpreference.cpp | 20 +- indra/newview/llfloaterpreference.h | 8 +- indra/newview/llkeyconflict.cpp | 18 +- indra/newview/llpanelpresetspulldown.cpp | 1 + indra/newview/llsetkeybinddialog.cpp | 18 +- indra/newview/llsetkeybinddialog.h | 18 +- indra/newview/llviewerinput.cpp | 164 ++++------ indra/newview/llviewerinput.h | 28 +- .../default/xui/en/control_table_contents.xml | 14 +- .../skins/default/xui/en/floater_select_key.xml | 15 +- 17 files changed, 445 insertions(+), 544 deletions(-) create mode 100644 indra/newview/app_settings/key_bindings.xml delete mode 100644 indra/newview/app_settings/keys.xml (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp index ff88a9c9aa..46a3230240 100644 --- a/indra/llcommon/llkeybind.cpp +++ b/indra/llcommon/llkeybind.cpp @@ -92,14 +92,11 @@ LLSD LLKeyData::asLLSD() const LLSD data; data["mouse"] = (LLSD::Integer)mMouse; data["key"] = (LLSD::Integer)mKey; + data["mask"] = (LLSD::Integer)mMask; if (mIgnoreMasks) { data["ignore_accelerators"] = (LLSD::Boolean)mIgnoreMasks; } - else - { - data["mask"] = (LLSD::Integer)mMask; - } return data; } @@ -147,7 +144,7 @@ bool LLKeyData::canHandle(const LLKeyData& data) const { if (data.mKey == mKey && data.mMouse == mMouse - && (mIgnoreMasks || data.mMask == mMask)) + && ((mIgnoreMasks && (data.mMask & mMask) == data.mMask) || data.mMask == mMask)) { return true; } @@ -158,7 +155,7 @@ bool LLKeyData::canHandle(EMouseClickType mouse, KEY key, MASK mask) const { if (mouse == mMouse && key == mKey - && (mIgnoreMasks || mask == mMask)) + && ((mIgnoreMasks && (mask & mMask) == mask) || mask == mMask)) { return true; } diff --git a/indra/llcommon/llkeybind.h b/indra/llcommon/llkeybind.h index 39cb668aac..ad0ebec67c 100644 --- a/indra/llcommon/llkeybind.h +++ b/indra/llcommon/llkeybind.h @@ -53,7 +53,8 @@ public: EMouseClickType mMouse; KEY mKey; MASK mMask; - bool mIgnoreMasks; + // Either to expect exact match or ignore not expected masks + bool mIgnoreMasks; }; // One function can bind to multiple Key options diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h index ef7f717b57..19576fb247 100644 --- a/indra/llui/llscrolllistcell.h +++ b/indra/llui/llscrolllistcell.h @@ -70,7 +70,7 @@ public: Optional color; Params() - : type("cell_type", "text"), // Don't use "type", it overlaps with xml's parameter + : type("type", "text"), column("column"), width("width"), enabled("enabled", true), diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 111aefe186..b8fa60ddcb 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1671,7 +1671,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/key_bindings.xml b/indra/newview/app_settings/key_bindings.xml new file mode 100644 index 0000000000..0c90ef26df --- /dev/null +++ b/indra/newview/app_settings/key_bindings.xml @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/indra/newview/app_settings/keys.xml b/indra/newview/app_settings/keys.xml deleted file mode 100644 index a8037fec05..0000000000 --- a/indra/newview/app_settings/keys.xml +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 7145f0f29c..857cd86739 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1003,11 +1003,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 e71c7d58e2..9e1330dca7 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -2875,7 +2875,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) @@ -2895,6 +2895,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) { @@ -2905,21 +2913,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 9c4f6fad46..8adfb79038 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -292,7 +292,7 @@ class LLPanelPreferenceControls : public LLPanelPreference, public LLKeyBindResp LOG_CLASS(LLPanelPreferenceControls); public: LLPanelPreferenceControls(); - ~LLPanelPreferenceControls(); + virtual ~LLPanelPreferenceControls(); BOOL postBuild(); @@ -303,10 +303,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 8a3bcf7172..d52ad8056f 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("Cancel")->setFocus(TRUE); pCheckBox = getChild("ignore_masks"); + pDesription = getChild("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("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 4a06a2012f..02d0dcb6c7 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1007,7 +1007,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 function_t; @@ -1048,57 +1048,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 function_t; @@ -1117,27 +1090,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) @@ -1146,23 +1103,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; } @@ -1171,8 +1117,7 @@ LLViewerInput::KeyBinding::KeyBinding() : key("key"), mouse("mouse"), mask("mask"), - command("command"), - ignore("ignore", false) + command("command") {} LLViewerInput::KeyMode::KeyMode() @@ -1191,10 +1136,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(); } } @@ -1218,6 +1161,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; @@ -1234,9 +1205,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 @@ -1251,9 +1221,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 @@ -1266,7 +1235,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; } @@ -1291,7 +1264,7 @@ EKeyboardMode LLViewerInput::getMode() const } } -bool LLViewerInput::scanKey(const LLKeyboardBinding* binding, +bool LLViewerInput::scanKey(const std::vector &binding, S32 binding_count, KEY key, MASK mask, @@ -1304,7 +1277,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) @@ -1352,12 +1325,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)) { @@ -1445,11 +1413,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 &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) @@ -1486,11 +1454,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 key, mask, command; - Optional mouse; // Note, not mandatory for the sake of backward campatibility - Optional ignore; + Optional 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 &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 &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 mKeyBindings[MODE_COUNT]; + std::vector mMouseBindings[MODE_COUNT]; typedef std::map 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=""> @@ -204,7 +204,7 @@ enabled="false" value=""> @@ -426,7 +426,7 @@ enabled="false" value=""> @@ -504,7 +504,7 @@ enabled="false" value=""> Mouse Buttons + + +Press a key to set your trigger. +Allowed input: [INPUT]. + + +Combination [KEYSTR] is reserved by menu. -- cgit v1.3 From 7cec1f3381291ffbf4cc6a07daf4a74d5af5a9ee Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 4 Oct 2019 16:20:07 +0300 Subject: SL-6109 Added default key for voice --- indra/newview/app_settings/key_bindings.xml | 12 +++++++++++- indra/newview/llkeyconflict.cpp | 1 + indra/newview/llviewerinput.cpp | 5 +++-- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/app_settings/key_bindings.xml b/indra/newview/app_settings/key_bindings.xml index 0c90ef26df..d0c25f3ed0 100644 --- a/indra/newview/app_settings/key_bindings.xml +++ b/indra/newview/app_settings/key_bindings.xml @@ -31,6 +31,8 @@ + + @@ -122,6 +124,8 @@ + + @@ -178,6 +182,8 @@ + + @@ -273,6 +279,8 @@ + + @@ -298,5 +306,7 @@ + + - \ No newline at end of file + diff --git a/indra/newview/llkeyconflict.cpp b/indra/newview/llkeyconflict.cpp index 0b9aaea478..71ba0d37b3 100644 --- a/indra/newview/llkeyconflict.cpp +++ b/indra/newview/llkeyconflict.cpp @@ -480,6 +480,7 @@ void LLKeyConflictHandler::saveToSettings() // Still write empty LLKeyData to make sure we will maintain UI position if (data.mKey == KEY_NONE) { + // Might be better idea to be consistent and use NONE. LLViewerInput can work with both cases binding.key = ""; } else diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index 02d0dcb6c7..2327ac7f4c 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1198,10 +1198,11 @@ S32 LLViewerInput::loadBindingMode(const LLViewerInput::KeyMode& keymode, S32 mo ++it) { bool processed = false; - if (!it->key.getValue().empty()) + std::string key_str = it->key.getValue(); + if (!key_str.empty() && key_str != "NONE") { KEY key; - LLKeyboard::keyFromString(it->key, &key); + LLKeyboard::keyFromString(key_str, &key); if (key != KEY_NONE) { MASK mask; -- cgit v1.3 From 6597c7696783ce56f89b34a4b6440363635be6a6 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 28 Oct 2019 17:52:31 +0200 Subject: SL-6109 - Fixed line endings in xml file - Removed obsolete UI element and it's code - Fixed issue with return value caused by rebase --- indra/newview/llfloaterpreference.cpp | 35 - indra/newview/llfloaterpreference.h | 1 - indra/newview/llviewerinput.cpp | 2 +- .../default/xui/en/control_table_contents.xml | 1138 ++++++++++---------- .../default/xui/en/panel_preferences_sound.xml | 15 - 5 files changed, 570 insertions(+), 621 deletions(-) (limited to 'indra/newview/llviewerinput.cpp') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 9e1330dca7..15e6c91ad0 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -285,7 +285,6 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this)); mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2)); mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this)); - mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this)); mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this)); mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this)); mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this)); @@ -1528,21 +1527,6 @@ void LLFloaterPreference::onChangeQuality(const LLSD& data) refresh(); } -void LLFloaterPreference::onClickSetMiddleMouse() -{ - LLUICtrl* p2t_line_editor = getChild("modifier_combo"); - - // update the control right away since we no longer wait for apply - p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV); - - //push2talk button "middle mouse" control value is in English, need to localize it for presentation - LLPanel* advanced_preferences = dynamic_cast(p2t_line_editor->getParent()); - if (advanced_preferences) - { - p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse")); - } -} - void LLFloaterPreference::onClickSetSounds() { // Disable Enable gesture sounds checkbox if the master sound is disabled @@ -2229,25 +2213,6 @@ BOOL LLPanelPreference::postBuild() getChild("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized)); } - //////////////////////PanelAdvanced /////////////////// - if (hasChild("modifier_combo", TRUE)) - { - //localizing if push2talk button is set to middle mouse - std::string modifier_value = getChild("modifier_combo")->getValue().asString(); - if (MIDDLE_MOUSE_CV == modifier_value) - { - getChild("modifier_combo")->setValue(getString("middle_mouse")); - } - else if (MOUSE_BUTTON_4_CV == modifier_value) - { - getChild("modifier_combo")->setValue(getString("button4_mouse")); - } - else if (MOUSE_BUTTON_5_CV == modifier_value) - { - getChild("modifier_combo")->setValue(getString("button5_mouse")); - } - } - //////////////////////PanelSetup /////////////////// if (hasChild("max_bandwidth"), TRUE) { diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 8adfb79038..1d6b3a9e1a 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -143,7 +143,6 @@ public: void onClickResetCache(); void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata); void onSelectSkin(); - void onClickSetMiddleMouse(); void onClickSetSounds(); void onClickEnablePopup(); void onClickDisablePopup(); diff --git a/indra/newview/llviewerinput.cpp b/indra/newview/llviewerinput.cpp index 2327ac7f4c..b847923c9c 100644 --- a/indra/newview/llviewerinput.cpp +++ b/indra/newview/llviewerinput.cpp @@ -1311,7 +1311,7 @@ bool LLViewerInput::scanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level) { if (LLApp::isExiting()) { - return; + return false; } S32 mode = getMode(); 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 7d4b9be894..f078e80dff 100644 --- a/indra/newview/skins/default/xui/en/control_table_contents.xml +++ b/indra/newview/skins/default/xui/en/control_table_contents.xml @@ -1,569 +1,569 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml index db88798d6b..74c9b10cff 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml @@ -470,21 +470,6 @@ width="237" tool_tip="When in toggle mode, press and release the trigger key ONCE to switch your microphone on or off. When not in toggle mode, the microphone broadcasts your voice only while the trigger is being held down." top_pad="3"/> -