fix long standing grind bug
[carveJwlIkooP6JGAAIwe30JlM.git] / input.h
diff --git a/input.h b/input.h
index 6f19634f606e4dde10fd52754dbcaf9d3804cd66..a909d7b70e537a94c8830a3b94413e46ef7ceb98 100644 (file)
--- a/input.h
+++ b/input.h
@@ -47,6 +47,7 @@ struct {
    float axis_states[ k_sraxis_max ][2];
    v2f joystick_states[ k_srjoystick_max ][2];
    u8 button_states[ k_srbind_max ][2];
+   u32 ignore_input_frames;
 }
 static srinput;
 
@@ -178,8 +179,8 @@ static const char *joystick_display_string( enum sr_joystick joystick )
 
 static int buttons_filter_fixed(void)
 {
-   if( vg_console.enabled )
-      return 1;
+   if( srinput.ignore_input_frames ) return 1;
+   if( vg_ui.wants_mouse ) return 1;
 
    if( vg.engine_stage == k_engine_stage_update_fixed )
       if( vg.fixed_iterations > 0 )
@@ -191,8 +192,7 @@ static int buttons_filter_fixed(void)
 /* Rising edge of button */
 static int button_down( enum sr_bind button )
 {
-   if( buttons_filter_fixed() )
-      return 0;
+   if( buttons_filter_fixed() ) return 0;
    
    if(  srinput.button_states[ button ][0] && 
        !srinput.button_states[ button ][1] )
@@ -204,8 +204,7 @@ static int button_down( enum sr_bind button )
 /* Falling edge of button */
 static int button_up( enum sr_bind button )
 {
-   if( buttons_filter_fixed() )
-      return 0;
+   if( buttons_filter_fixed() ) return 0;
    
    if( !srinput.button_states[ button ][0] && 
         srinput.button_states[ button ][1] )
@@ -217,15 +216,13 @@ static int button_up( enum sr_bind button )
 /* State of button */
 static int button_press( enum sr_bind button )
 {
-   if( vg_console.enabled )
-      return 0;
-
+   if( vg_ui.wants_mouse ) return 0;
    return srinput.button_states[ button ][0];
 }
 
 static void joystick_state( enum sr_joystick joystick, v2f state )
 {
-   if( vg_console.enabled )
+   if( vg_ui.wants_mouse )
       v2_zero( state );
    else
       v2_copy( srinput.joystick_states[ joystick ][0], state );
@@ -233,7 +230,7 @@ static void joystick_state( enum sr_joystick joystick, v2f state )
 
 static float axis_state( enum sr_axis axis )
 {
-   if( vg_console.enabled ) return 0.0f;
+   if( vg_ui.wants_mouse ) return 0.0f;
    else return srinput.axis_states[axis][0];
 }
 
@@ -244,6 +241,9 @@ static void setbtn( enum sr_bind button, u8 value )
 
 static void skaterift_preupdate_inputs(void)
 {
+   if( srinput.ignore_input_frames )
+      srinput.ignore_input_frames --;
+
    for( u32 i=0; i<k_srbind_max; i++ ){
       srinput.button_states[i][1] = srinput.button_states[i][0];
       srinput.button_states[i][0] = 0;
@@ -305,7 +305,7 @@ static void skaterift_preupdate_inputs(void)
    if( vg_getkey( SDLK_RIGHT ) )
       srinput.axis_states[ k_sraxis_mbrowse_h ][0] += 1.0f;
 
-   if( vg_input.active_controller_index != -1 ){
+   if( vg_input.active_controller_index >= 0 ){
       struct vg_controller *controller = 
          &vg_input.controllers[vg_input.active_controller_index];