Team Fortress 2 Source Code as on 22/4/2020
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.

155 lines
5.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // ilaunchermgr.h
  4. //
  5. //==================================================================================================
  6. #ifndef ILAUNCHERMGR_H
  7. #define ILAUNCHERMGR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #if defined( USE_SDL )
  12. #include "tier0/threadtools.h"
  13. #include "appframework/IAppSystem.h"
  14. #if defined( DX_TO_GL_ABSTRACTION )
  15. #include "togl/linuxwin/glmgrbasics.h"
  16. #include "togl/linuxwin/glmdisplay.h"
  17. class GLMDisplayDB;
  18. class CShowPixelsParams;
  19. #endif
  20. // if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly
  21. #define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001"
  22. class CCocoaEvent;
  23. class CStackCrawlParams;
  24. typedef struct SDL_Cursor SDL_Cursor;
  25. class ILauncherMgr : public IAppSystem
  26. {
  27. public:
  28. virtual bool Connect( CreateInterfaceFn factory ) = 0;
  29. virtual void Disconnect() = 0;
  30. virtual void *QueryInterface( const char *pInterfaceName ) = 0;
  31. // Init, shutdown
  32. virtual InitReturnVal_t Init() = 0;
  33. virtual void Shutdown() = 0;
  34. // Create the window.
  35. virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) = 0;
  36. virtual void IncWindowRefCount() = 0;
  37. virtual void DecWindowRefCount() = 0;
  38. // Get the next N events. The function returns the number of events that were filled into your array.
  39. virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0;
  40. #ifdef LINUX
  41. virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0;
  42. #endif
  43. // Set the mouse cursor position.
  44. virtual void SetCursorPosition( int x, int y ) = 0;
  45. virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) = 0;
  46. virtual bool IsWindowFullScreen() = 0;
  47. virtual void MoveWindow( int x, int y ) = 0;
  48. virtual void SizeWindow( int width, int tall ) = 0;
  49. virtual void PumpWindowsMessageLoop() = 0;
  50. virtual void DestroyGameWindow() = 0;
  51. virtual void SetApplicationIcon( const char *pchAppIconFile ) = 0;
  52. virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) = 0;
  53. virtual void GetNativeDisplayInfo( int nDisplay, uint &nWidth, uint &nHeight, uint &nRefreshHz ) = 0; // Retrieve the size of the monitor (desktop)
  54. virtual void RenderedSize( uint &width, uint &height, bool set ) = 0; // either set or retrieve rendered size value (from dxabstract)
  55. virtual void DisplayedSize( uint &width, uint &height ) = 0; // query backbuffer size (window size whether FS or windowed)
  56. #if defined( DX_TO_GL_ABSTRACTION )
  57. virtual PseudoGLContextPtr GetMainContext() = 0;
  58. // Get the NSGLContext for a window's main view - note this is the carbon windowref as an argument
  59. virtual PseudoGLContextPtr GetGLContextForWindow( void* windowref ) = 0;
  60. virtual PseudoGLContextPtr CreateExtraContext() = 0;
  61. virtual void DeleteContext( PseudoGLContextPtr hContext ) = 0;
  62. virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) = 0;
  63. virtual GLMDisplayDB *GetDisplayDB( void ) = 0;
  64. virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) = 0;
  65. virtual void ShowPixels( CShowPixelsParams *params ) = 0;
  66. #endif
  67. virtual void GetStackCrawl( CStackCrawlParams *params ) = 0;
  68. virtual void WaitUntilUserInput( int msSleepTime ) = 0;
  69. virtual void *GetWindowRef() = 0;
  70. virtual void SetMouseVisible( bool bState ) = 0;
  71. virtual void SetMouseCursor( SDL_Cursor *hCursor ) = 0;
  72. virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) = 0;
  73. virtual void OnFrameRendered() = 0;
  74. virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) = 0;
  75. virtual double GetPrevGLSwapWindowTime() = 0;
  76. };
  77. extern ILauncherMgr *g_pLauncherMgr;
  78. enum CocoaEventType_t
  79. {
  80. CocoaEvent_KeyDown,
  81. CocoaEvent_KeyUp,
  82. CocoaEvent_MouseButtonDown,
  83. CocoaEvent_MouseMove,
  84. CocoaEvent_MouseButtonUp,
  85. CocoaEvent_AppActivate,
  86. CocoaEvent_MouseScroll,
  87. CocoaEvent_AppQuit,
  88. CocoaEvent_Deleted, // Event was one of the above, but has been handled and should be ignored now.
  89. };
  90. // enum values need to match bit-shifting logic in CInputSystem::UpdateMouseButtonState and
  91. // the codes from NSEvent pressedMouseButtons, turns out the two are in agreement right now
  92. enum CocoaMouseButton_t
  93. {
  94. COCOABUTTON_LEFT = 1 << 0,
  95. COCOABUTTON_RIGHT = 1 << 1,
  96. COCOABUTTON_MIDDLE = 1 << 2,
  97. COCOABUTTON_4 = 1 << 3,
  98. COCOABUTTON_5 = 1 << 4,
  99. };
  100. enum ECocoaKeyModifier
  101. {
  102. eCapsLockKey,
  103. eShiftKey,
  104. eControlKey,
  105. eAltKey, // aka option
  106. eCommandKey
  107. };
  108. class CCocoaEvent
  109. {
  110. public:
  111. CocoaEventType_t m_EventType;
  112. int m_VirtualKeyCode;
  113. wchar_t m_UnicodeKey;
  114. wchar_t m_UnicodeKeyUnmodified;
  115. uint m_ModifierKeyMask; //
  116. int m_MousePos[2];
  117. int m_MouseButtonFlags; // Current state of the mouse buttons. See COCOABUTTON_xxxx.
  118. uint m_nMouseClickCount;
  119. int m_MouseButton; // which of the CocoaMouseButton_t buttons this is for from above
  120. };
  121. #endif // defined( USE_SDL )
  122. #endif // ILAUNCHERMGR_H