cmake: change project c++-lang to c++20

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2258>
This commit is contained in:
Korcan Hussein 2024-06-25 17:59:21 +01:00
parent 3139079aaa
commit 1e67a27326
3 changed files with 37 additions and 21 deletions

View file

@ -46,7 +46,7 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# We use C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# So that clangd/Intellisense/Sourcetrail know how to parse our code.

View file

@ -25,11 +25,19 @@ struct InputClass;
struct DeviceBuilder
{
std::shared_ptr<Context> ctx;
using ContextPtr = std::shared_ptr<Context>;
ContextPtr ctx;
vr::ITrackedDeviceServerDriver *driver;
const char *serial;
const std::string &steam_install;
DeviceBuilder(const ContextPtr &p_ctx,
vr::ITrackedDeviceServerDriver *p_driver,
const char *p_serial,
const std::string &p_stream_install)
: ctx{p_ctx}, driver{p_driver}, serial{p_serial}, steam_install{p_stream_install}
{}
// no copies!
DeviceBuilder(const DeviceBuilder &) = delete;
DeviceBuilder

View file

@ -1249,15 +1249,15 @@ CDeviceDriver_Monado::DebugRequest(const char *pchRequest, char *pchResponseBuff
//! @todo
}
static inline vr::HmdQuaternion_t
static constexpr inline vr::HmdQuaternion_t
HmdQuaternion_Init(double w, double x, double y, double z)
{
vr::HmdQuaternion_t quat;
quat.w = w;
quat.x = x;
quat.y = y;
quat.z = z;
return quat;
return vr::HmdQuaternion_t{
.w = w,
.x = x,
.y = y,
.z = z,
};
}
vr::DriverPose_t
@ -1275,23 +1275,31 @@ CDeviceDriver_Monado::GetPose()
m_relation_chain_push_pose_if_not_identity(&chain, offset);
m_relation_chain_resolve(&chain, &rel);
vr::DriverPose_t t = {};
vr::DriverPose_t t = {
// monado predicts pose "now", see xrt_device_get_tracked_pose
t.poseTimeOffset = 0;
.poseTimeOffset = 0,
.qWorldFromDriverRotation = HmdQuaternion_Init(1, 0, 0, 0),
.vecWorldFromDriverTranslation = {0, 0, 0},
.qDriverFromHeadRotation = HmdQuaternion_Init(1, 0, 0, 0),
.vecDriverFromHeadTranslation = {0, 0, 0},
.vecPosition = {0, 0, 0},
.vecVelocity = {0, 0, 0},
.vecAcceleration = {0, 0, 0},
.qRotation = HmdQuaternion_Init(1, 0, 0, 0),
.vecAngularVelocity = {0, 0, 0},
.vecAngularAcceleration = {0, 0, 0},
.result = vr::TrackingResult_Running_OK,
.poseIsValid = (rel.relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0,
.willDriftInYaw = !m_xdev->position_tracking_supported,
//! @todo: Monado head model?
t.shouldApplyHeadModel = !m_xdev->position_tracking_supported;
t.willDriftInYaw = !m_xdev->position_tracking_supported;
t.qWorldFromDriverRotation = HmdQuaternion_Init(1, 0, 0, 0);
t.qDriverFromHeadRotation = HmdQuaternion_Init(1, 0, 0, 0);
t.poseIsValid = rel.relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
t.result = vr::TrackingResult_Running_OK;
t.deviceIsConnected = true;
.shouldApplyHeadModel = !m_xdev->position_tracking_supported,
.deviceIsConnected = true,
};
apply_pose(&rel, &t);
#ifdef DUMP_POSE