viewer#3018 Expose mouse wrap in UI

And attempt some basic automation
master
Andrey Kleshchev 2024-11-13 00:11:53 +02:00 committed by Andrey Kleshchev
parent 46b4ea4d6d
commit 38257221d0
10 changed files with 84 additions and 6 deletions

View File

@ -95,6 +95,7 @@ public:
#if LL_WINDOWS
virtual bool getCursorDelta(LLCoordCommon* delta) = 0;
#endif
virtual bool isWrapMouse() const = 0;
virtual void showCursor() = 0;
virtual void hideCursor() = 0;
virtual bool isCursorHidden() = 0;

View File

@ -63,6 +63,7 @@ public:
#if LL_WINDOWS
/*virtual*/ bool getCursorDelta(LLCoordCommon* delta) override { return false; }
#endif
/*virtual*/ bool isWrapMouse() const override { return true; }
/*virtual*/ void showCursor() override {}
/*virtual*/ void hideCursor() override {}
/*virtual*/ void showCursorFromMouseMove() override {}

View File

@ -63,6 +63,7 @@ public:
bool switchContext(bool fullscreen, const LLCoordScreen &size, bool enable_vsync, const LLCoordScreen * const posp = NULL) override;
bool setCursorPosition(LLCoordWindow position) override;
bool getCursorPosition(LLCoordWindow *position) override;
bool isWrapMouse() const override { return !mCursorDecoupled; };
void showCursor() override;
void hideCursor() override;
void showCursorFromMouseMove() override;

View File

@ -68,6 +68,7 @@ public:
/*virtual*/ bool switchContext(bool fullscreen, const LLCoordScreen &size, bool disable_vsync, const LLCoordScreen * const posp = NULL);
/*virtual*/ bool setCursorPosition(LLCoordWindow position);
/*virtual*/ bool getCursorPosition(LLCoordWindow *position);
/*virtual*/ bool isWrapMouse() const override { return true; }
/*virtual*/ void showCursor();
/*virtual*/ void hideCursor();
/*virtual*/ void showCursorFromMouseMove();

View File

@ -450,6 +450,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
F32 max_gl_version)
:
LLWindow(callbacks, fullscreen, flags),
mAbsoluteCursorPosition(false),
mMaxGLVersion(max_gl_version),
mMaxCores(max_cores)
{
@ -3156,6 +3157,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
prev_absolute_x = absolute_x;
prev_absolute_y = absolute_y;
window_imp->mAbsoluteCursorPosition = true;
}
else
{
@ -3172,6 +3174,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
window_imp->mRawMouseDelta.mX += (S32)round((F32)raw->data.mouse.lLastX * (F32)speed / DEFAULT_SPEED);
window_imp->mRawMouseDelta.mY -= (S32)round((F32)raw->data.mouse.lLastY * (F32)speed / DEFAULT_SPEED);
}
window_imp->mAbsoluteCursorPosition = false;
}
}
}

View File

@ -70,6 +70,7 @@ public:
/*virtual*/ bool setCursorPosition(LLCoordWindow position);
/*virtual*/ bool getCursorPosition(LLCoordWindow *position);
/*virtual*/ bool getCursorDelta(LLCoordCommon* delta);
/*virtual*/ bool isWrapMouse() const override { return !mAbsoluteCursorPosition; };
/*virtual*/ void showCursor();
/*virtual*/ void hideCursor();
/*virtual*/ void showCursorFromMouseMove();
@ -195,6 +196,7 @@ protected:
HCURSOR mCursor[ UI_CURSOR_COUNT ]; // Array of all mouse cursors
LLCoordWindow mCursorPosition; // mouse cursor position, should only be mutated on main thread
bool mAbsoluteCursorPosition; // true if last position was received in absolute coordinates.
LLMutex mRawMouseMutex;
RAWINPUTDEVICE mRawMouse;
LLCoordWindow mLastCursorPosition; // mouse cursor position from previous frame

View File

@ -2469,16 +2469,16 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>DisableMouseWarp</key>
<key>MouseWarpMode</key>
<map>
<key>Comment</key>
<string>Disable warping of the mouse to the center of the screen during alt-zoom and mouse look. Useful with certain input devices, mouse sharing programs like Synergy, or running under Parallels.</string>
<string>Controls warping of the mouse to the center of the screen during alt-zoom and mouse look. Useful with certain input devices, mouse sharing programs like Synergy, or running under Parallels. 0 - automatic, 1 - on, 2 - off</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<string>S32</string>
<key>Value</key>
<integer>0</integer>
<integer>1</integer>
</map>
<key>DisableExternalBrowser</key>
<map>

View File

@ -774,6 +774,17 @@ void LLFloaterPreference::onOpen(const LLSD& key)
// Load (double-)click to walk/teleport settings.
updateClickActionViews();
#if LL_LINUX
// Lixux doesn't support automatic mode
LLComboBox* combo = getChild<LLComboBox>("double_click_action_combo");
S32 mode = gSavedSettings.getS32("MouseWarpMode");
if (mode == 0)
{
combo->setValue("1");
}
combo->setEnabledByValue("0", false);
#endif
// Enabled/disabled popups, might have been changed by user actions
// while preferences floater was closed.
buildPopupLists();

View File

@ -3340,7 +3340,31 @@ void LLViewerWindow::clearPopups()
void LLViewerWindow::moveCursorToCenter()
{
if (! gSavedSettings.getBOOL("DisableMouseWarp"))
bool mouse_warp = false;
LLCachedControl<S32> mouse_warp_mode(gSavedSettings, "MouseWarpMode", 1);
switch (mouse_warp_mode())
{
case 0:
// For Windows:
// Mouse usually uses 'delta' position since it isn't aware of own location, keep it centered.
// Touch screen reports absolute or virtual absolute position and warping a physical
// touch is pointless, so don't move it.
//
// MacOS
// If 'decoupled', CGAssociateMouseAndMouseCursorPosition can make mouse stay in
// one place and not move, do not move it (needs testing).
mouse_warp = mWindow->isWrapMouse();
break;
case 1:
mouse_warp = true;
break;
default:
mouse_warp = false;
break;
}
if (mouse_warp)
{
S32 x = getWorldViewWidthScaled() / 2;
S32 y = getWorldViewHeightScaled() / 2;

View File

@ -202,9 +202,43 @@
height="10"
layout="topleft"
left="86"
name="single_click_action_lbl"
name="mouse_warp_lbl"
width="150"
top_pad="20">
Mouse Warp:
</text>
<combo_box
control_name="MouseWarpMode"
height="23"
layout="topleft"
left_pad="10"
top_delta="-6"
name="mouse_warp_combo"
tooltip="Controls warping of the mouse to the center of the screen during alt-zoom and mouse look."
width="200">
<combo_box.item
label="Automatic"
name="0"
value="0"/>
<combo_box.item
label="On"
name="1"
value="1"/>
<combo_box.item
label="Off"
name="2"
value="2"/>
</combo_box>
<text
follows="left|top"
type="string"
length="1"
height="10"
layout="topleft"
left="86"
name="single_click_action_lbl"
width="150"
top_pad="12">
Single click on land:
</text>
<combo_box