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.

254 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. // Input modes for the Big Picture gamepad text entry
  24. enum EGamepadTextInputMode
  25. {
  26. k_EGamepadTextInputModeNormal = 0,
  27. k_EGamepadTextInputModePassword = 1
  28. };
  29. // Controls number of allowed lines for the Big Picture gamepad text entry
  30. enum EGamepadTextInputLineMode
  31. {
  32. k_EGamepadTextInputLineModeSingleLine = 0,
  33. k_EGamepadTextInputLineModeMultipleLines = 1
  34. };
  35. // function prototype for warning message hook
  36. #if defined( POSIX )
  37. #define __cdecl
  38. #endif
  39. extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *);
  40. //-----------------------------------------------------------------------------
  41. // Purpose: interface to user independent utility functions
  42. //-----------------------------------------------------------------------------
  43. class ISteamUtils
  44. {
  45. public:
  46. // return the number of seconds since the user
  47. virtual uint32 GetSecondsSinceAppActive() = 0;
  48. virtual uint32 GetSecondsSinceComputerActive() = 0;
  49. // the universe this client is connecting to
  50. virtual EUniverse GetConnectedUniverse() = 0;
  51. // Steam server time - in PST, number of seconds since January 1, 1970 (i.e unix time)
  52. virtual uint32 GetServerRealTime() = 0;
  53. // 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)
  54. // e.g "US" or "UK".
  55. virtual const char *GetIPCountry() = 0;
  56. // returns true if the image exists, and valid sizes were filled out
  57. virtual bool GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight ) = 0;
  58. // returns true if the image exists, and the buffer was successfully filled out
  59. // results are returned in RGBA format
  60. // the destination buffer size should be 4 * height * width * sizeof(char)
  61. virtual bool GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize ) = 0;
  62. // returns the IP of the reporting server for valve - currently only used in Source engine games
  63. virtual bool GetCSERIPPort( uint32 *unIP, uint16 *usPort ) = 0;
  64. // return the amount of battery power left in the current system in % [0..100], 255 for being on AC power
  65. virtual uint8 GetCurrentBatteryPower() = 0;
  66. // returns the appID of the current process
  67. virtual uint32 GetAppID() = 0;
  68. // Sets the position where the overlay instance for the currently calling game should show notifications.
  69. // This position is per-game and if this function is called from outside of a game context it will do nothing.
  70. virtual void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition ) = 0;
  71. // API asynchronous call results
  72. // can be used directly, but more commonly used via the callback dispatch API (see steam_api.h)
  73. virtual bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall, bool *pbFailed ) = 0;
  74. virtual ESteamAPICallFailure GetAPICallFailureReason( SteamAPICall_t hSteamAPICall ) = 0;
  75. virtual bool GetAPICallResult( SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed ) = 0;
  76. // Deprecated. Applications should use SteamAPI_RunCallbacks() instead. Game servers do not need to call this function.
  77. STEAM_PRIVATE_API( virtual void RunFrame() = 0; )
  78. // returns the number of IPC calls made since the last time this function was called
  79. // Used for perf debugging so you can understand how many IPC calls your game makes per frame
  80. // Every IPC call is at minimum a thread context switch if not a process one so you want to rate
  81. // control how often you do them.
  82. virtual uint32 GetIPCCallCount() = 0;
  83. // API warning handling
  84. // 'int' is the severity; 0 for msg, 1 for warning
  85. // 'const char *' is the text of the message
  86. // callbacks will occur directly after the API function is called that generated the warning or message
  87. virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0;
  88. // Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to
  89. // start & hook the game process, so this function will initially return false while the overlay is loading.
  90. virtual bool IsOverlayEnabled() = 0;
  91. // Normally this call is unneeded if your game has a constantly running frame loop that calls the
  92. // D3D Present API, or OGL SwapBuffers API every frame.
  93. //
  94. // However, if you have a game that only refreshes the screen on an event driven basis then that can break
  95. // the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also
  96. // need to Present() to the screen any time an even needing a notification happens or when the overlay is
  97. // brought up over the game by a user. You can use this API to ask the overlay if it currently need a present
  98. // in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you
  99. // refresh the screen with Present or SwapBuffers to allow the overlay to do it's work.
  100. virtual bool BOverlayNeedsPresent() = 0;
  101. // Asynchronous call to check if an executable file has been signed using the public key set on the signing tab
  102. // of the partner site, for example to refuse to load modified executable files.
  103. // The result is returned in CheckFileSignature_t.
  104. // k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function.
  105. // k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site.
  106. // k_ECheckFileSignatureFileNotFound - The file does not exist on disk.
  107. // 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.
  108. // k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid.
  109. CALL_RESULT( CheckFileSignature_t )
  110. virtual SteamAPICall_t CheckFileSignature( const char *szFileName ) = 0;
  111. // Activates the Big Picture text input dialog which only supports gamepad input
  112. virtual bool ShowGamepadTextInput( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32 unCharMax, const char *pchExistingText ) = 0;
  113. // Returns previously entered text & length
  114. virtual uint32 GetEnteredGamepadTextLength() = 0;
  115. virtual bool GetEnteredGamepadTextInput( char *pchText, uint32 cchText ) = 0;
  116. // returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases
  117. virtual const char *GetSteamUILanguage() = 0;
  118. // returns true if Steam itself is running in VR mode
  119. virtual bool IsSteamRunningInVR() = 0;
  120. // Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.
  121. virtual void SetOverlayNotificationInset( int nHorizontalInset, int nVerticalInset ) = 0;
  122. // returns true if Steam & the Steam Overlay are running in Big Picture mode
  123. // Games much be launched through the Steam client to enable the Big Picture overlay. During development,
  124. // a game can be added as a non-steam game to the developers library to test this feature
  125. virtual bool IsSteamInBigPictureMode() = 0;
  126. // ask SteamUI to create and render its OpenVR dashboard
  127. virtual void StartVRDashboard() = 0;
  128. };
  129. #define STEAMUTILS_INTERFACE_VERSION "SteamUtils008"
  130. // callbacks
  131. #if defined( VALVE_CALLBACK_PACK_SMALL )
  132. #pragma pack( push, 4 )
  133. #elif defined( VALVE_CALLBACK_PACK_LARGE )
  134. #pragma pack( push, 8 )
  135. #else
  136. #error isteamclient.h must be included
  137. #endif
  138. //-----------------------------------------------------------------------------
  139. // Purpose: The country of the user changed
  140. //-----------------------------------------------------------------------------
  141. struct IPCountry_t
  142. {
  143. enum { k_iCallback = k_iSteamUtilsCallbacks + 1 };
  144. };
  145. //-----------------------------------------------------------------------------
  146. // Purpose: Fired when running on a laptop and less than 10 minutes of battery is left, fires then every minute
  147. //-----------------------------------------------------------------------------
  148. struct LowBatteryPower_t
  149. {
  150. enum { k_iCallback = k_iSteamUtilsCallbacks + 2 };
  151. uint8 m_nMinutesBatteryLeft;
  152. };
  153. //-----------------------------------------------------------------------------
  154. // Purpose: called when a SteamAsyncCall_t has completed (or failed)
  155. //-----------------------------------------------------------------------------
  156. struct SteamAPICallCompleted_t
  157. {
  158. enum { k_iCallback = k_iSteamUtilsCallbacks + 3 };
  159. SteamAPICall_t m_hAsyncCall;
  160. int m_iCallback;
  161. uint32 m_cubParam;
  162. };
  163. //-----------------------------------------------------------------------------
  164. // called when Steam wants to shutdown
  165. //-----------------------------------------------------------------------------
  166. struct SteamShutdown_t
  167. {
  168. enum { k_iCallback = k_iSteamUtilsCallbacks + 4 };
  169. };
  170. //-----------------------------------------------------------------------------
  171. // results for CheckFileSignature
  172. //-----------------------------------------------------------------------------
  173. enum ECheckFileSignature
  174. {
  175. k_ECheckFileSignatureInvalidSignature = 0,
  176. k_ECheckFileSignatureValidSignature = 1,
  177. k_ECheckFileSignatureFileNotFound = 2,
  178. k_ECheckFileSignatureNoSignaturesFoundForThisApp = 3,
  179. k_ECheckFileSignatureNoSignaturesFoundForThisFile = 4,
  180. };
  181. //-----------------------------------------------------------------------------
  182. // callback for CheckFileSignature
  183. //-----------------------------------------------------------------------------
  184. struct CheckFileSignature_t
  185. {
  186. enum { k_iCallback = k_iSteamUtilsCallbacks + 5 };
  187. ECheckFileSignature m_eCheckFileSignature;
  188. };
  189. // k_iSteamUtilsCallbacks + 13 is taken
  190. //-----------------------------------------------------------------------------
  191. // Big Picture gamepad text input has been closed
  192. //-----------------------------------------------------------------------------
  193. struct GamepadTextInputDismissed_t
  194. {
  195. enum { k_iCallback = k_iSteamUtilsCallbacks + 14 };
  196. bool m_bSubmitted; // true if user entered & accepted text (Call ISteamUtils::GetEnteredGamepadTextInput() for text), false if canceled input
  197. uint32 m_unSubmittedText;
  198. };
  199. // k_iSteamUtilsCallbacks + 15 is taken
  200. #pragma pack( pop )
  201. #endif // ISTEAMUTILS_H