mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-11-20 09:01:39 -08:00
Controller bindings have been moved to the new logic. Recommended view sizes are now overriden as recommendation is based on the integrated GPU while for streaming headsets can usually do much better.
104 lines
3.1 KiB
C++
104 lines
3.1 KiB
C++
/*
|
|
* WiVRn VR streaming
|
|
* Copyright (C) 2023 Guillaume Meunier <[email protected]>
|
|
* Copyright (C) 2023 Patrick Nicolas <[email protected]>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "hardware.h"
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
#include <spdlog/spdlog.h>
|
|
|
|
#ifdef XR_USE_PLATFORM_ANDROID
|
|
#include "utils/wrap_lambda.h"
|
|
|
|
#include <sys/system_properties.h>
|
|
|
|
static std::string get_property(const char * property)
|
|
{
|
|
auto info = __system_property_find(property);
|
|
std::string result;
|
|
wrap_lambda cb = [&result](const char * name, const char * value, uint32_t serial) {
|
|
result = value;
|
|
};
|
|
|
|
__system_property_read_callback(info, cb.userdata_first(), cb);
|
|
return result;
|
|
}
|
|
#endif
|
|
|
|
model guess_model()
|
|
{
|
|
#ifdef XR_USE_PLATFORM_ANDROID
|
|
const auto device = get_property("ro.product.device");
|
|
if (device == "monterey")
|
|
return model::oculus_quest;
|
|
if (device == "hollywood")
|
|
return model::oculus_quest_2;
|
|
|
|
const auto manufacturer = get_property("ro.product.manufacturer");
|
|
const auto model = get_property("ro.product.model");
|
|
if (manufacturer == "Pico")
|
|
{
|
|
if (model == "Pico Neo 3")
|
|
return model::pico_neo_3;
|
|
|
|
spdlog::info("manufacturer={}, model={}, device={} assuming Pico 4", manufacturer, model, device);
|
|
return model::pico_4;
|
|
}
|
|
|
|
spdlog::info("Unknown model, manufacturer={}, model={}, device={}", manufacturer, model, device);
|
|
#endif
|
|
return model::unknown;
|
|
}
|
|
|
|
XrViewConfigurationView override_view(XrViewConfigurationView view, model m)
|
|
{
|
|
// Standalone headsets tend to report a lower resolution
|
|
// as the GPU can't handle full res.
|
|
// Return the panel resolution instead.
|
|
switch (m)
|
|
{
|
|
case model::oculus_quest:
|
|
spdlog::info("Using panel resolution 1440x1600 for Quest");
|
|
view.recommendedImageRectWidth = 1440;
|
|
view.recommendedImageRectHeight = 1600;
|
|
return view;
|
|
case model::oculus_quest_2:
|
|
spdlog::info("Using panel resolution 1832x1920 for Quest 2");
|
|
view.recommendedImageRectWidth = 1832;
|
|
view.recommendedImageRectHeight = 1920;
|
|
return view;
|
|
case model::meta_quest_3:
|
|
spdlog::info("Using panel resolution 2064x2208 for Quest 3");
|
|
view.recommendedImageRectWidth = 2064;
|
|
view.recommendedImageRectHeight = 2208;
|
|
return view;
|
|
case model::pico_neo_3:
|
|
return view;
|
|
case model::pico_4:
|
|
spdlog::info("Using panel resolution 2160x2160 for Pico 4");
|
|
view.recommendedImageRectWidth = 2160;
|
|
view.recommendedImageRectHeight = 2160;
|
|
return view;
|
|
case model::unknown:
|
|
return view;
|
|
}
|
|
throw std::range_error("invalid model " + std::to_string((int)m));
|
|
}
|