send chat messages to server
[carveJwlIkooP6JGAAIwe30JlM.git] / input.h
diff --git a/input.h b/input.h
index 7e1e6aa4f0afc84f6d16197ce1af1d9344b6dcc8..ee7cbee9e5f9d5828e970998878d78c7a20ffa34 100644 (file)
--- a/input.h
+++ b/input.h
@@ -32,6 +32,8 @@ enum sr_bind{
    k_srbind_world_left,
    k_srbind_world_right,
    k_srbind_home,
+   k_srbind_lobby,
+   k_srbind_chat,
    k_srbind_max,
 };
 
@@ -125,7 +127,9 @@ static const char *button_display_string( enum sr_bind button )
 [k_srbind_replay_play]= controller_glyph( SDL_CONTROLLER_BUTTON_X ),
 [k_srbind_replay_freecam]=controller_glyph(SDL_CONTROLLER_BUTTON_Y ),
 [k_srbind_replay_resume]=controller_glyph( SDL_CONTROLLER_BUTTON_A ),
-   [k_srbind_sit]     = controller_glyph( SDL_CONTROLLER_BUTTON_B )
+   [k_srbind_sit]     = controller_glyph( SDL_CONTROLLER_BUTTON_B ),
+    [k_srbind_lobby]  = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
+    [k_srbind_chat]   = ""
    };
 
    const char *keyboard_table[ k_srbind_max ] = {
@@ -150,7 +154,9 @@ static const char *button_display_string( enum sr_bind button )
 [k_srbind_replay_play]= KEYBOARD_GLYPH( "G" ),
 [k_srbind_replay_freecam] = KEYBOARD_GLYPH( "F" ),
 [k_srbind_replay_resume]= "\xa1",
-    [k_srbind_sit]    = KEYBOARD_GLYPH( "Z" )
+    [k_srbind_sit]    = KEYBOARD_GLYPH( "Z" ),
+    [k_srbind_lobby] = KEYBOARD_GLYPH( "" ), // FIXME: what is tab?
+    [k_srbind_chat] = KEYBOARD_GLYPH( "Y" )
    };
 
    if( vg_input.display_input_method == k_input_method_controller )
@@ -207,10 +213,16 @@ static const char *joystick_display_string( enum sr_joystick joystick,
    else  return keyboard_table[ joystick ][axis];
 }
 
-static int buttons_filter_fixed(void)
-{
-   if( !srinput.enabled ) return 1;
-   if( vg_ui.wants_mouse ) return 1;
+static int input_filter_generic(void){
+   if( !srinput.enabled || vg_ui.wants_mouse || vg_console.enabled )
+      return 1;
+   else 
+      return 0;
+}
+
+static int buttons_filter_fixed(void){
+   if( input_filter_generic() ) 
+      return 1;
 
    if( vg.engine_stage == k_engine_stage_update_fixed )
       if( vg.fixed_iterations > 0 )
@@ -220,8 +232,7 @@ static int buttons_filter_fixed(void)
 }
 
 /* Rising edge of button */
-static int button_down( enum sr_bind button )
-{
+static int button_down( enum sr_bind button ){
    if( buttons_filter_fixed() ) return 0;
    
    if(  srinput.button_states[ button ][0] && 
@@ -232,8 +243,7 @@ static int button_down( enum sr_bind button )
 }
 
 /* Falling edge of button */
-static int button_up( enum sr_bind button )
-{
+static int button_up( enum sr_bind button ){
    if( buttons_filter_fixed() ) return 0;
    
    if( !srinput.button_states[ button ][0] && 
@@ -244,23 +254,25 @@ static int button_up( enum sr_bind button )
 }
 
 /* State of button */
-static int button_press( enum sr_bind button )
-{
-   if( vg_ui.wants_mouse ) return 0;
-   return srinput.button_states[ button ][0];
+static int button_press( enum sr_bind button ){
+   if( input_filter_generic() )
+      return 0;
+   return 
+      srinput.button_states[ button ][0];
 }
 
-static void joystick_state( enum sr_joystick joystick, v2f state )
-{
-   if( vg_ui.wants_mouse )
+static void joystick_state( enum sr_joystick joystick, v2f state ){
+   if( input_filter_generic() )
       v2_zero( state );
    else
       v2_copy( srinput.joystick_states[ joystick ][0], state );
 }
 
 static float axis_state( enum sr_axis axis ){
-   if( vg_ui.wants_mouse ) return 0.0f;
-   else return srinput.axis_states[axis][0];
+   if( input_filter_generic() )
+      return 0.0f;
+   else 
+      return srinput.axis_states[axis][0];
 }
 
 static void setbtn( enum sr_bind button, u8 value )
@@ -315,6 +327,8 @@ static void skaterift_preupdate_inputs(void)
    setbtn( k_srbind_replay_freecam, vg_getkey(SDLK_f) );
    setbtn( k_srbind_replay_resume, vg_getkey(SDLK_SPACE) );
    setbtn( k_srbind_sit, vg_getkey(SDLK_z) );
+   setbtn( k_srbind_lobby, vg_getkey(SDLK_TAB) );
+   setbtn( k_srbind_chat, vg_getkey(SDLK_y) );
 
    /* axis
     * --------------------------------------------*/
@@ -376,6 +390,8 @@ static void skaterift_preupdate_inputs(void)
       setbtn( k_srbind_replay_play, buttons[ SDL_CONTROLLER_BUTTON_X ] );
       setbtn( k_srbind_replay_freecam, buttons[ SDL_CONTROLLER_BUTTON_Y ] );
       setbtn( k_srbind_sit, buttons[ SDL_CONTROLLER_BUTTON_B ] );
+      setbtn( k_srbind_lobby, buttons[ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] );
+      // k_srbind_chat 
 
       float *axis = controller->axises;
       float *steer = srinput.joystick_states[ k_srjoystick_steer ][0],