2020-03-05 06:47:24 +00:00
|
|
|
#include "headset/headset.h"
|
|
|
|
|
2023-07-09 20:12:01 +00:00
|
|
|
extern bool webxr_init(HeadsetConfig* config);
|
2021-06-10 23:26:15 +00:00
|
|
|
extern void webxr_start(void);
|
2020-03-05 06:47:24 +00:00
|
|
|
extern void webxr_destroy(void);
|
2023-07-11 02:35:21 +00:00
|
|
|
extern bool webxr_getDriverName(char* name, size_t length);
|
2020-03-05 06:47:24 +00:00
|
|
|
extern bool webxr_getName(char* name, size_t length);
|
Replace HeadsetOrigin with 'seated' flag;
Origin type used to be a query-able property of the VR system that
indicated whether the tracking was roomscale or seated-scale.
The t.headset.offset config value could be used to design an
origin-agnostic experience, which by default shifted content up 1.7
meters when tracking was seated-scale. That way, stuff rendered at
y=1.7m was always at "eye level". It worked pretty well.
It's getting replaced with a t.headset.seated flag.
- If seated is false (the default), the origin of the coordinate space
will be on the floor, enabling the y=1.7m eye level paradigm. If
tracking is not roomscale, a floor offset of 1.7m will be emulated.
- If seated is true, the origin of the coordinate space will be y=0
at eye level (where the headset was when the app started). This is
the case on both roomscale and seated-scale tracking.
So basically 'seated' is an opt-in preference for where the app wants
its vertical origin to be.
One advantage of this is that it's possible to consistently get a y=0
eye level coordinate space, which was not possible before. This makes
it easier to design simpler experiences that only need to render a
floating UI and don't want to render a full environment or deal with
offsetting everything relative to a 'floor'. This also makes it easier
to implement hybrid VR+flatscreen experiences, because the camera is at
y=0 when the headset module is disabled.
The opt-in nature of the flag, coupled with the fact that it is
consistent across all types of tracking and hardware, is hopefully a
more useful design.
2023-06-28 23:38:36 +00:00
|
|
|
extern bool webxr_isSeated(void);
|
2023-02-06 03:51:12 +00:00
|
|
|
extern void webxr_getDisplayDimensions(uint32_t* width, uint32_t* height);
|
2020-03-05 06:47:24 +00:00
|
|
|
extern double webxr_getDisplayTime(void);
|
2022-03-23 00:52:16 +00:00
|
|
|
extern double webxr_getDeltaTime(void);
|
2020-03-05 06:47:24 +00:00
|
|
|
extern uint32_t webxr_getViewCount(void);
|
|
|
|
extern bool webxr_getViewPose(uint32_t view, float* position, float* orientation);
|
|
|
|
extern bool webxr_getViewAngles(uint32_t view, float* left, float* right, float* up, float* down);
|
|
|
|
extern void webxr_getClipDistance(float* near, float* far);
|
|
|
|
extern void webxr_setClipDistance(float near, float far);
|
|
|
|
extern void webxr_getBoundsDimensions(float* width, float* depth);
|
|
|
|
extern const float* webxr_getBoundsGeometry(uint32_t* count);
|
|
|
|
extern bool webxr_getPose(Device device, float* position, float* orientation);
|
|
|
|
extern bool webxr_getVelocity(Device device, float* velocity, float* angularVelocity);
|
|
|
|
extern bool webxr_isDown(Device device, DeviceButton button, bool* down, bool* changed);
|
|
|
|
extern bool webxr_isTouched(Device device, DeviceButton button, bool* touched);
|
|
|
|
extern bool webxr_getAxis(Device device, DeviceAxis axis, float* value);
|
2020-08-20 19:23:00 +00:00
|
|
|
extern bool webxr_getSkeleton(Device device, float* poses);
|
2020-03-05 06:47:24 +00:00
|
|
|
extern bool webxr_vibrate(Device device, float strength, float duration, float frequency);
|
2023-06-28 03:45:44 +00:00
|
|
|
extern void webxr_stopVibration(Device device);
|
2020-08-02 23:25:51 +00:00
|
|
|
extern struct ModelData* webxr_newModelData(Device device, bool animated);
|
2022-11-19 15:26:44 +00:00
|
|
|
extern bool webxr_animate(struct Model* model);
|
2020-03-05 06:47:24 +00:00
|
|
|
extern void webxr_renderTo(void (*callback)(void*), void* userdata);
|
2022-03-23 02:43:00 +00:00
|
|
|
extern bool webxr_isFocused(void);
|
2023-02-06 03:51:12 +00:00
|
|
|
extern bool webxr_isPassthroughEnabled(void);
|
|
|
|
extern bool webxr_setPassthroughEnabled(bool enable);
|
2022-03-23 00:52:16 +00:00
|
|
|
extern double webxr_update(void);
|
2020-03-05 06:47:24 +00:00
|
|
|
|
2020-08-21 10:37:38 +00:00
|
|
|
static bool webxrAttached = false;
|
|
|
|
static HeadsetInterface* previousHeadsetDriver;
|
2020-08-20 19:23:00 +00:00
|
|
|
|
2023-04-26 04:45:30 +00:00
|
|
|
void webxr_attach(void) {
|
2022-03-23 20:11:16 +00:00
|
|
|
if (webxrAttached || lovrHeadsetInterface == &lovrHeadsetWebXRDriver) {
|
2020-08-20 19:23:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-23 20:11:16 +00:00
|
|
|
previousHeadsetDriver = lovrHeadsetInterface;
|
|
|
|
lovrHeadsetInterface = &lovrHeadsetWebXRDriver;
|
2020-08-20 19:23:00 +00:00
|
|
|
webxrAttached = true;
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:45:30 +00:00
|
|
|
void webxr_detach(void) {
|
2020-08-20 19:23:00 +00:00
|
|
|
if (!webxrAttached) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-23 20:11:16 +00:00
|
|
|
lovrHeadsetInterface = previousHeadsetDriver;
|
2020-08-21 10:37:38 +00:00
|
|
|
previousHeadsetDriver = NULL;
|
2020-08-20 19:23:00 +00:00
|
|
|
webxrAttached = false;
|
|
|
|
}
|
|
|
|
|
2020-03-05 06:47:24 +00:00
|
|
|
HeadsetInterface lovrHeadsetWebXRDriver = {
|
2020-08-16 06:31:20 +00:00
|
|
|
.driverType = DRIVER_WEBXR,
|
2020-03-05 06:47:24 +00:00
|
|
|
.init = webxr_init,
|
2021-06-10 23:26:15 +00:00
|
|
|
.start = webxr_start,
|
2020-03-05 06:47:24 +00:00
|
|
|
.destroy = webxr_destroy,
|
2023-07-11 02:35:21 +00:00
|
|
|
.getDriverName = webxr_getDriverName,
|
2020-03-05 06:47:24 +00:00
|
|
|
.getName = webxr_getName,
|
Replace HeadsetOrigin with 'seated' flag;
Origin type used to be a query-able property of the VR system that
indicated whether the tracking was roomscale or seated-scale.
The t.headset.offset config value could be used to design an
origin-agnostic experience, which by default shifted content up 1.7
meters when tracking was seated-scale. That way, stuff rendered at
y=1.7m was always at "eye level". It worked pretty well.
It's getting replaced with a t.headset.seated flag.
- If seated is false (the default), the origin of the coordinate space
will be on the floor, enabling the y=1.7m eye level paradigm. If
tracking is not roomscale, a floor offset of 1.7m will be emulated.
- If seated is true, the origin of the coordinate space will be y=0
at eye level (where the headset was when the app started). This is
the case on both roomscale and seated-scale tracking.
So basically 'seated' is an opt-in preference for where the app wants
its vertical origin to be.
One advantage of this is that it's possible to consistently get a y=0
eye level coordinate space, which was not possible before. This makes
it easier to design simpler experiences that only need to render a
floating UI and don't want to render a full environment or deal with
offsetting everything relative to a 'floor'. This also makes it easier
to implement hybrid VR+flatscreen experiences, because the camera is at
y=0 when the headset module is disabled.
The opt-in nature of the flag, coupled with the fact that it is
consistent across all types of tracking and hardware, is hopefully a
more useful design.
2023-06-28 23:38:36 +00:00
|
|
|
.isSeated = webxr_isSeated,
|
2020-03-05 06:47:24 +00:00
|
|
|
.getDisplayTime = webxr_getDisplayTime,
|
|
|
|
.getDisplayDimensions = webxr_getDisplayDimensions,
|
|
|
|
.getViewCount = webxr_getViewCount,
|
|
|
|
.getViewPose = webxr_getViewPose,
|
|
|
|
.getViewAngles = webxr_getViewAngles,
|
|
|
|
.getClipDistance = webxr_getClipDistance,
|
|
|
|
.setClipDistance = webxr_setClipDistance,
|
|
|
|
.getBoundsDimensions = webxr_getBoundsDimensions,
|
|
|
|
.getBoundsGeometry = webxr_getBoundsGeometry,
|
|
|
|
.getPose = webxr_getPose,
|
|
|
|
.getVelocity = webxr_getVelocity,
|
|
|
|
.isDown = webxr_isDown,
|
|
|
|
.isTouched = webxr_isTouched,
|
|
|
|
.getAxis = webxr_getAxis,
|
2020-08-20 19:23:00 +00:00
|
|
|
.getSkeleton = webxr_getSkeleton,
|
2020-03-05 06:47:24 +00:00
|
|
|
.vibrate = webxr_vibrate,
|
2023-06-28 03:45:44 +00:00
|
|
|
.stopVibration = webxr_stopVibration,
|
2020-03-05 06:47:24 +00:00
|
|
|
.newModelData = webxr_newModelData,
|
2020-08-02 23:25:51 +00:00
|
|
|
.animate = webxr_animate,
|
2022-03-23 02:43:00 +00:00
|
|
|
.isFocused = webxr_isFocused,
|
2020-03-05 06:47:24 +00:00
|
|
|
.update = webxr_update
|
|
|
|
};
|