input update 1
authorhgn <hgodden00@gmail.com>
Fri, 28 Apr 2023 14:43:51 +0000 (15:43 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 28 Apr 2023 14:43:51 +0000 (15:43 +0100)
18 files changed:
blender_export.py
ent_skateshop.c
font.h
gui.h
input.h [new file with mode: 0644]
menu.h
models_src/rs_font.mdl
player.c
player.h
player_common.c
player_drive.c
player_skate.c
player_walk.c
shaders/model_font.fs
shaders/model_font.h
shaders/model_font.vs
skaterift.c
steam.h

index 84dc3a72b18572c0b62e698c3ed2717a6067c02c..73d17059d19fded822a9af16c95c818104bae03d 100644 (file)
@@ -2413,7 +2413,8 @@ class SR_UL_FONT_GLYPH_LIST(bpy.types.UIList):
       s1 = c.split(factor=0.3)
       c = s1.column()
       row = c.row()
-      lbl = chr(item.utf32) if item.utf32 >= 32 and item.utf32 <= 126 else 'ERR'
+      lbl = chr(item.utf32) if item.utf32 >= 32 and item.utf32 <= 126 else \
+                                                              f'x{item.utf32:x}'
       row.label(text=lbl)
       c = s1.column()
       c.prop( item, 'utf32', text='', emboss=True )
index a30fca9b5b343921375195d80423e34fd99818e4..9d31a26627888a32b29b8373c8264037ccccf550 100644 (file)
@@ -437,34 +437,41 @@ VG_STATIC void global_skateshop_preupdate(void)
       return;
    }
 
