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.

256 lines
11 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: interface to utility functions in Steam
  4. //
  5. //=============================================================================
  6. #ifndef ISTEAMUTILS_H
  7. #define ISTEAMUTILS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "isteamclient.h"
  12. // Steam API call failure results
  13. enum ESteamAPICallFailure
  14. {
  15. k_ESteamAPICallFailureNone = -1, // no failure
  16. k_ESteamAPICallFailureSteamGone = 0, // the local Steam process has gone away
  17. k_ESteamAPICallFailureNetworkFailure = 1, // the network connection to Steam has been broken, or was already broken
  18. // SteamServersDisconnected_t callback will be sent around the same time
  19. // SteamServersConnected_t will be sent when the client is able to talk to the Steam servers again
  20. k_ESteamAPICallFailureInvalidHandle = 2, // the SteamAPICall_t handle passed in no longer exists
  21. k_ESteamAPICallFailureMismatchedCallback = 3,// GetAPICallResult() was called with the wrong callback type for this API call
  22. };
  23. // function prototype for warning message hook
  24. #if defined( POSIX )
  25. #define __cdecl
  26. #endif
  27. extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *);
  28. //-----------------------------------------------------------------------------
  29. // Purpose: interface to user independent utility functions
  30. //-----------------------------------------------------------------------------
  31. class ISteamUtils
  32. {
  33. public:
  34. // return the number of seconds since the user
  35. virtual uint32 GetSecondsSinceAppActive() = 0;
  36. virtual uint32 GetSecondsSinceComputerActive() = 0;
  37. // the universe this client is connecting to
  38. virtual EUniverse GetConnectedUniverse() = 0;
  39. // Steam server time - in PST, number of seconds since January 1, 1970 (i.e unix time)
  40. virtual uint32 GetServerRealTime() = 0;
  41. // returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database)
  42. // e.g "US" or "UK".
  43. virtual const char *GetIPCountry() = 0;
  44. // returns true if the image exists, and valid sizes were filled out
  45. virtual bool GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight ) = 0;
  46. // returns true if the image exists, and the buffer was successfully filled out
  47. // results are returned in RGBA format
  48. // the destination buffer size should be 4 * height * width * sizeof(char)
  49. virtual bool GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize ) = 0;
  50. // returns the IP of the reporting server for valve - currently only used in Source engine games
  51. virtual bool GetCSERIPPort( uint32 *unIP, uint16 *usPort ) = 0;
  52. // return the amount of battery power left in the current system in % [0..100], 255 for being on AC power
  53. virtual uint8 GetCurrentBatteryPower() = 0;
  54. // returns the appID of the current process
  55. virtual uint32 GetAppID() = 0;
  56. // Sets the position where the overlay instance for the currently calling game should show notifications.
  57. // This position is per-game and if this function is called from outside of a game context it will do nothing.
  58. virtual void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition ) = 0;
  59. // API asynchronous call results
  60. // can be used directly, but more commonly used via the callback dispatch API (see steam_api.h)
  61. virtual bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall, bool *pbFailed ) = 0;
  62. virtual ESteamAPICallFailure GetAPICallFailureReason( SteamAPICall_t hSteamAPICall ) = 0;
  63. virtual bool GetAPICallResult( SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed ) = 0;
  64. // this needs to be called every frame to process matchmaking results
  65. // redundant if you're already calling SteamAPI_RunCallbacks()
  66. virtual void RunFrame() = 0;
  67. // returns the number of IPC calls made since the last time this function was called
  68. // Used for perf debugging so you can understand how many IPC calls your game makes per frame
  69. // Every IPC call is at minimum a thread context switch if not a process one so you want to rate
  70. // control how often you do them.
  71. virtual uint32 GetIPCCallCount() = 0;
  72. // API warning handling
  73. // 'int' is the severity; 0 for msg, 1 for warning
  74. // 'const char *' is the text of the message
  75. // callbacks will occur directly after the API function is called that generated the warning or message
  76. virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0;
  77. // Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to
  78. // start & hook the game process, so this function will initially return false while the overlay is loading.
  79. virtual bool IsOverlayEnabled() = 0;
  80. // Normally this call is unneeded if your game has a constantly running frame loop that calls the
  81. // D3D Present API, or OGL SwapBuffers API every frame.
  82. //
  83. // However, if you have a game that only refreshes the screen on an event driven basis then that can break
  84. // the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also
  85. // need to Present() to the screen any time an even needing a notification happens or when the overlay is
  86. // brought up over the game by a user. You can use this API to ask the overlay if it currently need a present
  87. // in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you
  88. // refresh the screen with Present or SwapBuffers to allow the overlay to do it's work.
  89. virtual bool BOverlayNeedsPresent() = 0;
  90. #ifndef _PS3
  91. // Asynchronous call to check if an executable file has been signed using the public key set on the signing tab
  92. // of the partner site, for example to refuse to load modified executable files.
  93. // The result is returned in CheckFileSignature_t.
  94. // k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function.
  95. // k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site.
  96. // k_ECheckFileSignatureFileNotFound - The file does not exist on disk.
  97. // k_ECheckFileSignatureInvalidSignature - The file exists, and the signing tab has been set for this file, but the file is either not signed or the signature does not match.
  98. // k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid.
  99. virtual SteamAPICall_t CheckFileSignature( const char *szFileName ) = 0;
  100. #endif
  101. #ifdef _PS3
  102. virtual void PostPS3SysutilCallback( uint64_t status, uint64_t param, void* userdata ) = 0;
  103. virtual bool BIsReadyToShutdown() = 0;
  104. virtual bool BIsPSNOnline() = 0;
  105. // Call this with localized strings for the language the game is running in, otherwise default english
  106. // strings will be used by Steam.
  107. virtual void SetPSNGameBootInviteStrings( const char *pchSubject, const char *pchBody ) = 0;
  108. #endif
  109. };
  110. #define STEAMUTILS_INTERFACE_VERSION "SteamUtils005"
  111. // callbacks
  112. #pragma pack( push, 8 )
  113. //-----------------------------------------------------------------------------
  114. // Purpose: The country of the user changed
  115. //-----------------------------------------------------------------------------
  116. struct IPCountry_t
  117. {
  118. enum { k_iCallback = k_iSteamUtilsCallbacks + 1 };
  119. };
  120. //-----------------------------------------------------------------------------
  121. // Purpose: Fired when running on a laptop and less than 10 minutes of battery is left, fires then every minute
  122. //-----------------------------------------------------------------------------
  123. struct LowBatteryPower_t
  124. {
  125. enum { k_iCallback = k_iSteamUtilsCallbacks + 2 };
  126. uint8 m_nMinutesBatteryLeft;
  127. };
  128. //-----------------------------------------------------------------------------
  129. // Purpose: called when a SteamAsyncCall_t has completed (or failed)
  130. //-----------------------------------------------------------------------------
  131. struct SteamAPICallCompleted_t
  132. {
  133. enum { k_iCallback = k_iSteamUtilsCallbacks + 3 };
  134. SteamAPICall_t m_hAsyncCall;
  135. };
  136. //-----------------------------------------------------------------------------
  137. // called when Steam wants to shutdown
  138. //-----------------------------------------------------------------------------
  139. struct SteamShutdown_t
  140. {
  141. enum { k_iCallback = k_iSteamUtilsCallbacks + 4 };
  142. };
  143. //-----------------------------------------------------------------------------
  144. // results for CheckFileSignature
  145. //-----------------------------------------------------------------------------
  146. enum ECheckFileSignature
  147. {
  148. k_ECheckFileSignatureInvalidSignature = 0,
  149. k_ECheckFileSignatureValidSignature = 1,
  150. k_ECheckFileSignatureFileNotFound = 2,
  151. k_ECheckFileSignatureNoSignaturesFoundForThisApp = 3,
  152. k_ECheckFileSignatureNoSignaturesFoundForThisFile = 4,
  153. };
  154. //-----------------------------------------------------------------------------
  155. // callback for CheckFileSignature
  156. //-----------------------------------------------------------------------------
  157. struct CheckFileSignature_t
  158. {
  159. enum { k_iCallback = k_iSteamUtilsCallbacks + 5 };
  160. ECheckFileSignature m_eCheckFileSignature;
  161. };
  162. #ifdef _PS3
  163. //-----------------------------------------------------------------------------
  164. // callback for NetCtlNetStartDialog finishing on PS3
  165. //-----------------------------------------------------------------------------
  166. struct NetStartDialogFinished_t
  167. {
  168. enum { k_iCallback = k_iSteamUtilsCallbacks + 6 };
  169. };
  170. //-----------------------------------------------------------------------------
  171. // callback for NetCtlNetStartDialog unloaded on PS3
  172. //-----------------------------------------------------------------------------
  173. struct NetStartDialogUnloaded_t
  174. {
  175. enum { k_iCallback = k_iSteamUtilsCallbacks + 7 };
  176. };
  177. //-----------------------------------------------------------------------------
  178. // callback for system menu closing on PS3 - should trigger resyncronizing friends list, etc.
  179. //-----------------------------------------------------------------------------
  180. struct PS3SystemMenuClosed_t
  181. {
  182. enum { k_iCallback = k_iSteamUtilsCallbacks + 8 };
  183. };
  184. //-----------------------------------------------------------------------------
  185. // callback for NP message being selected by user on PS3 - should trigger handling of message if it's a lobby invite, etc.
  186. //-----------------------------------------------------------------------------
  187. struct PS3NPMessageSelected_t
  188. {
  189. enum { k_iCallback = k_iSteamUtilsCallbacks + 9 };
  190. uint32 dataid;
  191. };
  192. //-----------------------------------------------------------------------------
  193. // callback for when the PS3 keyboard dialog closes
  194. //-----------------------------------------------------------------------------
  195. struct PS3KeyboardDialogFinished_t
  196. {
  197. enum { k_iCallback = k_iSteamUtilsCallbacks + 10 };
  198. };
  199. // k_iSteamUtilsCallbacks + 11 is taken
  200. //-----------------------------------------------------------------------------
  201. // callback for PSN status changing on PS3
  202. //-----------------------------------------------------------------------------
  203. struct PS3PSNStatusChange_t
  204. {
  205. enum { k_iCallback = k_iSteamUtilsCallbacks + 12 };
  206. bool m_bPSNOnline;
  207. };
  208. #endif
  209. #pragma pack( pop )
  210. #endif // ISTEAMUTILS_H