6 #if defined(__linux__) || defined(__APPLE__)
8 * The 32-bit version of gcc has the alignment requirement for u64 and double
9 * set to 4 meaning that even with #pragma pack(8) these types will only be
10 * four-byte aligned. The 64-bit version of gcc has the alignment requirement
11 * for these types set to 8 meaning that unless we use #pragma pack(4) our
12 * structures will get bigger. The 64-bit structure packing has to match the
13 * 32-bit structure packing for each platform.
15 #define VALVE_CALLBACK_PACK_SMALL
16 #pragma pack( push, 4 )
18 #define VALVE_CALLBACK_PACK_LARGE
19 #pragma pack( push, 8 )
22 typedef i32 HSteamPipe
;
23 typedef i32 HSteamUser
;
25 typedef int E_iCallBack_t
;
27 typedef u64 u64_steamid
;
28 typedef u64 SteamAPICall_t
;
30 enum { k_iSteamUserCallbacks
= 100 };
31 enum { k_iSteamGameServerCallbacks
= 200 };
32 enum { k_iSteamFriendsCallbacks
= 300 };
33 enum { k_iSteamBillingCallbacks
= 400 };
34 enum { k_iSteamMatchmakingCallbacks
= 500 };
35 enum { k_iSteamContentServerCallbacks
= 600 };
36 enum { k_iSteamUtilsCallbacks
= 700 };
37 enum { k_iClientFriendsCallbacks
= 800 };
38 enum { k_iClientUserCallbacks
= 900 };
39 enum { k_iSteamAppsCallbacks
= 1000 };
40 enum { k_iSteamUserStatsCallbacks
= 1100 };
41 enum { k_iSteamNetworkingCallbacks
= 1200 };
42 enum { k_iSteamNetworkingSocketsCallbacks
= 1220 };
43 enum { k_iSteamNetworkingMessagesCallbacks
= 1250 };
44 enum { k_iSteamNetworkingUtilsCallbacks
= 1280 };
45 enum { k_iClientRemoteStorageCallbacks
= 1300 };
46 enum { k_iClientDepotBuilderCallbacks
= 1400 };
47 enum { k_iSteamGameServerItemsCallbacks
= 1500 };
48 enum { k_iClientUtilsCallbacks
= 1600 };
49 enum { k_iSteamGameCoordinatorCallbacks
= 1700 };
50 enum { k_iSteamGameServerStatsCallbacks
= 1800 };
51 enum { k_iSteam2AsyncCallbacks
= 1900 };
52 enum { k_iSteamGameStatsCallbacks
= 2000 };
53 enum { k_iClientHTTPCallbacks
= 2100 };
54 enum { k_iClientScreenshotsCallbacks
= 2200 };
55 enum { k_iSteamScreenshotsCallbacks
= 2300 };
56 enum { k_iClientAudioCallbacks
= 2400 };
57 enum { k_iClientUnifiedMessagesCallbacks
= 2500 };
58 enum { k_iSteamStreamLauncherCallbacks
= 2600 };
59 enum { k_iClientControllerCallbacks
= 2700 };
60 enum { k_iSteamControllerCallbacks
= 2800 };
61 enum { k_iClientParentalSettingsCallbacks
= 2900 };
62 enum { k_iClientDeviceAuthCallbacks
= 3000 };
63 enum { k_iClientNetworkDeviceManagerCallbacks
= 3100 };
64 enum { k_iClientMusicCallbacks
= 3200 };
65 enum { k_iClientRemoteClientManagerCallbacks
= 3300 };
66 enum { k_iClientUGCCallbacks
= 3400 };
67 enum { k_iSteamStreamClientCallbacks
= 3500 };
68 enum { k_IClientProductBuilderCallbacks
= 3600 };
69 enum { k_iClientShortcutsCallbacks
= 3700 };
70 enum { k_iClientRemoteControlManagerCallbacks
= 3800 };
71 enum { k_iSteamAppListCallbacks
= 3900 };
72 enum { k_iSteamMusicCallbacks
= 4000 };
73 enum { k_iSteamMusicRemoteCallbacks
= 4100 };
74 enum { k_iClientVRCallbacks
= 4200 };
75 enum { k_iClientGameNotificationCallbacks
= 4300 };
76 enum { k_iSteamGameNotificationCallbacks
= 4400 };
77 enum { k_iSteamHTMLSurfaceCallbacks
= 4500 };
78 enum { k_iClientVideoCallbacks
= 4600 };
79 enum { k_iClientInventoryCallbacks
= 4700 };
80 enum { k_iClientBluetoothManagerCallbacks
= 4800 };
81 enum { k_iClientSharedConnectionCallbacks
= 4900 };
82 enum { k_ISteamParentalSettingsCallbacks
= 5000 };
83 enum { k_iClientShaderCallbacks
= 5100 };
84 enum { k_iSteamGameSearchCallbacks
= 5200 };
85 enum { k_iSteamPartiesCallbacks
= 5300 };
86 enum { k_iClientPartiesCallbacks
= 5400 };
87 enum { k_iSteamSTARCallbacks
= 5500 };
88 enum { k_iClientSTARCallbacks
= 5600 };
89 enum { k_iSteamRemotePlayCallbacks
= 5700 };
90 enum { k_iClientCompatCallbacks
= 5800 };
91 enum { k_iSteamChatCallbacks
= 5900 };
93 // General result codes
96 k_EResultNone
= 0, // no result
97 k_EResultOK
= 1, // success
98 k_EResultFail
= 2, // generic failure
99 k_EResultNoConnection
= 3, // no/failed network connection
100 // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
101 k_EResultInvalidPassword
= 5, // password/ticket is invalid
102 k_EResultLoggedInElsewhere
= 6, // same user logged in elsewhere
103 k_EResultInvalidProtocolVer
= 7, // protocol version is incorrect
104 k_EResultInvalidParam
= 8, // a parameter is incorrect
105 k_EResultFileNotFound
= 9, // file was not found
106 k_EResultBusy
= 10, // called method busy - action not taken
107 k_EResultInvalidState
= 11, // called object was in an invalid state
108 k_EResultInvalidName
= 12, // name is invalid
109 k_EResultInvalidEmail
= 13, // email is invalid
110 k_EResultDuplicateName
= 14, // name is not unique
111 k_EResultAccessDenied
= 15, // access is denied
112 k_EResultTimeout
= 16, // operation timed out
113 k_EResultBanned
= 17, // VAC2 banned
114 k_EResultAccountNotFound
= 18, // account not found
115 k_EResultInvalidSteamID
= 19, // steamID is invalid
116 k_EResultServiceUnavailable
= 20,// The requested service is currently
118 k_EResultNotLoggedOn
= 21, // The user is not logged on
119 k_EResultPending
= 22, // Request is pending (may be in process, or
120 // waiting on third party)
121 k_EResultEncryptionFailure
= 23, // Encryption or Decryption failed
122 k_EResultInsufficientPrivilege
= 24,// Insufficient privilege
123 k_EResultLimitExceeded
= 25, // Too much of a good thing
124 k_EResultRevoked
= 26, // Access has been revoked (used for revoked
126 k_EResultExpired
= 27, // License/Guest pass the user is trying to
128 k_EResultAlreadyRedeemed
= 28, // Guest pass has already been redeemed by
129 // account, cannot be acked again
130 k_EResultDuplicateRequest
= 29, // The request is a duplicate and the action
131 // has already occurred in the past, ignored
133 k_EResultAlreadyOwned
= 30, // All the games in this guest pass
134 // redemption request are already owned by
136 k_EResultIPNotFound
= 31, // IP address not found
137 k_EResultPersistFailed
= 32, // failed to write change to the data store
138 k_EResultLockingFailed
= 33, // failed to acquire access lock for this
140 k_EResultLogonSessionReplaced
= 34,
141 k_EResultConnectFailed
= 35,
142 k_EResultHandshakeFailed
= 36,
143 k_EResultIOFailure
= 37,
144 k_EResultRemoteDisconnect
= 38,
145 k_EResultShoppingCartNotFound
= 39, // failed to find the shopping cart
147 k_EResultBlocked
= 40, // a user didn't allow it
148 k_EResultIgnored
= 41, // target is ignoring sender
149 k_EResultNoMatch
= 42, // nothing matching the request found
150 k_EResultAccountDisabled
= 43,
151 k_EResultServiceReadOnly
= 44, // this service is not accepting content
153 k_EResultAccountNotFeatured
= 45, // account doesn't have value, so this
154 // feature isn't available
155 k_EResultAdministratorOK
= 46, // allowed to take this action, but only
156 // because requester is admin
157 k_EResultContentVersion
= 47, // A Version mismatch in content
158 // transmitted within the Steam protocol.
159 k_EResultTryAnotherCM
= 48, // The current CM can't service the user
160 // making a request, user should try
162 k_EResultPasswordRequiredToKickSession
= 49, // You are already logged in
163 // elsewhere, this cached credential
165 k_EResultAlreadyLoggedInElsewhere
= 50, // You are already logged in
166 // elsewhere, you must wait
167 k_EResultSuspended
= 51, // Long running operation (content download)
169 k_EResultCancelled
= 52, // Operation canceled (typically by user:
171 k_EResultDataCorruption
= 53, // Operation canceled because data is ill
172 // formed or unrecoverable
173 k_EResultDiskFull
= 54, // Operation canceled - not enough disk space.
174 k_EResultRemoteCallFailed
= 55, // an remote call or IPC call failed
175 k_EResultPasswordUnset
= 56, // Password could not be verified as it's
177 k_EResultExternalAccountUnlinked
= 57, // External account (PSN, Facebook...)
178 // is not linked to a Steam account
179 k_EResultPSNTicketInvalid
= 58, // PSN ticket was invalid
180 k_EResultExternalAccountAlreadyLinked
= 59, // External account (PSN,
181 // Facebook...) is already linked to some other account,
182 // must explicitly request to replace/delete the link first
183 k_EResultRemoteFileConflict
= 60, // The sync cannot resume due to a conflict
184 // between the local and remote files
185 k_EResultIllegalPassword
= 61, // The requested new password is not legal
186 k_EResultSameAsPreviousValue
= 62,// new value is the same as the old one (
187 // secret question and answer )
188 k_EResultAccountLogonDenied
= 63, // account login denied due to 2nd factor
189 // authentication failure
190 k_EResultCannotUseOldPassword
= 64, // The requested new password is not
192 k_EResultInvalidLoginAuthCode
= 65, // account login denied due to auth code
194 k_EResultAccountLogonDeniedNoMail
= 66, // account login denied due to 2nd
195 // factor auth failure - and no mail
197 k_EResultHardwareNotCapableOfIPT
= 67,
198 k_EResultIPTInitError
= 68,
199 k_EResultParentalControlRestricted
= 69,// operation failed due to parental
200 // control restrictions for current
202 k_EResultFacebookQueryError
= 70, // Facebook query returned an error
203 k_EResultExpiredLoginAuthCode
= 71, // account login denied due to auth
205 k_EResultIPLoginRestrictionFailed
= 72,
206 k_EResultAccountLockedDown
= 73,
207 k_EResultAccountLogonDeniedVerifiedEmailRequired
= 74,
208 k_EResultNoMatchingURL
= 75,
209 k_EResultBadResponse
= 76, // parse failure, missing field, etc.
210 k_EResultRequirePasswordReEntry
= 77, // The user cannot complete the action
211 // until they re-enter their password
212 k_EResultValueOutOfRange
= 78, // the value entered is outside the
214 k_EResultUnexpectedError
= 79, // something happened that we didn't expect
216 k_EResultDisabled
= 80, // The requested service has been configured
218 k_EResultInvalidCEGSubmission
= 81, // The set of files submitted to the CEG
219 // server are not valid !
220 k_EResultRestrictedDevice
= 82, // The device being used is not allowed
221 // to perform this action
222 k_EResultRegionLocked
= 83, // The action could not be complete
223 // because it is region restricted
224 k_EResultRateLimitExceeded
= 84, // Temporary rate limit exceeded, try
225 // again later, different from
226 // k_EResultLimitExceeded which may be
228 k_EResultAccountLoginDeniedNeedTwoFactor
= 85, // Need two-factor code to
230 k_EResultItemDeleted
= 86, // The thing we're trying to access has been
232 k_EResultAccountLoginDeniedThrottle
= 87, // login attempt failed, try to
233 // throttle response to possible
235 k_EResultTwoFactorCodeMismatch
= 88, // two factor code mismatch
236 k_EResultTwoFactorActivationCodeMismatch
= 89, // activation code for
237 // two-factor didn't match
238 k_EResultAccountAssociatedToMultiplePartners
= 90, // account has been
239 // associated with multiple partners
240 k_EResultNotModified
= 91, // data not modified
241 k_EResultNoMobileDevice
= 92, // the account does not have a mobile
242 // device associated with it
243 k_EResultTimeNotSynced
= 93, // the time presented is out of range or
245 k_EResultSmsCodeFailed
= 94, // SMS code failure (no match, none pending,
247 k_EResultAccountLimitExceeded
= 95, // Too many accounts access this resource
248 k_EResultAccountActivityLimitExceeded
= 96,// Too many changes to
250 k_EResultPhoneActivityLimitExceeded
= 97, // Too many changes to this phone
251 k_EResultRefundToWallet
= 98, // Cannot refund to payment method, must use
253 k_EResultEmailSendFailure
= 99, // Cannot send an email
254 k_EResultNotSettled
= 100, // Can't perform operation till payment
256 k_EResultNeedCaptcha
= 101,// Needs to provide a valid captcha
257 k_EResultGSLTDenied
= 102, // a game server login token owned by this token's
258 // owner has been banned
259 k_EResultGSOwnerDenied
= 103, // game server owner is denied for other reason
260 // (account lock, community ban, vac ban, missing phone)
261 k_EResultInvalidItemType
= 104,// the type of thing we were requested to act
263 k_EResultIPBanned
= 105,// the ip address has been banned from taking this
265 k_EResultGSLTExpired
= 106,// this token has expired from disuse; can be
267 k_EResultInsufficientFunds
= 107,// user doesn't have enough wallet funds to
268 // complete the action
269 k_EResultTooManyPending
= 108, // There are too many of this thing pending
271 k_EResultNoSiteLicensesFound
= 109, // No site licenses found
272 k_EResultWGNetworkSendExceeded
= 110,// the WG couldn't send a response
273 // because we exceeded max network send size
274 k_EResultAccountNotFriends
= 111, // the user is not mutually friends
275 k_EResultLimitedUserAccount
= 112,// the user is limited
276 k_EResultCantRemoveItem
= 113, // item can't be removed
277 k_EResultAccountDeleted
= 114, // account has been deleted
278 k_EResultExistingUserCancelledLicense
= 115,
279 // A license for this already exists, but cancelled
280 k_EResultCommunityCooldown
= 116, // access is denied because of a
281 // community cooldown (probably from support profile data resets)
282 k_EResultNoLauncherSpecified
= 117, // No launcher was specified, but a
283 // launcher was needed to choose correct realm for operation.
284 k_EResultMustAgreeToSSA
= 118,// User must agree to china SSA or global SSA
286 k_EResultLauncherMigrated
= 119, // The specified launcher type is no longer
287 // supported; the user should be directed elsewhere
288 k_EResultSteamRealmMismatch
= 120, // The user's realm does not match the
289 // realm of the requested resource
290 k_EResultInvalidSignature
= 121, // signature check did not match
291 k_EResultParseFailure
= 122, // Failed to parse input
292 k_EResultNoVerifiedPhone
= 123, // account does not have a verified phone
298 HSteamUser m_hSteamUser
; // Specific user to whom this callback applies.
300 u8
*m_pubParam
; // Points to the callback structure
301 int m_cubParam
; // Size of the data pointed to by m_pubParam
307 SteamAPICall_t m_hAsyncCall
;
311 } SteamAPICallCompleted_t
;
313 enum { k_iSteamAPICallCompleted
= k_iSteamUtilsCallbacks
+ 3 };
315 // Steam universes. Each universe is a self-contained Steam instance.
317 k_EUniverseInvalid
= 0,
318 k_EUniversePublic
= 1,
320 k_EUniverseInternal
= 3,
322 // k_EUniverseRC = 5, // no such universe anymore
326 struct SteamIDComponent_t
328 #ifdef VALVE_BIG_ENDIAN
329 EUniverse_t m_EUniverse
: 8
330 unsigned int m_EAccountType
: 4;
331 unsigned int m_unAccountInstance
: 20;
332 u32 m_unAccountID
: 32;
334 u32 m_unAccountID
: 32;
335 unsigned int m_unAccountInstance
: 20;
336 unsigned int m_EAccountType
: 4;
337 EUniverse_t m_EUniverse
: 8;
346 struct SteamIDComponent_t m_comp
;
352 typedef struct GameID_t
354 #ifdef VALVE_BIG_ENDIAN
355 unsigned int m_nModID
: 32;
356 unsigned int m_nType
: 8;
357 unsigned int m_nAppID
: 24;
359 unsigned int m_nAppID
: 24;
360 unsigned int m_nType
: 8;
361 unsigned int m_nModID
: 32;
369 * =============================================================================
372 int SteamAPI_RestartAppIfNecessary( u32 unOwnAppID
);
373 int SteamAPI_Init(void);
374 void SteamAPI_Shutdown(void);
378 * =============================================================================
381 typedef enum EServerMode EServerMode
;
384 eServerModeInvalid
= 0,
385 eServerModeNoAuthentication
= 1,
386 eServerModeAuthentication
= 2,
387 eServerModeAuthenticationAndSecure
= 3,
390 int SteamInternal_GameServer_Init( u32 unIP
, u16 usLegacySteamPort
,
391 u16 usGamePort
, u16 usQueryPort
,
392 EServerMode eServerMode
,
393 const char *pchVersionString
);
395 /* Initialize SteamGameServer client and interface objects, and set server
396 * properties which may not be changed.
397 * After calling this function, you should set any additional server parameters,
398 * and then call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn()
400 * - unIP will usually be zero. If you are on a machine with multiple IP
401 * addresses, you can pass a non-zero value here and the relevant sockets will
402 * be bound to that IP. This can be used to ensure that the IP you desire is
403 * the one used in the server browser.
404 * - usGamePort is the port that clients will connect to for gameplay. You will
405 * usually open up your own socket bound to this port.
406 * - usQueryPort is the port that will manage server browser related duties and
407 * info pings from clients. If you pass STEAMGAMESERVER_QUERY_PORT_SHARED for
408 * usQueryPort, then it will use "GameSocketShare" mode, which means that the
409 * game is responsible for sending and receiving UDP packets for the master
410 * server updater. (See ISteamGameServer::HandleIncomingPacket and
411 * ISteamGameServer::GetNextOutgoingPacket.)
412 * - The version string should be in the form x.x.x.x, and is used by the master
413 * server to detect when the server is out of date. (Only servers with the
414 * latest version will be listed.)
416 int SteamGameServer_Init( u32 unIP
, u16 usGamePort
, u16 usQueryPort
,
417 EServerMode eServerMode
,
418 const char *pchVersionString
)
420 return SteamInternal_GameServer_Init( unIP
, 0, usGamePort
, usQueryPort
,
421 eServerMode
, pchVersionString
);
425 void *SteamAPI_SteamGameServer_v014(void);
426 void *SteamAPI_SteamGameServer(void)
428 return SteamAPI_SteamGameServer_v014();
431 void SteamAPI_ISteamGameServer_LogOnAnonymous( void* self
);
433 void SteamGameServer_Shutdown(void);
435 int SteamGameServer_BSecure(void);
436 u64
SteamGameServer_GetSteamID(void);
440 * =============================================================================
442 typedef struct steam_async steam_async
;
448 void (*p_handler
)( void *result
, void *userdata
);
450 static steam_async_trackers
[32];
451 static u32 steam_async_track_count
;
453 steam_async
*steam_new_async(void)
455 if( steam_async_track_count
== vg_list_size(steam_async_trackers
) )
457 vg_error( "Maximum concurrent API calls exceeded (%u)\n",
458 steam_async_track_count
);
462 return &steam_async_trackers
[ steam_async_track_count
++ ];
468 HSteamPipe
SteamAPI_GetHSteamPipe(void);
469 HSteamPipe
SteamGameServer_GetHSteamPipe(void);
470 HSteamUser
SteamAPI_GetHSteamUser(void);
471 void SteamAPI_ManualDispatch_Init(void);
472 void SteamAPI_ManualDispatch_RunFrame( HSteamPipe hSteamPipe
);
473 int SteamAPI_ManualDispatch_GetNextCallback( HSteamPipe hSteamPipe
,
474 CallbackMsg_t
*pCallbackMsg
);
475 void SteamAPI_ManualDispatch_FreeLastCallback( HSteamPipe hSteamPipe
);
476 int SteamAPI_ManualDispatch_GetAPICallResult( HSteamPipe hSteamPipe
,
477 SteamAPICall_t hSteamAPICall
, void *pCallback
, int cubCallback
,
478 int iCallbackExpected
, int *pbFailed
);
480 void SteamAPI_ReleaseCurrentThreadMemory(void);
482 static void steamworks_event_loop( HSteamPipe pipe
,
483 void(*callback_handler
)(CallbackMsg_t
*msg
) )
485 SteamAPI_ManualDispatch_RunFrame( pipe
);
486 CallbackMsg_t callback
;
488 while( SteamAPI_ManualDispatch_GetNextCallback( pipe
, &callback
) )
490 vg_log( "steamworks_event::callback( %i )\n", callback
.m_iCallback
);
492 /* Check for dispatching API call results */
493 if( callback
.m_iCallback
== k_iSteamAPICallCompleted
)
495 SteamAPICallCompleted_t
*pCallCompleted
=
496 (SteamAPICallCompleted_t
*)callback
.m_pubParam
;
498 void *pTmpCallResult
= malloc( pCallCompleted
->m_cubParam
);
501 if( SteamAPI_ManualDispatch_GetAPICallResult(
503 pCallCompleted
->m_hAsyncCall
,
505 pCallCompleted
->m_cubParam
,
506 pCallCompleted
->m_iCallback
,
511 * Dispatch the call result to the registered handler(s) for the
512 * call identified by pCallCompleted->m_hAsyncCall
515 vg_info( "steamworks_event::api_call_completed( %lu )\n",
516 pCallCompleted
->m_hAsyncCall
);
519 for( int i
=0; i
<steam_async_track_count
; i
++ )
521 if( steam_async_trackers
[j
].id
!= pCallCompleted
->m_hAsyncCall
)
523 steam_async_trackers
[j
++] = steam_async_trackers
[i
];
527 steam_async
*pasync
= &steam_async_trackers
[j
];
528 pasync
->p_handler( pTmpCallResult
, pasync
->data
);
532 if( steam_async_track_count
== j
)
534 vg_error( "No tracker was register for API call\n" );
537 steam_async_track_count
= j
;
542 typedef enum ESteamAPICallFailure
544 k_ESteamAPICallFailureNone
= -1,
545 k_ESteamAPICallFailureSteamGone
= 0,
546 k_ESteamAPICallFailureNetworkFailure
= 1,
547 k_ESteamAPICallFailureInvalidHandle
= 2,
548 k_ESteamAPICallFailureMismatchedCallback
= 3,
551 ESteamAPICallFailure
;
552 ESteamAPICallFailure fail_why
=
553 SteamAPI_ISteamUtils_GetAPICallFailureReason(
554 steam_api_classes
.utils
, pCallCompleted
->m_hAsyncCall
);
556 vg_error( "steamworks_event: error getting call result on"
558 pCallCompleted
->m_hAsyncCall
, fail_why
);
562 free( pTmpCallResult
);
567 * Look at callback.m_iCallback to see what kind of callback it is,
568 * and dispatch to appropriate handler(s)
569 * void *data = callback.m_pubParam;
572 callback_handler(&callback
);
575 SteamAPI_ManualDispatch_FreeLastCallback( pipe
);
579 #endif /* VG_STEAM_H */