lovr/src/headset/headset.h

92 lines
2.5 KiB
C
Raw Normal View History

2017-03-11 10:19:33 +00:00
#include "lib/vec/vec.h"
2019-04-05 12:08:03 +00:00
#include "types.h"
2017-10-31 08:14:09 +00:00
#include <stdbool.h>
2019-04-05 12:08:03 +00:00
#include <stdint.h>
2016-12-01 04:32:14 +00:00
2017-01-26 10:20:30 +00:00
#pragma once
2016-11-15 00:20:56 +00:00
2019-04-05 12:08:03 +00:00
struct ModelData;
struct Texture;
2017-08-04 05:21:49 +00:00
typedef enum {
ORIGIN_HEAD,
ORIGIN_FLOOR
} HeadsetOrigin;
typedef enum {
2019-03-07 07:02:03 +00:00
DRIVER_DESKTOP,
DRIVER_OCULUS,
DRIVER_OCULUS_MOBILE,
DRIVER_OPENVR,
DRIVER_WEBVR
} HeadsetDriver;
typedef enum {
2019-04-07 11:08:32 +00:00
P_NONE,
P_HEAD,
P_HAND,
2019-04-07 11:09:16 +00:00
P_EYE,
2019-04-07 11:08:32 +00:00
P_LEFT,
P_RIGHT,
P_PROXIMITY,
P_TRIGGER,
P_TRACKPAD,
2019-04-07 13:29:38 +00:00
P_JOYSTICK,
2019-04-07 11:08:32 +00:00
P_MENU,
P_GRIP,
P_A,
P_B,
P_X,
P_Y
} Subpath;
typedef union {
2019-04-07 13:29:38 +00:00
uint8_t p[8];
uint64_t u64;
} Path;
#define MAKE_PATH(...) ((Path) { { __VA_ARGS__ } })
#define PATH_EQ(p, ...) ((p).u64 == MAKE_PATH(__VA_ARGS__).u64)
#define PATH_STARTS_WITH(p, ...) ((MAKE_PATH(__VA_ARGS__).u64 ^ p.u64 & MAKE_PATH(__VA_ARGS__).u64) == 0)
typedef struct HeadsetInterface {
struct HeadsetInterface* next;
HeadsetDriver driverType;
bool (*init)(float offset, int msaa);
2019-02-17 22:39:51 +00:00
void (*destroy)(void);
2019-04-06 22:09:20 +00:00
const char* (*getName)(void);
2019-02-17 22:39:51 +00:00
HeadsetOrigin (*getOriginType)(void);
void (*getDisplayDimensions)(uint32_t* width, uint32_t* height);
void (*getClipDistance)(float* clipNear, float* clipFar);
void (*setClipDistance)(float clipNear, float clipFar);
2018-04-29 21:38:08 +00:00
void (*getBoundsDimensions)(float* width, float* depth);
const float* (*getBoundsGeometry)(int* count);
2019-03-20 13:15:23 +00:00
bool (*getPose)(Path path, float* x, float* y, float* z, float* angle, float* ax, float* ay, float* az);
bool (*getVelocity)(Path path, float* vx, float* vy, float* vz, float* vax, float* vay, float* vaz);
bool (*isDown)(Path path, bool* down);
bool (*isTouched)(Path path, bool* touched);
int (*getAxis)(Path path, float* x, float* y, float* z);
bool (*vibrate)(Path path, float strength, float duration, float frequency);
2019-04-03 04:28:41 +00:00
struct ModelData* (*newModelData)(Path path);
2018-03-11 07:42:33 +00:00
void (*renderTo)(void (*callback)(void*), void* userdata);
2019-04-05 12:08:03 +00:00
struct Texture* (*getMirrorTexture)(void);
void (*update)(float dt);
2017-10-22 23:44:26 +00:00
} HeadsetInterface;
2018-04-28 23:59:53 +00:00
// Available drivers
extern HeadsetInterface lovrHeadsetOculusDriver;
2017-10-22 23:44:26 +00:00
extern HeadsetInterface lovrHeadsetOpenVRDriver;
2017-11-23 22:19:20 +00:00
extern HeadsetInterface lovrHeadsetWebVRDriver;
2019-03-07 07:02:03 +00:00
extern HeadsetInterface lovrHeadsetDesktopDriver;
extern HeadsetInterface lovrHeadsetOculusMobileDriver;
// Active drivers
2018-04-28 23:59:53 +00:00
extern HeadsetInterface* lovrHeadsetDriver;
extern HeadsetInterface* lovrHeadsetTrackingDrivers;
#define FOREACH_TRACKING_DRIVER(i)\
for (HeadsetInterface* i = lovrHeadsetTrackingDrivers; i != NULL; i = i->next)
2016-12-01 07:03:58 +00:00
bool lovrHeadsetInit(HeadsetDriver* drivers, int count, float offset, int msaa);
2019-02-17 22:39:51 +00:00
void lovrHeadsetDestroy(void);