mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:23:39 +02:00
better check for oculus display in oculus legacy plugin because the sdk is buggy
This commit is contained in:
parent
a48cce2975
commit
284fcc8a0b
1 changed files with 32 additions and 3 deletions
|
@ -66,17 +66,46 @@ bool OculusLegacyDisplayPlugin::isSupported() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hmd = ovrHmd_Create(0);
|
auto hmd = ovrHmd_Create(0);
|
||||||
|
|
||||||
|
// The Oculus SDK seems to have trouble finding the right screen sometimes, so we have to guess
|
||||||
|
// Guesses, in order of best match:
|
||||||
|
// - resolution and position match
|
||||||
|
// - resolution and one component of position match
|
||||||
|
// - resolution matches
|
||||||
|
// - position matches
|
||||||
|
QList<int> matches({ -1, -1, -1, -1 });
|
||||||
if (hmd) {
|
if (hmd) {
|
||||||
QPoint targetPosition{ hmd->WindowsPos.x, hmd->WindowsPos.y };
|
QPoint targetPosition{ hmd->WindowsPos.x, hmd->WindowsPos.y };
|
||||||
|
QSize targetResolution{ hmd->Resolution.w, hmd->Resolution.h };
|
||||||
auto screens = qApp->screens();
|
auto screens = qApp->screens();
|
||||||
for(int i = 0; i < screens.size(); ++i) {
|
for(int i = 0; i < screens.size(); ++i) {
|
||||||
auto screen = screens[i];
|
auto screen = screens[i];
|
||||||
QPoint position = screen->geometry().topLeft();
|
QPoint position = screen->geometry().topLeft();
|
||||||
if (position == targetPosition) {
|
QSize resolution = screen->geometry().size();
|
||||||
_hmdScreen = i;
|
|
||||||
|
if (position == targetPosition && resolution == targetResolution) {
|
||||||
|
matches[0] = i;
|
||||||
|
} else if ((position.x() == targetPosition.x() || position.y() == targetPosition.y()) &&
|
||||||
|
resolution == targetResolution) {
|
||||||
|
matches[1] = i;
|
||||||
|
} else if (resolution == targetResolution) {
|
||||||
|
matches[2] = i;
|
||||||
|
} else if (position == targetPosition) {
|
||||||
|
matches[3] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int screen : matches) {
|
||||||
|
if (screen != -1) {
|
||||||
|
_hmdScreen = screen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_hmdScreen == -1) {
|
||||||
|
qDebug() << "Could not find Rift screen";
|
||||||
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ovr_Shutdown();
|
ovr_Shutdown();
|
||||||
|
|
Loading…
Reference in a new issue