mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Merge pull request #677 from HifiExperiments/mouse
Add option to capture mouse
This commit is contained in:
commit
d12cd36eb3
10 changed files with 167 additions and 123 deletions
|
@ -3,9 +3,9 @@
|
||||||
"channels": [
|
"channels": [
|
||||||
{ "from": "Keyboard.A", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
|
{ "from": "Keyboard.A", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
|
||||||
{ "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
{ "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
||||||
{ "from": "Keyboard.E", "when": ["!Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
{ "from": "Keyboard.Q", "when": ["!Application.CameraSelfie", "!Keyboard.Control", "!Application.CaptureMouse"], "to": "Actions.LATERAL_LEFT" },
|
||||||
{ "from": "Keyboard.Q", "when": ["!Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
|
|
||||||
{ "from": "Keyboard.Q", "when": ["Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
{ "from": "Keyboard.Q", "when": ["Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
||||||
|
{ "from": "Keyboard.E", "when": ["!Application.CameraSelfie", "!Keyboard.Control", "!Application.CaptureMouse"], "to": "Actions.LATERAL_RIGHT" },
|
||||||
{ "from": "Keyboard.E", "when": ["Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
|
{ "from": "Keyboard.E", "when": ["Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
|
||||||
{ "from": "Keyboard.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" },
|
{ "from": "Keyboard.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" },
|
||||||
|
|
||||||
|
@ -72,46 +72,20 @@
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": { "makeAxis" : [
|
||||||
["Keyboard.Left"],
|
["Keyboard.Left"],
|
||||||
["Keyboard.Right"]
|
["Keyboard.Right"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"when": ["Application.CameraFirstPerson", "!Keyboard.Shift"],
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "!Application.CaptureMouse", "!Keyboard.Shift"],
|
||||||
"to": "Actions.Yaw"
|
"to": "Actions.Yaw"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": "Keyboard.Left",
|
||||||
["Keyboard.Left"],
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Shift"],
|
||||||
["Keyboard.Right"]
|
"to": "Actions.LATERAL_LEFT"
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraFirstPersonLookat", "!Keyboard.Shift"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": "Keyboard.Right",
|
||||||
["Keyboard.Left"],
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Shift"],
|
||||||
["Keyboard.Right"]
|
"to": "Actions.LATERAL_RIGHT"
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraThirdPerson", "!Keyboard.Shift"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.Left"],
|
|
||||||
["Keyboard.Right"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraLookAt", "!Keyboard.Shift"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.Left"],
|
|
||||||
["Keyboard.Right"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraSelfie", "!Keyboard.Shift"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": { "makeAxis" : [
|
||||||
|
@ -119,53 +93,18 @@
|
||||||
["Keyboard.D"]
|
["Keyboard.D"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"when": ["Application.CameraFirstPerson", "!Keyboard.Control"],
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "!Application.CaptureMouse", "!Keyboard.Control"],
|
||||||
"to": "Actions.Yaw"
|
"to": "Actions.Yaw"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": "Keyboard.A",
|
||||||
["Keyboard.A"],
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Control"],
|
||||||
["Keyboard.D"]
|
"to": "Actions.LATERAL_LEFT"
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraFirstPersonLookat", "!Keyboard.Control"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": "Keyboard.D",
|
||||||
["Keyboard.A"],
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Control"],
|
||||||
["Keyboard.D"]
|
"to": "Actions.LATERAL_RIGHT"
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraThirdPerson", "!Keyboard.Control"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.A"],
|
|
||||||
["Keyboard.D"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraLookAt", "!Keyboard.Control"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.A"],
|
|
||||||
["Keyboard.D"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": ["Application.CameraSelfie", "!Keyboard.Control"],
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.TouchpadLeft"],
|
|
||||||
["Keyboard.TouchpadRight"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": "Application.CameraFirstPerson",
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
{ "from": { "makeAxis" : [
|
||||||
|
@ -173,39 +112,12 @@
|
||||||
["Keyboard.TouchpadRight"]
|
["Keyboard.TouchpadRight"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"when": "Application.CameraFirstPersonLookat",
|
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity"],
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.TouchpadLeft"],
|
|
||||||
["Keyboard.TouchpadRight"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": "Application.CameraThirdPerson",
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.TouchpadLeft"],
|
|
||||||
["Keyboard.TouchpadRight"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": "Application.CameraLookAt",
|
|
||||||
"to": "Actions.Yaw"
|
|
||||||
},
|
|
||||||
|
|
||||||
{ "from": { "makeAxis" : [
|
|
||||||
["Keyboard.TouchpadLeft"],
|
|
||||||
["Keyboard.TouchpadRight"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"when": "Application.CameraSelfie",
|
|
||||||
"to": "Actions.Yaw"
|
"to": "Actions.Yaw"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : ["Keyboard.MouseMoveLeft", "Keyboard.MouseMoveRight"] },
|
{ "from": { "makeAxis" : ["Keyboard.MouseMoveLeft", "Keyboard.MouseMoveRight"] },
|
||||||
"when": "Keyboard.RightMouseButton",
|
"when": ["Keyboard.RightMouseButton", "!Application.CaptureMouse"],
|
||||||
"to": "Actions.DeltaYaw",
|
"to": "Actions.DeltaYaw",
|
||||||
"filters":
|
"filters":
|
||||||
[
|
[
|
||||||
|
@ -213,8 +125,17 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ "from": { "makeAxis" : ["Keyboard.MouseMoveLeft", "Keyboard.MouseMoveRight"] },
|
||||||
|
"to": "Actions.DeltaYaw",
|
||||||
|
"when": "Application.CaptureMouse",
|
||||||
|
"filters":
|
||||||
|
[
|
||||||
|
{ "type": "scale", "scale": 0.2 }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
|
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
|
||||||
"when": ["!Application.CameraSelfie", "!Application.CameraLookAt", "Keyboard.RightMouseButton"],
|
"when": ["!Application.CameraSelfie", "!Application.CameraLookAt", "!Application.CaptureMouse", "Keyboard.RightMouseButton"],
|
||||||
"to": "Actions.DeltaPitch",
|
"to": "Actions.DeltaPitch",
|
||||||
"filters":
|
"filters":
|
||||||
[
|
[
|
||||||
|
@ -222,6 +143,15 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
|
||||||
|
"to": "Actions.DeltaPitch",
|
||||||
|
"when": "Application.CaptureMouse",
|
||||||
|
"filters":
|
||||||
|
[
|
||||||
|
{ "type": "scale", "scale": 0.2 }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
|
{ "from": { "makeAxis" : ["Keyboard.MouseMoveUp", "Keyboard.MouseMoveDown"] },
|
||||||
"when": ["Application.CameraLookAt", "Keyboard.RightMouseButton"],
|
"when": ["Application.CameraLookAt", "Keyboard.RightMouseButton"],
|
||||||
"to": "Actions.DeltaPitch",
|
"to": "Actions.DeltaPitch",
|
||||||
|
|
|
@ -681,6 +681,9 @@ private:
|
||||||
* <tr><td><code>CameraIndependent</code></td><td>number</td><td>number</td><td>The camera is in independent mode.</td></tr>
|
* <tr><td><code>CameraIndependent</code></td><td>number</td><td>number</td><td>The camera is in independent mode.</td></tr>
|
||||||
* <tr><td><code>CameraEntity</code></td><td>number</td><td>number</td><td>The camera is in entity mode.</td></tr>
|
* <tr><td><code>CameraEntity</code></td><td>number</td><td>number</td><td>The camera is in entity mode.</td></tr>
|
||||||
* <tr><td><code>InHMD</code></td><td>number</td><td>number</td><td>The user is in HMD mode.</td></tr>
|
* <tr><td><code>InHMD</code></td><td>number</td><td>number</td><td>The user is in HMD mode.</td></tr>
|
||||||
|
* <tr><td><code>CaptureMouse</code></td><td>number</td><td>number</td><td>The mouse is captured. In this mode,
|
||||||
|
* the mouse is invisible and cannot leave the bounds of Interface, as long as Interface is the active window and
|
||||||
|
* no menu item is selected.</td></tr>
|
||||||
* <tr><td><code>AdvancedMovement</code></td><td>number</td><td>number</td><td>Advanced movement (walking) controls are
|
* <tr><td><code>AdvancedMovement</code></td><td>number</td><td>number</td><td>Advanced movement (walking) controls are
|
||||||
* enabled.</td></tr>
|
* enabled.</td></tr>
|
||||||
* <tr><td><code>StrafeEnabled</code></td><td>number</td><td>number</td><td>Strafing is enabled</td></tr>
|
* <tr><td><code>StrafeEnabled</code></td><td>number</td><td>number</td><td>Strafing is enabled</td></tr>
|
||||||
|
@ -716,6 +719,7 @@ static const QString STATE_PLATFORM_ANDROID = "PlatformAndroid";
|
||||||
static const QString STATE_LEFT_HAND_DOMINANT = "LeftHandDominant";
|
static const QString STATE_LEFT_HAND_DOMINANT = "LeftHandDominant";
|
||||||
static const QString STATE_RIGHT_HAND_DOMINANT = "RightHandDominant";
|
static const QString STATE_RIGHT_HAND_DOMINANT = "RightHandDominant";
|
||||||
static const QString STATE_STRAFE_ENABLED = "StrafeEnabled";
|
static const QString STATE_STRAFE_ENABLED = "StrafeEnabled";
|
||||||
|
static const QString STATE_CAPTURE_MOUSE = "CaptureMouse";
|
||||||
|
|
||||||
// Statically provided display and input plugins
|
// Statically provided display and input plugins
|
||||||
extern DisplayPluginList getDisplayPlugins();
|
extern DisplayPluginList getDisplayPlugins();
|
||||||
|
@ -919,7 +923,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
||||||
DependencyManager::set<MessagesClient>();
|
DependencyManager::set<MessagesClient>();
|
||||||
controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_CAMERA_FULL_SCREEN_MIRROR,
|
controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_CAMERA_FULL_SCREEN_MIRROR,
|
||||||
STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_FIRST_PERSON_LOOK_AT, STATE_CAMERA_THIRD_PERSON,
|
STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_FIRST_PERSON_LOOK_AT, STATE_CAMERA_THIRD_PERSON,
|
||||||
STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, STATE_CAMERA_LOOK_AT, STATE_CAMERA_SELFIE,
|
STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT, STATE_CAMERA_LOOK_AT, STATE_CAMERA_SELFIE, STATE_CAPTURE_MOUSE,
|
||||||
STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED,
|
STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED,
|
||||||
STATE_PLATFORM_WINDOWS, STATE_PLATFORM_MAC, STATE_PLATFORM_ANDROID, STATE_LEFT_HAND_DOMINANT, STATE_RIGHT_HAND_DOMINANT, STATE_STRAFE_ENABLED } });
|
STATE_PLATFORM_WINDOWS, STATE_PLATFORM_MAC, STATE_PLATFORM_ANDROID, STATE_LEFT_HAND_DOMINANT, STATE_RIGHT_HAND_DOMINANT, STATE_STRAFE_ENABLED } });
|
||||||
DependencyManager::set<UserInputMapper>();
|
DependencyManager::set<UserInputMapper>();
|
||||||
|
@ -1892,6 +1896,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_INDEPENDENT, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_CAMERA_INDEPENDENT, []() -> float {
|
||||||
return qApp->getCamera().getMode() == CAMERA_MODE_INDEPENDENT ? 1 : 0;
|
return qApp->getCamera().getMode() == CAMERA_MODE_INDEPENDENT ? 1 : 0;
|
||||||
});
|
});
|
||||||
|
_applicationStateDevice->setInputVariant(STATE_CAPTURE_MOUSE, []() -> float {
|
||||||
|
return qApp->getCamera().getCaptureMouse() ? 1 : 0;
|
||||||
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float {
|
||||||
return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0;
|
return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0;
|
||||||
});
|
});
|
||||||
|
@ -2407,6 +2414,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
updateSystemTabletMode();
|
updateSystemTabletMode();
|
||||||
|
|
||||||
connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
|
connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
|
||||||
|
connect(&_myCamera, &Camera::captureMouseChanged, this, &Application::captureMouseChanged);
|
||||||
|
|
||||||
DependencyManager::get<PickManager>()->setShouldPickHUDOperator([]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
|
DependencyManager::get<PickManager>()->setShouldPickHUDOperator([]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
|
||||||
DependencyManager::get<PickManager>()->setCalculatePos2DFromHUDOperator([this](const glm::vec3& intersection) {
|
DependencyManager::get<PickManager>()->setCalculatePos2DFromHUDOperator([this](const glm::vec3& intersection) {
|
||||||
|
@ -4704,6 +4712,11 @@ void Application::maybeToggleMenuVisible(QMouseEvent* event) const {
|
||||||
void Application::mouseMoveEvent(QMouseEvent* event) {
|
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
PROFILE_RANGE(app_input_mouse, __FUNCTION__);
|
PROFILE_RANGE(app_input_mouse, __FUNCTION__);
|
||||||
|
|
||||||
|
if (_ignoreMouseMove) {
|
||||||
|
_ignoreMouseMove = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
maybeToggleMenuVisible(event);
|
maybeToggleMenuVisible(event);
|
||||||
|
|
||||||
auto& compositor = getApplicationCompositor();
|
auto& compositor = getApplicationCompositor();
|
||||||
|
@ -4749,7 +4762,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_keyboardMouseDevice->isActive()) {
|
if (_keyboardMouseDevice->isActive()) {
|
||||||
_keyboardMouseDevice->mouseMoveEvent(event);
|
_keyboardMouseDevice->mouseMoveEvent(event, _captureMouse, _mouseCaptureTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5950,6 +5963,20 @@ void Application::cameraModeChanged() {
|
||||||
cameraMenuChanged();
|
cameraMenuChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::shouldCaptureMouse() const {
|
||||||
|
return _captureMouse && _glWidget->isActiveWindow() && !ui::Menu::isSomeSubmenuShown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::captureMouseChanged(bool captureMouse) {
|
||||||
|
_captureMouse = captureMouse;
|
||||||
|
if (_captureMouse) {
|
||||||
|
_glWidget->setCursor(QCursor(Qt::BlankCursor));
|
||||||
|
} else {
|
||||||
|
_mouseCaptureTarget = QPointF(NAN, NAN);
|
||||||
|
_glWidget->unsetCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::changeViewAsNeeded(float boomLength) {
|
void Application::changeViewAsNeeded(float boomLength) {
|
||||||
// Switch between first and third person views as needed
|
// Switch between first and third person views as needed
|
||||||
// This is called when the boom length has changed
|
// This is called when the boom length has changed
|
||||||
|
@ -6300,6 +6327,15 @@ void Application::update(float deltaTime) {
|
||||||
PROFILE_ASYNC_END(app, "Scene Loading", "");
|
PROFILE_ASYNC_END(app, "Scene Loading", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldCaptureMouse()) {
|
||||||
|
QPoint point = _glWidget->mapToGlobal(_glWidget->geometry().center());
|
||||||
|
if (QCursor::pos() != point) {
|
||||||
|
_mouseCaptureTarget = point;
|
||||||
|
_ignoreMouseMove = true;
|
||||||
|
QCursor::setPos(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto myAvatar = getMyAvatar();
|
auto myAvatar = getMyAvatar();
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("devices");
|
PerformanceTimer perfTimer("devices");
|
||||||
|
@ -6355,8 +6391,8 @@ void Application::update(float deltaTime) {
|
||||||
if (deltaTime > FLT_EPSILON && userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z) == 0.0f) {
|
if (deltaTime > FLT_EPSILON && userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z) == 0.0f) {
|
||||||
myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
|
myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH));
|
||||||
myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
|
myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW));
|
||||||
myAvatar->setDriveKey(MyAvatar::DELTA_PITCH, -1.0f * userInputMapper->getActionState(controller::Action::DELTA_PITCH));
|
myAvatar->setDriveKey(MyAvatar::DELTA_PITCH, -_myCamera.getSensitivity() * userInputMapper->getActionState(controller::Action::DELTA_PITCH));
|
||||||
myAvatar->setDriveKey(MyAvatar::DELTA_YAW, -1.0f * userInputMapper->getActionState(controller::Action::DELTA_YAW));
|
myAvatar->setDriveKey(MyAvatar::DELTA_YAW, -_myCamera.getSensitivity() * userInputMapper->getActionState(controller::Action::DELTA_YAW));
|
||||||
myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,6 +431,7 @@ public slots:
|
||||||
void cycleCamera();
|
void cycleCamera();
|
||||||
void cameraModeChanged();
|
void cameraModeChanged();
|
||||||
void cameraMenuChanged();
|
void cameraMenuChanged();
|
||||||
|
void captureMouseChanged(bool captureMouse);
|
||||||
void toggleOverlays();
|
void toggleOverlays();
|
||||||
void setOverlaysVisible(bool visible);
|
void setOverlaysVisible(bool visible);
|
||||||
Q_INVOKABLE void centerUI();
|
Q_INVOKABLE void centerUI();
|
||||||
|
@ -603,6 +604,7 @@ private:
|
||||||
|
|
||||||
void maybeToggleMenuVisible(QMouseEvent* event) const;
|
void maybeToggleMenuVisible(QMouseEvent* event) const;
|
||||||
void toggleTabletUI(bool shouldOpen = false) const;
|
void toggleTabletUI(bool shouldOpen = false) const;
|
||||||
|
bool shouldCaptureMouse() const;
|
||||||
|
|
||||||
void userKickConfirmation(const QUuid& nodeID);
|
void userKickConfirmation(const QUuid& nodeID);
|
||||||
|
|
||||||
|
@ -756,7 +758,9 @@ private:
|
||||||
|
|
||||||
bool _settingsLoaded { false };
|
bool _settingsLoaded { false };
|
||||||
|
|
||||||
bool _fakedMouseEvent { false };
|
bool _captureMouse { false };
|
||||||
|
bool _ignoreMouseMove { false };
|
||||||
|
QPointF _mouseCaptureTarget { NAN, NAN };
|
||||||
|
|
||||||
bool _isMissingSequenceNumbers { false };
|
bool _isMissingSequenceNumbers { false };
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@ class FancyCamera : public Camera {
|
||||||
* @property {ViewFrustum} frustum - The camera frustum.
|
* @property {ViewFrustum} frustum - The camera frustum.
|
||||||
* @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
|
* @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
|
||||||
* camera is in entity mode.
|
* camera is in entity mode.
|
||||||
|
* @property {boolean} captureMouse - The mouse capture state. When <code>true</code>, the mouse is invisible and cannot leave the bounds of
|
||||||
|
* Interface, as long as Interface is the active window and no menu item is selected. When <code>false</code>, the mouse
|
||||||
|
* behaves normally.
|
||||||
|
* @property {number} sensitivity - The current camera sensitivity. Must be positive.
|
||||||
*/
|
*/
|
||||||
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
|
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
|
||||||
|
|
||||||
|
|
|
@ -358,6 +358,16 @@ void setupPreferences() {
|
||||||
preference->setItems(items);
|
preference->setItems(items);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
auto getter = [myAvatar]()->float { return qApp->getCamera().getSensitivity(); };
|
||||||
|
auto setter = [myAvatar](float value) { qApp->getCamera().setSensitivity(value); };
|
||||||
|
auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter);
|
||||||
|
preference->setMin(0.01f);
|
||||||
|
preference->setMax(5.0f);
|
||||||
|
preference->setStep(0.1);
|
||||||
|
preference->setDecimals(2);
|
||||||
|
preferences->addPreference(preference);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
auto getter = [myAvatar]()->int { return myAvatar->getControlScheme(); };
|
auto getter = [myAvatar]()->int { return myAvatar->getControlScheme(); };
|
||||||
auto setter = [myAvatar](int index) { myAvatar->setControlScheme(index); };
|
auto setter = [myAvatar](int index) { myAvatar->setControlScheme(index); };
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//
|
//
|
||||||
// Created by Benjamin Arnold on 5/27/14.
|
// Created by Benjamin Arnold on 5/27/14.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -213,7 +214,6 @@ void CompositorHelper::setAllowMouseCapture(bool capture) {
|
||||||
_allowMouseCapture = capture;
|
_allowMouseCapture = capture;
|
||||||
emit allowMouseCaptureChanged();
|
emit allowMouseCaptureChanged();
|
||||||
}
|
}
|
||||||
_allowMouseCapture = capture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositorHelper::handleLeaveEvent() {
|
void CompositorHelper::handleLeaveEvent() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//
|
//
|
||||||
// Created by Bradley Austin Davis Arnold on 2015/06/13
|
// Created by Bradley Austin Davis Arnold on 2015/06/13
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 4/27/15.
|
// Created by Sam Gateau on 4/27/15.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -36,13 +37,12 @@ void KeyboardMouseDevice::pluginUpdate(float deltaTime, const controller::InputC
|
||||||
_inputDevice->_axisStateMap[MOUSE_AXIS_X].value = _lastCursor.x();
|
_inputDevice->_axisStateMap[MOUSE_AXIS_X].value = _lastCursor.x();
|
||||||
_inputDevice->_axisStateMap[MOUSE_AXIS_Y].value = _lastCursor.y();
|
_inputDevice->_axisStateMap[MOUSE_AXIS_Y].value = _lastCursor.y();
|
||||||
|
|
||||||
QPoint currentMove = _lastCursor - _previousCursor;
|
updateDeltaAxisValue(MOUSE_AXIS_X_POS, _accumulatedMove.x() > 0 ? _accumulatedMove.x() : 0.0f);
|
||||||
updateDeltaAxisValue(MOUSE_AXIS_X_POS, currentMove.x() > 0 ? currentMove.x() : 0.0f);
|
updateDeltaAxisValue(MOUSE_AXIS_X_NEG, _accumulatedMove.x() < 0 ? -_accumulatedMove.x() : 0.0f);
|
||||||
updateDeltaAxisValue(MOUSE_AXIS_X_NEG, currentMove.x() < 0 ? -currentMove.x() : 0.0f);
|
|
||||||
// Y mouse is inverted positive is pointing up the screen
|
// Y mouse is inverted positive is pointing up the screen
|
||||||
updateDeltaAxisValue(MOUSE_AXIS_Y_POS, currentMove.y() < 0 ? -currentMove.y() : 0.0f);
|
updateDeltaAxisValue(MOUSE_AXIS_Y_POS, _accumulatedMove.y() < 0 ? -_accumulatedMove.y() : 0.0f);
|
||||||
updateDeltaAxisValue(MOUSE_AXIS_Y_NEG, currentMove.y() > 0 ? currentMove.y() : 0.0f);
|
updateDeltaAxisValue(MOUSE_AXIS_Y_NEG, _accumulatedMove.y() > 0 ? _accumulatedMove.y() : 0.0f);
|
||||||
_previousCursor = _lastCursor;
|
_accumulatedMove = QPoint(0.0f, 0.0f);
|
||||||
});
|
});
|
||||||
|
|
||||||
// For touch event, we need to check that the last event is not too long ago
|
// For touch event, we need to check that the last event is not too long ago
|
||||||
|
@ -113,9 +113,16 @@ void KeyboardMouseDevice::eraseMouseClicked() {
|
||||||
_inputDevice->_buttonPressedMap.erase(_inputDevice->makeInput(Qt::RightButton, true).getChannel());
|
_inputDevice->_buttonPressedMap.erase(_inputDevice->makeInput(Qt::RightButton, true).getChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardMouseDevice::mouseMoveEvent(QMouseEvent* event) {
|
void KeyboardMouseDevice::mouseMoveEvent(QMouseEvent* event, bool capture, QPointF captureTarget) {
|
||||||
QPoint currentPos = event->pos();
|
QPoint currentPos = event->pos();
|
||||||
|
|
||||||
|
if (!capture) {
|
||||||
|
_accumulatedMove += currentPos - _lastCursor;
|
||||||
|
} else if (!isNaN(captureTarget.x())) {
|
||||||
|
QPointF change = event->globalPos() - captureTarget;
|
||||||
|
_accumulatedMove += QPoint(change.x(), change.y());
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME - this has the characteristic that it will show large jumps when you move the cursor
|
// FIXME - this has the characteristic that it will show large jumps when you move the cursor
|
||||||
// outside of the application window, because we don't get MouseEvents when the cursor is outside
|
// outside of the application window, because we don't get MouseEvents when the cursor is outside
|
||||||
// of the application window.
|
// of the application window.
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Sam Gateau on 4/27/15.
|
// Created by Sam Gateau on 4/27/15.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -79,7 +80,7 @@ public:
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void keyReleaseEvent(QKeyEvent* event);
|
void keyReleaseEvent(QKeyEvent* event);
|
||||||
|
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event, bool capture, QPointF captureTarget);
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
void eraseMouseClicked();
|
void eraseMouseClicked();
|
||||||
|
@ -123,7 +124,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPoint _lastCursor;
|
QPoint _lastCursor;
|
||||||
QPoint _previousCursor;
|
QPoint _accumulatedMove;
|
||||||
QPoint _mousePressPos;
|
QPoint _mousePressPos;
|
||||||
quint64 _mousePressTime;
|
quint64 _mousePressTime;
|
||||||
qreal _lastTotalScaleFactor;
|
qreal _lastTotalScaleFactor;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// interface/src
|
// interface/src
|
||||||
//
|
//
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
// Copyright 2020 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -43,6 +44,8 @@ class Camera : public QObject {
|
||||||
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
|
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
|
||||||
Q_PROPERTY(QString mode READ getModeString WRITE setModeString NOTIFY modeUpdated)
|
Q_PROPERTY(QString mode READ getModeString WRITE setModeString NOTIFY modeUpdated)
|
||||||
Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT)
|
Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT)
|
||||||
|
Q_PROPERTY(bool captureMouse READ getCaptureMouse WRITE setCaptureMouse NOTIFY captureMouseChanged)
|
||||||
|
Q_PROPERTY(float sensitivity READ getSensitivity WRITE setSensitivity)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Camera();
|
Camera();
|
||||||
|
@ -110,6 +113,37 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void setOrientation(const glm::quat& orientation);
|
void setOrientation(const glm::quat& orientation);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Gets the current mouse capture state.
|
||||||
|
* @function Camera.getCaptureMouse
|
||||||
|
* @returns {boolean} <code>true</code> if the mouse is captured (is invisible and cannot leave the bounds of Interface,
|
||||||
|
* if Interface is the active window and no menu item is selected), <code>false</code> if the mouse is behaving normally.
|
||||||
|
*/
|
||||||
|
bool getCaptureMouse() const { return _captureMouse; }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Sets the mouse capture state. When <code>true</code>, the mouse is invisible and cannot leave the bounds of
|
||||||
|
* Interface, as long as Interface is the active window and no menu item is selected. When <code>false</code>, the mouse
|
||||||
|
* behaves normally.
|
||||||
|
* @function Camera.setCaptureMouse
|
||||||
|
* @param {boolean} captureMouse - <code>true</code> to capture the mouse, <code>false</code> to release the mouse.
|
||||||
|
*/
|
||||||
|
void setCaptureMouse(bool captureMouse) { _captureMouse = captureMouse; emit captureMouseChanged(captureMouse); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Gets the current camera sensitivity.
|
||||||
|
* @function Camera.getSensitivity
|
||||||
|
* @returns {number} The current camera sensitivity. Must be positive.
|
||||||
|
*/
|
||||||
|
float getSensitivity() const { return _sensitivity; }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Sets the camera sensitivity. Higher values mean that the camera will be more sensitive to mouse movements.
|
||||||
|
* @function Camera.setSensitivity
|
||||||
|
* @param {number} sensitivity - The desired camera sensitivity. Must be positive.
|
||||||
|
*/
|
||||||
|
void setSensitivity(float sensitivity) { _sensitivity = glm::max(0.0f, sensitivity); }
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Computes a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
|
* Computes a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
|
||||||
* screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and
|
* screen. The {@link PickRay} can be used in functions such as {@link Entities.findRayIntersection} and
|
||||||
|
@ -181,6 +215,20 @@ signals:
|
||||||
*/
|
*/
|
||||||
void modeUpdated(const QString& newMode);
|
void modeUpdated(const QString& newMode);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the camera mouse capture state changes.
|
||||||
|
* @function Camera.captureMouseChanged
|
||||||
|
* @param {boolean} newCaptureMouse - The new mouse capture state.
|
||||||
|
* @returns {Signal}
|
||||||
|
* @example <caption>Report mouse capture state changes.</caption>
|
||||||
|
* function onCaptureMouseChanged(newCaptureMouse) {
|
||||||
|
* print("The mouse capture has changed to " + newCaptureMouse);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Camera.captureMouseChanged.connect(onCaptureMouseChanged);
|
||||||
|
*/
|
||||||
|
void captureMouseChanged(bool newCaptureMouse);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recompose();
|
void recompose();
|
||||||
void decompose();
|
void decompose();
|
||||||
|
@ -194,6 +242,9 @@ private:
|
||||||
glm::quat _orientation;
|
glm::quat _orientation;
|
||||||
bool _isKeepLookingAt{ false };
|
bool _isKeepLookingAt{ false };
|
||||||
glm::vec3 _lookingAt;
|
glm::vec3 _lookingAt;
|
||||||
|
|
||||||
|
bool _captureMouse { false };
|
||||||
|
float _sensitivity { 1.0f };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Camera_h
|
#endif // hifi_Camera_h
|
||||||
|
|
Loading…
Reference in a new issue