Skip to content

Commit e3f8dfe

Browse files
committed
viewer#3018 Expose mouse wrap in UI
And attempt some basic automation
1 parent 695a53f commit e3f8dfe

File tree

10 files changed

+83
-5
lines changed

10 files changed

+83
-5
lines changed

indra/llwindow/llwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class LLWindow : public LLInstanceTracker<LLWindow>
9595
#if LL_WINDOWS
9696
virtual bool getCursorDelta(LLCoordCommon* delta) const = 0;
9797
#endif
98+
virtual bool isWrapMouse() const = 0;
9899
virtual void showCursor() = 0;
99100
virtual void hideCursor() = 0;
100101
virtual bool isCursorHidden() = 0;

indra/llwindow/llwindowheadless.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class LLWindowHeadless : public LLWindow
5858
#if LL_WINDOWS
5959
bool getCursorDelta(LLCoordCommon* delta) const override { return false; }
6060
#endif
61+
bool isWrapMouse() const override { return true; }
6162
void showCursor() override {}
6263
void hideCursor() override {}
6364
void showCursorFromMouseMove() override {}

indra/llwindow/llwindowmacosx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class LLWindowMacOSX : public LLWindow
6262
bool switchContext(bool fullscreen, const LLCoordScreen &size, bool enable_vsync, const LLCoordScreen * const posp = NULL) override;
6363
bool setCursorPosition(LLCoordWindow position) override;
6464
bool getCursorPosition(LLCoordWindow *position) override;
65+
bool isWrapMouse() const override { return !mCursorDecoupled; };
6566
void showCursor() override;
6667
void hideCursor() override;
6768
void showCursorFromMouseMove() override;

indra/llwindow/llwindowsdl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class LLWindowSDL : public LLWindow {
8080

8181
bool getCursorPosition(LLCoordWindow *position) override;
8282

83+
bool isWrapMouse() const override { return true; }
8384
void showCursor() override;
8485
void hideCursor() override;
8586
bool isCursorHidden() override;

indra/llwindow/llwindowwin32.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
418418
F32 max_gl_version)
419419
:
420420
LLWindow(callbacks, fullscreen, flags),
421+
mAbsoluteCursorPosition(false),
421422
mMaxGLVersion(max_gl_version),
422423
mMaxCores(max_cores)
423424
{
@@ -3060,6 +3061,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
30603061

30613062
prev_absolute_x = absolute_x;
30623063
prev_absolute_y = absolute_y;
3064+
window_imp->mAbsoluteCursorPosition = true;
30633065
}
30643066
else
30653067
{
@@ -3076,6 +3078,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
30763078
window_imp->mRawMouseDelta.mX += (S32)round((F32)raw->data.mouse.lLastX * (F32)speed / DEFAULT_SPEED);
30773079
window_imp->mRawMouseDelta.mY -= (S32)round((F32)raw->data.mouse.lLastY * (F32)speed / DEFAULT_SPEED);
30783080
}
3081+
window_imp->mAbsoluteCursorPosition = false;
30793082
}
30803083
}
30813084
}

indra/llwindow/llwindowwin32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class LLWindowWin32 : public LLWindow
6969
bool setCursorPosition(LLCoordWindow position) override;
7070
bool getCursorPosition(LLCoordWindow *position) override;
7171
bool getCursorDelta(LLCoordCommon* delta) const override;
72+
bool isWrapMouse() const override { return !mAbsoluteCursorPosition; };
7273
void showCursor() override;
7374
void hideCursor() override;
7475
void showCursorFromMouseMove() override;
@@ -195,6 +196,7 @@ class LLWindowWin32 : public LLWindow
195196

196197
HCURSOR mCursor[ UI_CURSOR_COUNT ]; // Array of all mouse cursors
197198
LLCoordWindow mCursorPosition; // mouse cursor position, should only be mutated on main thread
199+
bool mAbsoluteCursorPosition; // true if last position was received in absolute coordinates.
198200
LLMutex mRawMouseMutex;
199201
RAWINPUTDEVICE mRawMouse;
200202
LLCoordWindow mLastCursorPosition; // mouse cursor position from previous frame

