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;
}
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.