mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:16:56 +02:00
Stop mouse capturing when in vr
This commit is contained in:
parent
18b6e744a3
commit
d343fea626
6 changed files with 34 additions and 1 deletions
|
@ -225,6 +225,7 @@ Application::Application(
|
||||||
_hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR),
|
_hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR),
|
||||||
_preferStylusOverLaserSetting("preferStylusOverLaser", DEFAULT_PREFER_STYLUS_OVER_LASER),
|
_preferStylusOverLaserSetting("preferStylusOverLaser", DEFAULT_PREFER_STYLUS_OVER_LASER),
|
||||||
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
_preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
|
||||||
|
_defaultMouseLock("defaultMouseLock", DEFAULT_MOUSE_LOCK),
|
||||||
_showGraphicsIconSetting("showGraphicsIcon", DEFAULT_SHOW_GRAPHICS_ICON),
|
_showGraphicsIconSetting("showGraphicsIcon", DEFAULT_SHOW_GRAPHICS_ICON),
|
||||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||||
_awayStateWhenFocusLostInVREnabled("awayStateWhenFocusLostInVREnabled", DEFAULT_AWAY_STATE_WHEN_FOCUS_LOST_IN_VR_ENABLED),
|
_awayStateWhenFocusLostInVREnabled("awayStateWhenFocusLostInVREnabled", DEFAULT_AWAY_STATE_WHEN_FOCUS_LOST_IN_VR_ENABLED),
|
||||||
|
|
|
@ -188,6 +188,9 @@ public:
|
||||||
void setPreferStylusOverLaser(bool value) { _preferStylusOverLaserSetting.set(value); }
|
void setPreferStylusOverLaser(bool value) { _preferStylusOverLaserSetting.set(value); }
|
||||||
bool getPreferAvatarFingerOverStylus() { return _preferAvatarFingerOverStylusSetting.get(); }
|
bool getPreferAvatarFingerOverStylus() { return _preferAvatarFingerOverStylusSetting.get(); }
|
||||||
void setPreferAvatarFingerOverStylus(bool value) { _preferAvatarFingerOverStylusSetting.set(value); }
|
void setPreferAvatarFingerOverStylus(bool value) { _preferAvatarFingerOverStylusSetting.set(value); }
|
||||||
|
|
||||||
|
void setMouseLock(bool value);
|
||||||
|
bool getMouseLock();
|
||||||
|
|
||||||
bool getShowGraphicsIcon() { return _showGraphicsIconSetting.get(); }
|
bool getShowGraphicsIcon() { return _showGraphicsIconSetting.get(); }
|
||||||
void setShowGraphicsIcon(bool value);
|
void setShowGraphicsIcon(bool value);
|
||||||
|
@ -791,6 +794,7 @@ private:
|
||||||
Setting::Handle<bool> _hmdTabletBecomesToolbarSetting;
|
Setting::Handle<bool> _hmdTabletBecomesToolbarSetting;
|
||||||
Setting::Handle<bool> _preferStylusOverLaserSetting;
|
Setting::Handle<bool> _preferStylusOverLaserSetting;
|
||||||
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
Setting::Handle<bool> _preferAvatarFingerOverStylusSetting;
|
||||||
|
Setting::Handle<bool> _defaultMouseLock;
|
||||||
Setting::Handle<bool> _showGraphicsIconSetting;
|
Setting::Handle<bool> _showGraphicsIconSetting;
|
||||||
Setting::Handle<bool> _constrainToolbarPosition;
|
Setting::Handle<bool> _constrainToolbarPosition;
|
||||||
Setting::Handle<bool> _awayStateWhenFocusLostInVREnabled;
|
Setting::Handle<bool> _awayStateWhenFocusLostInVREnabled;
|
||||||
|
|
|
@ -269,6 +269,14 @@ void Application::setHmdTabletBecomesToolbarSetting(bool value) {
|
||||||
updateSystemTabletMode();
|
updateSystemTabletMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setMouseLock(bool value) {
|
||||||
|
_defaultMouseLock.set(value);
|
||||||
|
getApplicationCompositor().setMouseLockComposit(value);
|
||||||
|
}
|
||||||
|
bool Application::getMouseLock() {
|
||||||
|
return _defaultMouseLock.get();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setShowGraphicsIcon(bool value) {
|
void Application::setShowGraphicsIcon(bool value) {
|
||||||
_showGraphicsIconSetting.set(value);
|
_showGraphicsIconSetting.set(value);
|
||||||
DependencyManager::get<MessagesClient>()->sendLocalMessage("Overte-ShowGraphicsIconChanged", "");
|
DependencyManager::get<MessagesClient>()->sendLocalMessage("Overte-ShowGraphicsIconChanged", "");
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
void setupPreferences() {
|
void setupPreferences() {
|
||||||
auto preferences = DependencyManager::get<Preferences>();
|
auto preferences = DependencyManager::get<Preferences>();
|
||||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
|
|
||||||
|
|
||||||
static const QString AVATAR_BASICS { "Avatar Basics" };
|
static const QString AVATAR_BASICS { "Avatar Basics" };
|
||||||
{
|
{
|
||||||
auto getter = [myAvatar]()->QString { return myAvatar->getDisplayName(); };
|
auto getter = [myAvatar]()->QString { return myAvatar->getDisplayName(); };
|
||||||
|
@ -142,6 +144,14 @@ void setupPreferences() {
|
||||||
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//static const QString TEST{ "TEST SECTION" };
|
||||||
|
{
|
||||||
|
auto getter = []() -> bool { return qApp->getMouseLock(); };
|
||||||
|
auto setter = [](bool value) { qApp->setMouseLock(value); };
|
||||||
|
auto preference = new CheckPreference(UI_CATEGORY, "3D mouse cursor in VR", getter, setter);
|
||||||
|
preferences->addPreference(preference);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto getter = []()->bool { return qApp->getAwayStateWhenFocusLostInVREnabled(); };
|
auto getter = []()->bool { return qApp->getAwayStateWhenFocusLostInVREnabled(); };
|
||||||
auto setter = [](bool value) { qApp->setAwayStateWhenFocusLostInVREnabled(value); };
|
auto setter = [](bool value) { qApp->setAwayStateWhenFocusLostInVREnabled(value); };
|
||||||
|
|
|
@ -195,6 +195,10 @@ bool CompositorHelper::shouldCaptureMouse() const {
|
||||||
if (!isHMD()) {
|
if (!isHMD()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_mouseLockComposit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isWindowActive()) {
|
if (!isWindowActive()) {
|
||||||
|
@ -216,6 +220,10 @@ void CompositorHelper::setAllowMouseCapture(bool capture) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompositorHelper::setMouseLockComposit(bool capture) {
|
||||||
|
_mouseLockComposit = capture;
|
||||||
|
}
|
||||||
|
|
||||||
void CompositorHelper::handleLeaveEvent() {
|
void CompositorHelper::handleLeaveEvent() {
|
||||||
if (shouldCaptureMouse()) {
|
if (shouldCaptureMouse()) {
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
|
|
||||||
bool getAllowMouseCapture() const { return _allowMouseCapture; }
|
bool getAllowMouseCapture() const { return _allowMouseCapture; }
|
||||||
void setAllowMouseCapture(bool capture);
|
void setAllowMouseCapture(bool capture);
|
||||||
|
void setMouseLockComposit(bool capture);
|
||||||
|
|
||||||
/// if the reticle is pointing to a system overlay (a dialog box for example) then the function returns true otherwise false
|
/// if the reticle is pointing to a system overlay (a dialog box for example) then the function returns true otherwise false
|
||||||
bool getReticleOverDesktop() const;
|
bool getReticleOverDesktop() const;
|
||||||
|
@ -168,7 +169,8 @@ private:
|
||||||
|
|
||||||
bool _reticleOverQml { false };
|
bool _reticleOverQml { false };
|
||||||
|
|
||||||
std::atomic<bool> _allowMouseCapture { true };
|
std::atomic<bool> _allowMouseCapture{ true };
|
||||||
|
std::atomic<bool> _mouseLockComposit{ false };
|
||||||
|
|
||||||
bool _fakeMouseEvent { false };
|
bool _fakeMouseEvent { false };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue