2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 * All trademarks are property of their respective owners
9 #include "vg/vg_steam.h"
10 #include "vg/vg_steam_utils.h"
11 #include "vg/vg_steam_networking.h"
12 #include "vg/vg_steam_auth.h"
13 #include "vg/vg_steam_http.h"
14 #include "vg/vg_steam_friends.h"
17 * We only want to use steamworks if building for the networked version,
18 * theres not much point otherwise. We mainly want steamworks for setting
19 * achievements etc.. so that includes our own server too.
21 * This file also wraps the functions and interfaces that we want to use to
22 * make them a bit easier to read, since they are the flat API they have very
23 * long names. in non-networked builds they will return default errors or do
27 static char steam_username_at_startup
[128];
29 static void recv_steam_warning( int severity
, const char *msg
)
32 vg_low( "%s\n", msg
);
34 vg_info( "%s\n", msg
);
37 static int steam_ready
= 0;
38 static void *hSteamNetworkingSockets
,
41 static HSteamPipe hSteamClientPipe
;
43 static int steam_init(void)
45 const char *username
= NULL
;
48 vg_info( "Initializing steamworks\n" );
50 if( !SteamAPI_Init() )
53 vg_error( "Steamworks failed to initialize\n" );
59 SteamAPI_ManualDispatch_Init();
61 /* Connect interfaces */
62 hSteamClientPipe
= SteamAPI_GetHSteamPipe();
63 hSteamNetworkingSockets
= SteamAPI_SteamNetworkingSockets_SteamAPI();
64 hSteamUser
= SteamAPI_SteamUser();
66 ISteamUtils
*utils
= SteamAPI_SteamUtils();
67 SteamAPI_ISteamUtils_SetWarningMessageHook( utils
, recv_steam_warning
);
70 vg_success( "\nSteamworks API running\n" );
72 ISteamFriends
*hSteamFriends
= SteamAPI_SteamFriends();
73 username
= SteamAPI_ISteamFriends_GetPersonaName( hSteamFriends
);
76 /* TODO: On username update callback */
77 str_utf8_collapse( username
, steam_username_at_startup
,
78 vg_list_size(steam_username_at_startup
) );
83 static void steam_update(void)
86 steamworks_event_loop( hSteamClientPipe
);
89 static void steam_end(void *nothing
)
93 vg_info( "Shutting down\n..." );