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