2018-02-11 23:22:04 +00:00
|
|
|
#include "data/modelData.h"
|
2017-03-11 10:19:33 +00:00
|
|
|
#include "lib/vec/vec.h"
|
2016-12-01 07:03:58 +00:00
|
|
|
#include "util.h"
|
2017-10-31 08:14:09 +00:00
|
|
|
#include <stdbool.h>
|
2019-01-25 20:08:45 +00:00
|
|
|
#include "graphics/texture.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
|
|
|
|
2017-01-23 05:20:34 +00:00
|
|
|
typedef enum {
|
2018-09-29 21:15:53 +00:00
|
|
|
EYE_BOTH = -1,
|
2017-01-23 05:20:34 +00:00
|
|
|
EYE_LEFT,
|
|
|
|
EYE_RIGHT
|
|
|
|
} HeadsetEye;
|
|
|
|
|
2017-08-04 05:21:49 +00:00
|
|
|
typedef enum {
|
|
|
|
ORIGIN_HEAD,
|
|
|
|
ORIGIN_FLOOR
|
|
|
|
} HeadsetOrigin;
|
|
|
|
|
2017-11-25 21:01:56 +00:00
|
|
|
typedef enum {
|
|
|
|
DRIVER_FAKE,
|
2018-09-09 17:58:20 +00:00
|
|
|
DRIVER_OCULUS,
|
2018-10-25 03:40:11 +00:00
|
|
|
DRIVER_OCULUS_MOBILE,
|
2017-11-25 21:01:56 +00:00
|
|
|
DRIVER_OPENVR,
|
2018-10-25 03:40:11 +00:00
|
|
|
DRIVER_WEBVR
|
2017-11-25 21:01:56 +00:00
|
|
|
} HeadsetDriver;
|
|
|
|
|
2017-08-13 04:35:01 +00:00
|
|
|
typedef enum {
|
|
|
|
HEADSET_UNKNOWN,
|
|
|
|
HEADSET_VIVE,
|
2017-10-12 00:14:51 +00:00
|
|
|
HEADSET_RIFT,
|
2018-11-07 19:34:51 +00:00
|
|
|
HEADSET_GEAR,
|
|
|
|
HEADSET_GO,
|
2017-12-30 20:21:51 +00:00
|
|
|
HEADSET_WINDOWS_MR,
|
2017-10-12 00:14:51 +00:00
|
|
|
HEADSET_FAKE
|
2017-08-13 04:35:01 +00:00
|
|
|
} HeadsetType;
|
|
|
|
|
2016-11-15 00:20:56 +00:00
|
|
|
typedef enum {
|
|
|
|
CONTROLLER_AXIS_TRIGGER,
|
2017-08-13 05:58:59 +00:00
|
|
|
CONTROLLER_AXIS_GRIP,
|
2016-11-15 00:20:56 +00:00
|
|
|
CONTROLLER_AXIS_TOUCHPAD_X,
|
2017-08-13 11:35:49 +00:00
|
|
|
CONTROLLER_AXIS_TOUCHPAD_Y
|
2016-11-15 00:20:56 +00:00
|
|
|
} ControllerAxis;
|
|
|
|
|
2016-11-15 03:57:23 +00:00
|
|
|
typedef enum {
|
|
|
|
CONTROLLER_BUTTON_SYSTEM,
|
|
|
|
CONTROLLER_BUTTON_MENU,
|
2017-08-13 05:58:59 +00:00
|
|
|
CONTROLLER_BUTTON_TRIGGER,
|
2016-11-15 03:57:23 +00:00
|
|
|
CONTROLLER_BUTTON_GRIP,
|
2017-07-25 06:17:00 +00:00
|
|
|
CONTROLLER_BUTTON_TOUCHPAD,
|
2017-08-13 05:58:59 +00:00
|
|
|
CONTROLLER_BUTTON_A,
|
|
|
|
CONTROLLER_BUTTON_B,
|
|
|
|
CONTROLLER_BUTTON_X,
|
2018-08-20 17:29:45 +00:00
|
|
|
CONTROLLER_BUTTON_Y,
|
|
|
|
CONTROLLER_BUTTON_UNKNOWN // Must be last item
|
2016-11-15 03:57:23 +00:00
|
|
|
} ControllerButton;
|
|
|
|
|
2017-08-13 05:58:59 +00:00
|
|
|
typedef enum {
|
|
|
|
HAND_UNKNOWN,
|
|
|
|
HAND_LEFT,
|
|
|
|
HAND_RIGHT
|
|
|
|
} ControllerHand;
|
|
|
|
|
2016-10-03 01:09:33 +00:00
|
|
|
typedef struct {
|
2016-12-01 07:03:58 +00:00
|
|
|
Ref ref;
|
2018-05-05 23:40:53 +00:00
|
|
|
uint32_t id;
|
2016-10-03 01:09:33 +00:00
|
|
|
} Controller;
|
|
|
|
|
2016-12-01 07:03:58 +00:00
|
|
|
typedef vec_t(Controller*) vec_controller_t;
|
2016-12-01 04:32:14 +00:00
|
|
|
|
2019-01-25 20:08:45 +00:00
|
|
|
struct Texture;
|
|
|
|
|
2017-11-25 21:01:56 +00:00
|
|
|
typedef struct {
|
|
|
|
HeadsetDriver driverType;
|
2018-07-29 01:12:57 +00:00
|
|
|
bool (*init)(float offset, int msaa);
|
2017-11-25 21:01:56 +00:00
|
|
|
void (*destroy)();
|
|
|
|
HeadsetType (*getType)();
|
|
|
|
HeadsetOrigin (*getOriginType)();
|
2018-02-26 00:40:48 +00:00
|
|
|
bool (*isMounted)();
|
2018-10-21 15:40:57 +00:00
|
|
|
void (*getDisplayDimensions)(uint32_t* width, uint32_t* height);
|
2017-11-25 21:01:56 +00:00
|
|
|
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);
|
2018-10-10 00:51:05 +00:00
|
|
|
const float* (*getBoundsGeometry)(int* count);
|
2017-12-18 06:13:58 +00:00
|
|
|
void (*getPose)(float* x, float* y, float* z, float* angle, float* ax, float* ay, float* az);
|
2018-11-19 15:38:46 +00:00
|
|
|
void (*getVelocity)(float* vx, float* vy, float* vz);
|
|
|
|
void (*getAngularVelocity)(float* vx, float* vy, float* vz);
|
2018-05-05 23:40:53 +00:00
|
|
|
Controller** (*getControllers)(uint8_t* count);
|
2018-02-26 00:40:48 +00:00
|
|
|
bool (*controllerIsConnected)(Controller* controller);
|
2017-11-25 21:01:56 +00:00
|
|
|
ControllerHand (*controllerGetHand)(Controller* controller);
|
2017-12-18 06:13:58 +00:00
|
|
|
void (*controllerGetPose)(Controller* controller, float* x, float* y, float* z, float* angle, float* ax, float* ay, float* az);
|
2018-11-19 15:38:46 +00:00
|
|
|
void (*controllerGetVelocity)(Controller* controller, float* vx, float* vy, float* vz);
|
|
|
|
void (*controllerGetAngularVelocity)(Controller* controller, float* vx, float* vy, float* vz);
|
2017-11-25 21:01:56 +00:00
|
|
|
float (*controllerGetAxis)(Controller* controller, ControllerAxis axis);
|
|
|
|
bool (*controllerIsDown)(Controller* controller, ControllerButton button);
|
|
|
|
bool (*controllerIsTouched)(Controller* controller, ControllerButton button);
|
|
|
|
void (*controllerVibrate)(Controller* controller, float duration, float power);
|
|
|
|
ModelData* (*controllerNewModelData)(Controller* controller);
|
2018-03-11 07:42:33 +00:00
|
|
|
void (*renderTo)(void (*callback)(void*), void* userdata);
|
2019-01-25 20:08:45 +00:00
|
|
|
Texture* (*getMirrorTexture)();
|
2017-11-25 21:01:56 +00:00
|
|
|
void (*update)(float dt);
|
2017-10-22 23:44:26 +00:00
|
|
|
} HeadsetInterface;
|
2017-10-20 20:32:46 +00:00
|
|
|
|
2018-04-28 23:59:53 +00:00
|
|
|
// Available drivers
|
2018-09-09 17:58:20 +00:00
|
|
|
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;
|
2017-10-22 23:44:26 +00:00
|
|
|
extern HeadsetInterface lovrHeadsetFakeDriver;
|
2018-10-25 03:40:11 +00:00
|
|
|
extern HeadsetInterface lovrHeadsetOculusMobileDriver;
|
2017-10-21 09:39:33 +00:00
|
|
|
|
2018-04-28 23:59:53 +00:00
|
|
|
// Active driver
|
|
|
|
extern HeadsetInterface* lovrHeadsetDriver;
|
2016-12-01 07:03:58 +00:00
|
|
|
|
2018-11-19 16:08:56 +00:00
|
|
|
bool lovrHeadsetInit(HeadsetDriver* drivers, int count, float offset, int msaa);
|
2017-01-22 02:18:12 +00:00
|
|
|
void lovrHeadsetDestroy();
|
2018-12-19 09:41:01 +00:00
|
|
|
#define lovrControllerDestroy NULL
|