|
@@ -26,6 +26,8 @@ ohmd_context* OHMD_APIENTRY ohmd_ctx_create(void)
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ohmd_monotonic_init(ctx);
|
|
|
|
+
|
|
#if DRIVER_OCULUS_RIFT
|
|
#if DRIVER_OCULUS_RIFT
|
|
ctx->drivers[ctx->num_drivers++] = ohmd_create_oculus_rift_drv(ctx);
|
|
ctx->drivers[ctx->num_drivers++] = ohmd_create_oculus_rift_drv(ctx);
|
|
#endif
|
|
#endif
|
|
@@ -578,3 +580,22 @@ void ohmd_set_universal_aberration_k(ohmd_device_properties* props, float r, flo
|
|
props->universal_aberration_k[1] = g;
|
|
props->universal_aberration_k[1] = g;
|
|
props->universal_aberration_k[2] = b;
|
|
props->universal_aberration_k[2] = b;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+uint64_t ohmd_monotonic_per_sec(ohmd_context* ctx)
|
|
|
|
+{
|
|
|
|
+ return ctx->monotonic_ticks_per_sec;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Grabbed from druntime, good thing its BOOST v1.0 as well.
|
|
|
|
+ */
|
|
|
|
+uint64_t ohmd_monotonic_conv(uint64_t ticks, uint64_t srcTicksPerSecond, uint64_t dstTicksPerSecond)
|
|
|
|
+{
|
|
|
|
+ // This would be more straightforward with floating point arithmetic,
|
|
|
|
+ // but we avoid it here in order to avoid the rounding errors that that
|
|
|
|
+ // introduces. Also, by splitting out the units in this way, we're able
|
|
|
|
+ // to deal with much larger values before running into problems with
|
|
|
|
+ // integer overflow.
|
|
|
|
+ return ticks / srcTicksPerSecond * dstTicksPerSecond +
|
|
|
|
+ ticks % srcTicksPerSecond * dstTicksPerSecond / srcTicksPerSecond;
|
|
|
|
+}
|