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.

461 lines
14 KiB

  1. //========= Copyright 1996-2004, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose: Win32 replacements for XBox.
  4. //
  5. //=============================================================================
  6. #if !defined( XBOXSTUBS_H ) && !defined( _X360 )
  7. #define XBOXSTUBS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #ifdef _WIN32
  12. typedef unsigned long DWORD;
  13. //#include "winlite.h"
  14. #endif
  15. #include "tier0/platform.h"
  16. // Content creation/open flags
  17. #define XCONTENTFLAG_NONE 0x00
  18. #define XCONTENTFLAG_CREATENEW 0x00
  19. #define XCONTENTFLAG_CREATEALWAYS 0x00
  20. #define XCONTENTFLAG_OPENEXISTING 0x00
  21. #define XCONTENTFLAG_OPENALWAYS 0x00
  22. #define XCONTENTFLAG_TRUNCATEEXISTING 0x00
  23. // Content attributes
  24. #define XCONTENTFLAG_NOPROFILE_TRANSFER 0x00
  25. #define XCONTENTFLAG_NODEVICE_TRANSFER 0x00
  26. #define XCONTENTFLAG_STRONG_SIGNED 0x00
  27. #define XCONTENTFLAG_ALLOWPROFILE_TRANSFER 0x00
  28. #define XCONTENTFLAG_MOVEONLY_TRANSFER 0x00
  29. // XNet flags
  30. #define XNET_GET_XNADDR_PENDING 0x00000000 // Address acquisition is not yet complete
  31. #define XNET_GET_XNADDR_NONE 0x00000001 // XNet is uninitialized or no debugger found
  32. #define XNET_GET_XNADDR_ETHERNET 0x00000002 // Host has ethernet address (no IP address)
  33. #define XNET_GET_XNADDR_STATIC 0x00000004 // Host has statically assigned IP address
  34. #define XNET_GET_XNADDR_DHCP 0x00000008 // Host has DHCP assigned IP address
  35. #define XNET_GET_XNADDR_PPPOE 0x00000010 // Host has PPPoE assigned IP address
  36. #define XNET_GET_XNADDR_GATEWAY 0x00000020 // Host has one or more gateways configured
  37. #define XNET_GET_XNADDR_DNS 0x00000040 // Host has one or more DNS servers configured
  38. #define XNET_GET_XNADDR_ONLINE 0x00000080 // Host is currently connected to online service
  39. #define XNET_GET_XNADDR_TROUBLESHOOT 0x00008000 // Network configuration requires troubleshooting
  40. // Console device ports
  41. #define XDEVICE_PORT0 0
  42. #define XDEVICE_PORT1 1
  43. #define XDEVICE_PORT2 2
  44. #define XDEVICE_PORT3 3
  45. #ifndef _PS3
  46. #define XUSER_MAX_COUNT 4
  47. #endif // !_PS3
  48. #define XUSER_INDEX_NONE 0x000000FE
  49. #define XBX_CLR_DEFAULT 0xFF000000
  50. #define XBX_CLR_WARNING 0x0000FFFF
  51. #define XBX_CLR_ERROR 0x000000FF
  52. #ifndef _PS3
  53. #define XBOX_MINBORDERSAFE 0
  54. #define XBOX_MAXBORDERSAFE 0
  55. #endif // !_PS3
  56. #if defined( PLATFORM_PS3 )
  57. #include "ps3/ps3_core.h"
  58. #endif
  59. #ifndef _PS3
  60. typedef enum
  61. {
  62. XK_NULL,
  63. XK_BUTTON_UP,
  64. XK_BUTTON_DOWN,
  65. XK_BUTTON_LEFT,
  66. XK_BUTTON_RIGHT,
  67. XK_BUTTON_START,
  68. XK_BUTTON_BACK,
  69. XK_BUTTON_STICK1,
  70. XK_BUTTON_STICK2,
  71. XK_BUTTON_A,
  72. XK_BUTTON_B,
  73. XK_BUTTON_X,
  74. XK_BUTTON_Y,
  75. XK_BUTTON_LEFT_SHOULDER,
  76. XK_BUTTON_RIGHT_SHOULDER,
  77. XK_BUTTON_LTRIGGER,
  78. XK_BUTTON_RTRIGGER,
  79. XK_STICK1_UP,
  80. XK_STICK1_DOWN,
  81. XK_STICK1_LEFT,
  82. XK_STICK1_RIGHT,
  83. XK_STICK2_UP,
  84. XK_STICK2_DOWN,
  85. XK_STICK2_LEFT,
  86. XK_STICK2_RIGHT,
  87. XK_BUTTON_INACTIVE_START,
  88. XK_BUTTON_FIREMODE_SELECTOR_1,
  89. XK_BUTTON_FIREMODE_SELECTOR_2,
  90. XK_BUTTON_FIREMODE_SELECTOR_3,
  91. XK_BUTTON_RELOAD,
  92. XK_BUTTON_TRIGGER,
  93. XK_BUTTON_PUMP_ACTION,
  94. XK_XBUTTON_ROLL_RIGHT,
  95. XK_XBUTTON_ROLL_LEFT,
  96. XK_MAX_KEYS,
  97. } xKey_t;
  98. #endif
  99. //typedef enum
  100. //{
  101. // XVRB_NONE, // off
  102. // XVRB_ERROR, // fatal error
  103. // XVRB_ALWAYS, // no matter what
  104. // XVRB_WARNING, // non-fatal warnings
  105. // XVRB_STATUS, // status reports
  106. // XVRB_ALL,
  107. //} xverbose_e;
  108. #ifndef WORD
  109. typedef unsigned short WORD;
  110. #endif
  111. #if ( !defined ( DWORD ) && !defined( WIN32 ) && !defined( _PS3 ))
  112. typedef unsigned int DWORD;
  113. #endif
  114. #ifndef POSIX
  115. typedef void* HANDLE;
  116. # if defined(_PS3) || defined(POSIX)
  117. typedef unsigned long long ULONGLONG
  118. # else
  119. typedef unsigned __int64 ULONGLONG;
  120. # endif
  121. #endif
  122. #if defined( OSX )
  123. typedef DWORD COLORREF;
  124. #elif defined( POSIX ) && !defined( _PS3 )
  125. typedef DWORD COLORREF;
  126. #endif
  127. #ifndef INVALID_HANDLE_VALUE
  128. #define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
  129. #endif
  130. /*
  131. * Internet address (old style... should be updated)
  132. */
  133. #ifdef PLATFORM_PS3
  134. #include <netinet/in.h>
  135. typedef struct in_addr IN_ADDR;
  136. #elif defined( POSIX )
  137. struct ip4_addr {
  138. union {
  139. struct { unsigned char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  140. struct { unsigned short s_w1,s_w2; } S_un_w;
  141. unsigned long S_addr;
  142. } S_un;
  143. };
  144. typedef struct ip4_addr IN_ADDR;
  145. #else
  146. #ifndef s_addr
  147. /*
  148. * Internet address (old style... should be updated)
  149. */
  150. struct in_addr {
  151. union {
  152. struct { unsigned char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  153. struct { unsigned short s_w1,s_w2; } S_un_w;
  154. unsigned long S_addr;
  155. } S_un;
  156. #define s_addr S_un.S_addr
  157. /* can be used for most tcp & ip code */
  158. #define s_host S_un.S_un_b.s_b2
  159. /* host on imp */
  160. #define s_net S_un.S_un_b.s_b1
  161. /* network */
  162. #define s_imp S_un.S_un_w.s_w2
  163. /* imp */
  164. #define s_impno S_un.S_un_b.s_b4
  165. /* imp # */
  166. #define s_lh S_un.S_un_b.s_b3
  167. /* logical host */
  168. };
  169. typedef struct in_addr IN_ADDR;
  170. #endif
  171. #endif
  172. typedef unsigned int XIN_ADDR;
  173. typedef struct {
  174. IN_ADDR ina; // IP address (zero if not static/DHCP)
  175. IN_ADDR inaOnline; // Online IP address (zero if not online)
  176. WORD wPortOnline; // Online port
  177. BYTE abEnet[6]; // Ethernet MAC address
  178. BYTE abOnline[20]; // Online identification
  179. } XNADDR;
  180. typedef uint64 XUID;
  181. #ifndef INVALID_XUID
  182. #define INVALID_XUID ((XUID) 0)
  183. #endif
  184. #ifndef _PS3
  185. typedef struct {
  186. BYTE ab[8]; // xbox to xbox key identifier
  187. } XNKID;
  188. typedef struct {
  189. BYTE ab[16]; // xbox to xbox key exchange key
  190. } XNKEY;
  191. #endif
  192. typedef struct _XSESSION_INFO
  193. {
  194. XNKID sessionID; // 8 bytes
  195. XNADDR hostAddress; // 36 bytes
  196. XNKEY keyExchangeKey; // 16 bytes
  197. } XSESSION_INFO, *PXSESSION_INFO;
  198. typedef struct _XUSER_DATA
  199. {
  200. BYTE type;
  201. union
  202. {
  203. int nData; // XUSER_DATA_TYPE_INT32
  204. int64 i64Data; // XUSER_DATA_TYPE_INT64
  205. double dblData; // XUSER_DATA_TYPE_DOUBLE
  206. struct // XUSER_DATA_TYPE_UNICODE
  207. {
  208. uint cbData; // Includes null-terminator
  209. char * pwszData;
  210. } string;
  211. float fData; // XUSER_DATA_TYPE_FLOAT
  212. struct // XUSER_DATA_TYPE_BINARY
  213. {
  214. uint cbData;
  215. char * pbData;
  216. } binary;
  217. };
  218. } XUSER_DATA, *PXUSER_DATA;
  219. typedef struct _XUSER_PROPERTY
  220. {
  221. DWORD dwPropertyId;
  222. XUSER_DATA value;
  223. } XUSER_PROPERTY, *PXUSER_PROPERTY;
  224. typedef struct _XUSER_CONTEXT
  225. {
  226. DWORD dwContextId;
  227. DWORD dwValue;
  228. } XUSER_CONTEXT, *PXUSER_CONTEXT;
  229. typedef struct _XSESSION_SEARCHRESULT
  230. {
  231. XSESSION_INFO info;
  232. DWORD dwOpenPublicSlots;
  233. DWORD dwOpenPrivateSlots;
  234. DWORD dwFilledPublicSlots;
  235. DWORD dwFilledPrivateSlots;
  236. DWORD cProperties;
  237. DWORD cContexts;
  238. PXUSER_PROPERTY pProperties;
  239. PXUSER_CONTEXT pContexts;
  240. } XSESSION_SEARCHRESULT, *PXSESSION_SEARCHRESULT;
  241. typedef struct _XSESSION_SEARCHRESULT_HEADER
  242. {
  243. DWORD dwSearchResults;
  244. XSESSION_SEARCHRESULT *pResults;
  245. } XSESSION_SEARCHRESULT_HEADER, *PXSESSION_SEARCHRESULT_HEADER;
  246. typedef struct _XSESSION_REGISTRANT
  247. {
  248. uint64 qwMachineID;
  249. DWORD bTrustworthiness;
  250. DWORD bNumUsers;
  251. XUID *rgUsers;
  252. } XSESSION_REGISTRANT;
  253. typedef struct _XSESSION_REGISTRATION_RESULTS
  254. {
  255. DWORD wNumRegistrants;
  256. XSESSION_REGISTRANT *rgRegistrants;
  257. } XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS;
  258. typedef struct {
  259. BYTE bFlags;
  260. BYTE bReserved;
  261. WORD cProbesXmit;
  262. WORD cProbesRecv;
  263. WORD cbData;
  264. BYTE * pbData;
  265. WORD wRttMinInMsecs;
  266. WORD wRttMedInMsecs;
  267. DWORD dwUpBitsPerSec;
  268. DWORD dwDnBitsPerSec;
  269. } XNQOSINFO;
  270. typedef struct {
  271. uint cxnqos;
  272. uint cxnqosPending;
  273. XNQOSINFO axnqosinfo[1];
  274. } XNQOS;
  275. #define XSESSION_CREATE_HOST 0
  276. #define XSESSION_CREATE_USES_ARBITRATION 0
  277. #define XNET_QOS_LISTEN_ENABLE 0
  278. #define XNET_QOS_LISTEN_DISABLE 0
  279. #define XNET_QOS_LISTEN_SET_DATA 0
  280. #define XUSER_DATA_TYPE_CONTEXT ((BYTE)0)
  281. #define XUSER_DATA_TYPE_INT32 ((BYTE)1)
  282. #define XUSER_DATA_TYPE_INT64 ((BYTE)2)
  283. #define XUSER_DATA_TYPE_DOUBLE ((BYTE)3)
  284. #define XUSER_DATA_TYPE_UNICODE ((BYTE)4)
  285. #define XUSER_DATA_TYPE_FLOAT ((BYTE)5)
  286. #define XUSER_DATA_TYPE_BINARY ((BYTE)6)
  287. #define XUSER_DATA_TYPE_DATETIME ((BYTE)7)
  288. #define XUSER_DATA_TYPE_NULL ((BYTE)0xFF)
  289. #define XPROFILE_TITLE_SPECIFIC1 0x3FFF
  290. #define XPROFILE_TITLE_SPECIFIC2 0x3FFE
  291. #define XPROFILE_TITLE_SPECIFIC3 0x3FFD
  292. #define XPROFILE_SETTING_MAX_SIZE 1000
  293. FORCEINLINE unsigned int XBX_GetSystemTime() { return 0; }
  294. #ifndef PLATFORM_PS3
  295. FORCEINLINE DWORD XBX_GetNumGameUsers() { return 1; }
  296. FORCEINLINE void XBX_ProcessEvents() {}
  297. FORCEINLINE void XBX_DispatchEventsQueue() {}
  298. FORCEINLINE DWORD XBX_GetPrimaryUserId() { return 0; }
  299. FORCEINLINE void XBX_SetPrimaryUserId( DWORD idx ) {}
  300. FORCEINLINE void XBX_ResetStorageDeviceInfo() {}
  301. FORCEINLINE DWORD XBX_DescribeStorageDevice( DWORD nStorageID ) { return 1; }
  302. FORCEINLINE DWORD XBX_GetStorageDeviceId(int) { return 0; }
  303. FORCEINLINE void XBX_SetStorageDeviceId( int, DWORD ) {}
  304. FORCEINLINE const char *XBX_GetLanguageString() { return ""; }
  305. FORCEINLINE bool XBX_IsLocalized() { return false; }
  306. FORCEINLINE bool XBX_IsAudioLocalized() { return false; }
  307. FORCEINLINE const char *XBX_GetNextSupportedLanguage( const char *pLanguage, bool *pbHasAudio ) { return NULL; }
  308. FORCEINLINE bool XBX_IsRestrictiveLanguage() { return false; }
  309. FORCEINLINE int XBX_GetUserId( int nSlot ) { return nSlot; }
  310. FORCEINLINE int XBX_GetSlotByUserId( int idx ) { return idx; }
  311. FORCEINLINE void XBX_SetUserId( int nSlot, int idx ) {}
  312. #endif
  313. #define XCONTENT_MAX_DISPLAYNAME_LENGTH 128
  314. #define XCONTENT_MAX_FILENAME_LENGTH 42
  315. #ifndef _PS3
  316. #define XBX_INVALID_STORAGE_ID ((DWORD) -1)
  317. #define XBX_STORAGE_DECLINED ((DWORD) -2)
  318. #endif // !_PS3
  319. enum XUSER_SIGNIN_STATE
  320. {
  321. eXUserSigninState_NotSignedIn,
  322. eXUserSigninState_SignedInLocally,
  323. eXUserSigninState_SignedInToLive,
  324. };
  325. #if defined( _PS3 )
  326. #elif defined( POSIX )
  327. typedef size_t ULONG_PTR;
  328. #elif defined( _M_X64 )
  329. typedef _W64 unsigned __int64 ULONG_PTR;
  330. #else
  331. typedef _W64 unsigned long ULONG_PTR;
  332. #endif
  333. typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  334. typedef void * PXOVERLAPPED_COMPLETION_ROUTINE;
  335. #if defined( _PS3 ) || !defined( POSIX )
  336. typedef struct _XOVERLAPPED {
  337. ULONG_PTR InternalLow;
  338. ULONG_PTR InternalHigh;
  339. ULONG_PTR InternalContext;
  340. HANDLE hEvent;
  341. PXOVERLAPPED_COMPLETION_ROUTINE pCompletionRoutine;
  342. DWORD_PTR dwCompletionContext;
  343. DWORD dwExtendedError;
  344. } XOVERLAPPED, *PXOVERLAPPED;
  345. #endif
  346. #ifndef MAX_RICHPRESENCE_SIZE
  347. #define MAX_RICHPRESENCE_SIZE 64
  348. #endif
  349. #ifndef XUSER_NAME_SIZE
  350. #define XUSER_NAME_SIZE 16
  351. #endif
  352. #ifndef GPU_RESOLVE_ALIGNMENT
  353. #define GPU_RESOLVE_ALIGNMENT 8
  354. #endif
  355. #define XCONTENT_MAX_DISPLAYNAME_LENGTH 128
  356. #define XCONTENT_MAX_FILENAME_LENGTH 42
  357. #define XCONTENTDEVICE_MAX_NAME_LENGTH 27
  358. typedef DWORD XCONTENTDEVICEID, *PXCONTENTDEVICEID;
  359. #ifndef _PS3
  360. typedef struct _XCONTENT_DATA
  361. {
  362. XCONTENTDEVICEID DeviceID;
  363. DWORD dwContentType;
  364. wchar_t szDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH];
  365. char szFileName[XCONTENT_MAX_FILENAME_LENGTH];
  366. } XCONTENT_DATA, *PXCONTENT_DATA;
  367. #endif
  368. #define X_CONTEXT_PRESENCE 0x00010001
  369. #define X_CONTEXT_GAME_TYPE 0x0001000A
  370. #define X_CONTEXT_GAME_MODE 0x0001000B
  371. #define X_PROPERTY_RANK 0x00011001
  372. #define X_PROPERTY_GAMERNAME 0x00011002
  373. #define X_PROPERTY_SESSION_ID 0x00011003
  374. // System attributes used in matchmaking queries
  375. #define X_PROPERTY_GAMER_ZONE 0x00011101
  376. #define X_PROPERTY_GAMER_COUNTRY 0x00011102
  377. #define X_PROPERTY_GAMER_LANGUAGE 0x00011103
  378. #define X_PROPERTY_GAMER_RATING 0x00011104
  379. #define X_PROPERTY_GAMER_MU 0x00011105
  380. #define X_PROPERTY_GAMER_SIGMA 0x00011106
  381. #define X_PROPERTY_GAMER_PUID 0x00011107
  382. #define X_PROPERTY_AFFILIATE_SCORE 0x00011108
  383. #define X_PROPERTY_GAMER_HOSTNAME 0x00011109
  384. // Properties used to write to skill leaderboards
  385. #define X_PROPERTY_RELATIVE_SCORE 0x0001100A
  386. #define X_PROPERTY_SESSION_TEAM 0x0001100B
  387. // Properties written at the session level to override TrueSkill parameters
  388. #define X_PROPERTY_PLAYER_PARTIAL_PLAY_PERCENTAGE 0x0001100C
  389. #define X_PROPERTY_PLAYER_SKILL_UPDATE_WEIGHTING_FACTOR 0x0001100D
  390. #define X_PROPERTY_SESSION_SKILL_BETA 0x0001100E
  391. #define X_PROPERTY_SESSION_SKILL_TAU 0x0001100F
  392. #define X_PROPERTY_SESSION_SKILL_DRAW_PROBABILITY 0x00011010
  393. // Attachment size is written to a leaderboard when the entry qualifies for
  394. // a gamerclip. The rating can be retrieved via XUserEstimateRankForRating.
  395. #define X_PROPERTY_ATTACHMENT_SIZE 0x00011011
  396. // Values for X_CONTEXT_GAME_TYPE
  397. #define X_CONTEXT_GAME_TYPE_RANKED 0
  398. #define X_CONTEXT_GAME_TYPE_STANDARD 1
  399. #endif // XBOXSTUBS_H