isteamutils.cs (16308B)
1 // This file is provided under The MIT License as part of Steamworks.NET. 2 // Copyright (c) 2013-2019 Riley Labrecque 3 // Please see the included LICENSE.txt for additional information. 4 5 // This file is automatically generated. 6 // Changes to this file will be reverted when you update Steamworks.NET 7 8 #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH 9 #define DISABLESTEAMWORKS 10 #endif 11 12 #if !DISABLESTEAMWORKS 13 14 using System.Runtime.InteropServices; 15 using IntPtr = System.IntPtr; 16 17 namespace Steamworks { 18 public static class SteamUtils { 19 /// <summary> 20 /// <para> return the number of seconds since the user</para> 21 /// </summary> 22 public static uint GetSecondsSinceAppActive() { 23 InteropHelp.TestIfAvailableClient(); 24 return NativeMethods.ISteamUtils_GetSecondsSinceAppActive(CSteamAPIContext.GetSteamUtils()); 25 } 26 27 public static uint GetSecondsSinceComputerActive() { 28 InteropHelp.TestIfAvailableClient(); 29 return NativeMethods.ISteamUtils_GetSecondsSinceComputerActive(CSteamAPIContext.GetSteamUtils()); 30 } 31 32 /// <summary> 33 /// <para> the universe this client is connecting to</para> 34 /// </summary> 35 public static EUniverse GetConnectedUniverse() { 36 InteropHelp.TestIfAvailableClient(); 37 return NativeMethods.ISteamUtils_GetConnectedUniverse(CSteamAPIContext.GetSteamUtils()); 38 } 39 40 /// <summary> 41 /// <para> Steam server time. Number of seconds since January 1, 1970, GMT (i.e unix time)</para> 42 /// </summary> 43 public static uint GetServerRealTime() { 44 InteropHelp.TestIfAvailableClient(); 45 return NativeMethods.ISteamUtils_GetServerRealTime(CSteamAPIContext.GetSteamUtils()); 46 } 47 48 /// <summary> 49 /// <para> 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)</para> 50 /// <para> e.g "US" or "UK".</para> 51 /// </summary> 52 public static string GetIPCountry() { 53 InteropHelp.TestIfAvailableClient(); 54 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamUtils_GetIPCountry(CSteamAPIContext.GetSteamUtils())); 55 } 56 57 /// <summary> 58 /// <para> returns true if the image exists, and valid sizes were filled out</para> 59 /// </summary> 60 public static bool GetImageSize(int iImage, out uint pnWidth, out uint pnHeight) { 61 InteropHelp.TestIfAvailableClient(); 62 return NativeMethods.ISteamUtils_GetImageSize(CSteamAPIContext.GetSteamUtils(), iImage, out pnWidth, out pnHeight); 63 } 64 65 /// <summary> 66 /// <para> returns true if the image exists, and the buffer was successfully filled out</para> 67 /// <para> results are returned in RGBA format</para> 68 /// <para> the destination buffer size should be 4 * height * width * sizeof(char)</para> 69 /// </summary> 70 public static bool GetImageRGBA(int iImage, byte[] pubDest, int nDestBufferSize) { 71 InteropHelp.TestIfAvailableClient(); 72 return NativeMethods.ISteamUtils_GetImageRGBA(CSteamAPIContext.GetSteamUtils(), iImage, pubDest, nDestBufferSize); 73 } 74 75 /// <summary> 76 /// <para> returns the IP of the reporting server for valve - currently only used in Source engine games</para> 77 /// </summary> 78 public static bool GetCSERIPPort(out uint unIP, out ushort usPort) { 79 InteropHelp.TestIfAvailableClient(); 80 return NativeMethods.ISteamUtils_GetCSERIPPort(CSteamAPIContext.GetSteamUtils(), out unIP, out usPort); 81 } 82 83 /// <summary> 84 /// <para> return the amount of battery power left in the current system in % [0..100], 255 for being on AC power</para> 85 /// </summary> 86 public static byte GetCurrentBatteryPower() { 87 InteropHelp.TestIfAvailableClient(); 88 return NativeMethods.ISteamUtils_GetCurrentBatteryPower(CSteamAPIContext.GetSteamUtils()); 89 } 90 91 /// <summary> 92 /// <para> returns the appID of the current process</para> 93 /// </summary> 94 public static AppId_t GetAppID() { 95 InteropHelp.TestIfAvailableClient(); 96 return (AppId_t)NativeMethods.ISteamUtils_GetAppID(CSteamAPIContext.GetSteamUtils()); 97 } 98 99 /// <summary> 100 /// <para> Sets the position where the overlay instance for the currently calling game should show notifications.</para> 101 /// <para> This position is per-game and if this function is called from outside of a game context it will do nothing.</para> 102 /// </summary> 103 public static void SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition) { 104 InteropHelp.TestIfAvailableClient(); 105 NativeMethods.ISteamUtils_SetOverlayNotificationPosition(CSteamAPIContext.GetSteamUtils(), eNotificationPosition); 106 } 107 108 /// <summary> 109 /// <para> API asynchronous call results</para> 110 /// <para> can be used directly, but more commonly used via the callback dispatch API (see steam_api.h)</para> 111 /// </summary> 112 public static bool IsAPICallCompleted(SteamAPICall_t hSteamAPICall, out bool pbFailed) { 113 InteropHelp.TestIfAvailableClient(); 114 return NativeMethods.ISteamUtils_IsAPICallCompleted(CSteamAPIContext.GetSteamUtils(), hSteamAPICall, out pbFailed); 115 } 116 117 public static ESteamAPICallFailure GetAPICallFailureReason(SteamAPICall_t hSteamAPICall) { 118 InteropHelp.TestIfAvailableClient(); 119 return NativeMethods.ISteamUtils_GetAPICallFailureReason(CSteamAPIContext.GetSteamUtils(), hSteamAPICall); 120 } 121 122 public static bool GetAPICallResult(SteamAPICall_t hSteamAPICall, IntPtr pCallback, int cubCallback, int iCallbackExpected, out bool pbFailed) { 123 InteropHelp.TestIfAvailableClient(); 124 return NativeMethods.ISteamUtils_GetAPICallResult(CSteamAPIContext.GetSteamUtils(), hSteamAPICall, pCallback, cubCallback, iCallbackExpected, out pbFailed); 125 } 126 127 /// <summary> 128 /// <para> returns the number of IPC calls made since the last time this function was called</para> 129 /// <para> Used for perf debugging so you can understand how many IPC calls your game makes per frame</para> 130 /// <para> Every IPC call is at minimum a thread context switch if not a process one so you want to rate</para> 131 /// <para> control how often you do them.</para> 132 /// </summary> 133 public static uint GetIPCCallCount() { 134 InteropHelp.TestIfAvailableClient(); 135 return NativeMethods.ISteamUtils_GetIPCCallCount(CSteamAPIContext.GetSteamUtils()); 136 } 137 138 /// <summary> 139 /// <para> API warning handling</para> 140 /// <para> 'int' is the severity; 0 for msg, 1 for warning</para> 141 /// <para> 'const char *' is the text of the message</para> 142 /// <para> callbacks will occur directly after the API function is called that generated the warning or message</para> 143 /// </summary> 144 public static void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction) { 145 InteropHelp.TestIfAvailableClient(); 146 NativeMethods.ISteamUtils_SetWarningMessageHook(CSteamAPIContext.GetSteamUtils(), pFunction); 147 } 148 149 /// <summary> 150 /// <para> Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to</para> 151 /// <para> start & hook the game process, so this function will initially return false while the overlay is loading.</para> 152 /// </summary> 153 public static bool IsOverlayEnabled() { 154 InteropHelp.TestIfAvailableClient(); 155 return NativeMethods.ISteamUtils_IsOverlayEnabled(CSteamAPIContext.GetSteamUtils()); 156 } 157 158 /// <summary> 159 /// <para> Normally this call is unneeded if your game has a constantly running frame loop that calls the</para> 160 /// <para> D3D Present API, or OGL SwapBuffers API every frame.</para> 161 /// <para> However, if you have a game that only refreshes the screen on an event driven basis then that can break</para> 162 /// <para> the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also</para> 163 /// <para> need to Present() to the screen any time an even needing a notification happens or when the overlay is</para> 164 /// <para> brought up over the game by a user. You can use this API to ask the overlay if it currently need a present</para> 165 /// <para> in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you</para> 166 /// <para> refresh the screen with Present or SwapBuffers to allow the overlay to do it's work.</para> 167 /// </summary> 168 public static bool BOverlayNeedsPresent() { 169 InteropHelp.TestIfAvailableClient(); 170 return NativeMethods.ISteamUtils_BOverlayNeedsPresent(CSteamAPIContext.GetSteamUtils()); 171 } 172 173 /// <summary> 174 /// <para> Asynchronous call to check if an executable file has been signed using the public key set on the signing tab</para> 175 /// <para> of the partner site, for example to refuse to load modified executable files.</para> 176 /// <para> The result is returned in CheckFileSignature_t.</para> 177 /// <para> k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function.</para> 178 /// <para> k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site.</para> 179 /// <para> k_ECheckFileSignatureFileNotFound - The file does not exist on disk.</para> 180 /// <para> 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.</para> 181 /// <para> k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid.</para> 182 /// </summary> 183 public static SteamAPICall_t CheckFileSignature(string szFileName) { 184 InteropHelp.TestIfAvailableClient(); 185 using (var szFileName2 = new InteropHelp.UTF8StringHandle(szFileName)) { 186 return (SteamAPICall_t)NativeMethods.ISteamUtils_CheckFileSignature(CSteamAPIContext.GetSteamUtils(), szFileName2); 187 } 188 } 189 190 /// <summary> 191 /// <para> Activates the Big Picture text input dialog which only supports gamepad input</para> 192 /// </summary> 193 public static bool ShowGamepadTextInput(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, string pchDescription, uint unCharMax, string pchExistingText) { 194 InteropHelp.TestIfAvailableClient(); 195 using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) 196 using (var pchExistingText2 = new InteropHelp.UTF8StringHandle(pchExistingText)) { 197 return NativeMethods.ISteamUtils_ShowGamepadTextInput(CSteamAPIContext.GetSteamUtils(), eInputMode, eLineInputMode, pchDescription2, unCharMax, pchExistingText2); 198 } 199 } 200 201 /// <summary> 202 /// <para> Returns previously entered text & length</para> 203 /// </summary> 204 public static uint GetEnteredGamepadTextLength() { 205 InteropHelp.TestIfAvailableClient(); 206 return NativeMethods.ISteamUtils_GetEnteredGamepadTextLength(CSteamAPIContext.GetSteamUtils()); 207 } 208 209 public static bool GetEnteredGamepadTextInput(out string pchText, uint cchText) { 210 InteropHelp.TestIfAvailableClient(); 211 IntPtr pchText2 = Marshal.AllocHGlobal((int)cchText); 212 bool ret = NativeMethods.ISteamUtils_GetEnteredGamepadTextInput(CSteamAPIContext.GetSteamUtils(), pchText2, cchText); 213 pchText = ret ? InteropHelp.PtrToStringUTF8(pchText2) : null; 214 Marshal.FreeHGlobal(pchText2); 215 return ret; 216 } 217 218 /// <summary> 219 /// <para> returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases</para> 220 /// </summary> 221 public static string GetSteamUILanguage() { 222 InteropHelp.TestIfAvailableClient(); 223 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamUtils_GetSteamUILanguage(CSteamAPIContext.GetSteamUtils())); 224 } 225 226 /// <summary> 227 /// <para> returns true if Steam itself is running in VR mode</para> 228 /// </summary> 229 public static bool IsSteamRunningInVR() { 230 InteropHelp.TestIfAvailableClient(); 231 return NativeMethods.ISteamUtils_IsSteamRunningInVR(CSteamAPIContext.GetSteamUtils()); 232 } 233 234 /// <summary> 235 /// <para> Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.</para> 236 /// </summary> 237 public static void SetOverlayNotificationInset(int nHorizontalInset, int nVerticalInset) { 238 InteropHelp.TestIfAvailableClient(); 239 NativeMethods.ISteamUtils_SetOverlayNotificationInset(CSteamAPIContext.GetSteamUtils(), nHorizontalInset, nVerticalInset); 240 } 241 242 /// <summary> 243 /// <para> returns true if Steam & the Steam Overlay are running in Big Picture mode</para> 244 /// <para> Games much be launched through the Steam client to enable the Big Picture overlay. During development,</para> 245 /// <para> a game can be added as a non-steam game to the developers library to test this feature</para> 246 /// </summary> 247 public static bool IsSteamInBigPictureMode() { 248 InteropHelp.TestIfAvailableClient(); 249 return NativeMethods.ISteamUtils_IsSteamInBigPictureMode(CSteamAPIContext.GetSteamUtils()); 250 } 251 252 /// <summary> 253 /// <para> ask SteamUI to create and render its OpenVR dashboard</para> 254 /// </summary> 255 public static void StartVRDashboard() { 256 InteropHelp.TestIfAvailableClient(); 257 NativeMethods.ISteamUtils_StartVRDashboard(CSteamAPIContext.GetSteamUtils()); 258 } 259 260 /// <summary> 261 /// <para> Returns true if the HMD content will be streamed via Steam In-Home Streaming</para> 262 /// </summary> 263 public static bool IsVRHeadsetStreamingEnabled() { 264 InteropHelp.TestIfAvailableClient(); 265 return NativeMethods.ISteamUtils_IsVRHeadsetStreamingEnabled(CSteamAPIContext.GetSteamUtils()); 266 } 267 268 /// <summary> 269 /// <para> Set whether the HMD content will be streamed via Steam In-Home Streaming</para> 270 /// <para> If this is set to true, then the scene in the HMD headset will be streamed, and remote input will not be allowed.</para> 271 /// <para> If this is set to false, then the application window will be streamed instead, and remote input will be allowed.</para> 272 /// <para> The default is true unless "VRHeadsetStreaming" "0" is in the extended appinfo for a game.</para> 273 /// <para> (this is useful for games that have asymmetric multiplayer gameplay)</para> 274 /// </summary> 275 public static void SetVRHeadsetStreamingEnabled(bool bEnabled) { 276 InteropHelp.TestIfAvailableClient(); 277 NativeMethods.ISteamUtils_SetVRHeadsetStreamingEnabled(CSteamAPIContext.GetSteamUtils(), bEnabled); 278 } 279 280 /// <summary> 281 /// <para> Returns whether this steam client is a Steam China specific client, vs the global client.</para> 282 /// </summary> 283 public static bool IsSteamChinaLauncher() { 284 InteropHelp.TestIfAvailableClient(); 285 return NativeMethods.ISteamUtils_IsSteamChinaLauncher(CSteamAPIContext.GetSteamUtils()); 286 } 287 288 /// <summary> 289 /// <para> Initializes text filtering.</para> 290 /// <para> Returns false if filtering is unavailable for the language the user is currently running in.</para> 291 /// </summary> 292 public static bool InitFilterText() { 293 InteropHelp.TestIfAvailableClient(); 294 return NativeMethods.ISteamUtils_InitFilterText(CSteamAPIContext.GetSteamUtils()); 295 } 296 297 /// <summary> 298 /// <para> Filters the provided input message and places the filtered result into pchOutFilteredText.</para> 299 /// <para> pchOutFilteredText is where the output will be placed, even if no filtering or censoring is performed</para> 300 /// <para> nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText</para> 301 /// <para> pchInputText is the input string that should be filtered, which can be ASCII or UTF-8</para> 302 /// <para> bLegalOnly should be false if you want profanity and legally required filtering (where required) and true if you want legally required filtering only</para> 303 /// <para> Returns the number of characters (not bytes) filtered.</para> 304 /// </summary> 305 public static int FilterText(out string pchOutFilteredText, uint nByteSizeOutFilteredText, string pchInputMessage, bool bLegalOnly) { 306 InteropHelp.TestIfAvailableClient(); 307 IntPtr pchOutFilteredText2 = Marshal.AllocHGlobal((int)nByteSizeOutFilteredText); 308 using (var pchInputMessage2 = new InteropHelp.UTF8StringHandle(pchInputMessage)) { 309 int ret = NativeMethods.ISteamUtils_FilterText(CSteamAPIContext.GetSteamUtils(), pchOutFilteredText2, nByteSizeOutFilteredText, pchInputMessage2, bLegalOnly); 310 pchOutFilteredText = ret != -1 ? InteropHelp.PtrToStringUTF8(pchOutFilteredText2) : null; 311 Marshal.FreeHGlobal(pchOutFilteredText2); 312 return ret; 313 } 314 } 315 } 316 } 317 318 #endif // !DISABLESTEAMWORKS