mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 18:34:48 +02:00
Merge pull request #1317 from OfficialR3ido101/fix/VR_Mouse_Lock
Stop VR mouse capture.
This commit is contained in:
commit
ce86f59437
6 changed files with 34 additions and 1 deletions
interface/src
libraries/display-plugins/src/display-plugins
|
@ -159,6 +159,7 @@ const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true;
|
|||
const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false;
|
||||
const bool DEFAULT_PREFER_STYLUS_OVER_LASER = false;
|
||||
const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
|
||||
const bool DEFAULT_MOUSE_CAPTURE_VR = false;
|
||||
const bool DEFAULT_SHOW_GRAPHICS_ICON = true;
|
||||
const bool DEFAULT_MINI_TABLET_ENABLED = false;
|
||||
const bool DEFAULT_AWAY_STATE_WHEN_FOCUS_LOST_IN_VR_ENABLED = true;
|
||||
|
@ -225,6 +226,7 @@ Application::Application(
|
|||
_hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR),
|
||||
_preferStylusOverLaserSetting("preferStylusOverLaser", DEFAULT_PREFER_STYLUS_OVER_LASER),
|
||||
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
||||
_defaultMouseCaptureVR("defaultMouseCaptureVR", DEFAULT_MOUSE_CAPTURE_VR),
|
||||
_showGraphicsIconSetting("showGraphicsIcon", DEFAULT_SHOW_GRAPHICS_ICON),
|
||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||
_awayStateWhenFocusLostInVREnabled("awayStateWhenFocusLostInVREnabled", DEFAULT_AWAY_STATE_WHEN_FOCUS_LOST_IN_VR_ENABLED),
|
||||
|
|
|
@ -188,6 +188,9 @@ public:
|
|||
void setPreferStylusOverLaser(bool value) { _preferStylusOverLaserSetting.set(value); }
|
||||
bool getPreferAvatarFingerOverStylus() { return _preferAvatarFingerOverStylusSetting.get(); }
|
||||
void setPreferAvatarFingerOverStylus(bool value) { _preferAvatarFingerOverStylusSetting.set(value); }
|
||||
|
||||
void setMouseCaptureVR(bool value);
|
||||
bool getMouseCaptureVR();
|
||||
|
||||
bool getShowGraphicsIcon() { return _showGraphicsIconSetting.get(); }
|
||||
void setShowGraphicsIcon(bool value);
|
||||
|
@ -791,6 +794,7 @@ private:
|
|||
Setting::Handle<bool> _hmdTabletBecomesToolbarSetting;
|
||||
Setting::Handle<bool> _preferStylusOverLaserSetting;
|
||||
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
||||
Setting::Handle<bool> _defaultMouseCaptureVR;
|
||||
Setting::Handle<bool> _showGraphicsIconSetting;
|
||||
Setting::Handle<bool> _constrainToolbarPosition;
|
||||
Setting::Handle<bool> _awayStateWhenFocusLostInVREnabled;
|
||||
|
|
|
@ -269,6 +269,14 @@ void Application::setHmdTabletBecomesToolbarSetting(bool value) {
|
|||
updateSystemTabletMode();
|
||||
}
|
||||
|
||||
void Application::setMouseCaptureVR(bool value) {
|
||||
_defaultMouseCaptureVR.set(value);
|
||||
getApplicationCompositor().setEnableMouseCaptureVR(value);
|
||||
}
|
||||
bool Application::getMouseCaptureVR() {
|
||||
return _defaultMouseCaptureVR.get();
|
||||
}
|
||||
|
||||
void Application::setShowGraphicsIcon(bool value) {
|
||||
_showGraphicsIconSetting.set(value);
|
||||
DependencyManager::get<MessagesClient>()->sendLocalMessage("Overte-ShowGraphicsIconChanged", "");
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
void setupPreferences() {
|
||||
auto preferences = DependencyManager::get<Preferences>();
|
||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
|
||||
static const QString AVATAR_BASICS { "Avatar Basics" };
|
||||
{
|
||||
auto getter = [myAvatar]()->QString { return myAvatar->getDisplayName(); };
|
||||
|
@ -165,6 +167,13 @@ void setupPreferences() {
|
|||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
{
|
||||
auto getter = []() -> bool { return qApp->getMouseCaptureVR(); };
|
||||
auto setter = [](bool value) { qApp->setMouseCaptureVR(value); };
|
||||
auto preference = new CheckPreference(UI_CATEGORY, "3D mouse cursor in VR", getter, setter);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
{
|
||||
static const QString RETICLE_ICON_NAME = { Cursor::Manager::getIconName(Cursor::Icon::RETICLE) };
|
||||
|
|
|
@ -195,6 +195,10 @@ bool CompositorHelper::shouldCaptureMouse() const {
|
|||
if (!isHMD()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_enableMouseCaptureVR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!isWindowActive()) {
|
||||
|
@ -216,6 +220,10 @@ void CompositorHelper::setAllowMouseCapture(bool capture) {
|
|||
}
|
||||
}
|
||||
|
||||
void CompositorHelper::setEnableMouseCaptureVR(bool capture) {
|
||||
_enableMouseCaptureVR = capture;
|
||||
}
|
||||
|
||||
void CompositorHelper::handleLeaveEvent() {
|
||||
if (shouldCaptureMouse()) {
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ public:
|
|||
|
||||
bool getAllowMouseCapture() const { return _allowMouseCapture; }
|
||||
void setAllowMouseCapture(bool capture);
|
||||
void setEnableMouseCaptureVR(bool capture);
|
||||
|
||||
/// if the reticle is pointing to a system overlay (a dialog box for example) then the function returns true otherwise false
|
||||
bool getReticleOverDesktop() const;
|
||||
|
@ -168,7 +169,8 @@ private:
|
|||
|
||||
bool _reticleOverQml { false };
|
||||
|
||||
std::atomic<bool> _allowMouseCapture { true };
|
||||
std::atomic<bool> _allowMouseCapture{ true };
|
||||
std::atomic<bool> _enableMouseCaptureVR{ false };
|
||||
|
||||
bool _fakeMouseEvent { false };
|
||||
|
||||
|
|
Loading…
Reference in a new issue