way better controller handling
[vg.git] / vg.h
diff --git a/vg.h b/vg.h
index d98828e3bd380b2f9d041436e2dc29045110487f..2eb8e7a4e7bd2a7c39110e60980a7a6cf1dfa291 100644 (file)
--- a/vg.h
+++ b/vg.h
@@ -200,6 +200,8 @@ struct vg
       k_quality_profile_low = 1,
    }
    quality_profile;
+
+   float loader_ring;
 }
 VG_STATIC vg = { .time_rate = 1.0 };
 
@@ -332,12 +334,14 @@ VG_STATIC void _vg_process_events(void)
          vg.mouse_wheel[0] += event.wheel.preciseX;
          vg.mouse_wheel[1] += event.wheel.preciseY;
       }
+      else if( event.type == SDL_CONTROLLERDEVICEADDED ||
+               event.type == SDL_CONTROLLERDEVICEREMOVED )
+      {
+         vg_input_device_event( &event );
+      }
       else if( event.type == SDL_CONTROLLERAXISMOTION ||
                event.type == SDL_CONTROLLERBUTTONDOWN ||
-               event.type == SDL_CONTROLLERBUTTONUP ||
-               event.type == SDL_CONTROLLERDEVICEADDED ||
-               event.type == SDL_CONTROLLERDEVICEREMOVED
-               )
+               event.type == SDL_CONTROLLERBUTTONUP )
       {
          vg_input_controller_event( &event );
       }
@@ -374,7 +378,7 @@ VG_STATIC void _vg_process_events(void)
    vg.mouse_pos[1] += vg.mouse_delta[1];
 
    /* Update input */
-   vg_update_inputs();
+   vg_process_inputs();
 }
 
 VG_STATIC void _vg_gameloop_update(void)
@@ -546,11 +550,10 @@ VG_STATIC int vg_framefilter( double dt )
 
 VG_STATIC int _vg_crashscreen(void)
 {
-   if( vg.window_should_close )
-      return 1;
-
+#if 0
    if( vg_getkey( SDLK_ESCAPE ) )
       return 1;
+#endif
 
    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
    glEnable(GL_BLEND);
@@ -594,20 +597,20 @@ VG_STATIC void _vg_gameloop(void)
 
       enum engine_status status = _vg_engine_status();
 
+      vg.time_delta = vg.time_frame_delta * vg.time_rate;
+      vg.time += vg.time_delta;
+
+      vg_run_async_checked();
+      _vg_process_events();
+
+      if( vg.window_should_close )
+         break;
+         
       if( status == k_engine_status_crashed ){
          if( _vg_crashscreen() )
             break;
       }
       else{
-         vg.time_delta = vg.time_frame_delta * vg.time_rate;
-         vg.time += vg.time_delta;
-
-         vg_run_async_checked();
-         _vg_process_events();
-
-         if( vg.window_should_close )
-            break;
-         
          if( status == k_engine_status_running ){
             _vg_gameloop_update();
             _vg_gameloop_render();
@@ -617,6 +620,11 @@ VG_STATIC void _vg_gameloop(void)
          }
       }
 
+      if( vg.loader_ring > 0.01f ){
+         vg.loader_ring -= vg.time_frame_delta * 0.5f;
+         _vg_loader_render_ring( vg.loader_ring );
+      }
+
       vg.time_frame_delta = 0.0;
       vg.time_spinning = 0;
    }