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.

219 lines
4.1 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Linux support for the IGame interface
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #include "iengine.h"
  10. #include <stdlib.h>
  11. #include "engine_launcher_api.h"
  12. #include "basetypes.h"
  13. #include "ivideomode.h"
  14. #include "igame.h"
  15. #define UINT unsigned int
  16. #define WPARAM int
  17. #define LPARAM int
  18. #include "profile.h"
  19. #include "server.h"
  20. #include "cdll_int.h"
  21. // NOTE: This has to be the last file included!
  22. #include "tier0/memdbgon.h"
  23. #ifdef DEDICATED
  24. void ForceReloadProfile( void );
  25. void ClearIOStates( void );
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Main game interface, including message pump and window creation
  28. //-----------------------------------------------------------------------------
  29. class CGame : public IGame
  30. {
  31. public:
  32. CGame( void );
  33. virtual ~CGame( void );
  34. bool Init( void *pvInstance );
  35. bool Shutdown( void );
  36. bool CreateGameWindow( void );
  37. virtual void DestroyGameWindow( void );
  38. virtual void SetGameWindow( void *hWnd );
  39. virtual bool InputAttachToGameWindow();
  40. virtual void InputDetachFromGameWindow();
  41. void* GetMainWindow( void );
  42. void** GetMainWindowAddress( void );
  43. void SetWindowXY( int x, int y );
  44. void SetWindowSize( int w, int h );
  45. void GetWindowRect( int *x, int *y, int *w, int *h );
  46. bool IsActiveApp( void );
  47. virtual void DispatchAllStoredGameMessages();
  48. virtual void PlayStartupVideos() {}
  49. virtual void GetDesktopInfo( int &width, int &height, int &refreshRate );
  50. virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight )
  51. {
  52. }
  53. private:
  54. void SetActiveApp( bool fActive );
  55. private:
  56. bool m_bActiveApp;
  57. static const char CLASSNAME[];
  58. };
  59. static CGame g_Game;
  60. IGame *game = ( IGame * )&g_Game;
  61. const char CGame::CLASSNAME[] = "Valve001";
  62. // In VCR playback mode, it sleeps this amount each frame.
  63. int g_iVCRPlaybackSleepInterval = 0;
  64. // During VCR playback, if this is true, then it'll pause at the end of each frame.
  65. bool g_bVCRSingleStep = false;
  66. void VCR_EnterPausedState()
  67. {
  68. // Turn this off in case they're in single-step mode.
  69. g_bVCRSingleStep = false;
  70. // This is cheesy, but GetAsyncKeyState is blocked (in protected_things. h)
  71. // from being accidentally used, so we get it through it by getting its pointer directly.
  72. // In this mode, we enter a wait state where we only pay attention to R and Q.
  73. /* while ( 1 )
  74. {
  75. if ( pfn( 'R' ) & 0x8000 )
  76. break;
  77. if ( pfn( 'Q' ) & 0x8000 )
  78. kill( getpid(), SIGKILL );
  79. if ( pfn( 'S' ) & 0x8000 )
  80. {
  81. // Do a single step.
  82. g_bVCRSingleStep = true;
  83. break;
  84. }
  85. Sleep( 2 );
  86. }
  87. */
  88. }
  89. bool CGame::CreateGameWindow( void )
  90. {
  91. return true;
  92. }
  93. void CGame::DestroyGameWindow( void )
  94. {
  95. }
  96. // This is used in edit mode to override the default wnd proc associated w/
  97. bool CGame::InputAttachToGameWindow()
  98. {
  99. return true;
  100. }
  101. void CGame::InputDetachFromGameWindow()
  102. {
  103. }
  104. void CGame::SetGameWindow( void *hWnd )
  105. {
  106. return;
  107. }
  108. CGame::CGame( void )
  109. {
  110. m_bActiveApp = true;
  111. }
  112. CGame::~CGame( void )
  113. {
  114. }
  115. bool CGame::Init( void *pvInstance )
  116. {
  117. return true;
  118. }
  119. bool CGame::Shutdown( void )
  120. {
  121. return true;
  122. }
  123. void *CGame::GetMainWindow( void )
  124. {
  125. return 0;
  126. }
  127. void **CGame::GetMainWindowAddress( void )
  128. {
  129. return NULL;
  130. }
  131. void CGame::SetWindowXY( int x, int y )
  132. {
  133. }
  134. void CGame::SetWindowSize( int w, int h )
  135. {
  136. }
  137. void CGame::GetWindowRect( int *x, int *y, int *w, int *h )
  138. {
  139. if ( x )
  140. {
  141. *x = 0;
  142. }
  143. if ( y )
  144. {
  145. *y = 0;
  146. }
  147. if ( w )
  148. {
  149. *w = 0;
  150. }
  151. if ( h )
  152. {
  153. *h = 0;
  154. }
  155. }
  156. bool CGame::IsActiveApp( void )
  157. {
  158. return m_bActiveApp;
  159. }
  160. void CGame::SetActiveApp( bool active )
  161. {
  162. m_bActiveApp = active;
  163. }
  164. void CGame::DispatchAllStoredGameMessages()
  165. {
  166. }
  167. void CGame::GetDesktopInfo( int &width, int &height, int &refreshRate )
  168. {
  169. width = 0;
  170. height = 0;
  171. refreshRate = 0;
  172. }
  173. #endif