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.

473 lines
13 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Interface to Xbox 360 system functions. Helps deal with the async system and Live
  4. // functions by either providing a handle for the caller to check results or handling
  5. // automatic cleanup of the async data when the caller doesn't care about the results.
  6. //
  7. //===========================================================================//
  8. #ifndef IXBOXSYSTEM_H
  9. #define IXBOXSYSTEM_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #if !defined( _X360 )
  14. #include "xbox/xboxstubs.h"
  15. #endif
  16. typedef void* AsyncHandle_t;
  17. typedef void* XboxHandle_t;
  18. #if !defined( _PS3 ) && defined( POSIX )
  19. struct XOVERLAPPED
  20. {
  21. };
  22. #endif
  23. #ifdef POSIX
  24. #define ERROR_SUCCESS 0
  25. #define ERROR_IO_PENDING 1
  26. #define ERROR_IO_INCOMPLETE 2
  27. #define ERROR_INSUFFICIENT_BUFFER 3
  28. #define ERROR_NO_SUCH_USER 4
  29. #define ERROR_NO_SUCH_PRIVILEGE 5
  30. #define ERROR_ACCESS_DISABLED_BY_POLICY 6
  31. #endif
  32. //-----------------------------------------------------------------------------
  33. // Xbox system interface
  34. //-----------------------------------------------------------------------------
  35. abstract_class IXboxSystem
  36. {
  37. public:
  38. virtual AsyncHandle_t CreateAsyncHandle( void ) = 0;
  39. virtual void ReleaseAsyncHandle( AsyncHandle_t handle ) = 0;
  40. virtual int GetOverlappedResult( AsyncHandle_t handle, uint *pResultCode, bool bWait ) = 0;
  41. virtual void CancelOverlappedOperation( AsyncHandle_t handle ) = 0;
  42. // Save/Load
  43. virtual bool GameHasSavegames( void ) = 0;
  44. virtual void GetModSaveContainerNames( const char *pchModName, const wchar_t **ppchDisplayName, const char **ppchName ) = 0;
  45. virtual uint GetContainerRemainingSpace( DWORD nStorageID ) = 0;
  46. virtual bool DeviceCapacityAdequate( int iController, DWORD nStorageID, const char *pModName ) = 0;
  47. virtual DWORD DiscoverUserData( DWORD nUserID, const char *pModName ) = 0;
  48. virtual void FinishContainerWrites( int iController ) = 0;
  49. virtual uint GetContainerOpenResult( int iController ) = 0;
  50. virtual uint OpenContainers( int iController ) = 0;
  51. virtual void CloseContainers( int iController ) = 0;
  52. virtual void FinishAllContainerWrites( void ) = 0;
  53. virtual void CloseAllContainers( void ) = 0;
  54. // XUI
  55. virtual bool ShowDeviceSelector( int iController, bool bForce, uint *pStorageID, AsyncHandle_t *pHandle ) = 0;
  56. virtual void ShowSigninUI( uint nPanes, uint nFlags ) = 0;
  57. // Rich Presence and Matchmaking
  58. virtual int UserSetContext( uint nUserIdx, XUSER_CONTEXT const &xc, bool bAsync = true, AsyncHandle_t *pHandle = NULL ) = 0;
  59. virtual int UserSetProperty( uint nUserIndex, XUSER_PROPERTY const &xp, bool bAsync = true, AsyncHandle_t *pHandle = NULL ) = 0;
  60. virtual int UserGetContext( uint nUserIdx, uint nContextID, uint &nContextValue) = 0;
  61. virtual int UserGetPropertyInt( uint nUserIndex, uint nPropertyId, uint &nPropertyValue) = 0;
  62. // Matchmaking
  63. virtual int CreateSession( uint nFlags, uint nUserIdx, uint nMaxPublicSlots, uint nMaxPrivateSlots, uint64 *pNonce, void *pSessionInfo, XboxHandle_t *pSessionHandle, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  64. virtual uint DeleteSession( XboxHandle_t hSession, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  65. virtual uint SessionSearch( uint nProcedureIndex, uint nUserIndex, uint nNumResults, uint nNumUsers, uint nNumProperties, uint nNumContexts, XUSER_PROPERTY *pSearchProperties, XUSER_CONTEXT *pSearchContexts, uint *pcbResultsBuffer, XSESSION_SEARCHRESULT_HEADER *pSearchResults, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  66. virtual uint SessionStart( XboxHandle_t hSession, uint nFlags, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  67. virtual uint SessionEnd( XboxHandle_t hSession, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  68. virtual int SessionJoinLocal( XboxHandle_t hSession, uint nUserCount, const uint *pUserIndexes, const bool *pPrivateSlots, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  69. virtual int SessionJoinRemote( XboxHandle_t hSession, uint nUserCount, const XUID *pXuids, const bool *pPrivateSlots, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  70. virtual int SessionLeaveLocal( XboxHandle_t hSession, uint nUserCount, const uint *pUserIndexes, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  71. virtual int SessionLeaveRemote( XboxHandle_t hSession, uint nUserCount, const XUID *pXuids, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  72. virtual int SessionMigrate( XboxHandle_t hSession, uint nUserIndex, void *pSessionInfo, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  73. virtual int SessionArbitrationRegister( XboxHandle_t hSession, uint nFlags, uint64 nonce, uint *pBytes, void *pBuffer, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  74. // Friends
  75. virtual int EnumerateFriends( uint userIndex, void **pBuffer, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  76. // Stats
  77. virtual int WriteStats( XboxHandle_t hSession, XUID xuid, uint nViews, void* pViews, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  78. virtual int FlushStats( XboxHandle_t hSession, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  79. virtual int EnumerateStatsByRank( uint nStartingRank, uint nNumRows, uint nNumSpecs, void *pSpecs, void **ppResults, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  80. virtual int EnumerateStatsByXuid( XUID nUserId, uint nNumRows, uint nNumSpecs, void *pSpecs, void **ppResults, bool bAsync, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  81. // Achievements
  82. virtual int EnumerateAchievements( uint nUserIdx, uint64 xuid, uint nStartingIdx, uint nCount, void *pBuffer, uint nBufferBytes, bool bAsync = true, AsyncHandle_t *pAsyncHandle = NULL ) = 0;
  83. virtual int AwardAchievement( uint nUserIdx, uint nAchievementId, AsyncHandle_t *ppOverlappedResult ) = 0;
  84. virtual int AwardAvatarAsset( uint nUserIdx, uint nAwardId, AsyncHandle_t *ppOverlappedResult ) = 0;
  85. // Arcade titles
  86. virtual void ShowUnlockFullGameUI( void ) = 0;
  87. virtual bool UpdateArcadeTitleUnlockStatus( void ) = 0;
  88. virtual bool IsArcadeTitleUnlocked( void ) = 0;
  89. virtual float GetArcadeRemainingTrialTime( int nSlot = 0 ) = 0;
  90. //
  91. // Overlapped
  92. //
  93. virtual int Io_HasOverlappedIoCompleted( XOVERLAPPED *pOverlapped ) = 0;
  94. //
  95. // XNet
  96. //
  97. virtual int NetRandom( byte *pb, unsigned numBytes ) = 0;
  98. virtual DWORD NetGetTitleXnAddr( XNADDR *pxna ) = 0;
  99. virtual int NetXnAddrToMachineId( const XNADDR *pxnaddr, uint64 *pqwMachineId ) = 0;
  100. virtual int NetInAddrToXnAddr( const IN_ADDR ina, XNADDR *pxna, XNKID *pxnkid ) = 0;
  101. virtual int NetXnAddrToInAddr( const XNADDR *pxna, const XNKID *pxnkid, IN_ADDR *pina ) = 0;
  102. //
  103. // User
  104. //
  105. virtual XUSER_SIGNIN_STATE UserGetSigninState( int iCtrlr ) = 0;
  106. };
  107. #define XBOXSYSTEM_INTERFACE_VERSION "XboxSystemInterface002"
  108. //
  109. // XOnline.lib abstraction
  110. //
  111. #ifdef _X360
  112. abstract_class IXOnline
  113. {
  114. public:
  115. virtual void RunFrame() = 0;
  116. public:
  117. virtual DWORD XCancelOverlapped( PXOVERLAPPED pOverlapped ) = 0;
  118. public:
  119. virtual DWORD XFriendsCreateEnumerator(
  120. DWORD dwUserIndex,
  121. DWORD dwStartingIndex,
  122. DWORD dwFriendsToReturn,
  123. DWORD *pcbBuffer,
  124. HANDLE *ph
  125. ) = 0;
  126. virtual INT XNetQosRelease(
  127. XNQOS * pxnqos
  128. ) = 0;
  129. virtual INT XNetQosServiceLookup(
  130. DWORD dwFlags,
  131. WSAEVENT hEvent,
  132. XNQOS * * ppxnqos
  133. ) = 0;
  134. virtual DWORD XInviteGetAcceptedInfo(
  135. DWORD dwUserIndex,
  136. XINVITE_INFO *pInfo
  137. ) = 0;
  138. virtual DWORD XInviteSend(
  139. DWORD dwUserIndex,
  140. DWORD cInvitees,
  141. const XUID *pXuidInvitees,
  142. const WCHAR *pszText,
  143. XOVERLAPPED *pXOverlapped
  144. ) = 0;
  145. virtual DWORD XTitleServerCreateEnumerator(
  146. LPCSTR pszServerInfo,
  147. DWORD cItem,
  148. PDWORD pcbBuffer,
  149. PHANDLE phEnum
  150. ) = 0;
  151. virtual INT XNetQosLookup(
  152. UINT cxna,
  153. const XNADDR * apxna[],
  154. const XNKID * apxnkid[],
  155. const XNKEY * apxnkey[],
  156. UINT cina,
  157. const IN_ADDR aina[],
  158. const DWORD adwServiceId[],
  159. UINT cProbes,
  160. DWORD dwBitsPerSec,
  161. DWORD dwFlags,
  162. WSAEVENT hEvent,
  163. XNQOS ** ppxnqos
  164. ) = 0;
  165. virtual INT XNetUnregisterInAddr(
  166. const IN_ADDR ina
  167. ) = 0;
  168. virtual INT XNetServerToInAddr(
  169. const IN_ADDR ina,
  170. DWORD dwServiceId,
  171. IN_ADDR *pina
  172. ) = 0;
  173. virtual DWORD XSessionSearchEx(
  174. DWORD dwProcedureIndex,
  175. DWORD dwUserIndex,
  176. DWORD dwNumResults,
  177. DWORD dwNumUsers,
  178. WORD wNumProperties,
  179. WORD wNumContexts,
  180. PXUSER_PROPERTY pSearchProperties,
  181. PXUSER_CONTEXT pSearchContexts,
  182. DWORD *pcbResultsBuffer,
  183. PXSESSION_SEARCHRESULT_HEADER pSearchResults,
  184. PXOVERLAPPED pXOverlapped
  185. ) = 0;
  186. virtual DWORD XSessionGetDetails(
  187. HANDLE hSession,
  188. DWORD *pcbResultsBuffer,
  189. XSESSION_LOCAL_DETAILS *pSessionDetails,
  190. PXOVERLAPPED pXOverlapped
  191. ) = 0;
  192. virtual INT XNetQosListen(
  193. const XNKID * pxnkid,
  194. const BYTE * pb,
  195. UINT cb,
  196. DWORD dwBitsPerSec,
  197. DWORD dwFlags
  198. ) = 0;
  199. virtual DWORD XSessionModify(
  200. HANDLE hSession,
  201. DWORD dwFlags,
  202. DWORD dwMaxPublicSlots,
  203. DWORD dwMaxPrivateSlots,
  204. PXOVERLAPPED pXOverlapped
  205. ) = 0;
  206. virtual DWORD XNetGetTitleXnAddr(
  207. XNADDR *pxna
  208. ) = 0;
  209. virtual INT XNetRegisterKey(
  210. const XNKID *pxnkid,
  211. const XNKEY *pxnkey
  212. ) = 0;
  213. virtual INT XNetUnregisterKey(
  214. const XNKID *pxnkid
  215. ) = 0;
  216. virtual INT XNetCreateKey(
  217. XNKID *pxnkid,
  218. XNKEY *pxnkey
  219. ) = 0;
  220. virtual INT XNetReplaceKey(
  221. const XNKID *pxnkidUnregister,
  222. const XNKID * pxnkidReplace
  223. ) = 0;
  224. virtual DWORD XSessionDelete(
  225. HANDLE hSession,
  226. PXOVERLAPPED pXOverlapped
  227. ) = 0;
  228. virtual DWORD XSessionCreate(
  229. DWORD dwFlags,
  230. DWORD dwUserIndex,
  231. DWORD dwMaxPublicSlots,
  232. DWORD dwMaxPrivateSlots,
  233. ULONGLONG *pqwSessionNonce,
  234. PXSESSION_INFO pSessionInfo,
  235. PXOVERLAPPED pXOverlapped,
  236. HANDLE *ph
  237. ) = 0;
  238. virtual DWORD XSessionSearchByID(
  239. XNKID sessionID,
  240. DWORD dwUserIndex,
  241. DWORD *pcbResultsBuffer,
  242. PXSESSION_SEARCHRESULT_HEADER pSearchResults,
  243. PXOVERLAPPED pXOverlapped
  244. ) = 0;
  245. virtual DWORD XSessionMigrateHost(
  246. HANDLE hSession,
  247. DWORD dwUserIndex,
  248. XSESSION_INFO *pSessionInfo,
  249. PXOVERLAPPED pXOverlapped
  250. ) = 0;
  251. virtual DWORD XSessionJoinRemote(
  252. HANDLE hSession,
  253. DWORD dwXuidCount,
  254. const XUID *pXuids,
  255. const BOOL *pfPrivateSlots,
  256. PXOVERLAPPED pXOverlapped
  257. ) = 0;
  258. virtual DWORD XSessionJoinLocal(
  259. HANDLE hSession,
  260. DWORD dwUserCount,
  261. const DWORD *pdwUserIndexes,
  262. const BOOL *pfPrivateSlots,
  263. PXOVERLAPPED pXOverlapped
  264. ) = 0;
  265. virtual DWORD XSessionLeaveRemote(
  266. HANDLE hSession,
  267. DWORD dwXuidCount,
  268. const XUID *pXuids,
  269. PXOVERLAPPED pXOverlapped
  270. ) = 0;
  271. virtual DWORD XSessionLeaveLocal(
  272. HANDLE hSession,
  273. DWORD dwUserCount,
  274. const DWORD *pdwUserIndexes,
  275. PXOVERLAPPED pXOverlapped
  276. ) = 0;
  277. virtual DWORD XSessionEnd(
  278. HANDLE hSession,
  279. PXOVERLAPPED pXOverlapped
  280. ) = 0;
  281. virtual DWORD XSessionStart(
  282. HANDLE hSession,
  283. DWORD dwFlags,
  284. PXOVERLAPPED pXOverlapped
  285. ) = 0;
  286. virtual DWORD XNetGetConnectStatus(
  287. const IN_ADDR ina
  288. ) = 0;
  289. virtual INT XNetInAddrToXnAddr(
  290. const IN_ADDR ina,
  291. XNADDR *pxna,
  292. XNKID *pxnkid
  293. ) = 0;
  294. virtual INT XNetXnAddrToInAddr(
  295. const XNADDR *pxna,
  296. const XNKID *pxnkid,
  297. IN_ADDR *pina
  298. ) = 0;
  299. virtual INT XNetConnect(
  300. const IN_ADDR ina
  301. ) = 0;
  302. virtual DWORD XUserReadProfileSettingsByXuid(
  303. DWORD dwTitleId,
  304. DWORD dwUserIndexRequester,
  305. DWORD dwNumFor,
  306. const XUID *pxuidFor,
  307. DWORD dwNumSettingIds,
  308. const DWORD *pdwSettingIds,
  309. DWORD *pcbResults,
  310. PXUSER_READ_PROFILE_SETTING_RESULT pResults,
  311. PXOVERLAPPED pXOverlapped
  312. ) = 0;
  313. virtual DWORD XUserReadProfileSettings(
  314. DWORD dwTitleId,
  315. DWORD dwUserIndex,
  316. DWORD dwNumSettingIds,
  317. const DWORD *pdwSettingIds,
  318. DWORD *pcbResults,
  319. PXUSER_READ_PROFILE_SETTING_RESULT pResults,
  320. PXOVERLAPPED pXOverlapped
  321. ) = 0;
  322. virtual DWORD XUserWriteProfileSettings(
  323. DWORD dwUserIndex,
  324. DWORD dwNumSettings,
  325. const PXUSER_PROFILE_SETTING pSettings,
  326. PXOVERLAPPED pXOverlapped
  327. ) = 0;
  328. virtual DWORD XUserMuteListQuery(
  329. DWORD dwUserIndex,
  330. XUID XuidRemoteTalker,
  331. BOOL *pfOnMuteList
  332. ) = 0;
  333. virtual DWORD XSessionWriteStats(
  334. HANDLE hSession,
  335. XUID xuid,
  336. DWORD dwNumViews,
  337. const XSESSION_VIEW_PROPERTIES *pViews,
  338. XOVERLAPPED *pXOverlapped
  339. ) = 0;
  340. virtual DWORD XSessionFlushStats(
  341. HANDLE hSession,
  342. XOVERLAPPED *pXOverlapped
  343. ) = 0;
  344. virtual DWORD XShowMarketplaceDownloadItemsUI(
  345. DWORD dwUserIndex,
  346. DWORD dwEntryPoint,
  347. CONST ULONGLONG *pOfferIDs,
  348. DWORD dwOfferIdCount,
  349. HRESULT *phrResult,
  350. PXOVERLAPPED pOverlapped
  351. ) = 0;
  352. virtual DWORD XMarketplaceGetDownloadStatus(
  353. DWORD dwUserIndex,
  354. ULONGLONG qwOfferID,
  355. LPDWORD pdwResult
  356. ) = 0;
  357. virtual DWORD XShowMarketplaceUI(
  358. DWORD dwUserIndex,
  359. DWORD dwEntryPoint,
  360. ULONGLONG qwOfferID,
  361. DWORD dwContentCategories
  362. ) = 0;
  363. virtual DWORD XShowGameInviteUI(
  364. DWORD dwUserIndex,
  365. CONST XUID *pXuidRecipients,
  366. DWORD cRecipients,
  367. LPCWSTR wszUnused
  368. ) = 0;
  369. virtual HRESULT XShowPartyUI(
  370. DWORD dwUserIndex
  371. ) = 0;
  372. virtual DWORD XPartySendGameInvites(
  373. DWORD dwUserIndex,
  374. XOVERLAPPED *pOverlapped
  375. ) = 0;
  376. virtual HRESULT XShowCommunitySessionsUI(
  377. DWORD dwUserIndex,
  378. DWORD dwSocialSessionsFlags
  379. ) = 0;
  380. virtual INT XNetXnAddrToMachineId(
  381. const XNADDR *pxnaddr,
  382. ULONGLONG *pqwMachineId
  383. ) = 0;
  384. virtual DWORD XNetGetEthernetLinkStatus() = 0;
  385. virtual XONLINE_NAT_TYPE XOnlineGetNatType() = 0;
  386. };
  387. #define XONLINE_INTERFACE_VERSION "XOnlineInterface001"
  388. #endif
  389. #endif // IXBOXSYSTEM_H