Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
7.4 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Main interface for loading and accessing Steamworks API's from the
  4. // Steam client.
  5. // For most uses, this code is wrapped inside of SteamAPI_Init()
  6. //=============================================================================
  7. #ifndef ISTEAMCLIENT_H
  8. #define ISTEAMCLIENT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "steamtypes.h"
  13. #include "steamclientpublic.h"
  14. // handle to a communication pipe to the Steam client
  15. typedef int32 HSteamPipe;
  16. // handle to single instance of a steam user
  17. typedef int32 HSteamUser;
  18. // function prototype
  19. #if defined( POSIX )
  20. #define __cdecl
  21. #endif
  22. extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *);
  23. #if defined( __SNC__ )
  24. #pragma diag_suppress=1700 // warning 1700: class "%s" has virtual functions but non-virtual destructor
  25. #endif
  26. // interface predec
  27. class ISteamUser;
  28. class ISteamGameServer;
  29. class ISteamFriends;
  30. class ISteamUtils;
  31. class ISteamMatchmaking;
  32. class ISteamContentServer;
  33. class ISteamMatchmakingServers;
  34. class ISteamUserStats;
  35. class ISteamApps;
  36. class ISteamNetworking;
  37. class ISteamRemoteStorage;
  38. class ISteamScreenshots;
  39. class ISteamGameServerStats;
  40. class ISteamPS3OverlayRender;
  41. class ISteamHTTP;
  42. //-----------------------------------------------------------------------------
  43. // Purpose: Interface to creating a new steam instance, or to
  44. // connect to an existing steam instance, whether it's in a
  45. // different process or is local.
  46. //
  47. // For most scenarios this is all handled automatically via SteamAPI_Init().
  48. // You'll only need to use these interfaces if you have a more complex versioning scheme,
  49. // where you want to get different versions of the same interface in different dll's in your project.
  50. //-----------------------------------------------------------------------------
  51. class ISteamClient
  52. {
  53. public:
  54. // Creates a communication pipe to the Steam client
  55. virtual HSteamPipe CreateSteamPipe() = 0;
  56. // Releases a previously created communications pipe
  57. virtual bool BReleaseSteamPipe( HSteamPipe hSteamPipe ) = 0;
  58. // connects to an existing global user, failing if none exists
  59. // used by the game to coordinate with the steamUI
  60. virtual HSteamUser ConnectToGlobalUser( HSteamPipe hSteamPipe ) = 0;
  61. // used by game servers, create a steam user that won't be shared with anyone else
  62. virtual HSteamUser CreateLocalUser( HSteamPipe *phSteamPipe, EAccountType eAccountType ) = 0;
  63. // removes an allocated user
  64. virtual void ReleaseUser( HSteamPipe hSteamPipe, HSteamUser hUser ) = 0;
  65. // retrieves the ISteamUser interface associated with the handle
  66. virtual ISteamUser *GetISteamUser( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  67. // retrieves the ISteamGameServer interface associated with the handle
  68. virtual ISteamGameServer *GetISteamGameServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  69. // set the local IP and Port to bind to
  70. // this must be set before CreateLocalUser()
  71. virtual void SetLocalIPBinding( uint32 unIP, uint16 usPort ) = 0;
  72. // returns the ISteamFriends interface
  73. virtual ISteamFriends *GetISteamFriends( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  74. // returns the ISteamUtils interface
  75. virtual ISteamUtils *GetISteamUtils( HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  76. // returns the ISteamMatchmaking interface
  77. virtual ISteamMatchmaking *GetISteamMatchmaking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  78. // returns the ISteamMatchmakingServers interface
  79. virtual ISteamMatchmakingServers *GetISteamMatchmakingServers( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  80. // returns the a generic interface
  81. virtual void *GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  82. // returns the ISteamUserStats interface
  83. virtual ISteamUserStats *GetISteamUserStats( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  84. // returns the ISteamGameServerStats interface
  85. virtual ISteamGameServerStats *GetISteamGameServerStats( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  86. // returns apps interface
  87. virtual ISteamApps *GetISteamApps( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  88. // networking
  89. virtual ISteamNetworking *GetISteamNetworking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  90. // remote storage
  91. virtual ISteamRemoteStorage *GetISteamRemoteStorage( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  92. // user screenshots
  93. virtual ISteamScreenshots *GetISteamScreenshots( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  94. // this needs to be called every frame to process matchmaking results
  95. // redundant if you're already calling SteamAPI_RunCallbacks()
  96. virtual void RunFrame() = 0;
  97. // returns the number of IPC calls made since the last time this function was called
  98. // Used for perf debugging so you can understand how many IPC calls your game makes per frame
  99. // Every IPC call is at minimum a thread context switch if not a process one so you want to rate
  100. // control how often you do them.
  101. virtual uint32 GetIPCCallCount() = 0;
  102. // API warning handling
  103. // 'int' is the severity; 0 for msg, 1 for warning
  104. // 'const char *' is the text of the message
  105. // callbacks will occur directly after the API function is called that generated the warning or message
  106. virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0;
  107. // Trigger global shutdown for the DLL
  108. virtual bool BShutdownIfAllPipesClosed() = 0;
  109. #ifdef _PS3
  110. virtual ISteamPS3OverlayRender *GetISteamPS3OverlayRender() = 0;
  111. #endif
  112. // Expose HTTP interface
  113. virtual ISteamHTTP *GetISteamHTTP( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0;
  114. };
  115. #define STEAMCLIENT_INTERFACE_VERSION "SteamClient012"
  116. //-----------------------------------------------------------------------------
  117. // Purpose: Base values for callback identifiers, each callback must
  118. // have a unique ID.
  119. //-----------------------------------------------------------------------------
  120. enum { k_iSteamUserCallbacks = 100 };
  121. enum { k_iSteamGameServerCallbacks = 200 };
  122. enum { k_iSteamFriendsCallbacks = 300 };
  123. enum { k_iSteamBillingCallbacks = 400 };
  124. enum { k_iSteamMatchmakingCallbacks = 500 };
  125. enum { k_iSteamContentServerCallbacks = 600 };
  126. enum { k_iSteamUtilsCallbacks = 700 };
  127. enum { k_iClientFriendsCallbacks = 800 };
  128. enum { k_iClientUserCallbacks = 900 };
  129. enum { k_iSteamAppsCallbacks = 1000 };
  130. enum { k_iSteamUserStatsCallbacks = 1100 };
  131. enum { k_iSteamNetworkingCallbacks = 1200 };
  132. enum { k_iClientRemoteStorageCallbacks = 1300 };
  133. enum { k_iSteamUserItemsCallbacks = 1400 };
  134. enum { k_iSteamGameServerItemsCallbacks = 1500 };
  135. enum { k_iClientUtilsCallbacks = 1600 };
  136. enum { k_iSteamGameCoordinatorCallbacks = 1700 };
  137. enum { k_iSteamGameServerStatsCallbacks = 1800 };
  138. enum { k_iSteam2AsyncCallbacks = 1900 };
  139. enum { k_iSteamGameStatsCallbacks = 2000 };
  140. enum { k_iClientHTTPCallbacks = 2100 };
  141. enum { k_iClientScreenshotsCallbacks = 2200 };
  142. enum { k_iSteamScreenshotsCallbacks = 2300 };
  143. enum { k_iClientAudioCallbacks = 2400 };
  144. #endif // ISTEAMCLIENT_H