+unsigned char ui_threaded_timer_create ( void ) {
+
+ g_timer_thread = SDL_CreateThread ( (void*)ui_threaded_timer, NULL );
+
+ if ( ! g_timer_thread ) {
+ pnd_log ( pndn_error, "ERROR: Couldn't create timer thread\n" );
+ return ( 0 );
+ }
+
+ return ( 1 );
+}
+
+int ui_threaded_timer ( pnd_disco_t *p ) {
+
+ // this timer's job is to ..
+ // - do nothing for quite awhile
+ // - on wake, post event to SDL event queue, so that main thread will check if SD insert/eject occurred
+ // - goto 10
+
+ unsigned int delay_s = 2; // seconds
+
+ while ( 1 ) {
+
+ // pause...
+ sleep ( delay_s );
+
+ // .. trigger SD check
+ SDL_Event e;
+ bzero ( &e, sizeof(SDL_Event) );
+ e.type = SDL_USEREVENT;
+ e.user.code = sdl_user_checksd;
+ SDL_PushEvent ( &e );
+
+ } // while
+
+ return ( 0 );
+}
+