indra/newview/app_settings/settings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,14 +2403,14 @@
24032403
<key>Value</key>
24042404
<integer>0</integer>
24052405
</map>
2406-
<key>DisableMouseWarp</key>
2406+
<key>MouseWarpMode</key>
24072407
<map>
24082408
<key>Comment</key>
2409-
<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>
2409+
<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>
24102410
<key>Persist</key>
24112411
<integer>1</integer>
24122412
<key>Type</key>
2413-
<string>Boolean</string>
2413+
<string>S32</string>
24142414
<key>Value</key>
24152415
<integer>0</integer>
24162416
</map>

indra/newview/llfloaterpreference.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,17 @@ void LLFloaterPreference::onOpen(const LLSD& key)
768768
// Load (double-)click to walk/teleport settings.
769769
updateClickActionViews();
770770

771+
#if LL_LINUX
772+
// Lixux doesn't support automatic mode
773+
LLComboBox* combo = getChild<LLComboBox>("double_click_action_combo");
774+
S32 mode = gSavedSettings.getS32("MouseWarpMode");
775+
if (mode == 0)
776+
{
777+
combo->setValue("1");
778+
}
779+
combo->setEnabledByValue("0", false);
780+
#endif
781+
771782
// Enabled/disabled popups, might have been changed by user actions
772783
// while preferences floater was closed.
773784
buildPopupLists();

indra/newview/llviewerwindow.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3272,7 +3272,31 @@ void LLViewerWindow::clearPopups()
32723272

32733273
void LLViewerWindow::moveCursorToCenter()
32743274
{
3275-
if (! gSavedSettings.getBOOL("DisableMouseWarp"))
3275+
bool mouse_warp = false;
3276+
LLCachedControl<S32> mouse_warp_mode(gSavedSettings, "MouseWarpMode", 0);
3277+
3278+
switch (mouse_warp_mode())
3279+
{
3280+
case 0:
3281+
// For Windows:
3282+
// Mouse usually uses 'delta' position since it isn't aware of own location, keep it centered.
3283+
// Touch screen reports absolute or virtual absolute position and warping a physical
3284+
// touch is pointless, so don't move it.
3285+
//
3286+
// MacOS
3287+
// If 'decoupled', CGAssociateMouseAndMouseCursorPosition can make mouse stay in
3288+
// one place and not move, do not move it (needs testing).
3289+
mouse_warp = mWindow->isWrapMouse();
3290+
break;
3291+
case 1:
3292+
mouse_warp = true;
3293+
break;
3294+
default:
3295+
mouse_warp = false;
3296+
break;
3297+
}
3298+
3299+
if (mouse_warp)
32763300
{
32773301
S32 x = getWorldViewWidthScaled() / 2;
32783302
S32 y = getWorldViewHeightScaled() / 2;

indra/newview/skins/default/xui/en/panel_preferences_move.xml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,43 @@
202202
height="10"
203203
layout="topleft"
204204
left="86"
205-
name="single_click_action_lbl"
205+
name="mouse_warp_lbl"
206206
width="150"
207207
top_pad="20">
208+
Mouse Warp:
209+
</text>
210+
<combo_box
211+
control_name="MouseWarpMode"
212+
height="23"
213+
layout="topleft"
214+
left_pad="10"
215+
top_delta="-6"
216+
name="mouse_warp_combo"
217+
tooltip="Controls warping of the mouse to the center of the screen during alt-zoom and mouse look."
218+
width="200">
219+
<combo_box.item
220+
label="Automatic"
221+
name="0"
222+
value="0"/>
223+
<combo_box.item
224+
label="On"
225+
name="1"
226+
value="1"/>
227+
<combo_box.item
228+
label="Off"
229+
name="2"
230+
value="2"/>
231+
</combo_box>
232+
<text
233+
follows="left|top"
234+
type="string"
235+
length="1"
236+
height="10"
237+
layout="topleft"
238+
left="86"
239+
name="single_click_action_lbl"
240+
width="150"
241+
top_pad="12">
208242
Single click on land:
209243
</text>
210244
<combo_box

0 commit comments

Comments
 (0)