retry on error
This commit is contained in:
parent
c72bf3be8e
commit
581b5df371
19
src/main.c
19
src/main.c
|
@ -117,12 +117,13 @@ GLuint initOverlayTexture() {
|
||||||
return textureid;
|
return textureid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void attach() {
|
bool attach() {
|
||||||
TrackedDeviceIndex_t index;
|
TrackedDeviceIndex_t index;
|
||||||
index = oSystem->GetTrackedDeviceIndexForControllerRole( ETrackedControllerRole_TrackedControllerRole_LeftHand );
|
index = oSystem->GetTrackedDeviceIndexForControllerRole( ETrackedControllerRole_TrackedControllerRole_LeftHand );
|
||||||
|
|
||||||
if( index == k_unTrackedDeviceIndexInvalid || index == k_unTrackedDeviceIndex_Hmd ) {
|
if( index == k_unTrackedDeviceIndexInvalid || index == k_unTrackedDeviceIndex_Hmd ) {
|
||||||
printf( "Couldn't find your controller to attach our overlay to (%d)\n", index );
|
printf( "Couldn't find your controller to attach our overlay to (%d)\n", index );
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// We have a ETrackedControllerRole_TrackedControllerRole_LeftHand. Associate it.
|
// We have a ETrackedControllerRole_TrackedControllerRole_LeftHand. Associate it.
|
||||||
EVROverlayError err;
|
EVROverlayError err;
|
||||||
|
@ -146,22 +147,30 @@ void attach() {
|
||||||
// Notify the terminal that this was associated.
|
// Notify the terminal that this was associated.
|
||||||
printf( "Successfully associated your clock to the tracked device (%d %d %08x).\n",
|
printf( "Successfully associated your clock to the tracked device (%d %d %08x).\n",
|
||||||
err, index, overlayID );
|
err, index, overlayID );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
if(initVR()) return 1;
|
|
||||||
|
|
||||||
CNFGSetup( "CHAC", -WIDTH, -HEIGHT );
|
CNFGSetup( "CHAC", -WIDTH, -HEIGHT );
|
||||||
|
|
||||||
|
while(initVR()) {
|
||||||
|
OGUSleep( (int)( 1000000 ) );
|
||||||
|
}
|
||||||
|
|
||||||
oOverlay->ShowOverlay( overlayID );
|
oOverlay->ShowOverlay( overlayID );
|
||||||
GLuint texture = initOverlayTexture();
|
GLuint texture = initOverlayTexture();
|
||||||
|
|
||||||
//associate with controller
|
bool isAttached = false;
|
||||||
attach();
|
|
||||||
|
|
||||||
CNFGBGColor = 0x00000000; //Background
|
CNFGBGColor = 0x00000000; //Background
|
||||||
while(1) {
|
while(1) {
|
||||||
|
if(!isAttached) {
|
||||||
|
isAttached = attach();
|
||||||
|
OGUSleep( (int)( 1000000 ) ); //wait one sec
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
CNFGClearFrame();
|
CNFGClearFrame();
|
||||||
|
|
||||||
//Change color to white.
|
//Change color to white.
|
||||||
|
|
Loading…
Reference in New Issue