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);
}
char lovrHeadsetIsControllerPresent(Controller* controller) {
return headset->interface->isControllerPresent(headset, controller);
}
void lovrHeadsetRenderTo(headsetRenderCallback callback, void* 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 (*getAngularVelocity)(void* headset, float* x, float* y, float* z);
Controller* (*getController)(void* headset, ControllerHand hand);
char (*isControllerPresent)(void* headset, Controller* controller);
void (*renderTo)(void* headset, headsetRenderCallback callback, void* userdata);
} HeadsetInterface;
@ -46,4 +47,5 @@ void lovrHeadsetGetOrientation(float* x, float* y, float* z, float* w);
void lovrHeadsetGetVelocity(float* x, float* y, float* z);
void lovrHeadsetGetAngularVelocity(float* x, float* y, float* z);
Controller* lovrHeadsetGetController(ControllerHand hand);
char lovrHeadsetIsControllerPresent(Controller* controller);
void lovrHeadsetRenderTo(headsetRenderCallback callback, void* userdata);

View File

@ -40,6 +40,7 @@ static HeadsetInterface interface = {
.getVelocity = viveGetVelocity,
.getAngularVelocity = viveGetAngularVelocity,
.getController = viveGetController,
.isControllerPresent = viveIsControllerPresent,
.renderTo = viveRenderTo
};
@ -241,6 +242,12 @@ Controller* viveGetController(void* headset, ControllerHand 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) {
Headset* this = headset;
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 viveGetAngularVelocity(void* headset, float* x, float* y, float* z);
Controller* viveGetController(void* headset, ControllerHand hand);
char viveIsControllerPresent(void* headset, Controller* controller);
void viveRenderTo(void* headset, headsetRenderCallback callback, void* userdata);