From 01eb9ad09055c7add1ef29726f985325bb3f489b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 12:48:52 +0200 Subject: js: don't spin forever in bg thread on detach --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ftnoir_tracker_joystick') diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index a132f472..66138e90 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -183,14 +183,14 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) if( !g_pDI || !g_pJoystick) return false; -start: auto hr = g_pJoystick->Poll(); if( FAILED( hr )) { hr = g_pJoystick->Acquire(); - while( hr == DIERR_INPUTLOST ) + for (int i = 0; hr == DIERR_INPUTLOST && i < 200; i++) hr = g_pJoystick->Acquire(); - goto start; + if (hr != DI_OK) + return false; } if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( js ), &js ) ) ) -- cgit v1.2.3