mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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,18 +66,47 @@ bool OculusLegacyDisplayPlugin::isSupported() const {
|
|||
}
|
||||
|
||||
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) {
|
||||
QPoint targetPosition{ hmd->WindowsPos.x, hmd->WindowsPos.y };
|
||||
QSize targetResolution{ hmd->Resolution.w, hmd->Resolution.h };
|
||||
auto screens = qApp->screens();
|
||||
for(int i = 0; i < screens.size(); ++i) {
|
||||
auto screen = screens[i];
|
||||
QPoint position = screen->geometry().topLeft();
|
||||
if (position == targetPosition) {
|
||||
_hmdScreen = i;
|
||||
break;
|
||||
QSize resolution = screen->geometry().size();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (_hmdScreen == -1) {
|
||||
qDebug() << "Could not find Rift screen";
|
||||
result = false;
|
||||
}
|
||||
|
||||
ovr_Shutdown();
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue