mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 11:51:26 +02:00
FUUUUUUUCK FINALLY
This commit is contained in:
parent
776b1071a0
commit
5281f89d0d
7 changed files with 61 additions and 130 deletions
interface
libraries
display-plugins/src/display-plugins
input-plugins/src/input-plugins
shared/src/shared
|
@ -3,9 +3,9 @@
|
|||
"channels": [
|
||||
{ "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.E", "when": ["!Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
||||
{ "from": "Keyboard.Q", "when": ["!Application.CameraSelfie", "!Keyboard.Control"], "to": "Actions.LATERAL_LEFT" },
|
||||
{ "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_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.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" },
|
||||
|
||||
|
@ -72,46 +72,20 @@
|
|||
{ "from": { "makeAxis" : [
|
||||
["Keyboard.Left"],
|
||||
["Keyboard.Right"]
|
||||
]
|
||||
]
|
||||
},
|
||||
"when": ["Application.CameraFirstPerson", "!Keyboard.Shift"],
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "!Application.CaptureMouse", "!Keyboard.Shift"],
|
||||
"to": "Actions.Yaw"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : [
|
||||
["Keyboard.Left"],
|
||||
["Keyboard.Right"]
|
||||
]
|
||||
},
|
||||
"when": ["Application.CameraFirstPersonLookat", "!Keyboard.Shift"],
|
||||
"to": "Actions.Yaw"
|
||||
{ "from": "Keyboard.Left",
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Shift"],
|
||||
"to": "Actions.LATERAL_LEFT"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : [
|
||||
["Keyboard.Left"],
|
||||
["Keyboard.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": "Keyboard.Right",
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Shift"],
|
||||
"to": "Actions.LATERAL_RIGHT"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : [
|
||||
|
@ -119,53 +93,18 @@
|
|||
["Keyboard.D"]
|
||||
]
|
||||
},
|
||||
"when": ["Application.CameraFirstPerson", "!Keyboard.Control"],
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "!Application.CaptureMouse", "!Keyboard.Control"],
|
||||
"to": "Actions.Yaw"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : [
|
||||
["Keyboard.A"],
|
||||
["Keyboard.D"]
|
||||
]
|
||||
},
|
||||
"when": ["Application.CameraFirstPersonLookat", "!Keyboard.Control"],
|
||||
"to": "Actions.Yaw"
|
||||
{ "from": "Keyboard.A",
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Control"],
|
||||
"to": "Actions.LATERAL_LEFT"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : [
|
||||
["Keyboard.A"],
|
||||
["Keyboard.D"]
|
||||
]
|
||||
},
|
||||
"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": "Keyboard.D",
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity", "Application.CaptureMouse", "!Keyboard.Control"],
|
||||
"to": "Actions.LATERAL_RIGHT"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : [
|
||||
|
@ -173,39 +112,12 @@
|
|||
["Keyboard.TouchpadRight"]
|
||||
]
|
||||
},
|
||||
"when": "Application.CameraFirstPersonLookat",
|
||||
"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",
|
||||
"when": ["!Application.CameraFSM", "!Application.CameraIndependent", "!Application.CameraEntity"],
|
||||
"to": "Actions.Yaw"
|
||||
},
|
||||
|
||||
{ "from": { "makeAxis" : ["Keyboard.MouseMoveLeft", "Keyboard.MouseMoveRight"] },
|
||||
"when": "Keyboard.RightMouseButton",
|
||||
"when": ["Keyboard.RightMouseButton", "!Application.CaptureMouse"],
|
||||
"to": "Actions.DeltaYaw",
|
||||
"filters":
|
||||
[
|
||||
|
@ -223,7 +135,7 @@
|
|||
},
|
||||
|
||||
{ "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",
|
||||
"filters":
|
||||
[
|
||||
|
|
|
@ -4699,6 +4699,11 @@ void Application::maybeToggleMenuVisible(QMouseEvent* event) const {
|
|||
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||
PROFILE_RANGE(app_input_mouse, __FUNCTION__);
|
||||
|
||||
if (_ignoreMouseMove) {
|
||||
_ignoreMouseMove = false;
|
||||
return;
|
||||
}
|
||||
|
||||
maybeToggleMenuVisible(event);
|
||||
|
||||
auto& compositor = getApplicationCompositor();
|
||||
|
@ -4744,7 +4749,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
|||
}
|
||||
|
||||
if (_keyboardMouseDevice->isActive()) {
|
||||
_keyboardMouseDevice->mouseMoveEvent(event);
|
||||
_keyboardMouseDevice->mouseMoveEvent(event, _captureMouse, _mouseCaptureTarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5916,15 +5921,13 @@ void Application::cameraModeChanged() {
|
|||
cameraMenuChanged();
|
||||
}
|
||||
|
||||
void Application::captureMouseChanged() {
|
||||
if (_myCamera.getCaptureMouse()) {
|
||||
// we want to grab the mouse here so that no other widgets get events, and also hide the mouse, but these don't work:
|
||||
//_glWidget->grabMouse();
|
||||
//QCursor::setShape(Qt::CursorShape::BlankCursor);
|
||||
void Application::captureMouseChanged(bool captureMouse) {
|
||||
_captureMouse = captureMouse;
|
||||
if (_captureMouse) {
|
||||
_glWidget->setCursor(QCursor(Qt::BlankCursor));
|
||||
} else {
|
||||
// we want to release the mouse here so that other widgets get events, and also show the mouse, but these don't work:
|
||||
//_glWidget->releaseMouse();
|
||||
//QCursor::setShape(Qt::CursorShape::ArrowCursor);
|
||||
_mouseCaptureTarget = QPointF(NAN, NAN);
|
||||
_glWidget->unsetCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6278,6 +6281,15 @@ void Application::update(float deltaTime) {
|
|||
PROFILE_ASYNC_END(app, "Scene Loading", "");
|
||||
}
|
||||
|
||||
if (_captureMouse) {
|
||||
QPoint point = _glWidget->mapToGlobal(_glWidget->geometry().center());
|
||||
if (QCursor::pos() != point) {
|
||||
_mouseCaptureTarget = point;
|
||||
_ignoreMouseMove = true;
|
||||
QCursor::setPos(point);
|
||||
}
|
||||
}
|
||||
|
||||
auto myAvatar = getMyAvatar();
|
||||
{
|
||||
PerformanceTimer perfTimer("devices");
|
||||
|
|
|
@ -430,7 +430,7 @@ public slots:
|
|||
void cycleCamera();
|
||||
void cameraModeChanged();
|
||||
void cameraMenuChanged();
|
||||
void captureMouseChanged();
|
||||
void captureMouseChanged(bool captureMouse);
|
||||
void toggleOverlays();
|
||||
void setOverlaysVisible(bool visible);
|
||||
Q_INVOKABLE void centerUI();
|
||||
|
@ -756,7 +756,9 @@ private:
|
|||
|
||||
bool _settingsLoaded { false };
|
||||
|
||||
bool _fakedMouseEvent { false };
|
||||
bool _captureMouse { false };
|
||||
bool _ignoreMouseMove { false };
|
||||
QPointF _mouseCaptureTarget { NAN, NAN };
|
||||
|
||||
bool _isMissingSequenceNumbers { false };
|
||||
|
||||
|
|
|
@ -213,7 +213,6 @@ void CompositorHelper::setAllowMouseCapture(bool capture) {
|
|||
_allowMouseCapture = capture;
|
||||
emit allowMouseCaptureChanged();
|
||||
}
|
||||
_allowMouseCapture = capture;
|
||||
}
|
||||
|
||||
void CompositorHelper::handleLeaveEvent() {
|
||||
|
|
|
@ -36,13 +36,12 @@ void KeyboardMouseDevice::pluginUpdate(float deltaTime, const controller::InputC
|
|||
_inputDevice->_axisStateMap[MOUSE_AXIS_X].value = _lastCursor.x();
|
||||
_inputDevice->_axisStateMap[MOUSE_AXIS_Y].value = _lastCursor.y();
|
||||
|
||||
QPoint currentMove = _lastCursor - _previousCursor;
|
||||
updateDeltaAxisValue(MOUSE_AXIS_X_POS, currentMove.x() > 0 ? currentMove.x() : 0.0f);
|
||||
updateDeltaAxisValue(MOUSE_AXIS_X_NEG, currentMove.x() < 0 ? -currentMove.x() : 0.0f);
|
||||
updateDeltaAxisValue(MOUSE_AXIS_X_POS, _accumulatedMove.x() > 0 ? _accumulatedMove.x() : 0.0f);
|
||||
updateDeltaAxisValue(MOUSE_AXIS_X_NEG, _accumulatedMove.x() < 0 ? -_accumulatedMove.x() : 0.0f);
|
||||
// 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_NEG, currentMove.y() > 0 ? currentMove.y() : 0.0f);
|
||||
_previousCursor = _lastCursor;
|
||||
updateDeltaAxisValue(MOUSE_AXIS_Y_POS, _accumulatedMove.y() < 0 ? -_accumulatedMove.y() : 0.0f);
|
||||
updateDeltaAxisValue(MOUSE_AXIS_Y_NEG, _accumulatedMove.y() > 0 ? _accumulatedMove.y() : 0.0f);
|
||||
_accumulatedMove = QPoint(0.0f, 0.0f);
|
||||
});
|
||||
|
||||
// For touch event, we need to check that the last event is not too long ago
|
||||
|
@ -113,9 +112,16 @@ void KeyboardMouseDevice::eraseMouseClicked() {
|
|||
_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();
|
||||
|
||||
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
|
||||
// outside of the application window, because we don't get MouseEvents when the cursor is outside
|
||||
// of the application window.
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event, bool capture, QPointF captureTarget);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
void eraseMouseClicked();
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
|
||||
protected:
|
||||
QPoint _lastCursor;
|
||||
QPoint _previousCursor;
|
||||
QPoint _accumulatedMove;
|
||||
QPoint _mousePressPos;
|
||||
quint64 _mousePressTime;
|
||||
qreal _lastTotalScaleFactor;
|
||||
|
|
|
@ -123,7 +123,7 @@ public slots:
|
|||
* @function Camera.setCaptureMouse
|
||||
* @param {boolean} captureMouse - Whether or not to capture the mouse.
|
||||
*/
|
||||
void setCaptureMouse(bool captureMouse) { _captureMouse = captureMouse; }
|
||||
void setCaptureMouse(bool captureMouse) { _captureMouse = captureMouse; emit captureMouseUpdated(captureMouse); }
|
||||
|
||||
/**jsdoc
|
||||
* Computes a {@link PickRay} based on the current camera configuration and the specified <code>x, y</code> position on the
|
||||
|
|
Loading…
Reference in a new issue