poll functions
[vg.git] / vg_input.h
index 87109d25e777d2d2f844472ce88e3b62b44ed3ca..1052c42937f1c61ce535b8199d8857494b08e57d 100644 (file)
@@ -380,10 +380,10 @@ VG_STATIC void vg_apply_bind_str( struct input_binding *bind,
 }
 
 /* 
- * bind x jump 
- * bind a -horizontal
- * bind d +horizontal
- * bind -gp-ls-h horizontal
+ * bind  jump        x
+ * bind -horizontal  a
+ * bind +horizontal  d
+ * bind  horizontal -gp-ls-h 
  */
 
 VG_STATIC int vg_rebind_input_cmd( int argc, const char *argv[] )
@@ -422,6 +422,32 @@ VG_STATIC int vg_rebind_input_cmd( int argc, const char *argv[] )
    return 0;
 }
 
+VG_STATIC void vg_rebind_input_cmd_poll( int argc, const char *argv[] )
+{
+   if( argc == 0 )
+      return;
+
+   const char *str_bind_name = argv[0];
+
+   if( argc == 1 )
+   {
+      for( u32 i=0; i<vg_input.named_input_count; i++ )
+      {
+         struct input_binding *bind = &vg_input.named_inputs[i];
+         console_suggest_score_text( bind->name, argv[argc-1], 0 );
+      }
+   }
+
+   else if( argc == 2 )
+   {
+      for( int i=0; i<vg_list_size(vg_all_bindable_inputs); i++ )
+      {
+         struct input_en *desc = &vg_all_bindable_inputs[i];
+         console_suggest_score_text( desc->alias, argv[argc-1], 0 );
+      }
+   }
+}
+
 VG_STATIC u8 vg_getkey( SDL_Keycode kc )
 {
    SDL_Scancode sc = SDL_GetScancodeFromKey( kc );
@@ -588,13 +614,14 @@ VG_STATIC void vg_input_init(void)
    vg_function_push( (struct vg_cmd)
    {
       .name = "bind",
-      .function = vg_rebind_input_cmd
+      .function = vg_rebind_input_cmd,
+      .poll_suggest = vg_rebind_input_cmd_poll
    });
 
-   vg_convar_push( (struct vg_convar){
+   vg_var_push( (struct vg_var){
       .name = "controller_deadzone",
       .data = &g_controller_deadzone,
-      .data_type = k_convar_dtype_f32,
+      .data_type = k_var_dtype_f32,
       .opt_f32 = { .clamp = 0 },
       .persistent = 1
    });