add player guide
[carveJwlIkooP6JGAAIwe30JlM.git] / steam.h
diff --git a/steam.h b/steam.h
index 969f632aadeb0500de27fe474f72ee63efb03794..09e3935aecff37421f81fd31058136961a3bf3e6 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
@@ -48,7 +38,7 @@ VG_STATIC void recv_steam_warning( int severity, const char *msg )
 }
 
 VG_STATIC int steam_ready = 0,
-           steam_stats_ready = 0;
+              steam_stats_ready = 0;
 
 VG_STATIC void *hSteamNetworkingSockets,
             *hSteamUser;
@@ -101,13 +91,12 @@ VG_STATIC void steam_clear_achievement( const char *name )
 }
 
 
-VG_STATIC int steam_list_achievements( int argc, char const *argv[] )
-{
+VG_STATIC void steam_print_all_achievements(void){
    vg_info( "Achievements: \n" );
 
    if( steam_ready && steam_stats_ready ){
       for( int i=0; i<vg_list_size(steam_achievement_names); i++ ){
-         int set = 0;
+         steamapi_bool set = 0;
          const char *name = steam_achievement_names[i];
 
          if( SteamAPI_ISteamUserStats_GetAchievement( 
@@ -123,38 +112,39 @@ VG_STATIC int steam_list_achievements( int argc, char const *argv[] )
    else{
       vg_warn( "  Steam is not initialized, no results\n" );
    }
-
-   return 0;
 }
 
-VG_STATIC int steam_clear_all_achievements( int argc, char const *argv[] )
+VG_STATIC int steam_achievement_ccmd( int argc, char const *argv[] )
 {
-   if( steam_ready && steam_stats_ready ){
-      for( int i=0; i<vg_list_size(steam_achievement_names); i++ ){
-         steam_clear_achievement( steam_achievement_names[i] );
+   if( !(steam_ready && steam_stats_ready) ) return 1;
+
+   if( argc == 1 ){
+      if( !strcmp( argv[0], "list" ) ){
+         steam_print_all_achievements();
+         return 0;
+      }
+      else if( !strcmp( argv[0], "clearall" )){
+         for( int i=0; i<vg_list_size(steam_achievement_names); i++ )
+            steam_clear_achievement( steam_achievement_names[i] );
+         
+         steam_store_achievements();
       }
-      
-      steam_store_achievements();
-   }
-   else{
-      vg_warn( "steam is not initialized, cannot clear\n" );
    }
 
-   return 0;
-}
-
-VG_STATIC int steam_set_achievemnt_test( int argc, char const *argv[] )
-{
-   if( argc < 2 )
-      return 0;
-
-   if( strcmp( argv[0], "monkey_island" ) )
-      return 0;
-
-   steam_set_achievement( argv[1] );
-   steam_store_achievements();
+   if( argc == 2 ){
+      if( !strcmp( argv[0], "set" ) ){
+         steam_set_achievement( argv[1] );
+         steam_store_achievements();
+         return 0;
+      }
+      else if( strcmp( argv[0], "clear" ) ){
+         steam_clear_achievement( argv[1] );
+         steam_store_achievements();
+         return 0;
+      }
+   }
 
-   return 0;
+   return 1;
 }
 
 VG_STATIC void steam_on_recieve_current_stats( CallbackMsg_t *msg )
@@ -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++ ){
@@ -260,7 +248,6 @@ VG_STATIC int steam_init(void)
     * --------------------------------------------------------
     */
    hSteamUserStats = SteamAPI_SteamUserStats();
-
    steam_register_callback( k_iUserStatsReceived,
                             steam_on_recieve_current_stats );
 
@@ -268,14 +255,8 @@ VG_STATIC int steam_init(void)
       vg_warn( "No Steam Logon: Cannot request stats\n" );
 
 
-   vg_console_reg_cmd( "ach_list", steam_list_achievements, NULL );
-   vg_console_reg_cmd( "ach_clear_all", steam_clear_all_achievements, NULL );
-   vg_console_reg_cmd( "ach_set", steam_set_achievemnt_test, NULL );
+   vg_console_reg_cmd( "ach", steam_achievement_ccmd, 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 +270,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;
-      }
    }
 }