retry on error

This commit is contained in:
mrbesen 2021-05-28 14:43:05 +02:00
parent c72bf3be8e
commit 581b5df371
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 14 additions and 5 deletions

View File

@ -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.