-   float h = localplayer.input_js1h->axis.value;
-
    if( global_skateshop.interface_loc <= k_skateshop_loc_page__viewing ){
-      if( fabsf(h) > 0.25f ){
-         if( h < 0.0f ){
-            if( global_skateshop.selected_registry_id > 0 )
-               global_skateshop.selected_registry_id --;
+
+      gui_helper_action( NULL, "\x88 \x02\xaf\x03""browse" );
+      gui_helper_action( NULL, "\x1e\x85 \x02\xaf\x03""pick" );
+      gui_helper_action( NULL, "\x1e\x86 \x02\xaf\x03""exit" );
+      
+      int moved = 0;
+
+      if( button_down( k_srbind_mleft ) ){
+         if( global_skateshop.selected_registry_id > 0 ){
+            global_skateshop.selected_registry_id --;
+            moved = 1;
          }
-         else{
-            if( global_skateshop.selected_registry_id < 
-                     global_skateshop.registry_count-1 )
-            {
-               global_skateshop.selected_registry_id ++;
-            }
+      }
+
+      if( button_down( k_srbind_mright ) ){
+         if( global_skateshop.selected_registry_id < 
+                  global_skateshop.registry_count-1 )
+         {
+            global_skateshop.selected_registry_id ++;
+            moved = 1;
          }
+      }
 
+      if( moved ){
          vg_info( "Select registry: %u\n", 
                   global_skateshop.selected_registry_id );
          global_skateshop.interaction_cooldown = 0.125f;
          return;
       }
 
-      if( vg_input_button_down( &input_menu_back ) ){
+      if( button_down( k_srbind_mback ) ){
          global_skateshop_exit();
          return;
       }
-
-      gui_helper_action( localplayer.input_use, "Select" );
    }
 }
 
diff --git a/font.h b/font.h
index a7826f504926038f09b7c17e7766d63fe1a47a4b..82af99a5126d81798def08996bc3679ac53c89bd 100644 (file)
--- a/font.h
+++ b/font.h
@@ -8,8 +8,12 @@
 
 
 enum efont_SRglyph{
-   k_SRglyph_end           = 0,  /* control characters */
-   k_SRglyph_ctrl_variant  = 1,
+   k_SRglyph_end           = 0x00, /* control characters */
+   k_SRglyph_ctrl_variant  = 0x01,
+   k_SRglyph_ctrl_size     = 0x02, /* normalized 0-1 */
+   k_SRglyph_ctrl_center   = 0x03, /* useful when text is scaled down */
+   k_SRglyph_ctrl_baseline = 0x04, /* . */
+   k_SRglyph_ctrl_top      = 0x05, /* . */
    k_SRglyph_mod_circle    = 0x1e, /* surround and center next charater */
    k_SRglyph_mod_square    = 0x1f, /* surround and center next character */
    k_SRglyph_ascii_min     = 0x20, /* standard ascii */
@@ -20,8 +24,8 @@ enum efont_SRglyph{
    k_SRglyph_ps4_cross     = 0x82,
    k_SRglyph_xb1_x         = 0x83,/* xbox buttons */
    k_SRglyph_xb1_y         = 0x84,
-   k_SRglyph_xb1_b         = 0x85,
-   k_SRglyph_xb1_a         = 0x86,
+   k_SRglyph_xb1_a         = 0x85,
+   k_SRglyph_xb1_b         = 0x86,
    k_SRglyph_gen_ls        = 0x87,/* generic gamepad */
    k_SRglyph_gen_lsh       = 0x88,
    k_SRglyph_gen_lsv       = 0x89,
@@ -48,7 +52,8 @@ enum efont_SRglyph{
    k_SRglyph_kbm_shift     = 0x9e,/* modifiers */
    k_SRglyph_kbm_ctrl      = 0x9f,
    k_SRglyph_kbm_alt       = 0xa0,
-   k_SRglyph_kbm_space     = 0xa1
+   k_SRglyph_kbm_space     = 0xa1,
+   k_SRglyph_kbm_return    = 0xa2
 };
 
 typedef struct font3d font3d;
@@ -86,7 +91,7 @@ VG_STATIC void font3d_load( font3d *font, const char *mdl_path, void *alloc )
 
    mdl_async_load_glmesh( &font->mdl, &font->mesh );
    vg_tex2d_load_qoi_async( data, tex0->file.pack_size, 
-                            VG_TEX2D_NEAREST|VG_TEX2D_REPEAT|VG_TEX2D_NOMIP,
+                            VG_TEX2D_LINEAR|VG_TEX2D_CLAMP,
                             &font->texture );
 
    mdl_close( &font->mdl );
@@ -137,8 +142,8 @@ VG_STATIC
 float font3d_simple_draw( font3d *font, u32 variant_id, const char *text, 
                          camera *cam, m4x3f transform )
 {
-   v3f offset;
-   v3_zero( offset );
+   v4f offset;
+   q_identity( offset );
 
    m4x4f prev_mtx;
 
@@ -150,50 +155,66 @@ float font3d_simple_draw( font3d *font, u32 variant_id, const char *text,
 
    const u8 *u8str = (u8*)text;
 
-   for( int i=0;; i++ ){
-      u32 c = u8str[i];
-      if(!c) break;
+   for( u32 i=0;; i++ ){
+      u32 c0 = u8str[i],
+          c1;
+
+      if( !c0 ) break;
+
+      ent_glyph *glyph0 = font3d_glyph( font, variant_id, c0 ),
+                *glyph1;
+
+      /* multibyte characters */
+      if( c0 >= 1 && c0 < k_SRglyph_ascii_min ){
+         c1 = u8str[i+1];
+         if( !c1 ) break;
+         glyph1 = font3d_glyph( font, variant_id, c1 );
+      }
 
-      if( c == k_SRglyph_ctrl_variant ){
-         variant_id = u8str[i+1];
+      if( c0 == k_SRglyph_ctrl_variant ){
+         variant_id = c1;
+         i ++;
+         continue;
+      }
+      else if( c0 == k_SRglyph_ctrl_size ){
+         offset[3] = (float)c1 * (1.0f/255.0f);
+         i ++;
+         continue;
+      }
+      else if( c0 == k_SRglyph_ctrl_baseline ){
+         offset[1] = 0.0f;
+         continue;
+      }
+      else if( c0 == k_SRglyph_ctrl_center ){
+         if( glyph1 )
+            offset[1] = (glyph1->size[1] - glyph1->size[1]*offset[3]) * 0.5f;
+         continue;
+      }
+      else if( c0 == k_SRglyph_ctrl_top ){
+         if( glyph1 )
+            offset[1] = glyph1->size[1] - glyph1->size[1]*offset[3];
          continue;
       }
 
-      ent_glyph *glyph = font3d_glyph( font, variant_id, c );
-      if( !glyph ) continue;
+      if( !glyph0 ) continue;
+
+      if( glyph1 && (c0 == k_SRglyph_mod_square || c0 == k_SRglyph_mod_circle)){
+         v4f v0;
+         v2_sub( glyph0->size, glyph1->size, v0 );
+         v2_muladds( offset, v0, -0.5f, v0 );
+         v0[2] = offset[2];
+         v0[3] = offset[3];
 
-      if( glyph->indice_count ){
-         if( c == k_SRglyph_mod_square || c == k_SRglyph_mod_circle ){
-            u32 c1 = u8str[i+1];
-            if( c1 == '\0' ) break;
-
-            ent_glyph *glyph1 = font3d_glyph( font, variant_id, c1 );
-
-            if( glyph1 ){
-               if( glyph1->indice_count ){
-                  v3f v0;
-                  v2_sub( glyph->size, glyph1->size, v0 );
-                  v2_muladds( offset, v0, -0.5f, v0 );
-                  v0[2] = 0.0f;
-
-                  shader_model_font_uOffset( v0 );
-                  mesh_drawn( glyph->indice_start, glyph->indice_count );
-                  
-                  shader_model_font_uOffset( offset );
-                  mesh_drawn( glyph1->indice_start, glyph1->indice_count );
-                  offset[0] += glyph1->size[0];
-               }
-            }
-
-            i ++;
-            continue;
-         }
-         else{
-            shader_model_font_uOffset( offset );
-            mesh_drawn( glyph->indice_start, glyph->indice_count );
-         }
+         shader_model_font_uOffset( v0 );
+         mesh_drawn( glyph0->indice_start, glyph0->indice_count );
+         continue;
       }
-      offset[0] += glyph->size[0];
+      else{
+         shader_model_font_uOffset( offset );
+         mesh_drawn( glyph0->indice_start, glyph0->indice_count );
+      }
+
+      offset[0] += glyph0->size[0]*offset[3];
    }
 
    return offset[0];
diff --git a/gui.h b/gui.h
index 1e576e62c87d0ec2185f8da340a533c4e23d4b0d..8cb94f1200fc0615b07f02ae72163aeff6644b09 100644 (file)
--- a/gui.h
+++ b/gui.h
@@ -10,6 +10,8 @@ struct{
    }
    helpers[4];
    u32 helper_count;
+
+   float factive;
 }
 static gui;
 
@@ -35,7 +37,10 @@ void gui_draw(void)
    camera_update_view( &ortho );
    camera_finalize( &ortho );
 
-   if( gui.helper_count ){
+   gui.factive = vg_lerpf( gui.factive, gui.helper_count?1.0f:0.0f,
+                           vg.time_delta*2.0f );
+
+   if( gui.factive > 0.01f ){
       /* draw bottom bar */
       glEnable(GL_BLEND);
       glDisable(GL_DEPTH_TEST);
@@ -43,10 +48,9 @@ void gui_draw(void)
       glBlendEquation(GL_FUNC_ADD);
 
       shader_blitcolour_use();
-      shader_blitcolour_uColour( (v4f){ 0.0f, 0.0f, 0.0f, 0.8f } );
+      shader_blitcolour_uColour( (v4f){ 0.0f, 0.0f, 0.0f, gui.factive*0.8f } );
       render_fsquad1();
    }
-   glDisable(GL_BLEND);
 
    font3d *font = &world_global.font;
    font3d_bind( font, &ortho );
@@ -61,7 +65,7 @@ void gui_draw(void)
    v3_zero( mmdl[3] );
 
    float pad = dy*0x1p-4f*0.125f;
-   mmdl[3][0] = pad;
+   mmdl[3][0] = pad*2.0f;
    mmdl[3][1] = pad;
 
    for( u32 i=0; i<gui.helper_count; i++ ){
@@ -69,7 +73,7 @@ void gui_draw(void)
 
       shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} );
 
-      float w = font3d_simple_draw( font, 1, helper->text, &ortho, mmdl )+0.2f;
+      float w = font3d_simple_draw( font, 2, helper->text, &ortho, mmdl )+1.0f;
       mmdl[3][0] += w*scale;
    }
 
@@ -77,7 +81,7 @@ void gui_draw(void)
 }
 
 VG_STATIC 
-void gui_helper_action( struct input_binding *bind, const char *text )
+void gui_helper_action( void *bind, const char *text )
 {
    if( gui.helper_count >= vg_list_size(gui.helpers) )
       vg_fatal_error( "Too many helpers\n" );
diff --git a/input.h b/input.h
new file mode 100644 (file)
index 0000000..c6710f2
--- /dev/null
+++ b/input.h
@@ -0,0 +1,174 @@
+#ifndef INPUT_H
+#define INPUT_H
+
+#define VG_GAME
+#include "vg/vg.h"
+#include "vg/vg_platform.h" 
+#include "vg/vg_console.h"
+#include "vg/vg_input.h"
+#include "vg/vg_m.h"
+#include "conf.h"
+
+enum sr_bind{
+   k_srbind_jump = 0,
+   k_srbind_push,
+   k_srbind_trick0,
+   k_srbind_trick1,
+   k_srbind_trick2,
+   k_srbind_use,
+   k_srbind_reset,
+   k_srbind_camera,
+   k_srbind_mleft, 
+   k_srbind_mright, 
+   k_srbind_mup, 
+   k_srbind_mdown,
+   k_srbind_mback, 
+   k_srbind_maccept,
+   k_srbind_max
+};
+
+struct {
+   v2f joy_steer,
+       joy_grab,
+       joy_look;
+
+   float axis_grab;
+
+   u8 button_states[ k_srbind_max ][2];
+   float repeaters[4];
+}
+static srinput;
+
+static int button_down( enum sr_bind button )
+{
+   if( vg_console.enabled )
+      return 0;
+
+   if( vg.engine_stage == k_engine_stage_update_fixed )
+      if( vg.fixed_iterations > 0 )
+         return 0;
+   
+   if(  srinput.button_states[ button ][0] && 
+       !srinput.button_states[ button ][1] )
+      return 1;
+   else
+      return 0;
+}
+
+static int button_up( enum sr_bind button )
+{
+   if( vg_console.enabled )
+      return 0;
+
+   if( vg.engine_stage == k_engine_stage_update_fixed )
+      if( vg.fixed_iterations > 0 )
+         return 0;
+   
+   if( !srinput.button_states[ button ][0] && 
+        srinput.button_states[ button ][1] )
+      return 1;
+   else
+      return 0;
+}
+
+static int button_press( enum sr_bind button )
+{
+   if( vg_console.enabled )
+      return 0;
+
+   return srinput.button_states[ button ][0];
+}
+
+static void setbtn( enum sr_bind button, u8 value )
+{
+   srinput.button_states[button][0] |= value;
+}
+
+static void skaterift_preupdate_inputs(void)
+{
+   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;
+   }
+
+   u32 mouse = SDL_GetMouseState(NULL,NULL),
+       mouse1= (mouse & SDL_BUTTON(SDL_BUTTON_LEFT))? 1: 0,
+       mouse2= (mouse & SDL_BUTTON(SDL_BUTTON_RIGHT))? 1: 0;
+
+   /* button inputs
+    * ------------------------------------- */
+   setbtn( k_srbind_jump,    vg_getkey(SDLK_SPACE) );
+   setbtn( k_srbind_push,    vg_getkey(SDLK_w) );
+   setbtn( k_srbind_trick0,  mouse1 );
+   setbtn( k_srbind_trick1,  mouse2 );
+   setbtn( k_srbind_trick2,  mouse1 & mouse2 );
+   setbtn( k_srbind_use,     vg_getkey(SDLK_e) );
+   setbtn( k_srbind_reset,   vg_getkey(SDLK_r) );
+   setbtn( k_srbind_camera,  vg_getkey(SDLK_c) );
+   setbtn( k_srbind_mleft,   vg_getkey(SDLK_LEFT) );
+   setbtn( k_srbind_mright,  vg_getkey(SDLK_RIGHT) );
+   setbtn( k_srbind_mup,     vg_getkey(SDLK_UP) );
+   setbtn( k_srbind_mdown,   vg_getkey(SDLK_DOWN) );
+   setbtn( k_srbind_mback,   vg_getkey(SDLK_ESCAPE) );
+   setbtn( k_srbind_maccept, vg_getkey(SDLK_e) );
+   setbtn( k_srbind_maccept, vg_getkey(SDLK_RETURN));
+   setbtn( k_srbind_maccept, vg_getkey(SDLK_RETURN2));
+
+   /* axis
+    * --------------------------------------------*/
+   srinput.axis_grab = vg_getkey( SDLK_LSHIFT );
+
+   v2_zero( srinput.joy_steer );
+   v2_zero( srinput.joy_grab );
+   v2_zero( srinput.joy_look );
+
+   if( vg_getkey( SDLK_d ) ) srinput.joy_steer[0] += 1.0f;
+   if( vg_getkey( SDLK_a ) ) srinput.joy_steer[0] -= 1.0f;
+   if( vg_getkey( SDLK_w ) ) srinput.joy_steer[1] -= 1.0f;
+   if( vg_getkey( SDLK_s ) ) srinput.joy_steer[1] += 1.0f;
+
+   if( vg_input.active_controller_index != -1 ){
+      struct vg_controller *controller = 
+         &vg_input.controllers[vg_input.active_controller_index];
+
+      u32 *buttons = controller->buttons;
+      setbtn( k_srbind_jump,   buttons[ SDL_CONTROLLER_BUTTON_A ] );
+      setbtn( k_srbind_push,   buttons[ SDL_CONTROLLER_BUTTON_B ] );
+      setbtn( k_srbind_trick0, buttons[ SDL_CONTROLLER_BUTTON_A ] );
+      setbtn( k_srbind_trick1, buttons[ SDL_CONTROLLER_BUTTON_B ] );
+      setbtn( k_srbind_trick2, buttons[ SDL_CONTROLLER_BUTTON_X ] );
+      setbtn( k_srbind_use,    buttons[ SDL_CONTROLLER_BUTTON_Y ] );
+      setbtn( k_srbind_reset,  buttons[ SDL_CONTROLLER_BUTTON_LEFTSHOULDER ] );
+      setbtn( k_srbind_camera, buttons[ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ] );
+      setbtn( k_srbind_mleft,  buttons[ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] );
+      setbtn( k_srbind_mright, buttons[ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ] );
+      setbtn( k_srbind_mup,    buttons[ SDL_CONTROLLER_BUTTON_DPAD_UP ] );
+      setbtn( k_srbind_mdown,  buttons[ SDL_CONTROLLER_BUTTON_DPAD_DOWN ] );
+
+      float *axis = controller->axises;
+      
+      srinput.joy_steer[0] += axis[ SDL_CONTROLLER_AXIS_LEFTX ],
+      srinput.joy_steer[1] += axis[ SDL_CONTROLLER_AXIS_LEFTY ],
+      srinput.joy_look[0]  += axis[ SDL_CONTROLLER_AXIS_RIGHTX ];
+      srinput.joy_look[1]  += axis[ SDL_CONTROLLER_AXIS_RIGHTY ];
+      srinput.joy_grab[0]  += axis[ SDL_CONTROLLER_AXIS_RIGHTX ];
+      srinput.joy_grab[1]  += axis[ SDL_CONTROLLER_AXIS_RIGHTY ];
+      srinput.axis_grab    += vg_maxf( 0.0f, 
+                                    axis[ SDL_CONTROLLER_AXIS_TRIGGERRIGHT ] );
+
+      float lh = axis[ SDL_CONTROLLER_AXIS_LEFTX ],
+            lv = axis[ SDL_CONTROLLER_AXIS_LEFTY ],
+            sensitivity = 0.35f;
+
+      if( lh >  sensitivity ) setbtn( k_srbind_mright, 1 );
+      if( lh < -sensitivity ) setbtn( k_srbind_mleft, 1 );
+      if( lv >  sensitivity ) setbtn( k_srbind_mup, 1 );
+      if( lv < -sensitivity ) setbtn( k_srbind_mdown, 1 );
+   }
+
+   //v2_normalize_clamp( srinput.joy_steer );
+   //v2_normalize_clamp( srinput.joy_grab );
+   srinput.axis_grab = vg_minf( 1.0f, srinput.axis_grab );
+}
+
+#endif /* INPUT_H */
diff --git a/menu.h b/menu.h
index 4f9e671304c89ce0ea04df8e4508f7058a4578f5..7a5117d2422d56ae0029d19489c25215a8dece48 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -31,12 +31,14 @@ VG_STATIC const char *playermodels[] = { "ch_new", "ch_jordan", "ch_outlaw" };
 
 GLuint tex_menu;
 
+#if 0
 VG_STATIC struct input_binding input_menu_h,
                                input_menu_v,
                                input_menu_press,
                                input_menu_back,
                                input_menu_toggle,
                                input_menu_toggle_kbm;
+#endif
 
 VG_STATIC void menu_btn_quit( int event );
 VG_STATIC void menu_btn_skater( int event );
@@ -106,6 +108,7 @@ VG_STATIC int menu_vis( struct menu_btn_userdata ud )
       return 0;
 }
 
+#if 0
 VG_STATIC int menu_controller( struct menu_btn_userdata ud )
 {
    if( (game_menu.page & (k_menu_page_main|k_menu_page_settings)) 
@@ -121,6 +124,7 @@ VG_STATIC int menu_controller_inf( struct menu_btn_userdata ud )
       return 1;
    return 0;
 }
+#endif
 
 struct menu_button
 {
@@ -217,6 +221,7 @@ VG_STATIC menu_buttons[] =
 {
    "res_info", menu_vis, {k_menu_page_settings},
 },
+#if 0
 { "ctr_xbox",       menu_controller_inf, {k_steam_controller_type_xbox}},
 { "ctr_xbox_text",  menu_controller_inf, {k_steam_controller_type_xbox}},
 { "ctr_steam",      menu_controller_inf, {k_steam_controller_type_steam}},
@@ -227,6 +232,7 @@ VG_STATIC menu_buttons[] =
 { "ctr_ps_text",    menu_controller_inf, {k_steam_controller_type_playstation}},
 { "ctr_kbm",        menu_controller_inf, {k_steam_controller_type_keyboard}},
 { "ctr_kbm_text",   menu_controller_inf, {k_steam_controller_type_keyboard}},
+#endif
 {
    "text_paused", menu_vis, {k_menu_page_main} 
 },
@@ -358,13 +364,7 @@ VG_STATIC void steam_on_game_overlay( CallbackMsg_t *msg )
 
 VG_STATIC void menu_init(void)
 {
-   vg_create_unnamed_input( &input_menu_h, k_input_type_axis );
-   vg_create_unnamed_input( &input_menu_v, k_input_type_axis );
-   vg_create_unnamed_input( &input_menu_back, k_input_type_button );
-   vg_create_unnamed_input( &input_menu_press, k_input_type_button );
-   vg_create_unnamed_input( &input_menu_toggle, k_input_type_button );
-   vg_create_unnamed_input( &input_menu_toggle_kbm, k_input_type_button );
-
+#if 0
    vg_apply_bind_str( &input_menu_h, "", "gp-ls-h" );
    vg_apply_bind_str( &input_menu_h, "+", "right" );
    vg_apply_bind_str( &input_menu_h, "-", "left" );
@@ -377,6 +377,7 @@ VG_STATIC void menu_init(void)
    vg_apply_bind_str( &input_menu_back, "", "\2escape" );
    vg_apply_bind_str( &input_menu_toggle_kbm, "", "\2escape" );
    vg_apply_bind_str( &input_menu_toggle, "", "\2gp-menu" );
+#endif
 
    vg_linear_clear( vg_mem.scratch );
 
@@ -428,6 +429,7 @@ VG_STATIC void menu_init(void)
 
 VG_STATIC void menu_run_directional(void)
 {
+#if 0
    struct menu_button *btn = &menu_buttons[ game_menu.loc ];
 
    if( vg_input_button_down( &input_menu_press ) ){
@@ -463,11 +465,15 @@ VG_STATIC void menu_run_directional(void)
          }
       }
    }
+#endif
 }
 
 VG_STATIC int menu_page_should_backout(void)
 {
+   return 0;
+#if 0
    return vg_input_button_down( &input_menu_back );
+#endif
 }
 
 VG_STATIC void menu_close(void)
@@ -497,6 +503,7 @@ VG_STATIC void menu_page_map(void)
    }
 
    if( game_menu.map_count > 0 ){
+#if 0 
       float v = input_menu_v.axis.value;
       if( (fabsf(v) > 0.7f) && (menu_input_cooldown <= 0.0f) ){
          audio_lock();
@@ -532,6 +539,7 @@ VG_STATIC void menu_page_map(void)
          menu_close();
 #endif
       }
+#endif
    }
 
    menu_fov_target = 80.0f;
@@ -551,6 +559,7 @@ VG_STATIC void menu_page_quit(void)
 void temp_update_playermodel(void);
 VG_STATIC void menu_page_skater(void)
 {
+#if 0
    float h = input_menu_h.axis.value;
    menu_fov_target = 97.0f;
 
@@ -594,11 +603,13 @@ VG_STATIC void menu_page_skater(void)
 
       temp_update_playermodel();
    }
+#endif
 }
 
 VG_STATIC void menu_slider( float *value, int set_value,
                             mdl_mesh *slider, v3f co_min, v3f co_max )
 {
+#if 0
    if( set_value ){
       float h = input_menu_h.axis.value;
       if( fabsf(h) > 0.04f )
@@ -607,6 +618,7 @@ VG_STATIC void menu_slider( float *value, int set_value,
    }
 
    v3_lerp( co_min, co_max, *value, slider->transform.co );
+#endif
 }
 
 VG_STATIC void menu_page_settings(void)
@@ -640,14 +652,18 @@ VG_STATIC void menu_page_settings(void)
 
 VG_STATIC void menu_update(void)
 {
+#if 0
    vg_input_update( 1, &input_menu_h );
    vg_input_update( 1, &input_menu_v );
    vg_input_update( 1, &input_menu_back );
    vg_input_update( 1, &input_menu_press );
    vg_input_update( 1, &input_menu_toggle );
    vg_input_update( 1, &input_menu_toggle_kbm );
+#endif
    return;
 
+
+#if 0
    int toggle_gp = vg_input_button_down( &input_menu_toggle ),
        toggle_kb = vg_input_button_down( &input_menu_toggle_kbm ),
        wait_for_a_sec = 0;
@@ -762,6 +778,7 @@ VG_STATIC void menu_update(void)
    if( cl_menu ){
       menu_input_cooldown -= vg.time_frame_delta;
    }
+#endif
 }
 
 /* https://iquilezles.org/articles/functions/ */
index d1049e3258eedd142955fe956e5ff2962a729b0a..d351fa05d65025eec693226a053d87f36669d925 100644 (file)
Binary files a/models_src/rs_font.mdl and b/models_src/rs_font.mdl differ
index e2052029635dc3cc40cd8a7ab036fd0461043d54..5b64b8d7f99084f5b2c364e6640d681fbf0738dd 100644 (file)
--- a/player.c
+++ b/player.c
@@ -4,6 +4,7 @@
 #include "player.h"
 #include "camera.h"
 #include "player_model.h"
+#include "input.h"
 
 VG_STATIC int localplayer_cmd_respawn( int argc, const char *argv[] )
 {
@@ -58,72 +59,6 @@ void player__create( player_instance *inst )
    assert( only_once == 0 );
    only_once ++;
 
-   inst->input_js1h = vg_create_named_input( "steer-h", k_input_type_axis );
-   inst->input_js1v = vg_create_named_input( "steer-v", k_input_type_axis );
-   inst->input_grab = vg_create_named_input( "grab",    k_input_type_axis_norm);
-   inst->input_js2h = vg_create_named_input( "grab-h",  k_input_type_axis );
-   inst->input_js2v = vg_create_named_input( "grab-v",  k_input_type_axis );
-   inst->input_jump = vg_create_named_input( "jump",    k_input_type_button );
-   inst->input_push = vg_create_named_input( "push",    k_input_type_button );
-   inst->input_walk = vg_create_named_input( "walk",    k_input_type_button );
-   inst->input_walkh= vg_create_named_input( "walk-h",  k_input_type_axis );
-   inst->input_walkv= vg_create_named_input( "walk-v",  k_input_type_axis );
-   inst->input_use  = vg_create_named_input( "use",     k_input_type_button );
-   inst->input_reset= vg_create_named_input( "reset",   k_input_type_button );
-   inst->input_camera=vg_create_named_input( "camera",  k_input_type_button );
-   inst->input_trick0=vg_create_named_input( "trick0",  k_input_type_button );
-   inst->input_trick1=vg_create_named_input( "trick1",  k_input_type_button );
-   inst->input_trick2=vg_create_named_input( "trick2",  k_input_type_button );
-
-   const char *default_cfg[] = 
-   {
-      "bind  steer-h gp-ls-h",
-      "bind -steer-h a",
-      "bind +steer-h d",
-
-      "bind  steer-v gp-ls-v",
-      "bind -steer-v w",
-      "bind +steer-v s",
-
-      "bind  grab gp-rt",
-      "bind +grab shift",
-      "bind  grab-h gp-rs-h",
-      "bind  grab-v gp-rs-v",
-
-      "bind jump space",
-      "bind jump gp-a",
-
-      "bind trick0 mouse1",
-      "bind trick0 gp-a",
-      "bind trick1 mouse2",
-      "bind trick1 gp-b",
-      "bind trick2 gp-x",     /* keyboard: m0 + m1 */
-
-      "bind push gp-b",
-      "bind push w",
-
-      "bind walk shift",
-      "bind walk gp-ls",
-      
-      "bind  walk-h  gp-ls-h",
-      "bind  walk-v -gp-ls-v",
-      "bind +walk-h d",
-      "bind -walk-h a",
-      "bind +walk-v w",
-      "bind -walk-v s",
-
-      "bind reset gp-lb",
-      "bind reset r",
-
-      "bind use gp-y",
-      "bind use e",
-      "bind camera c",
-      "bind camera gp-rb"
-   };
-
-   for( int i=0; i<vg_list_size(default_cfg); i++ )
-      vg_execute_console_input(default_cfg[i]);
-
    v3_zero( inst->rb.co );
    v3_zero( inst->rb.w );
    v3_zero( inst->rb.v );
@@ -192,7 +127,7 @@ void player__pre_update( player_instance *player )
       return;
    }
 
-   if( vg_input_button_down( player->input_reset ) && !player->immobile ){
+   if( button_down( k_srbind_reset ) && !player->immobile ){
       double delta = world_global.time - world_global.last_use;
 
       if( (delta <= RESET_MAX_TIME) && (world_global.last_use != 0.0) ){
@@ -236,7 +171,7 @@ void player__pre_update( player_instance *player )
       }
    }
 
-   if( vg_input_button_down( player->input_camera ) && !player->immobile ){
+   if( button_down( k_srbind_camera ) && !player->immobile ){
       if( player->camera_mode == k_cam_firstperson )
          player->camera_mode = k_cam_thirdperson;
       else
index d21212baebd6ce9f4f38c26d0442d3e593bc6041..1e3ba671cad5c63d70561bdab470fd8d5a6a3c91 100644 (file)
--- a/player.h
+++ b/player.h
@@ -61,27 +61,6 @@ struct player_instance
 
    ent_gate *gate_waiting;
 
-   /*
-    * Input  TODO: move this
-    * --------------------------------
-    */
-   struct input_binding *input_js1h,
-                        *input_js1v,
-                        *input_js2h,
-                        *input_js2v,
-                        *input_jump,
-                        *input_push,
-                        *input_trick0,
-                        *input_trick1,
-                        *input_trick2,
-                        *input_walk,
-                        *input_walkh,
-                        *input_walkv,
-                        *input_use,
-                        *input_reset,
-                        *input_grab,
-                        *input_camera;
-
    int immobile;
 
    /*
index 4991d231a31f00671635c154c246f9d0b1643e87..a2a2ab2d18771da26f56f5fabadd1b03a9aae2d0 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "player.h"
 #include "conf.h"
+#include "input.h"
 
 VG_STATIC float
    k_cam_spring            = 20.0f,
@@ -243,39 +244,12 @@ VG_STATIC void player_look( player_instance *player, v3f angles )
       mouse_input[1] *= -1.0f;
    v2_muladds( angles, mouse_input, 0.0025f, angles );
 
-   if( vg_input.controller_should_use_trackpad_look ){
-      static v2f last_input;
-      static v2f vel;
-      static v2f vel_smooth;
-
-      v2f input = { player->input_js2h->axis.value,
-                    player->input_js2v->axis.value };
-
-      if( cl_invert_y )
-         input[1] *= -1.0f;
-
-      if( (v2_length2(last_input) > 0.001f) && (v2_length2(input) > 0.001f) ){
-         v2_sub( input, last_input, vel );
-         v2_muls( vel, 1.0f/vg.time_delta, vel );
-      }
-      else{
-         v2_zero( vel );
-      }
-
-      v2_lerp( vel_smooth, vel, vg.time_delta*8.0f, vel_smooth );
-      
-      v2_muladds( angles, vel_smooth, vg.time_delta, angles );
-      v2_copy( input, last_input );
-   }
-   else{
-      angles[0] += player->input_js2h->axis.value * vg.time_delta * 4.0f;
-
-      float input_y = player->input_js2v->axis.value * vg.time_delta * 4.0f;
-      if( cl_invert_y )
-         input_y *= -1.0f;
+   angles[0] += srinput.joy_look[0] * vg.time_delta * 4.0f;
+   float input_y = srinput.joy_look[1] * vg.time_delta * 4.0f;
+   if( cl_invert_y )
+      input_y *= -1.0f;
 
-      angles[1] += input_y;
-   }
+   angles[1] += input_y;
 
    angles[1] = vg_clampf( angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
 }
index 1c082121026d50934fc01958a9739e35588c99cf..89b3f405c2b98d9a2d5b4035ca5615d975c6a9b4 100644 (file)
@@ -2,16 +2,16 @@
 #define PLAYER_DRIVE_C
 
 #include "player.h"
+#include "input.h"
 
 VG_STATIC void player__drive_pre_update( player_instance *player )
 {
    struct player_drive *drive = &player->_drive;
    drivable_vehicle *vehc = drive->vehicle;
 
-   vehc->steer = vg_lerpf( vehc->steer, 
-                           player->input_walkh->axis.value * 0.4f,
+   vehc->steer = vg_lerpf( vehc->steer, srinput.joy_steer[0] * 0.4f,
                            k_rb_delta * 8.0f );
-   vehc->drive = player->input_walkv->axis.value;
+   vehc->drive = srinput.joy_steer[1];
 }
 
 VG_STATIC void player__drive_update( player_instance *player )
index 9b1aea11a47c83f7b35af6553dcecfc0287919f3..fed00580d88dedfa414942e23710ea2b1c64f2de 100644 (file)
@@ -662,15 +662,16 @@ invalidated_grind:;
       v3_copy( best->v, player->rb.v );
       s->land_dist = best->land_dist;
 
-      v2f steer = { player->input_js1h->axis.value,
-                    player->input_js1v->axis.value };
-      v2_normalize_clamp( steer );
       s->state.gravity_bias = best->gravity;
 
       if( best->type == k_prediction_grind ){
          s->state.activity = k_skate_activity_air_to_grind;
       }
 
+      v2f steer;
+      v2_copy( srinput.joy_steer, steer ); 
+      v2_normalize_clamp( steer );
+
       if( (fabsf(steer[1]) > 0.5f) && (s->land_dist >= 1.5f) ){
          s->state.flip_rate = (1.0f/s->land_dist) * vg_signf(steer[1]) *
                                  s->state.reverse ;
@@ -712,10 +713,6 @@ VG_STATIC void skate_apply_air_model( player_instance *player )
    q_axis_angle( correction, axis, 
                   acosf(angle)*2.0f*VG_TIMESTEP_FIXED );
    q_mul( correction, player->rb.q, player->rb.q );
-
-   v2f steer = { player->input_js1h->axis.value,
-                 player->input_js1v->axis.value };
-   v2_normalize_clamp( steer );
 }
 
 VG_STATIC int player_skate_trick_input( player_instance *player );
@@ -793,7 +790,7 @@ VG_STATIC void skate_apply_grab_model( player_instance *player )
 {
    struct player_skate *s = &player->_skate;
 
-   float grabt = player->input_grab->axis.value;
+   float grabt = srinput.axis_grab;
 
    if( grabt > 0.5f ){
       v2_muladds( s->state.grab_mouse_delta, vg.mouse_delta, 0.02f, 
@@ -812,8 +809,8 @@ VG_STATIC void skate_apply_steering_model( player_instance *player )
    struct player_skate *s = &player->_skate;
 
    /* Steering */
-   float steer = player->input_js1h->axis.value,
-         grab  = player->input_grab->axis.value;
+   float steer = srinput.joy_steer[0],
+         grab  = srinput.axis_grab;
 
    steer = vg_signf( steer ) * steer*steer * k_steer_ground;
 
@@ -892,9 +889,8 @@ VG_STATIC void skate_apply_friction_model( player_instance *player )
 
    /* Pushing additive force */
 
-   if( !player->input_jump->button.value ){
-      if( player->input_push->button.value || 
-          (vg.time-s->state.start_push<0.75) )
+   if( !button_press( k_srbind_jump ) ){
+      if( button_press( k_srbind_push ) || (vg.time-s->state.start_push<0.75) )
       {
          if( (vg.time - s->state.cur_push) > 0.25 )
             s->state.start_push = vg.time;
@@ -922,7 +918,7 @@ VG_STATIC void skate_apply_jump_model( player_instance *player )
 {
    struct player_skate *s = &player->_skate;
    int charging_jump_prev = s->state.charging_jump;
-   s->state.charging_jump = player->input_jump->button.value;
+   s->state.charging_jump = button_press( k_srbind_jump );
 
    /* Cannot charge this in air */
    if( s->state.activity <= k_skate_activity_air_to_grind ){
@@ -962,7 +958,7 @@ VG_STATIC void skate_apply_jump_model( player_instance *player )
          s->grind_cooldown = 30;
          s->state.activity = k_skate_activity_ground;
 
-         float tilt  = player->input_js1h->axis.value * 0.3f;
+         float tilt  = srinput.joy_steer[0] * 0.4f;
                tilt *= vg_signf(v3_dot( player->rb.v, s->grind_dir ));
 
          v4f qtilt;
@@ -976,10 +972,6 @@ VG_STATIC void skate_apply_jump_model( player_instance *player )
       s->state.jump_charge = 0.0f;
       s->state.jump_time = vg.time;
 
-      v2f steer = { player->input_js1h->axis.value,
-                    player->input_js1v->axis.value };
-      v2_normalize_clamp( steer );
-
       audio_lock();
       audio_oneshot_3d( &audio_jumps[rand()%2], player->rb.co, 40.0f, 1.0f );
       audio_unlock();
@@ -997,7 +989,7 @@ VG_STATIC void skate_apply_pump_model( player_instance *player )
 
    /* Throw / collect routine 
     */
-   if( player->input_grab->axis.value > 0.5f ){
+   if( srinput.axis_grab > 0.5f ){
       if( s->state.activity == k_skate_activity_ground ){
          /* Throw */
          v3_muls( player->rb.to_world[1], k_mmthrow_scale, s->state.throw_v );
@@ -1042,7 +1034,7 @@ VG_STATIC void skate_apply_cog_model( player_instance *player )
    v3_normalize( ideal_dir );
 
    v3_muladds( player->rb.co, ideal_dir,
-               1.0f-player->input_grab->axis.value, ideal_cog );
+               1.0f-srinput.axis_grab, ideal_cog );
    v3_sub( ideal_cog, s->state.cog, ideal_diff );
 
    /* Apply velocities */
@@ -1109,17 +1101,17 @@ VG_STATIC void skate_copy_holdout( player_instance *player )
 
 VG_STATIC int player_skate_trick_input( player_instance *player )
 {
-   return (player->input_trick0->button.value) |
-          (player->input_trick1->button.value << 1) |
-          (player->input_trick2->button.value << 1) |
-          (player->input_trick2->button.value);
+   return (button_press( k_srbind_trick0 )     ) |
+          (button_press( k_srbind_trick1 ) << 1) |
+          (button_press( k_srbind_trick2 ) << 1) |
+          (button_press( k_srbind_trick2 )     );
 }
 
 VG_STATIC void player__skate_pre_update( player_instance *player )
 {
    struct player_skate *s = &player->_skate;
 
-   if( vg_input_button_down( player->input_use ) ){
+   if( button_down( k_srbind_use ) ){
       player->subsystem = k_player_subsystem_walk;
 
       v3f angles;
@@ -1452,13 +1444,13 @@ VG_STATIC void skate_weight_distribute( player_instance *player )
    int reverse_dir = v3_dot( player->rb.to_world[2], player->rb.v ) < 0.0f?1:-1;
 
    if( s->state.manual_direction == 0 ){
-      if( (player->input_js1v->axis.value > 0.7f) && 
+      if( (srinput.joy_steer[1] > 0.7f) && 
           (s->state.activity == k_skate_activity_ground) &&
           (s->state.jump_charge <= 0.01f) )
          s->state.manual_direction = reverse_dir;
    }
    else{
-      if( player->input_js1v->axis.value < 0.1f ){
+      if( srinput.joy_steer[1] < 0.1f ){
          s->state.manual_direction = 0;
       }
       else{
@@ -1469,7 +1461,7 @@ VG_STATIC void skate_weight_distribute( player_instance *player )
    }
 
    if( s->state.manual_direction ){
-      float amt = vg_minf( player->input_js1v->axis.value * 8.0f, 1.0f );
+      float amt = vg_minf( srinput.joy_steer[1] * 8.0f, 1.0f );
       s->weight_distribution[2] = k_board_length * amt * 
                                           (float)s->state.manual_direction;
    }
@@ -1623,7 +1615,7 @@ VG_STATIC void skate_grind_truck_apply( player_instance *player,
    v3_normalize( fwd );
 
 
-   float way = player->input_js1v->axis.value *
+   float way = srinput.joy_steer[1] *
                   vg_signf( v3_dot( raw_nplane, player->rb.v ) );
 
    v4f q;
@@ -1677,7 +1669,7 @@ VG_STATIC void skate_5050_apply( player_instance *player,
    skate_grind_decay( player, &inf_avg, 1.0f );
 
 
-   float way = player->input_js1v->axis.value *
+   float way = srinput.joy_steer[1] *
                   vg_signf( v3_dot( player->rb.to_world[2], player->rb.v ) );
    v4f q;
    v3f up, target_up;
@@ -1975,14 +1967,13 @@ VG_STATIC enum skate_activity skate_availible_grind( player_instance *player )
        s->state.activity == k_skate_activity_grind_back50 ||
        s->state.activity == k_skate_activity_grind_front50 )
    {
-      float tilt = player->input_js1v->axis.value;
+      float tilt = srinput.joy_steer[1];
 
       if( fabsf(tilt) >= 0.25f ){
          v3f raw = {0.0f,0.0f,tilt};
          m3x3_mulv( player->rb.to_world, raw, raw );
 
-         float way = player->input_js1v->axis.value *
-                        vg_signf( v3_dot( raw, player->rb.v ) );
+         float way = tilt * vg_signf( v3_dot( raw, player->rb.v ) );
 
          if( way < 0.0f ) allow_front = 0;
          else allow_back = 0;
@@ -2020,7 +2011,7 @@ VG_STATIC enum skate_activity skate_availible_grind( player_instance *player )
          res_front50 = skate_grind_truck_entry( player, -1.0f, &inf_front50 );
 
       if( res_back50 != res_front50 ){
-         int wants_to_do_that = fabsf(player->input_js1v->axis.value) >= 0.25f;
+         int wants_to_do_that = fabsf(srinput.joy_steer[1]) >= 0.25f;
 
          res_back50  &= wants_to_do_that;
          res_front50 &= wants_to_do_that;
@@ -2772,7 +2763,7 @@ VG_STATIC void player__skate_animate( player_instance *player,
    
    mdl_keyframe air_pose[32];
    {
-      float target = -player->input_js1h->axis.value;
+      float target = -srinput.joy_steer[1];
 
       s->blend_airdir = vg_lerpf( s->blend_airdir, target, 2.4f*vg.time_delta );
       
@@ -2781,9 +2772,10 @@ VG_STATIC void player__skate_animate( player_instance *player,
 
       static v2f grab_choice;
 
-      v2f grab_input = { player->input_js2h->axis.value,
-                         player->input_js2v->axis.value };
+      v2f grab_input;
+      v2_copy( srinput.joy_grab, grab_input );
       v2_add( s->state.grab_mouse_delta, grab_input, grab_input );
+
       if( v2_length2( grab_input ) <= 0.001f )
          grab_input[0] = -1.0f;
       else
index d8fe3d1fc86868af333c1155b1acc538d8435dc7..4334473e63335f8dde25db931ccfb54727d238bc 100644 (file)
@@ -2,6 +2,7 @@
 #define PLAYER_WALK_C
 
 #include "player.h"
+#include "input.h"
 
 VG_STATIC void player_walk_drop_in_vector( player_instance *player, v3f vec )
 {
@@ -276,7 +277,7 @@ VG_STATIC void player__walk_pre_update( player_instance *player )
          return;
       }
    }
-   else if( vg_input_button_down( player->input_use ) && !player->immobile ){
+   else if( button_down( k_srbind_use ) && !player->immobile ){
       if( v3_dist2( player->rb.co, gzoomer.obj.rb.co ) <= 4.0f*4.0f ){
          player->subsystem = k_player_subsystem_drive;
       }
@@ -375,20 +376,13 @@ VG_STATIC void player__walk_update( player_instance *player )
 
    float yaw = player->angles[0];
 
-   v3f forward_dir = { sinf(yaw),          0.0f, -cosf(yaw) };
-   v3f right_dir   = { -forward_dir[2],    0.0f,  forward_dir[0] };
+   v3f forward_dir = { -sinf(yaw),         0.0f,  cosf(yaw) };
+   v3f right_dir   = {  forward_dir[2],    0.0f, -forward_dir[0] };
 
    m3x3_mulv( player->basis, forward_dir, forward_dir );
    m3x3_mulv( player->basis, right_dir,   right_dir );
 
-
-   v2f walk = { player->input_walkh->axis.value,
-                player->input_walkv->axis.value };
-
-   if( v2_length2(walk) > 0.001f )
-      v2_normalize_clamp( walk );
-
-   w->move_speed = v2_length( walk );
+   w->move_speed = v2_length( srinput.joy_steer );
    world_instance *world = get_active_world();
 
    /* 
@@ -430,8 +424,8 @@ VG_STATIC void player__walk_update( player_instance *player )
     */
    float accel_speed = 0.0f, nominal_speed = 0.0f;
    v3f movedir;
-   v3_muls( right_dir,  walk[0], movedir );
-   v3_muladds( movedir, forward_dir, walk[1], movedir );
+   v3_muls( right_dir, srinput.joy_steer[0], movedir );
+   v3_muladds( movedir, forward_dir, srinput.joy_steer[1], movedir );
 
    if( w->state.activity == k_walk_activity_ground ){
       v3_normalize( surface_avg );
@@ -439,7 +433,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       v3f tx, ty;
       rb_tangent_basis( surface_avg, tx, ty );
 
-      if( v2_length2(walk) > 0.001f ){
+      if( v2_length2(srinput.joy_steer) > 0.001f ){
          /* clip movement to the surface */
          float d = v3_dot(surface_avg,movedir);
          v3_muladds( movedir, surface_avg, -d, movedir );
@@ -449,7 +443,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_walkspeed;
 
       /* jump */
-      if( player->input_jump->button.value ){
+      if( button_down( k_srbind_jump ) ){
          float d = v3_dot( player->basis[1], player->rb.v );
          v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v );
          v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v );
@@ -467,7 +461,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_airspeed;
    }
 
-   if( v2_length2(walk) > 0.001f ){
+   if( v2_length2( srinput.joy_steer ) > 0.001f ){
       player_accelerate( player->rb.v, movedir, nominal_speed, accel_speed );
       v3_normalize( movedir );
    }
@@ -688,10 +682,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
          rate = 9.0f;
 
       w->blend_fly = vg_lerpf( w->blend_fly, fly, rate*vg.time_delta );
-      w->blend_run = vg_lerpf( w->blend_run,
-                               w->move_speed *
-                               (1.0f + player->input_walk->button.value*0.5f),
-                               2.0f*vg.time_delta );
+      w->blend_run = vg_lerpf( w->blend_run, w->move_speed, 2.0f*vg.time_delta);
    }
 
    player_pose apose, bpose;
index 673238c39417885bb90baa8822d299437d34a9e6..31e4e8dd39b6e9fe0a1d3ff6e2f5f0cdc33cce9d 100644 (file)
@@ -13,6 +13,5 @@ in vec3 aCo;
 void main()
 {
    compute_motion_vectors();
-   vec4 diffuse = texture( uTexMain, aUv );
-   FragColor = vec4( diffuse.rgb, 1.0 ) * uColour;
+   FragColor = texture( uTexMain, aUv ) * uColour;
 }
index 7de7971be0a42c9a34ed4453af9fa981d53c69b3..65d53e3f83d1a1a43d97cdbb0661af2643e5a1cb 100644 (file)
@@ -39,7 +39,7 @@ static struct vg_shader _shader_model_font = {
 "uniform mat4x3 uMdl;\n"
 "uniform mat4 uPv;\n"
 "uniform mat4 uPvmPrev;\n"
-"uniform vec3 uOffset;\n"
+"uniform vec4 uOffset;\n"
 "\n"
 "out vec4 aColour;\n"
 "out vec2 aUv;\n"
@@ -49,7 +49,7 @@ static struct vg_shader _shader_model_font = {
 "\n"
 "void main()\n"
 "{\n"
-"   vec3 co = a_co+uOffset;\n"
+"   vec3 co = a_co*uOffset.w+uOffset.xyz;\n"
 "   vec3 world_pos0 = uMdl     * vec4( co, 1.0 );\n"
 "   vec4 vproj0     = uPv      * vec4( world_pos0, 1.0 );\n"
 "   vec4 vproj1     = uPvmPrev * vec4( co, 1.0 );\n"
@@ -102,8 +102,7 @@ static struct vg_shader _shader_model_font = {
 "void main()\n"
 "{\n"
 "   compute_motion_vectors();\n"
-"   vec4 diffuse = texture( uTexMain, aUv );\n"
-"   FragColor = vec4( diffuse.rgb, 1.0 ) * uColour;\n"
+"   FragColor = texture( uTexMain, aUv ) * uColour;\n"
 "}\n"
 ""},
 };
@@ -123,8 +122,8 @@ static void shader_model_font_uPv(m4x4f m){
 static void shader_model_font_uPvmPrev(m4x4f m){
    glUniformMatrix4fv(_uniform_model_font_uPvmPrev,1,GL_FALSE,(float*)m);
 }
-static void shader_model_font_uOffset(v3f v){
-   glUniform3fv(_uniform_model_font_uOffset,1,v);
+static void shader_model_font_uOffset(v4f v){
+   glUniform4fv(_uniform_model_font_uOffset,1,v);
 }
 static void shader_model_font_uTexMain(int i){
    glUniform1i(_uniform_model_font_uTexMain,i);
index 764f008b5d8bc9e66dc015054fb93c717a328b42..6773cf41e0a85ea39d7fef197701b4b7fd2eebb2 100644 (file)
@@ -10,7 +10,7 @@ layout (location=5) in ivec4 a_groups;
 uniform mat4x3 uMdl;
 uniform mat4 uPv;
 uniform mat4 uPvmPrev;
-uniform vec3 uOffset;
+uniform vec4 uOffset;
 
 out vec4 aColour;
 out vec2 aUv;
@@ -20,7 +20,7 @@ out vec3 aWorldCo;
 
 void main()
 {
-   vec3 co = a_co+uOffset;
+   vec3 co = a_co*uOffset.w+uOffset.xyz;
    vec3 world_pos0 = uMdl     * vec4( co, 1.0 );
    vec4 vproj0     = uPv      * vec4( world_pos0, 1.0 );
    vec4 vproj1     = uPvmPrev * vec4( co, 1.0 );
index 8edd117cebcad3929e2d1cf85a44a12d5210add4..e8b1f4dd5e3dea85dee98e0abfe75372d50f0041 100644 (file)
@@ -181,6 +181,8 @@ VG_STATIC void vg_update(void)
 {
    steam_update();
 
+   skaterift_preupdate_inputs();
+
    if( skaterift_status == 1 ){
       draw_origin_axis();
       network_update();
@@ -190,7 +192,7 @@ VG_STATIC void vg_update(void)
 
       world_update( get_active_world(), localplayer.rb.co );
       audio_ambient_sprites_update( get_active_world(), localplayer.rb.co );
-      gui_helper_action( localplayer.input_use, "\x7f Hello \x1f""A \x1e\x84" );
+      //gui_helper_action( localplayer.input_use, "\x7f Hello \x1f""A \x1e\x84" );
    }
 }
 
diff --git a/steam.h b/steam.h
index 969f632aadeb0500de27fe474f72ee63efb03794..52b7a4fe6f8c9d9c9ddd8647a5c9567fc2354b9f 100644 (file)
--- a/steam.h
+++ b/steam.h
 #include "vg/vg_steam_user_stats.h"
 #include "submodules/anyascii/impl/c/anyascii.c"
 
-enum steam_controller_type{
-   k_steam_controller_type_keyboard,
-   k_steam_controller_type_xbox,
-   k_steam_controller_type_playstation,
-   k_steam_controller_type_steam,
-   k_steam_controller_type_steam_deck
-};
-
-VG_STATIC enum steam_controller_type steam_display_controller;
-
 /*
  * We only want to use steamworks if building for the networked version,
  * theres not much point otherwise. We mainly want steamworks for setting
@@ -171,8 +161,6 @@ VG_STATIC void steam_on_recieve_current_stats( CallbackMsg_t *msg )
    }
 }
 
-VG_STATIC ISteamInput *steam_hInput;
-
 VG_STATIC u32 utf8_byte0_byte_count( u8 char0 )
 {
    for( u32 k=2; k<4; k++ ){
@@ -272,10 +260,6 @@ VG_STATIC int steam_init(void)
    vg_console_reg_cmd( "ach_clear_all", steam_clear_all_achievements, NULL );
    vg_console_reg_cmd( "ach_set", steam_set_achievemnt_test, NULL );
 
-   steam_hInput = SteamAPI_SteamInput();
-   SteamAPI_ISteamInput_Init( steam_hInput, 0 );
-   SteamAPI_ISteamInput_RunFrame( steam_hInput, 0 );
-   
 #endif
 
    /* TODO: On username update callback */
@@ -289,47 +273,6 @@ VG_STATIC void steam_update(void)
 {
    if( steam_ready ){
       steamworks_event_loop( hSteamClientPipe );
-
-      /* TODO
-       * We can probably request this from SDL too
-       */
-      if( steam_hInput ){
-         SteamAPI_ISteamInput_RunFrame( steam_hInput, 0 );
-
-         InputHandle_t joy0 = SteamAPI_ISteamInput_GetControllerForGamepadIndex( 
-                                 steam_hInput, 0 );
-
-         vg_input.controller_should_use_trackpad_look = 0;
-         if( joy0 != 0 ){
-            ESteamInputType type = SteamAPI_ISteamInput_GetInputTypeForHandle(
-                                 steam_hInput, joy0 );
-
-            if( type == k_ESteamInputType_SteamController ){
-               vg_input.controller_should_use_trackpad_look = 1;
-               steam_display_controller = k_steam_controller_type_steam;
-            }
-            else if( type == k_ESteamInputType_SteamDeckController ){
-               steam_display_controller = k_steam_controller_type_steam_deck;
-            }
-            else if( type == k_ESteamInputType_PS3Controller ||
-                     type == k_ESteamInputType_PS4Controller ||
-                     type == k_ESteamInputType_PS5Controller )
-            {
-               steam_display_controller = k_steam_controller_type_playstation;
-            }
-            else if( type == k_ESteamInputType_XBox360Controller ||
-                     type == k_ESteamInputType_XBoxOneController )
-            {
-               steam_display_controller = k_steam_controller_type_xbox;
-            }
-            else{
-               /* currently unsupported controller */
-               steam_display_controller = k_steam_controller_type_xbox;
-            }
-         }
-         else
-            steam_display_controller = k_steam_controller_type_keyboard;
-      }
    }
 }