1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2024-12-23 01:59:43 +08:00

Imported some changes from sdk2013.

This commit is contained in:
Scott Ehlert 2017-05-30 15:15:48 -05:00
parent f00294a14d
commit d73aca3068
2 changed files with 246 additions and 0 deletions

View File

@ -0,0 +1,162 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// ilaunchermgr.h
//
//==================================================================================================
#ifndef ILAUNCHERMGR_H
#define ILAUNCHERMGR_H
#ifdef _WIN32
#pragma once
#endif
#if defined( USE_SDL )
#include "tier0/threadtools.h"
#include "appframework/IAppSystem.h"
#if defined( DX_TO_GL_ABSTRACTION )
#if !defined(DEDICATED)
#include "togl/linuxwin/glmgrbasics.h"
#include "togl/linuxwin/glmdisplay.h"
#endif
class GLMDisplayDB;
class CShowPixelsParams;
#if defined(DEDICATED)
typedef void *PseudoGLContextPtr;
class GLMRendererInfoFields;
#endif
#endif
// if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly
#define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001"
class CCocoaEvent;
class CStackCrawlParams;
typedef struct SDL_Cursor SDL_Cursor;
class ILauncherMgr : public IAppSystem
{
public:
virtual bool Connect( CreateInterfaceFn factory ) = 0;
virtual void Disconnect() = 0;
virtual void *QueryInterface( const char *pInterfaceName ) = 0;
// Init, shutdown
virtual InitReturnVal_t Init() = 0;
virtual void Shutdown() = 0;
// Create the window.
virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) = 0;
virtual void IncWindowRefCount() = 0;
virtual void DecWindowRefCount() = 0;
// Get the next N events. The function returns the number of events that were filled into your array.
virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0;
#ifdef LINUX
virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0;
#endif
// Set the mouse cursor position.
virtual void SetCursorPosition( int x, int y ) = 0;
virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) = 0;
virtual bool IsWindowFullScreen() = 0;
virtual void MoveWindow( int x, int y ) = 0;
virtual void SizeWindow( int width, int tall ) = 0;
virtual void PumpWindowsMessageLoop() = 0;
virtual void DestroyGameWindow() = 0;
virtual void SetApplicationIcon( const char *pchAppIconFile ) = 0;
virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) = 0;
virtual void GetNativeDisplayInfo( int nDisplay, uint &nWidth, uint &nHeight, uint &nRefreshHz ) = 0; // Retrieve the size of the monitor (desktop)
virtual void RenderedSize( uint &width, uint &height, bool set ) = 0; // either set or retrieve rendered size value (from dxabstract)
virtual void DisplayedSize( uint &width, uint &height ) = 0; // query backbuffer size (window size whether FS or windowed)
#if defined( DX_TO_GL_ABSTRACTION )
virtual PseudoGLContextPtr GetMainContext() = 0;
// Get the NSGLContext for a window's main view - note this is the carbon windowref as an argument
virtual PseudoGLContextPtr GetGLContextForWindow( void* windowref ) = 0;
virtual PseudoGLContextPtr CreateExtraContext() = 0;
virtual void DeleteContext( PseudoGLContextPtr hContext ) = 0;
virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) = 0;
virtual GLMDisplayDB *GetDisplayDB( void ) = 0;
virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) = 0;
virtual void ShowPixels( CShowPixelsParams *params ) = 0;
#endif
virtual void GetStackCrawl( CStackCrawlParams *params ) = 0;
virtual void WaitUntilUserInput( int msSleepTime ) = 0;
virtual void *GetWindowRef() = 0;
virtual void SetMouseVisible( bool bState ) = 0;
virtual void SetMouseCursor( SDL_Cursor *hCursor ) = 0;
virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) = 0;
virtual void OnFrameRendered() = 0;
virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) = 0;
virtual double GetPrevGLSwapWindowTime() = 0;
};
extern ILauncherMgr *g_pLauncherMgr;
enum CocoaEventType_t
{
CocoaEvent_KeyDown,
CocoaEvent_KeyUp,
CocoaEvent_MouseButtonDown,
CocoaEvent_MouseMove,
CocoaEvent_MouseButtonUp,
CocoaEvent_AppActivate,
CocoaEvent_MouseScroll,
CocoaEvent_AppQuit,
CocoaEvent_Deleted, // Event was one of the above, but has been handled and should be ignored now.
};
// enum values need to match bit-shifting logic in CInputSystem::UpdateMouseButtonState and
// the codes from NSEvent pressedMouseButtons, turns out the two are in agreement right now
enum CocoaMouseButton_t
{
COCOABUTTON_LEFT = 1 << 0,
COCOABUTTON_RIGHT = 1 << 1,
COCOABUTTON_MIDDLE = 1 << 2,
COCOABUTTON_4 = 1 << 3,
COCOABUTTON_5 = 1 << 4,
};
enum ECocoaKeyModifier
{
eCapsLockKey,
eShiftKey,
eControlKey,
eAltKey, // aka option
eCommandKey
};
class CCocoaEvent
{
public:
CocoaEventType_t m_EventType;
int m_VirtualKeyCode;
wchar_t m_UnicodeKey;
wchar_t m_UnicodeKeyUnmodified;
uint m_ModifierKeyMask; //
int m_MousePos[2];
int m_MouseButtonFlags; // Current state of the mouse buttons. See COCOABUTTON_xxxx.
uint m_nMouseClickCount;
int m_MouseButton; // which of the CocoaMouseButton_t buttons this is for from above
};
#endif // defined( USE_SDL )
#endif // ILAUNCHERMGR_H

