1
0
Fork 0
mirror of https://github.com/bjornbytes/lovr.git synced 2024-07-02 20:43:35 +00:00

Controller:isPresent;

This commit is contained in:
bjorn 2016-10-03 11:12:06 -07:00
parent dbc1037d4c
commit b594b218b2
4 changed files with 14 additions and 0 deletions

View file

@ -55,6 +55,10 @@ Controller* lovrHeadsetGetController(ControllerHand hand) {
return headset->interface->getController(headset, hand); return headset->interface->getController(headset, hand);
} }
char lovrHeadsetIsControllerPresent(Controller* controller) {
return headset->interface->isControllerPresent(headset, controller);
}
void lovrHeadsetRenderTo(headsetRenderCallback callback, void* userdata) { void lovrHeadsetRenderTo(headsetRenderCallback callback, void* userdata) {
headset->interface->renderTo(headset, callback, userdata); headset->interface->renderTo(headset, callback, userdata);
} }

View file

@ -24,6 +24,7 @@ typedef struct {
void (*getVelocity)(void* headset, float* x, float* y, float* z); void (*getVelocity)(void* headset, float* x, float* y, float* z);
void (*getAngularVelocity)(void* headset, float* x, float* y, float* z); void (*getAngularVelocity)(void* headset, float* x, float* y, float* z);
Controller* (*getController)(void* headset, ControllerHand hand); Controller* (*getController)(void* headset, ControllerHand hand);
char (*isControllerPresent)(void* headset, Controller* controller);
void (*renderTo)(void* headset, headsetRenderCallback callback, void* userdata); void (*renderTo)(void* headset, headsetRenderCallback callback, void* userdata);
} HeadsetInterface; } HeadsetInterface;
@ -46,4 +47,5 @@ void lovrHeadsetGetOrientation(float* x, float* y, float* z, float* w);
void lovrHeadsetGetVelocity(float* x, float* y, float* z); void lovrHeadsetGetVelocity(float* x, float* y, float* z);
void lovrHeadsetGetAngularVelocity(float* x, float* y, float* z); void lovrHeadsetGetAngularVelocity(float* x, float* y, float* z);
Controller* lovrHeadsetGetController(ControllerHand hand); Controller* lovrHeadsetGetController(ControllerHand hand);
char lovrHeadsetIsControllerPresent(Controller* controller);
void lovrHeadsetRenderTo(headsetRenderCallback callback, void* userdata); void lovrHeadsetRenderTo(headsetRenderCallback callback, void* userdata);

View file

@ -40,6 +40,7 @@ static HeadsetInterface interface = {
.getVelocity = viveGetVelocity, .getVelocity = viveGetVelocity,
.getAngularVelocity = viveGetAngularVelocity, .getAngularVelocity = viveGetAngularVelocity,
.getController = viveGetController, .getController = viveGetController,
.isControllerPresent = viveIsControllerPresent,
.renderTo = viveRenderTo .renderTo = viveRenderTo
}; };
@ -241,6 +242,12 @@ Controller* viveGetController(void* headset, ControllerHand hand) {
return state->controllers[hand]; return state->controllers[hand];
} }
char viveIsControllerPresent(void* headset, Controller* controller) {
Headset* this = headset;
ViveState* state = this->state;
return state->vrSystem->IsTrackedDeviceConnected(state->controllerIndex[controller->hand]);
}
void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata) { void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata) {
Headset* this = headset; Headset* this = headset;
ViveState* state = this->state; ViveState* state = this->state;

View file

@ -15,4 +15,5 @@ void viveGetOrientation(void* headset, float* x, float* y, float* z, float* w);
void viveGetVelocity(void* headset, float* x, float* y, float* z); void viveGetVelocity(void* headset, float* x, float* y, float* z);
void viveGetAngularVelocity(void* headset, float* x, float* y, float* z); void viveGetAngularVelocity(void* headset, float* x, float* y, float* z);
Controller* viveGetController(void* headset, ControllerHand hand); Controller* viveGetController(void* headset, ControllerHand hand);
char viveIsControllerPresent(void* headset, Controller* controller);
void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata); void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata);