Rise
The Vieneo Province
Loading...
Searching...
No Matches
steam_api.h
Go to the documentation of this file.
1//====== Copyright Valve Corporation, All rights reserved. ====================
2//
3// This header includes *all* of the interfaces and callback structures
4// in the Steamworks SDK, and some high level functions to control the SDK
5// (init, shutdown, etc) that you probably only need in one or two files.
6//
7// To save your compile times, we recommend that you not include this file
8// in header files. Instead, include the specific headers for the interfaces
9// and callback structures you need. The one file you might consider including
10// in your precompiled header (e.g. stdafx.h) is steam_api_common.h
11//
12//=============================================================================
13
14#ifndef STEAM_API_H
15#define STEAM_API_H
16#ifdef _WIN32
17#pragma once
18#endif
19
20// Basic stuff
21#include "steam_api_common.h"
22
23// All of the interfaces
24#include "isteamclient.h"
25#include "isteamuser.h"
26#include "isteamfriends.h"
27#include "isteamutils.h"
28#include "isteammatchmaking.h"
29#include "isteamuserstats.h"
30#include "isteamapps.h"
31#include "isteamnetworking.h"
32#include "isteamremotestorage.h"
33#include "isteamscreenshots.h"
34#include "isteammusic.h"
35#include "isteamhttp.h"
36#include "isteamcontroller.h"
37#include "isteamugc.h"
38#include "isteamhtmlsurface.h"
39#include "isteaminventory.h"
40#include "isteamtimeline.h"
41#include "isteamvideo.h"
43#include "isteaminput.h"
44#include "isteamremoteplay.h"
48
49
50//----------------------------------------------------------------------------------------------------------------------------------------------------------//
51// Steam API setup & shutdown
52//
53// These functions manage loading, initializing and shutdown of the steamclient.dll
54//
55//----------------------------------------------------------------------------------------------------------------------------------------------------------//
56
58{
60 k_ESteamAPIInitResult_FailedGeneric = 1, // Some other failure
61 k_ESteamAPIInitResult_NoSteamClient = 2, // We cannot connect to Steam, steam probably isn't running
62 k_ESteamAPIInitResult_VersionMismatch = 3, // Steam client appears to be out of date
63};
64
65// Initializing the Steamworks SDK
66// -----------------------------
67//
68// There are three different methods you can use to initialize the Steamworks SDK, depending on
69// your project's environment. You should only use one method in your project.
70//
71// If you are able to include this C++ header in your project, we recommend using the following
72// initialization methods. They will ensure that all ISteam* interfaces defined in other
73// C++ header files have versions that are supported by the user's Steam Client:
74// - SteamAPI_InitEx() for new projects so you can show a detailed error message to the user
75// - SteamAPI_Init() for existing projects that only display a generic error message
76//
77// If you are unable to include this C++ header in your project and are dynamically loading
78// Steamworks SDK methods from dll/so, you can use the following method:
79// - SteamAPI_InitFlat()
80
81
82// See "Initializing the Steamworks SDK" above for how to choose an init method.
83// On success k_ESteamAPIInitResult_OK is returned. Otherwise, returns a value that can be used
84// to create a localized error message for the user. If pOutErrMsg is non-NULL,
85// it will receive an example error message, in English, that explains the reason for the failure.
86//
87// Example usage:
88//
89// SteamErrMsg errMsg;
90// if ( SteamAPI_Init(&errMsg) != k_ESteamAPIInitResult_OK )
91// FatalError( "Failed to init Steam. %s", errMsg );
93
94// See "Initializing the Steamworks SDK" above for how to choose an init method.
95// Returns true on success
96inline bool SteamAPI_Init()
97{
99}
100
101// See "Initializing the Steamworks SDK" above for how to choose an init method.
102// Same usage as SteamAPI_InitEx(), however does not verify ISteam* interfaces are
103// supported by the user's client and is exported from the dll
105
106// SteamAPI_Shutdown should be called during process shutdown if possible.
108
109// SteamAPI_RestartAppIfNecessary ensures that your executable was launched through Steam.
110//
111// Returns true if the current process should terminate. Steam is now re-launching your application.
112//
113// Returns false if no action needs to be taken. This means that your executable was started through
114// the Steam client, or a steam_appid.txt file is present in your game's directory (for development).
115// Your current process should continue if false is returned.
116//
117// NOTE: If you use the Steam DRM wrapper on your primary executable file, this check is unnecessary
118// since the DRM wrapper will ensure that your application was launched properly through Steam.
120
121// Many Steam API functions allocate a small amount of thread-local memory for parameter storage.
122// SteamAPI_ReleaseCurrentThreadMemory() will free API memory associated with the calling thread.
123// This function is also called automatically by SteamAPI_RunCallbacks(), so a single-threaded
124// program never needs to explicitly call this function.
126
127
128// crash dump recording functions
129S_API void S_CALLTYPE SteamAPI_WriteMiniDump( uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID );
131
132//----------------------------------------------------------------------------------------------------------------------------------------------------------//
133// steamclient.dll private wrapper functions
134//
135// The following functions are part of abstracting API access to the steamclient.dll, but should only be used in very specific cases
136//----------------------------------------------------------------------------------------------------------------------------------------------------------//
137
138// SteamAPI_IsSteamRunning() returns true if Steam is currently running
140
141// returns the filename path of the current running Steam process, used if you need to load an explicit steam dll by name.
142// DEPRECATED - implementation is Windows only, and the path returned is a UTF-8 string which must be converted to UTF-16 for use with Win32 APIs
144
145// sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks
146// This is ignored if you are using the manual callback dispatch method
147S_API void SteamAPI_SetTryCatchCallbacks( bool bTryCatchCallbacks );
148
149#if defined( VERSION_SAFE_STEAM_API_INTERFACES )
150// exists only for backwards compat with code written against older SDKs
151S_API bool S_CALLTYPE SteamAPI_InitSafe();
152#endif
153
154#if defined(USE_BREAKPAD_HANDLER) || defined(STEAM_API_EXPORTS)
155// this should be called before the game initialized the steam APIs
156// pchDate should be of the format "Mmm dd yyyy" (such as from the __ DATE __ macro )
157// pchTime should be of the format "hh:mm:ss" (such as from the __ TIME __ macro )
158// bFullMemoryDumps (Win32 only) -- writes out a uuid-full.dmp in the client/dumps folder
159// pvContext-- can be NULL, will be the void * context passed into m_pfnPreMinidumpCallback
160// PFNPreMinidumpCallback m_pfnPreMinidumpCallback -- optional callback which occurs just before a .dmp file is written during a crash. Applications can hook this to allow adding additional information into the .dmp comment stream.
161S_API void S_CALLTYPE SteamAPI_UseBreakpadCrashHandler( char const *pchVersion, char const *pchDate, char const *pchTime, bool bFullMemoryDumps, void *pvContext, PFNPreMinidumpCallback m_pfnPreMinidumpCallback );
162S_API void S_CALLTYPE SteamAPI_SetBreakpadAppID( uint32 unAppID );
163#endif
164
165//----------------------------------------------------------------------------------------------------------------------------------------------------------//
166//
167// Manual callback loop
168//
169// An alternative method for dispatching callbacks. Similar to a windows message loop.
170//
171// If you use the manual callback dispatch, you must NOT use:
172//
173// - SteamAPI_RunCallbacks or SteamGameServer_RunCallbacks
174// - STEAM_CALLBACK, CCallResult, CCallback, or CCallbackManual
175//
176// Here is the basic template for replacing SteamAPI_RunCallbacks() with manual dispatch
177/*
178
179 HSteamPipe hSteamPipe = SteamAPI_GetHSteamPipe(); // See also SteamGameServer_GetHSteamPipe()
180 SteamAPI_ManualDispatch_RunFrame( hSteamPipe )
181 CallbackMsg_t callback;
182 while ( SteamAPI_ManualDispatch_GetNextCallback( hSteamPipe, &callback ) )
183 {
184 // Check for dispatching API call results
185 if ( callback.m_iCallback == SteamAPICallCompleted_t::k_iCallback )
186 {
187 SteamAPICallCompleted_t *pCallCompleted = (SteamAPICallCompleted_t *)callback.
188 void *pTmpCallResult = malloc( pCallback->m_cubParam );
189 bool bFailed;
190 if ( SteamAPI_ManualDispatch_GetAPICallResult( hSteamPipe, pCallCompleted->m_hAsyncCall, pTmpCallResult, pCallback->m_cubParam, pCallback->m_iCallback, &bFailed ) )
191 {
192 // Dispatch the call result to the registered handler(s) for the
193 // call identified by pCallCompleted->m_hAsyncCall
194 }
195 free( pTmpCallResult );
196 }
197 else
198 {
199 // Look at callback.m_iCallback to see what kind of callback it is,
200 // and dispatch to appropriate handler(s)
201 }
202 SteamAPI_ManualDispatch_FreeLastCallback( hSteamPipe );
203 }
204
205*/
206//----------------------------------------------------------------------------------------------------------------------------------------------------------//
207
211
214
219
222
225S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed );
226
227// Internal implementation of SteamAPI_InitEx. This is done in a way that checks
228// all of the versions of interfaces from headers being compiled into this code.
229S_API ESteamAPIInitResult S_CALLTYPE SteamInternal_SteamAPI_Init( const char *pszInternalCheckInterfaceVersions, SteamErrMsg *pOutErrMsg );
262
263#endif // STEAM_API_H
#define STEAMAPPS_INTERFACE_VERSION
Definition isteamapps.h:140
#define STEAMCONTROLLER_INTERFACE_VERSION
#define STEAMFRIENDS_INTERFACE_VERSION
#define STEAMHTMLSURFACE_INTERFACE_VERSION
#define STEAMHTTP_INTERFACE_VERSION
Definition isteamhttp.h:143
#define STEAMINPUT_INTERFACE_VERSION
#define STEAMINVENTORY_INTERFACE_VERSION
#define STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION
#define STEAMMATCHMAKING_INTERFACE_VERSION
#define STEAMPARTIES_INTERFACE_VERSION
#define STEAMMUSIC_INTERFACE_VERSION
Definition isteammusic.h:45
#define STEAMNETWORKING_INTERFACE_VERSION
#define STEAMNETWORKINGMESSAGES_INTERFACE_VERSION
#define STEAMNETWORKINGSOCKETS_INTERFACE_VERSION
#define STEAMNETWORKINGUTILS_INTERFACE_VERSION
#define STEAMPARENTALSETTINGS_INTERFACE_VERSION
#define STEAMREMOTEPLAY_INTERFACE_VERSION
#define STEAMREMOTESTORAGE_INTERFACE_VERSION
#define STEAMSCREENSHOTS_INTERFACE_VERSION
#define STEAMUGC_INTERFACE_VERSION
Definition isteamugc.h:416
#define STEAMUSER_INTERFACE_VERSION
Definition isteamuser.h:222
#define STEAMUSERSTATS_INTERFACE_VERSION
#define STEAMUTILS_INTERFACE_VERSION
#define STEAMVIDEO_INTERFACE_VERSION
Definition isteamvideo.h:45
S_API bool S_CALLTYPE SteamAPI_RestartAppIfNecessary(uint32 unOwnAppID)
S_API void S_CALLTYPE SteamAPI_SetMiniDumpComment(const char *pchMsg)
ESteamAPIInitResult
Definition steam_api.h:58
@ k_ESteamAPIInitResult_FailedGeneric
Definition steam_api.h:60
@ k_ESteamAPIInitResult_VersionMismatch
Definition steam_api.h:62
@ k_ESteamAPIInitResult_NoSteamClient
Definition steam_api.h:61
@ k_ESteamAPIInitResult_OK
Definition steam_api.h:59
S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetAPICallResult(HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed)
S_API void S_CALLTYPE SteamAPI_ManualDispatch_FreeLastCallback(HSteamPipe hSteamPipe)
You must call this after dispatching the callback, if SteamAPI_ManualDispatch_GetNextCallback returns...
S_API bool S_CALLTYPE SteamAPI_ManualDispatch_GetNextCallback(HSteamPipe hSteamPipe, CallbackMsg_t *pCallbackMsg)
S_API ESteamAPIInitResult S_CALLTYPE SteamInternal_SteamAPI_Init(const char *pszInternalCheckInterfaceVersions, SteamErrMsg *pOutErrMsg)
S_API void SteamAPI_SetTryCatchCallbacks(bool bTryCatchCallbacks)
S_API ESteamAPIInitResult S_CALLTYPE SteamAPI_InitFlat(SteamErrMsg *pOutErrMsg)
S_API void S_CALLTYPE SteamAPI_ManualDispatch_RunFrame(HSteamPipe hSteamPipe)
Perform certain periodic actions that need to be performed.
S_API void S_CALLTYPE SteamAPI_ManualDispatch_Init()
ESteamAPIInitResult SteamAPI_InitEx(SteamErrMsg *pOutErrMsg)
Definition steam_api.h:230
S_API void S_CALLTYPE SteamAPI_Shutdown()
S_API const char * SteamAPI_GetSteamInstallPath()
S_API bool S_CALLTYPE SteamAPI_IsSteamRunning()
S_API void S_CALLTYPE SteamAPI_WriteMiniDump(uint32 uStructuredExceptionCode, void *pvExceptionInfo, uint32 uBuildID)
bool SteamAPI_Init()
Definition steam_api.h:96
S_API void S_CALLTYPE SteamAPI_ReleaseCurrentThreadMemory()
#define S_API
int32 HSteamPipe
char SteamErrMsg[k_cchMaxSteamErrMsg]
const char *typedef uint32(S_CALLTYPE *SteamAPI_CheckCallbackRegistered_t)(int iCallbackNum)
void(*) PFNPreMinidumpCallback(void *context)
uint64 SteamAPICall_t
Definition steamtypes.h:93
#define S_CALLTYPE
Definition steamtypes.h:6
Internal structure used in manual callback dispatch.