View File

@ -0,0 +1,84 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef ANALYSIS_ANNOTATIONS_H
#define ANALYSIS_ANNOTATIONS_H
#if _MSC_VER >= 1600 // VS 2010 and above.
//-----------------------------------------------------------------------------
// Upgrading important helpful warnings to errors
//-----------------------------------------------------------------------------
#pragma warning(error : 4789 ) // warning C4789: destination of memory copy is too small
// Suppress some code analysis warnings
#ifdef _PREFAST_
// Include the annotation header file.
#include <sal.h>
// For temporarily suppressing warnings -- the warnings are suppressed for the next source line.
#define ANALYZE_SUPPRESS(wnum) __pragma(warning(suppress: wnum))
#define ANALYZE_SUPPRESS2(wnum1, wnum2) __pragma(warning(supress: wnum1 wnum2))
#define ANALYZE_SUPPRESS3(wnum1, wnum2, wnum3) __pragma(warning(suppress: wnum1 wnum2 wnum3))
#define ANALYZE_SUPPRESS4(wnum1, wnum2, wnum3, wnum4) __pragma(warning(suppress: wnum1 wnum2 wnum3 wnum4))
// Tag all printf style format strings with this
#define PRINTF_FORMAT_STRING _Printf_format_string_
#define SCANF_FORMAT_STRING _Scanf_format_string_impl_
// Various macros for specifying the capacity of the buffer pointed
// to by a function parameter. Variations include in/out/inout,
// CAP (elements) versus BYTECAP (bytes), and null termination or
// not (_Z).
#define IN_Z _In_z_
#define IN_CAP(x) _In_count_(x)
#define IN_BYTECAP(x) _In_bytecount_(x)
#define OUT_Z_CAP(x) _Out_z_cap_(x)
#define OUT_CAP(x) _Out_cap_(x)
#define OUT_CAP_C(x) _Out_cap_c_(x) // Output buffer with specified *constant* capacity in elements
#define OUT_BYTECAP(x) _Out_bytecap_(x)
#define OUT_Z_BYTECAP(x) _Out_z_bytecap_(x)
#define INOUT_BYTECAP(x) _Inout_bytecap_(x)
#define INOUT_Z_CAP(x) _Inout_z_cap_(x)
#define INOUT_Z_BYTECAP(x) _Inout_z_bytecap_(x)
// These macros are use for annotating array reference parameters, typically used in functions
// such as V_strcpy_safe. Because they are array references the capacity is already known.
#if _MSC_VER >= 1700
#define IN_Z_ARRAY _Pre_z_
#define OUT_Z_ARRAY _Post_z_
#define INOUT_Z_ARRAY _Prepost_z_
#else
#define IN_Z_ARRAY _Deref_pre_z_
#define OUT_Z_ARRAY _Deref_post_z_
#define INOUT_Z_ARRAY _Deref_prepost_z_
#endif // _MSC_VER >= 1700
// Used for annotating functions to describe their return types.
#define MUST_CHECK_RETURN _Check_return_
// Use the macros above to annotate string functions that fill buffers as shown here,
// in order to give VS's /analyze more opportunities to find bugs.
// void V_wcsncpy( OUT_Z_BYTECAP(maxLenInBytes) wchar_t *pDest, wchar_t const *pSrc, int maxLenInBytes );
// int V_snwprintf( OUT_Z_CAP(maxLenInCharacters) wchar_t *pDest, int maxLenInCharacters, PRINTF_FORMAT_STRING const wchar_t *pFormat, ... );
#endif // _PREFAST_
#endif // _MSC_VER >= 1600 // VS 2010 and above.
#ifndef ANALYZE_SUPPRESS
#define ANALYZE_SUPPRESS(wnum)
#define ANALYZE_SUPPRESS2(wnum1, wnum2)
#define ANALYZE_SUPPRESS3(wnum1, wnum2, wnum3)
#define ANALYZE_SUPPRESS4(wnum1, wnum2, wnum3, wnum4)
#define PRINTF_FORMAT_STRING
#define SCANF_FORMAT_STRING
#define IN_Z
#define IN_CAP(x)
#define IN_BYTECAP(x)
#define OUT_Z_CAP(x)
#define OUT_CAP(x)
#define OUT_CAP_C(x)
#define OUT_BYTECAP(x)
#define OUT_Z_BYTECAP(x)
#define INOUT_BYTECAP(x)
#define INOUT_Z_CAP(x)
#define INOUT_Z_BYTECAP(x)
#define OUT_Z_ARRAY
#define INOUT_Z_ARRAY
#define MUST_CHECK_RETURN
#endif
#endif // ANALYSIS_ANNOTATIONS_H