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

Add missing files from last sync.

This commit is contained in:
Nicholas Hastings 2014-10-30 17:22:22 -04:00
parent 5c7d90ed0f
commit 2445f07be4
17 changed files with 1983 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#include "common_ps_fxc.h"
sampler TextureSampler : register( s0 );
struct PS_INPUT
{
float2 baseTexCoord : TEXCOORD0;
};
float4 main( PS_INPUT i ) : COLOR
{
float4 result = tex2D( TextureSampler, i.baseTexCoord );
return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
}

View File

@ -0,0 +1,40 @@
#include "common_vs_fxc.h"
const float4 cLightmapTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
struct VS_INPUT
{
float3 vPos : POSITION;
float2 vBaseTexCoord : TEXCOORD0;
float2 vLightmapTexCoord : TEXCOORD1;
};
struct VS_OUTPUT
{
float4 projPos : POSITION;
float2 baseTexCoord : TEXCOORD0;
};
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o = ( VS_OUTPUT )0;
float4 projPos;
float3 worldPos;
worldPos = mul4x3( float4( v.vPos, 1 ), cModel[0] );
projPos = mul( float4( worldPos, 1 ), cViewProj );
o.projPos = projPos;
o.baseTexCoord.x = dot( v.vLightmapTexCoord, cLightmapTexCoordTransform[0].xy ) + cLightmapTexCoordTransform[0].w;
o.baseTexCoord.y = dot( v.vLightmapTexCoord, cLightmapTexCoordTransform[1].xy ) + cLightmapTexCoordTransform[1].w;
#ifdef _PS3
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
o.projPos.y = -o.projPos.y;
o.projPos.z = 2.0f * o.projPos.z - o.projPos.w;
#endif // _PS3
return o;
}

View File

@ -0,0 +1,87 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Hardware Texels
//
// Contains texture data that was encoded with the map. The initial use case
// is for per-texel lightmaps to allow static props to match the lighting
// of the surrounding BSP geometry.
//
//=============================================================================//
#ifndef HARDWARETEXELS_H
#define HARDWARETEXELS_H
#ifdef _WIN32
#pragma once
#endif
#include "bitmap/imageformat.h"
#include "datamap.h"
// valve hardware texels
#define VHT_VERSION 0
namespace HardwareTexels
{
#pragma pack(1)
// ------------------------------------------------------------------------------------------------
struct MeshHeader_t
{
DECLARE_BYTESWAP_DATADESC();
// this mesh is part of this lod
unsigned int m_nLod;
// starting at this offset
unsigned int m_nOffset;
// this mesh consumes this many bytes
unsigned int m_nBytes;
// with this width and height
unsigned int m_nWidth;
unsigned int m_nHeight;
unsigned int m_nUnused[3];
};
// ------------------------------------------------------------------------------------------------
struct FileHeader_t
{
DECLARE_BYTESWAP_DATADESC();
// file version as defined by VHV_VERSION
int m_nVersion;
// must match checkSum in the .mdl header
unsigned int m_nChecksum;
// all texels are encoded in the same format
// This is a value from ImageFormat.
unsigned int m_nTexelFormat;
// Number of meshes
int m_nMeshes;
inline MeshHeader_t *pMesh( int nMesh ) const
{
Assert(nMesh < m_nMeshes);
return (MeshHeader_t *)(((byte *)this) + sizeof(FileHeader_t)) + nMesh;
};
inline void *pTexelBase( int nMesh ) const
{
return (void *)((byte *)this + pMesh( nMesh )->m_nOffset);
};
unsigned int m_nUnused[4];
};
#pragma pack()
}; // end namespace
#endif // HARDWARETEXELS_H

View File

@ -0,0 +1,63 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose: interface to app data in Steam
//
//=============================================================================
#ifndef ISTEAMAPPLIST_H
#define ISTEAMAPPLIST_H
#ifdef _WIN32
#pragma once
#endif
#include "isteamclient.h"
#include "steamtypes.h"
//-----------------------------------------------------------------------------
// Purpose: This is a restricted interface that can only be used by previously approved apps,
// contact your Steam Account Manager if you believe you need access to this API.
// This interface lets you detect installed apps for the local Steam client, useful for debugging tools
// to offer lists of apps to debug via Steam.
//-----------------------------------------------------------------------------
class ISteamAppList
{
public:
virtual uint32 GetNumInstalledApps() = 0;
virtual uint32 GetInstalledApps( AppId_t *pvecAppID, uint32 unMaxAppIDs ) = 0;
virtual int GetAppName( AppId_t nAppID, char *pchName, int cchNameMax ) = 0; // returns -1 if no name was found
virtual int GetAppInstallDir( AppId_t nAppID, char *pchDirectory, int cchNameMax ) = 0; // returns -1 if no dir was found
virtual int GetAppBuildId( AppId_t nAppID ) = 0; // return the buildid of this app, may change at any time based on backend updates to the game
};
#define STEAMAPPLIST_INTERFACE_VERSION "STEAMAPPLIST_INTERFACE_VERSION001"
// callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL )
#pragma pack( push, 4 )
#elif defined( VALVE_CALLBACK_PACK_LARGE )
#pragma pack( push, 8 )
#else
#error isteamclient.h must be included
#endif
//---------------------------------------------------------------------------------
// Purpose: Sent when a new app is installed
//---------------------------------------------------------------------------------
DEFINE_CALLBACK( SteamAppInstalled_t, k_iSteamAppListCallbacks + 1 );
CALLBACK_MEMBER( 0, AppId_t, m_nAppID ) // ID of the app that installs
END_DEFINE_CALLBACK_1()
//---------------------------------------------------------------------------------
// Purpose: Sent when an app is uninstalled
//---------------------------------------------------------------------------------
DEFINE_CALLBACK( SteamAppUninstalled_t, k_iSteamAppListCallbacks + 2 );
CALLBACK_MEMBER( 0, AppId_t, m_nAppID ) // ID of the app that installs
END_DEFINE_CALLBACK_1()
#pragma pack( pop )
#endif // ISTEAMAPPLIST_H

View File

@ -0,0 +1,476 @@
//====== Copyright 1996-2013, Valve Corporation, All rights reserved. =======
//
// Purpose: interface to display html pages in a texture
//
//=============================================================================
#ifndef ISTEAMHTMLSURFACE_H
#define ISTEAMHTMLSURFACE_H
#ifdef _WIN32
#pragma once
#endif
#include "isteamclient.h"
typedef uint32 HHTMLBrowser;
const uint32 INVALID_HTTMLBROWSER = 0;
//-----------------------------------------------------------------------------
// Purpose: Functions for displaying HTML pages and interacting with them
//-----------------------------------------------------------------------------
class ISteamHTMLSurface
{
public:
virtual ~ISteamHTMLSurface() {}
// Must call init and shutdown when starting/ending use of the interface
virtual bool Init() = 0;
virtual bool Shutdown() = 0;
// Create a browser object for display of a html page, when creation is complete the call handle
// will return a HTML_BrowserReady_t callback for the HHTMLBrowser of your new browser.
// The user agent string is a substring to be added to the general user agent string so you can
// identify your client on web servers.
// The userCSS string lets you apply a CSS style sheet to every displayed page, leave null if
// you do not require this functionality.
virtual SteamAPICall_t CreateBrowser( const char *pchUserAgent, const char *pchUserCSS ) = 0;
// Call this when you are done with a html surface, this lets us free the resources being used by it
virtual void RemoveBrowser( HHTMLBrowser unBrowserHandle ) = 0;
// Navigate to this URL, results in a HTML_StartRequest_t as the request commences
virtual void LoadURL( HHTMLBrowser unBrowserHandle, const char *pchURL, const char *pchPostData ) = 0;
// Tells the surface the size in pixels to display the surface
virtual void SetSize( HHTMLBrowser unBrowserHandle, uint32 unWidth, uint32 unHeight ) = 0;
// Stop the load of the current html page
virtual void StopLoad( HHTMLBrowser unBrowserHandle ) = 0;
// Reload (most likely from local cache) the current page
virtual void Reload( HHTMLBrowser unBrowserHandle ) = 0;
// navigate back in the page history
virtual void GoBack( HHTMLBrowser unBrowserHandle ) = 0;
// navigate forward in the page history
virtual void GoForward( HHTMLBrowser unBrowserHandle ) = 0;
// add this header to any url requests from this browser
virtual void AddHeader( HHTMLBrowser unBrowserHandle, const char *pchKey, const char *pchValue ) = 0;
// run this javascript script in the currently loaded page
virtual void ExecuteJavascript( HHTMLBrowser unBrowserHandle, const char *pchScript ) = 0;
enum EHTMLMouseButton
{
eHTMLMouseButton_Left = 0,
eHTMLMouseButton_Right = 1,
eHTMLMouseButton_Middle = 2,
};
// Mouse click and mouse movement commands
virtual void MouseUp( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0;
virtual void MouseDown( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0;
virtual void MouseDoubleClick( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0;
// x and y are relative to the HTML bounds
virtual void MouseMove( HHTMLBrowser unBrowserHandle, int x, int y ) = 0;
// nDelta is pixels of scroll
virtual void MouseWheel( HHTMLBrowser unBrowserHandle, int32 nDelta ) = 0;
enum EMouseCursor
{
dc_user = 0,
dc_none,
dc_arrow,
dc_ibeam,
dc_hourglass,
dc_waitarrow,
dc_crosshair,
dc_up,
dc_sizenw,
dc_sizese,
dc_sizene,
dc_sizesw,
dc_sizew,
dc_sizee,
dc_sizen,
dc_sizes,
dc_sizewe,
dc_sizens,
dc_sizeall,
dc_no,
dc_hand,
dc_blank, // don't show any custom cursor, just use your default
dc_middle_pan,
dc_north_pan,
dc_north_east_pan,
dc_east_pan,
dc_south_east_pan,
dc_south_pan,
dc_south_west_pan,
dc_west_pan,
dc_north_west_pan,
dc_alias,
dc_cell,
dc_colresize,
dc_copycur,
dc_verticaltext,
dc_rowresize,
dc_zoomin,
dc_zoomout,
dc_help,
dc_custom,
dc_last, // custom cursors start from this value and up
};
enum EHTMLKeyModifiers
{
eHTMLKeyModifier_None = 0,
eHTMLKeyModifier_AltDown = 1 << 0,
eHTMLKeyModifier_CrtlDown = 1 << 1,
eHTMLKeyModifier_ShiftDown = 1 << 2,
};
// keyboard interactions, native keycode is the virtual key code value from your OS
virtual void KeyDown( HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0;
virtual void KeyUp( HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0;
// cUnicodeChar is the unicode character point for this keypress (and potentially multiple chars per press)
virtual void KeyChar( HHTMLBrowser unBrowserHandle, uint32 cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0;
// programmatically scroll this many pixels on the page
virtual void SetHorizontalScroll( HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll ) = 0;
virtual void SetVerticalScroll( HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll ) = 0;
// tell the html control if it has key focus currently, controls showing the I-beam cursor in text controls amongst other things
virtual void SetKeyFocus( HHTMLBrowser unBrowserHandle, bool bHasKeyFocus ) = 0;
// open the current pages html code in the local editor of choice, used for debugging
virtual void ViewSource( HHTMLBrowser unBrowserHandle ) = 0;
// copy the currently selected text on the html page to the local clipboard
virtual void CopyToClipboard( HHTMLBrowser unBrowserHandle ) = 0;
// paste from the local clipboard to the current html page
virtual void PasteFromClipboard( HHTMLBrowser unBrowserHandle ) = 0;
// find this string in the browser, if bCurrentlyInFind is true then instead cycle to the next matching element
virtual void Find( HHTMLBrowser unBrowserHandle, const char *pchSearchStr, bool bCurrentlyInFind, bool bReverse ) = 0;
// cancel a currently running find
virtual void StopFind( HHTMLBrowser unBrowserHandle ) = 0;
// return details about the link at position x,y on the current page
virtual void GetLinkAtPosition( HHTMLBrowser unBrowserHandle, int x, int y ) = 0;
// set a webcookie for the hostname in question
virtual void SetCookie( const char *pchHostname, const char *pchKey, const char *pchValue, const char *pchPath = "/", RTime32 nExpires = 0, bool bSecure = false, bool bHTTPOnly = false ) = 0;
// Zoom the current page by flZoom ( from 0.0 to 4.0, so to zoom to 120% use 1.2 ), zooming around point X,Y in the page (use 0,0 if you don't care)
virtual void SetPageScaleFactor( HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY ) = 0;
// CALLBACKS
//
// These set of functions are used as responses to callback requests
//
// You MUST call this in response to a HTML_StartRequest_t callback
// Set bAllowed to true to allow this navigation, false to cancel it and stay
// on the current page. You can use this feature to limit the valid pages
// allowed in your HTML surface.
virtual void AllowStartRequest( HHTMLBrowser unBrowserHandle, bool bAllowed ) = 0;
// You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback
// Set bResult to true for the OK option of a confirm, use false otherwise
virtual void JSDialogResponse( HHTMLBrowser unBrowserHandle, bool bResult ) = 0;
// You MUST call this in response to a HTML_FileOpenDialog_t callback
virtual void FileLoadDialogResponse( HHTMLBrowser unBrowserHandle, const char **pchSelectedFiles ) = 0;
};
#define STEAMHTMLSURFACE_INTERFACE_VERSION "STEAMHTMLSURFACE_INTERFACE_VERSION_002"
// callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL )
#pragma pack( push, 4 )
#elif defined( VALVE_CALLBACK_PACK_LARGE )
#pragma pack( push, 8 )
#else
#error isteamclient.h must be included
#endif
//-----------------------------------------------------------------------------
// Purpose: The browser is ready for use
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_BrowserReady_t, k_iSteamHTMLSurfaceCallbacks + 1 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // this browser is now fully created and ready to navigate to pages
END_DEFINE_CALLBACK_1()
//-----------------------------------------------------------------------------
// Purpose: the browser has a pending paint
//-----------------------------------------------------------------------------
DEFINE_CALLBACK(HTML_NeedsPaint_t, k_iSteamHTMLSurfaceCallbacks + 2)
CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the browser that needs the paint
CALLBACK_MEMBER(1, const char *, pBGRA ) // a pointer to the B8G8R8A8 data for this surface, valid until SteamAPI_RunCallbacks is next called
CALLBACK_MEMBER(2, uint32, unWide) // the total width of the pBGRA texture
CALLBACK_MEMBER(3, uint32, unTall) // the total height of the pBGRA texture
CALLBACK_MEMBER(4, uint32, unUpdateX) // the offset in X for the damage rect for this update
CALLBACK_MEMBER(5, uint32, unUpdateY) // the offset in Y for the damage rect for this update
CALLBACK_MEMBER(6, uint32, unUpdateWide) // the width of the damage rect for this update
CALLBACK_MEMBER(7, uint32, unUpdateTall) // the height of the damage rect for this update
CALLBACK_MEMBER(8, uint32, unScrollX) // the page scroll the browser was at when this texture was rendered
CALLBACK_MEMBER(9, uint32, unScrollY) // the page scroll the browser was at when this texture was rendered
CALLBACK_MEMBER(10, float, flPageScale) // the page scale factor on this page when rendered
CALLBACK_MEMBER(11, uint32, unPageSerial) // incremented on each new page load, you can use this to reject draws while navigating to new pages
END_DEFINE_CALLBACK_12()
//-----------------------------------------------------------------------------
// Purpose: The browser wanted to navigate to a new page
// NOTE - you MUST call AllowStartRequest in response to this callback
//-----------------------------------------------------------------------------
DEFINE_CALLBACK(HTML_StartRequest_t, k_iSteamHTMLSurfaceCallbacks + 3)
CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface navigating
CALLBACK_MEMBER(1, const char *, pchURL) // the url they wish to navigate to
CALLBACK_MEMBER(2, const char *, pchTarget) // the html link target type (i.e _blank, _self, _parent, _top )
CALLBACK_MEMBER(3, const char *, pchPostData ) // any posted data for the request
CALLBACK_MEMBER(4, bool, bIsRedirect) // true if this was a http/html redirect from the last load request
END_DEFINE_CALLBACK_5()
//-----------------------------------------------------------------------------
// Purpose: The browser has been requested to close due to user interaction (usually from a javascript window.close() call)
//-----------------------------------------------------------------------------
DEFINE_CALLBACK(HTML_CloseBrowser_t, k_iSteamHTMLSurfaceCallbacks + 4)
CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface
END_DEFINE_CALLBACK_1()
//-----------------------------------------------------------------------------
// Purpose: the browser is navigating to a new url
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_URLChanged_t, k_iSteamHTMLSurfaceCallbacks + 5 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface navigating
CALLBACK_MEMBER( 1, const char *, pchURL ) // the url they wish to navigate to
CALLBACK_MEMBER( 2, const char *, pchPostData ) // any posted data for the request
CALLBACK_MEMBER( 3, bool, bIsRedirect ) // true if this was a http/html redirect from the last load request
CALLBACK_MEMBER( 4, const char *, pchPageTitle ) // the title of the page
CALLBACK_MEMBER( 5, bool, bNewNavigation ) // true if this was from a fresh tab and not a click on an existing page
END_DEFINE_CALLBACK_6()
//-----------------------------------------------------------------------------
// Purpose: A page is finished loading
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_FinishedRequest_t, k_iSteamHTMLSurfaceCallbacks + 6 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchURL ) //
CALLBACK_MEMBER( 2, const char *, pchPageTitle ) //
END_DEFINE_CALLBACK_3()
//-----------------------------------------------------------------------------
// Purpose: a request to load this url in a new tab
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_OpenLinkInNewTab_t, k_iSteamHTMLSurfaceCallbacks + 7 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchURL ) //
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: the page has a new title now
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_ChangedTitle_t, k_iSteamHTMLSurfaceCallbacks + 8 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchTitle ) //
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: results from a search
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_SearchResults_t, k_iSteamHTMLSurfaceCallbacks + 9 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, uint32, unResults ) //
CALLBACK_MEMBER( 2, uint32, unCurrentMatch ) //
END_DEFINE_CALLBACK_3()
//-----------------------------------------------------------------------------
// Purpose: page history status changed on the ability to go backwards and forward
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_CanGoBackAndForward_t, k_iSteamHTMLSurfaceCallbacks + 10 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, bool, bCanGoBack ) //
CALLBACK_MEMBER( 2, bool, bCanGoForward ) //
END_DEFINE_CALLBACK_3()
//-----------------------------------------------------------------------------
// Purpose: details on the visibility and size of the horizontal scrollbar
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_HorizontalScroll_t, k_iSteamHTMLSurfaceCallbacks + 11 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, uint32, unScrollMax ) //
CALLBACK_MEMBER( 2, uint32, unScrollCurrent ) //
CALLBACK_MEMBER( 3, float, flPageScale ) //
CALLBACK_MEMBER( 4, bool , bVisible ) //
CALLBACK_MEMBER( 5, uint32, unPageSize ) //
END_DEFINE_CALLBACK_6()
//-----------------------------------------------------------------------------
// Purpose: details on the visibility and size of the vertical scrollbar
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_VerticalScroll_t, k_iSteamHTMLSurfaceCallbacks + 12 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, uint32, unScrollMax ) //
CALLBACK_MEMBER( 2, uint32, unScrollCurrent ) //
CALLBACK_MEMBER( 3, float, flPageScale ) //
CALLBACK_MEMBER( 4, bool, bVisible ) //
CALLBACK_MEMBER( 5, uint32, unPageSize ) //
END_DEFINE_CALLBACK_6()
//-----------------------------------------------------------------------------
// Purpose: response to GetLinkAtPosition call
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_LinkAtPosition_t, k_iSteamHTMLSurfaceCallbacks + 13 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, uint32, x ) //
CALLBACK_MEMBER( 2, uint32, y ) //
CALLBACK_MEMBER( 3, const char *, pchURL ) //
CALLBACK_MEMBER( 4, bool, bInput ) //
CALLBACK_MEMBER( 5, bool, bLiveLink ) //
END_DEFINE_CALLBACK_6()
//-----------------------------------------------------------------------------
// Purpose: show a Javascript alert dialog, call JSDialogResponse
// when the user dismisses this dialog (or right away to ignore it)
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_JSAlert_t, k_iSteamHTMLSurfaceCallbacks + 14 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchMessage ) //
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: show a Javascript confirmation dialog, call JSDialogResponse
// when the user dismisses this dialog (or right away to ignore it)
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_JSConfirm_t, k_iSteamHTMLSurfaceCallbacks + 15 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchMessage ) //
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: show a Javascript confirmation dialog, call JSDialogResponse
// when the user dismisses this dialog (or right away to ignore it)
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_FileOpenDialog_t, k_iSteamHTMLSurfaceCallbacks + 16 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchTitle ) //
CALLBACK_MEMBER( 2, const char *, pchInitialFile ) //
END_DEFINE_CALLBACK_3()
//-----------------------------------------------------------------------------
// Purpose: a popup item (i.e combo box) on the page needs rendering
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_ComboNeedsPaint_t, k_iSteamHTMLSurfaceCallbacks + 17 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pBGRA ) // a pointer to the B8G8R8A8 data for this surface, valid until SteamAPI_RunCallbacks is next called
CALLBACK_MEMBER( 2, uint32, unWide ) // the total width of the pBGRA texture
CALLBACK_MEMBER( 3, uint32, unTall ) // the total height of the pBGRA texture
END_DEFINE_CALLBACK_4()
//-----------------------------------------------------------------------------
// Purpose: a popup (i.e combo box) wants to display
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_ShowPopup_t, k_iSteamHTMLSurfaceCallbacks + 18 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
END_DEFINE_CALLBACK_1()
//-----------------------------------------------------------------------------
// Purpose: a popup (i.e combo box) wants to hide
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_HidePopup_t, k_iSteamHTMLSurfaceCallbacks + 19 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
END_DEFINE_CALLBACK_1()
//-----------------------------------------------------------------------------
// Purpose: a popup (i.e combo box) wants to hide
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_SizePopup_t, k_iSteamHTMLSurfaceCallbacks + 20 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, uint32, unX ) // the x pos into the page to display the popup
CALLBACK_MEMBER( 2, uint32, unY ) // the y pos into the page to display the popup
CALLBACK_MEMBER( 3, uint32, unWide ) // the total width of the pBGRA texture
CALLBACK_MEMBER( 4, uint32, unTall ) // the total height of the pBGRA texture
END_DEFINE_CALLBACK_5()
//-----------------------------------------------------------------------------
// Purpose: a new html window has been created
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_NewWindow_t, k_iSteamHTMLSurfaceCallbacks + 21 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchURL ) // the page to load
CALLBACK_MEMBER( 2, uint32, unX ) // the x pos into the page to display the popup
CALLBACK_MEMBER( 3, uint32, unY ) // the y pos into the page to display the popup
CALLBACK_MEMBER( 4, uint32, unWide ) // the total width of the pBGRA texture
CALLBACK_MEMBER( 5, uint32, unTall ) // the total height of the pBGRA texture
END_DEFINE_CALLBACK_6()
//-----------------------------------------------------------------------------
// Purpose: change the cursor to display
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_SetCursor_t, k_iSteamHTMLSurfaceCallbacks + 22 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, uint32, eMouseCursor ) // the EMouseCursor to display
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: informational message from the browser
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_StatusText_t, k_iSteamHTMLSurfaceCallbacks + 23 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: show a tooltip
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_ShowToolTip_t, k_iSteamHTMLSurfaceCallbacks + 24 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: update the text of an existing tooltip
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_UpdateToolTip_t, k_iSteamHTMLSurfaceCallbacks + 25 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display
END_DEFINE_CALLBACK_2()
//-----------------------------------------------------------------------------
// Purpose: hide the tooltip you are showing
//-----------------------------------------------------------------------------
DEFINE_CALLBACK( HTML_HideToolTip_t, k_iSteamHTMLSurfaceCallbacks + 26 )
CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface
END_DEFINE_CALLBACK_1()
#pragma pack( pop )
#endif // ISTEAMHTMLSURFACE_H

View File

@ -0,0 +1,67 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ============
#ifndef ISTEAMMUSIC_H
#define ISTEAMMUSIC_H
#ifdef _WIN32
#pragma once
#endif
#include "isteamclient.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
enum AudioPlayback_Status
{
AudioPlayback_Undefined = 0,
AudioPlayback_Playing = 1,
AudioPlayback_Paused = 2,
AudioPlayback_Idle = 3
};
//-----------------------------------------------------------------------------
// Purpose: Functions to control music playback in the steam client
//-----------------------------------------------------------------------------
class ISteamMusic
{
public:
virtual bool BIsEnabled() = 0;
virtual bool BIsPlaying() = 0;
virtual AudioPlayback_Status GetPlaybackStatus() = 0;
virtual void Play() = 0;
virtual void Pause() = 0;
virtual void PlayPrevious() = 0;
virtual void PlayNext() = 0;
// volume is between 0.0 and 1.0
virtual void SetVolume( float flVolume ) = 0;
virtual float GetVolume() = 0;
};
#define STEAMMUSIC_INTERFACE_VERSION "STEAMMUSIC_INTERFACE_VERSION001"
// callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL )
#pragma pack( push, 4 )
#elif defined( VALVE_CALLBACK_PACK_LARGE )
#pragma pack( push, 8 )
#else
#error isteamclient.h must be included
#endif
DEFINE_CALLBACK( PlaybackStatusHasChanged_t, k_iSteamMusicCallbacks + 1 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( VolumeHasChanged_t, k_iSteamMusicCallbacks + 2 )
CALLBACK_MEMBER( 0, float, m_flNewVolume )
END_DEFINE_CALLBACK_1()
#pragma pack( pop )
#endif // #define ISTEAMMUSIC_H

View File

@ -0,0 +1,126 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ============
#ifndef ISTEAMMUSICREMOTE_H
#define ISTEAMMUSICREMOTE_H
#ifdef _WIN32
#pragma once
#endif
#include "isteamclient.h"
#include "isteammusic.h"
#define k_SteamMusicNameMaxLength 255
#define k_SteamMusicPNGMaxLength 65535
class ISteamMusicRemote
{
public:
// Service Definition
virtual bool RegisterSteamMusicRemote( const char *pchName ) = 0;
virtual bool DeregisterSteamMusicRemote() = 0;
virtual bool BIsCurrentMusicRemote() = 0;
virtual bool BActivationSuccess( bool bValue ) = 0;
virtual bool SetDisplayName( const char *pchDisplayName ) = 0;
virtual bool SetPNGIcon_64x64( void *pvBuffer, uint32 cbBufferLength ) = 0;
// Abilities for the user interface
virtual bool EnablePlayPrevious(bool bValue) = 0;
virtual bool EnablePlayNext( bool bValue ) = 0;
virtual bool EnableShuffled( bool bValue ) = 0;
virtual bool EnableLooped( bool bValue ) = 0;
virtual bool EnableQueue( bool bValue ) = 0;
virtual bool EnablePlaylists( bool bValue ) = 0;
// Status
virtual bool UpdatePlaybackStatus( AudioPlayback_Status nStatus ) = 0;
virtual bool UpdateShuffled( bool bValue ) = 0;
virtual bool UpdateLooped( bool bValue ) = 0;
virtual bool UpdateVolume( float flValue ) = 0; // volume is between 0.0 and 1.0
// Current Entry
virtual bool CurrentEntryWillChange() = 0;
virtual bool CurrentEntryIsAvailable( bool bAvailable ) = 0;
virtual bool UpdateCurrentEntryText( const char *pchText ) = 0;
virtual bool UpdateCurrentEntryElapsedSeconds( int nValue ) = 0;
virtual bool UpdateCurrentEntryCoverArt( void *pvBuffer, uint32 cbBufferLength ) = 0;
virtual bool CurrentEntryDidChange() = 0;
// Queue
virtual bool QueueWillChange() = 0;
virtual bool ResetQueueEntries() = 0;
virtual bool SetQueueEntry( int nID, int nPosition, const char *pchEntryText ) = 0;
virtual bool SetCurrentQueueEntry( int nID ) = 0;
virtual bool QueueDidChange() = 0;
// Playlist
virtual bool PlaylistWillChange() = 0;
virtual bool ResetPlaylistEntries() = 0;
virtual bool SetPlaylistEntry( int nID, int nPosition, const char *pchEntryText ) = 0;
virtual bool SetCurrentPlaylistEntry( int nID ) = 0;
virtual bool PlaylistDidChange() = 0;
};
#define STEAMMUSICREMOTE_INTERFACE_VERSION "STEAMMUSICREMOTE_INTERFACE_VERSION001"
// callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL )
#pragma pack( push, 4 )
#elif defined( VALVE_CALLBACK_PACK_LARGE )
#pragma pack( push, 8 )
#else
#error isteamclient.h must be included
#endif
DEFINE_CALLBACK( MusicPlayerRemoteWillActivate_t, k_iSteamMusicRemoteCallbacks + 1)
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerRemoteWillDeactivate_t, k_iSteamMusicRemoteCallbacks + 2 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerRemoteToFront_t, k_iSteamMusicRemoteCallbacks + 3 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerWillQuit_t, k_iSteamMusicRemoteCallbacks + 4 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerWantsPlay_t, k_iSteamMusicRemoteCallbacks + 5 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerWantsPause_t, k_iSteamMusicRemoteCallbacks + 6 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerWantsPlayPrevious_t, k_iSteamMusicRemoteCallbacks + 7 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerWantsPlayNext_t, k_iSteamMusicRemoteCallbacks + 8 )
END_DEFINE_CALLBACK_0()
DEFINE_CALLBACK( MusicPlayerWantsShuffled_t, k_iSteamMusicRemoteCallbacks + 9 )
CALLBACK_MEMBER( 0, bool, m_bShuffled )
END_DEFINE_CALLBACK_1()
DEFINE_CALLBACK( MusicPlayerWantsLooped_t, k_iSteamMusicRemoteCallbacks + 10 )
CALLBACK_MEMBER(0, bool, m_bLooped )
END_DEFINE_CALLBACK_1()
DEFINE_CALLBACK( MusicPlayerWantsVolume_t, k_iSteamMusicCallbacks + 11 )
CALLBACK_MEMBER(0, float, m_flNewVolume)
END_DEFINE_CALLBACK_1()
DEFINE_CALLBACK( MusicPlayerSelectsQueueEntry_t, k_iSteamMusicCallbacks + 12 )
CALLBACK_MEMBER(0, int, nID )
END_DEFINE_CALLBACK_1()
DEFINE_CALLBACK( MusicPlayerSelectsPlaylistEntry_t, k_iSteamMusicCallbacks + 13 )
CALLBACK_MEMBER(0, int, nID )
END_DEFINE_CALLBACK_1()
#pragma pack( pop )
#endif // #define ISTEAMMUSICREMOTE_H

270
public/steam/isteamugc.h Normal file
View File

@ -0,0 +1,270 @@
//====== Copyright 1996-2013, Valve Corporation, All rights reserved. =======
//
// Purpose: interface to steam ugc
//
//=============================================================================
#ifndef ISTEAMUGC_H
#define ISTEAMUGC_H
#ifdef _WIN32
#pragma once
#endif
#include "isteamclient.h"
// callbacks
#if defined( VALVE_CALLBACK_PACK_SMALL )
#pragma pack( push, 4 )
#elif defined( VALVE_CALLBACK_PACK_LARGE )
#pragma pack( push, 8 )
#else
#error isteamclient.h must be included
#endif
typedef uint64 UGCQueryHandle_t;
typedef uint64 UGCUpdateHandle_t;
const UGCQueryHandle_t k_UGCQueryHandleInvalid = 0xffffffffffffffffull;
const UGCUpdateHandle_t k_UGCUpdateHandleInvalid = 0xffffffffffffffffull;
// Matching UGC types for queries
enum EUGCMatchingUGCType
{
k_EUGCMatchingUGCType_Items = 0, // both mtx items and ready-to-use items
k_EUGCMatchingUGCType_Items_Mtx = 1,
k_EUGCMatchingUGCType_Items_ReadyToUse = 2,
k_EUGCMatchingUGCType_Collections = 3,
k_EUGCMatchingUGCType_Artwork = 4,
k_EUGCMatchingUGCType_Videos = 5,
k_EUGCMatchingUGCType_Screenshots = 6,
k_EUGCMatchingUGCType_AllGuides = 7, // both web guides and integrated guides
k_EUGCMatchingUGCType_WebGuides = 8,
k_EUGCMatchingUGCType_IntegratedGuides = 9,
k_EUGCMatchingUGCType_UsableInGame = 10, // ready-to-use items and integrated guides
k_EUGCMatchingUGCType_ControllerBindings = 11,
};
// Different lists of published UGC for a user.
// If the current logged in user is different than the specified user, then some options may not be allowed.
enum EUserUGCList
{
k_EUserUGCList_Published,
k_EUserUGCList_VotedOn,
k_EUserUGCList_VotedUp,
k_EUserUGCList_VotedDown,
k_EUserUGCList_WillVoteLater,
k_EUserUGCList_Favorited,
k_EUserUGCList_Subscribed,
k_EUserUGCList_UsedOrPlayed,
k_EUserUGCList_Followed,
};
// Sort order for user published UGC lists (defaults to creation order descending)
enum EUserUGCListSortOrder
{
k_EUserUGCListSortOrder_CreationOrderDesc,
k_EUserUGCListSortOrder_CreationOrderAsc,
k_EUserUGCListSortOrder_TitleAsc,
k_EUserUGCListSortOrder_LastUpdatedDesc,
k_EUserUGCListSortOrder_SubscriptionDateDesc,
k_EUserUGCListSortOrder_VoteScoreDesc,
k_EUserUGCListSortOrder_ForModeration,
};
// Combination of sorting and filtering for queries across all UGC
enum EUGCQuery
{
k_EUGCQuery_RankedByVote = 0,
k_EUGCQuery_RankedByPublicationDate = 1,
k_EUGCQuery_AcceptedForGameRankedByAcceptanceDate = 2,
k_EUGCQuery_RankedByTrend = 3,
k_EUGCQuery_FavoritedByFriendsRankedByPublicationDate = 4,
k_EUGCQuery_CreatedByFriendsRankedByPublicationDate = 5,
k_EUGCQuery_RankedByNumTimesReported = 6,
k_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate = 7,
k_EUGCQuery_NotYetRated = 8,
k_EUGCQuery_RankedByTotalVotesAsc = 9,
k_EUGCQuery_RankedByVotesUp = 10,
k_EUGCQuery_RankedByTextSearch = 11,
};
enum EItemUpdateStatus
{
k_EItemUpdateStatusInvalid = 0, // The item update handle was invalid, job might be finished, listen too SubmitItemUpdateResult_t
k_EItemUpdateStatusPreparingConfig = 1, // The item update is processing configuration data
k_EItemUpdateStatusPreparingContent = 2, // The item update is reading and processing content files
k_EItemUpdateStatusUploadingContent = 3, // The item update is uploading content changes to Steam
k_EItemUpdateStatusUploadingPreviewFile = 4, // The item update is uploading new preview file image
k_EItemUpdateStatusCommittingChanges = 5 // The item update is committing all changes
};
const uint32 kNumUGCResultsPerPage = 50;
// Details for a single published file/UGC
struct SteamUGCDetails_t
{
PublishedFileId_t m_nPublishedFileId;
EResult m_eResult; // The result of the operation.
EWorkshopFileType m_eFileType; // Type of the file
AppId_t m_nCreatorAppID; // ID of the app that created this file.
AppId_t m_nConsumerAppID; // ID of the app that will consume this file.
char m_rgchTitle[k_cchPublishedDocumentTitleMax]; // title of document
char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; // description of document
uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content.
uint32 m_rtimeCreated; // time when the published file was created
uint32 m_rtimeUpdated; // time when the published file was last updated
uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable)
ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility
bool m_bBanned; // whether the file was banned
bool m_bAcceptedForUse; // developer has specifically flagged this item as accepted in the Workshop
bool m_bTagsTruncated; // whether the list of tags was too long to be returned in the provided buffer
char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file
// file/url information
UGCHandle_t m_hFile; // The handle of the primary file
UGCHandle_t m_hPreviewFile; // The handle of the preview file
char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file
int32 m_nFileSize; // Size of the primary file
int32 m_nPreviewFileSize; // Size of the preview file
char m_rgchURL[k_cchPublishedFileURLMax]; // URL (for a video or a website)
// voting information
uint32 m_unVotesUp; // number of votes up
uint32 m_unVotesDown; // number of votes down
float m_flScore; // calculated score
uint32 m_unNumChildren; // if m_eFileType == k_EWorkshopFileTypeCollection, then this number will be the number of children contained within the collection
};
//-----------------------------------------------------------------------------
// Purpose: Steam UGC support API
//-----------------------------------------------------------------------------
class ISteamUGC
{
public:
// Query UGC associated with a user. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1.
virtual UGCQueryHandle_t CreateQueryUserUGCRequest( AccountID_t unAccountID, EUserUGCList eListType, EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage ) = 0;
// Query for all matching UGC. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1.
virtual UGCQueryHandle_t CreateQueryAllUGCRequest( EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage ) = 0;
// Send the query to Steam
virtual SteamAPICall_t SendQueryUGCRequest( UGCQueryHandle_t handle ) = 0;
// Retrieve an individual result after receiving the callback for querying UGC
virtual bool GetQueryUGCResult( UGCQueryHandle_t handle, uint32 index, SteamUGCDetails_t *pDetails ) = 0;
// Release the request to free up memory, after retrieving results
virtual bool ReleaseQueryUGCRequest( UGCQueryHandle_t handle ) = 0;
// Options to set for querying UGC
virtual bool AddRequiredTag( UGCQueryHandle_t handle, const char *pTagName ) = 0;
virtual bool AddExcludedTag( UGCQueryHandle_t handle, const char *pTagName ) = 0;
virtual bool SetReturnLongDescription( UGCQueryHandle_t handle, bool bReturnLongDescription ) = 0;
virtual bool SetReturnTotalOnly( UGCQueryHandle_t handle, bool bReturnTotalOnly ) = 0;
virtual bool SetAllowCachedResponse( UGCQueryHandle_t handle, uint32 unMaxAgeSeconds ) = 0;
// Options only for querying user UGC
virtual bool SetCloudFileNameFilter( UGCQueryHandle_t handle, const char *pMatchCloudFileName ) = 0;
// Options only for querying all UGC
virtual bool SetMatchAnyTag( UGCQueryHandle_t handle, bool bMatchAnyTag ) = 0;
virtual bool SetSearchText( UGCQueryHandle_t handle, const char *pSearchText ) = 0;
virtual bool SetRankedByTrendDays( UGCQueryHandle_t handle, uint32 unDays ) = 0;
// Request full details for one piece of UGC
virtual SteamAPICall_t RequestUGCDetails( PublishedFileId_t nPublishedFileID, uint32 unMaxAgeSeconds ) = 0;
// Steam Workshop Creator API
virtual SteamAPICall_t CreateItem( AppId_t nConsumerAppId, EWorkshopFileType eFileType ) = 0; // create new item for this app with no content attached yet
virtual UGCUpdateHandle_t StartItemUpdate( AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID ) = 0; // start an UGC item update. Set changed properties before commiting update with CommitItemUpdate()
virtual bool SetItemTitle( UGCUpdateHandle_t handle, const char *pchTitle ) = 0; // change the title of an UGC item
virtual bool SetItemDescription( UGCUpdateHandle_t handle, const char *pchDescription ) = 0; // change the description of an UGC item
virtual bool SetItemVisibility( UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility ) = 0; // change the visibility of an UGC item
virtual bool SetItemTags( UGCUpdateHandle_t updateHandle, const SteamParamStringArray_t *pTags ) = 0; // change the tags of an UGC item
virtual bool SetItemContent( UGCUpdateHandle_t handle, const char *pszContentFolder ) = 0; // update item content from this local folder
virtual bool SetItemPreview( UGCUpdateHandle_t handle, const char *pszPreviewFile ) = 0; // change preview image file for this item. pszPreviewFile points to local image file
virtual SteamAPICall_t SubmitItemUpdate( UGCUpdateHandle_t handle, const char *pchChangeNote ) = 0; // commit update process started with StartItemUpdate()
virtual EItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, uint64 *punBytesProcessed, uint64* punBytesTotal ) = 0;
// Steam Workshop Consumer API
virtual SteamAPICall_t SubscribeItem( PublishedFileId_t nPublishedFileID ) = 0; // subscript to this item, will be installed ASAP
virtual SteamAPICall_t UnsubscribeItem( PublishedFileId_t nPublishedFileID ) = 0; // unsubscribe from this item, will be uninstalled after game quits
virtual uint32 GetNumSubscribedItems() = 0; // number of subscribed items
virtual uint32 GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries ) = 0; // all subscribed item PublishFileIDs
// Get info about the item on disk. If you are supporting items published through the legacy RemoteStorage APIs then *pbLegacyItem will be set to true
// and pchFolder will contain the full path to the file rather than the containing folder.
virtual bool GetItemInstallInfo( PublishedFileId_t nPublishedFileID, uint64 *punSizeOnDisk, char *pchFolder, uint32 cchFolderSize, bool *pbLegacyItem ) = 0; // returns true if item is installed
virtual bool GetItemUpdateInfo( PublishedFileId_t nPublishedFileID, bool *pbNeedsUpdate, bool *pbIsDownloading, uint64 *punBytesDownloaded, uint64 *punBytesTotal ) = 0;
};
#define STEAMUGC_INTERFACE_VERSION "STEAMUGC_INTERFACE_VERSION003"
//-----------------------------------------------------------------------------
// Purpose: Callback for querying UGC
//-----------------------------------------------------------------------------
struct SteamUGCQueryCompleted_t
{
enum { k_iCallback = k_iClientUGCCallbacks + 1 };
UGCQueryHandle_t m_handle;
EResult m_eResult;
uint32 m_unNumResultsReturned;
uint32 m_unTotalMatchingResults;
bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache
};
//-----------------------------------------------------------------------------
// Purpose: Callback for requesting details on one piece of UGC
//-----------------------------------------------------------------------------
struct SteamUGCRequestUGCDetailsResult_t
{
enum { k_iCallback = k_iClientUGCCallbacks + 2 };
SteamUGCDetails_t m_details;
bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache
};
//-----------------------------------------------------------------------------
// Purpose: result for ISteamUGC::CreateItem()
//-----------------------------------------------------------------------------
struct CreateItemResult_t
{
enum { k_iCallback = k_iClientUGCCallbacks + 3 };
EResult m_eResult;
PublishedFileId_t m_nPublishedFileId; // new item got this UGC PublishFileID
bool m_bUserNeedsToAcceptWorkshopLegalAgreement;
};
//-----------------------------------------------------------------------------
// Purpose: result for ISteamUGC::SubmitItemUpdate()
//-----------------------------------------------------------------------------
struct SubmitItemUpdateResult_t
{
enum { k_iCallback = k_iClientUGCCallbacks + 4 };
EResult m_eResult;
bool m_bUserNeedsToAcceptWorkshopLegalAgreement;
};
//-----------------------------------------------------------------------------
// Purpose: a new Workshop item has been installed
//-----------------------------------------------------------------------------
struct ItemInstalled_t
{
enum { k_iCallback = k_iClientUGCCallbacks + 5 };
AppId_t m_unAppID;
PublishedFileId_t m_nPublishedFileId;
};
#pragma pack( pop )
#endif // ISTEAMUGC_H

View File

@ -0,0 +1,79 @@
//========= Copyright © 1996-2013, Valve LLC, All rights reserved. ============
//
// Purpose: Controller related public types/constants
//
//=============================================================================
#ifndef STEAMCONTROLLERPUBLIC_H
#define STEAMCONTROLLERPUBLIC_H
#ifdef _WIN32
#pragma once
#endif
#if defined( STEAM ) || defined( ISTEAMCONTROLLER_H )
// This file should only be included by the Steam build or directly from
// isteamcontroller.h.
#include "steamtypes.h"
#else
#include <stdint.h>
typedef uint32_t uint32;
#ifdef __C51__
typedef uint8_t uint64[8];
#else
typedef uint64_t uint64;
#endif
#endif
#pragma pack(1)
// Safe to add new bitfields at the end of this list for new buttons/actions,
// but never re-use or re-number an existing flag as old client code will be
// confused.
#define STEAM_RIGHT_TRIGGER_MASK 0x0000000000000001l
#define STEAM_LEFT_TRIGGER_MASK 0x0000000000000002l
#define STEAM_RIGHT_BUMPER_MASK 0x0000000000000004l
#define STEAM_LEFT_BUMPER_MASK 0x0000000000000008l
#define STEAM_BUTTON_0_MASK 0x0000000000000010l
#define STEAM_BUTTON_1_MASK 0x0000000000000020l
#define STEAM_BUTTON_2_MASK 0x0000000000000040l
#define STEAM_BUTTON_3_MASK 0x0000000000000080l
#define STEAM_TOUCH_0_MASK 0x0000000000000100l
#define STEAM_TOUCH_1_MASK 0x0000000000000200l
#define STEAM_TOUCH_2_MASK 0x0000000000000400l
#define STEAM_TOUCH_3_MASK 0x0000000000000800l
#define STEAM_BUTTON_MENU_MASK 0x0000000000001000l
#define STEAM_BUTTON_STEAM_MASK 0x0000000000002000l
#define STEAM_BUTTON_ESCAPE_MASK 0x0000000000004000l
#define STEAM_BUTTON_BACK_LEFT_MASK 0x0000000000008000l
#define STEAM_BUTTON_BACK_RIGHT_MASK 0x0000000000010000l
#define STEAM_BUTTON_LEFTPAD_CLICKED_MASK 0x0000000000020000l
#define STEAM_BUTTON_RIGHTPAD_CLICKED_MASK 0x0000000000040000l
#define STEAM_LEFTPAD_FINGERDOWN_MASK 0x0000000000080000l
#define STEAM_RIGHTPAD_FINGERDOWN_MASK 0x0000000000100000l
// Only add fields to the end of this struct, or if you need to change it in a larger
// way add a new message id and new struct completely so as to not break old clients.
typedef struct
{
// If packet num matches that on your prior call, then the controller state hasn't been changed since
// your last call and there is no need to process it
uint32 unPacketNum;
// bit flags for each of the buttons
uint64 ulButtons;
// Left pad coordinates
short sLeftPadX;
short sLeftPadY;
// Right pad coordinates
short sRightPadX;
short sRightPadY;
} SteamControllerState_t;
#pragma pack()
#endif // STEAMCONTROLLERPUBLIC_H

View File

@ -0,0 +1,27 @@
//========= Copyright <20> 1996-2008, Valve LLC, All rights reserved. ============
//
// Purpose:
//
//=============================================================================
#ifndef STEAMUNIVERSE_H
#define STEAMUNIVERSE_H
#ifdef _WIN32
#pragma once
#endif
// Steam universes. Each universe is a self-contained Steam instance.
enum EUniverse
{
k_EUniverseInvalid = 0,
k_EUniversePublic = 1,
k_EUniverseBeta = 2,
k_EUniverseInternal = 3,
k_EUniverseDev = 4,
// k_EUniverseRC = 5, // no such universe anymore
k_EUniverseMax
};
#endif // STEAMUNIVERSE_H

261
public/steam/steamvr.h Normal file
View File

@ -0,0 +1,261 @@
#pragma once
#include <stdint.h>
namespace vr
{
#if defined(__linux__) || defined(__APPLE__)
// The 32-bit version of gcc has the alignment requirement for uint64 and double set to
// 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
// The 64-bit version of gcc has the alignment requirement for these types set to
// 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
// The 64-bit structure packing has to match the 32-bit structure packing for each platform.
#pragma pack( push, 4 )
#else
#pragma pack( push, 8 )
#endif
// right-handed system
// +y is up
// +x is to the right
// -z is going away from you
// Distance unit is meters
struct HmdMatrix34_t
{
float m[3][4];
};
struct HmdMatrix44_t
{
float m[4][4];
};
/** Used to return the post-distortion UVs for each color channel.
* UVs range from 0 to 1 with 0,0 in the upper left corner of the
* source render target. The 0,0 to 1,1 range covers a single eye. */
struct DistortionCoordinates_t
{
float rfRed[2];
float rfGreen[2];
float rfBlue[2];
};
enum Hmd_Eye
{
Eye_Left = 0,
Eye_Right = 1
};
enum GraphicsAPIConvention
{
API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane
API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane
};
enum HmdTrackingResult
{
TrackingResult_Uninitialized = 1,
TrackingResult_Calibrating_InProgress = 100,
TrackingResult_Calibrating_OutOfRange = 101,
TrackingResult_Running_OK = 200,
TrackingResult_Running_OutOfRange = 201,
};
class IHmd
{
public:
// ------------------------------------
// Display Methods
// ------------------------------------
/** Size and position that the window needs to be on the VR display. */
virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
/** Suggested size for the intermediate render target that the distortion pulls from. */
virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
/** Gets the viewport in the frame buffer to draw the output of the distortion into */
virtual void GetEyeOutputViewport( Hmd_Eye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
/** The projection matrix for the specified eye */
virtual HmdMatrix44_t GetProjectionMatrix( Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType ) = 0;
/** The components necessary to build your own projection matrix in case your
* application is doing something fancy like infinite Z */
virtual void GetProjectionRaw( Hmd_Eye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
/** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
* the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
virtual DistortionCoordinates_t ComputeDistortion( Hmd_Eye eEye, float fU, float fV ) = 0;
/** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head
* space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection.
* Normally View and Eye^-1 will be multiplied together and treated as View in your application.
*/
virtual HmdMatrix34_t GetHeadFromEyePose( Hmd_Eye eEye ) = 0;
/** For use in simple VR apps, this method returns the concatenation of the
* tracking pose and the eye matrix to get a full view matrix for each eye.
* This is ( GetEyeMatrix() ) * (GetWorldFromHeadPose() ^ -1 ) */
virtual bool GetViewMatrix( float fSecondsFromNow, HmdMatrix44_t *pMatLeftView, HmdMatrix44_t *pMatRightView, HmdTrackingResult *peResult ) = 0;
/** [D3D9 Only]
* Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such
* a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error.
*/
virtual int32_t GetD3D9AdapterIndex() = 0;
/** [D3D10/11 Only]
* Returns the adapter index and output index that the user should pass into EnumAdapters adn EnumOutputs
* to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1.
*/
virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex, int32_t *pnAdapterOutputIndex ) = 0;
/** [Windows Only]
* Notifies the system that the VR output will appear in a particular window.
*/
virtual void AttachToWindow( void *hWnd ) = 0;
// ------------------------------------
// Tracking Methods
// ------------------------------------
/** The pose that the tracker thinks that the HMD will be in at the specified
* number of seconds into the future. Pass 0 to get the current state.
*
* This is roughly analogous to the inverse of the view matrix in most applications, though
* many games will need to do some additional rotation or translation on top of the rotation
* and translation provided by the head pose.
*
* If this function returns true the pose has been populated with a pose that can be used by the application.
* Check peResult for details about the pose, including messages that should be displayed to the user.
*/
virtual bool GetTrackerFromHeadPose( float fPredictedSecondsFromNow, HmdMatrix34_t *pmPose, HmdTrackingResult *peResult ) = 0;
/** Passes back the pose matrix from the last successful call to GetWorldFromHeadPose(). Returns true if that matrix is
* valid (because there has been a previous successful pose.) */
virtual bool GetLastTrackerFromHeadPose( HmdMatrix34_t *pmPose ) = 0;
/** Returns true if the tracker for this HMD will drift the Yaw component of its pose over time regardless of
* actual head motion. This is true for gyro-based trackers with no ground truth. */
virtual bool WillDriftInYaw() = 0;
/** Sets the zero pose for the tracker coordinate system. After this call all WorldFromHead poses will be relative
* to the pose whenever this was called. The new zero coordinate system will not change the fact that the Y axis is
* up in the real world, so the next pose returned from GetWorldFromHeadPose after a call to ZeroTracker may not be
* exactly an identity matrix. */
virtual void ZeroTracker() = 0;
/** Returns the zero pose for the tracker coordinate system. If the tracker has never had a valid pose, this
* will be an identity matrix. */
virtual HmdMatrix34_t GetTrackerZeroPose() = 0;
// ------------------------------------
// Administrative methods
// ------------------------------------
/** The ID of the driver this HMD uses as a UTF-8 string. Returns the length of the ID in bytes. If
* the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes
* will be enough to fit any ID. */
virtual uint32_t GetDriverId( char *pchBuffer, uint32_t unBufferLen ) = 0;
/** The ID of this display within its driver this HMD uses as a UTF-8 string. Returns the length of the ID in bytes. If
* the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes
* will be enough to fit any ID. */
virtual uint32_t GetDisplayId( char *pchBuffer, uint32_t unBufferLen ) = 0;
};
static const char * const IHmd_Version = "IHmd_005";
/** error codes returned by Vr_Init */
enum HmdError
{
HmdError_None = 0,
HmdError_Init_InstallationNotFound = 100,
HmdError_Init_InstallationCorrupt = 101,
HmdError_Init_VRClientDLLNotFound = 102,
HmdError_Init_FileNotFound = 103,
HmdError_Init_FactoryNotFound = 104,
HmdError_Init_InterfaceNotFound = 105,
HmdError_Init_InvalidInterface = 106,
HmdError_Init_UserConfigDirectoryInvalid = 107,
HmdError_Init_HmdNotFound = 108,
HmdError_Init_NotInitialized = 109,
HmdError_Driver_Failed = 200,
HmdError_Driver_Unknown = 201,
HmdError_Driver_HmdUnknown = 202,
HmdError_Driver_NotLoaded = 203,
HmdError_IPC_ServerInitFailed = 300,
HmdError_IPC_ConnectFailed = 301,
HmdError_IPC_SharedStateInitFailed = 302,
HmdError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
};
// figure out how to import from the VR API dll
#if defined(_WIN32)
#ifdef VR_API_EXPORT
#define VR_INTERFACE extern "C" __declspec( dllexport )
#else
#define VR_INTERFACE extern "C" __declspec( dllimport )
#endif
#elif defined(GNUC) || defined(COMPILER_GCC)
#ifdef VR_API_EXPORT
#define VR_INTERFACE extern "C" __attribute__((visibility("default")))
#else
#define VR_INTERFACE extern "C"
#endif
#else
#error "Unsupported Platform."
#endif
/** Finds the active installation of the VR API and initializes it. The priority for figuring
* out where to load vrclient from are:
* 1. The convar "VR_OVERRIDE", which should contain an absolute path to the root of
* an vr API directory.
* 2. The pchVROverride argument. This should be an absolute path or a path relative to
* the current executable.
* 3. The path "./vr" relative to the current executable's path.
*
* Each of these paths are to the "root" of the VR API install. That's the directory with
* the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself.
*/
VR_INTERFACE IHmd *VR_Init( HmdError *peError );
/** unloads vrclient.dll. Any interface pointers from the interface are
* invalid after this point */
VR_INTERFACE void VR_Shutdown( );
/** Returns true if there is an HMD attached. This check is as lightweight as possible and
* can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants
* to know if initializing VR is a possibility but isn't ready to take that step yet.
*/
VR_INTERFACE bool VR_IsHmdPresent();
/** Returns the string version of an HMD error. This function may be called outside of VR_Init()/VR_Shutdown(). */
VR_INTERFACE const char *VR_GetStringForHmdError( HmdError error );
#pragma pack( pop )
}

View File

@ -0,0 +1,33 @@
#ifndef CPU_MONITORING_H
#define CPU_MONITORING_H
/*
This header defines functions and structures for controlling the measurement of CPU frequency
in order to detect thermal throttling. For details see the associated source file.
*/
struct CPUFrequencyResults
{
double m_timeStamp; // Time (from Plat_FloatTime) when the measurements were made.
float m_GHz;
float m_percentage;
float m_lowestPercentage;
};
// Call this to get results.
// When CPU monitoring is 'disabled' it may still be running at a low frequency,
// for OGS purposes or for proactively warning users of problems. If fGetDisabledResults
// is true then results will be returned when disabled (if available).
PLATFORM_INTERFACE CPUFrequencyResults GetCPUFrequencyResults( bool fGetDisabledResults = false );
// Call this to set the monitoring frequency. Intervals of 2-5 seconds (2,000 to 5,000 ms)
// are recommended. An interval of zero will disable CPU monitoring. Short delays (below
// about 300 ms) will be rounded up.
PLATFORM_INTERFACE void SetCPUMonitoringInterval( unsigned nDelayMilliseconds );
// Warn with increasing strident colors when CPU percentages go below these levels.
// They are const int instead of float because const float in C++ is stupid.
const int kCPUMonitoringWarning1 = 80;
const int kCPUMonitoringWarning2 = 50;
#endif

View File

@ -0,0 +1,98 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: sesse@google.com (Steinar H. Gunderson)
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Various type stubs for the open-source version of Snappy.
//
// This file cannot include config.h, as it is included from snappy.h,
// which is a public header. Instead, snappy-stubs-public.h is generated by
// from snappy-stubs-public.h.in at configure time.
#ifndef UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#define UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
#if 1
#include <stdint.h>
#endif
#if 1
#include <stddef.h>
#endif
#if 0
#include <sys/uio.h>
#endif
#define SNAPPY_MAJOR 1
#define SNAPPY_MINOR 1
#define SNAPPY_PATCHLEVEL 2
#define SNAPPY_VERSION \
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
#include <string>
namespace snappy {
#if 1
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#else
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
#endif
typedef std::string string;
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
#if !0
// Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec {
void* iov_base;
size_t iov_len;
};
#endif
} // namespace snappy
#endif // UTIL_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_

View File

@ -0,0 +1,107 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef UTLBINARYBLOCK_H
#define UTLBINARYBLOCK_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlmemory.h"
#include "tier1/strtools.h"
#include "limits.h"
//-----------------------------------------------------------------------------
// Base class, containing simple memory management
//-----------------------------------------------------------------------------
class CUtlBinaryBlock
{
public:
CUtlBinaryBlock( int growSize = 0, int initSize = 0 );
// NOTE: nInitialLength indicates how much of the buffer starts full
CUtlBinaryBlock( void* pMemory, int nSizeInBytes, int nInitialLength );
CUtlBinaryBlock( const void* pMemory, int nSizeInBytes );
CUtlBinaryBlock( const CUtlBinaryBlock& src );
void Get( void *pValue, int nMaxLen ) const;
void Set( const void *pValue, int nLen );
const void *Get( ) const;
void *Get( );
unsigned char& operator[]( int i );
const unsigned char& operator[]( int i ) const;
int Length() const;
void SetLength( int nLength ); // Undefined memory will result
bool IsEmpty() const;
void Clear();
void Purge();
bool IsReadOnly() const;
CUtlBinaryBlock &operator=( const CUtlBinaryBlock &src );
// Test for equality
bool operator==( const CUtlBinaryBlock &src ) const;
private:
CUtlMemory<unsigned char> m_Memory;
int m_nActualLength;
};
//-----------------------------------------------------------------------------
// class inlines
//-----------------------------------------------------------------------------
inline const void *CUtlBinaryBlock::Get( ) const
{
return m_Memory.Base();
}
inline void *CUtlBinaryBlock::Get( )
{
return m_Memory.Base();
}
inline int CUtlBinaryBlock::Length() const
{
return m_nActualLength;
}
inline unsigned char& CUtlBinaryBlock::operator[]( int i )
{
return m_Memory[i];
}
inline const unsigned char& CUtlBinaryBlock::operator[]( int i ) const
{
return m_Memory[i];
}
inline bool CUtlBinaryBlock::IsReadOnly() const
{
return m_Memory.IsReadOnly();
}
inline bool CUtlBinaryBlock::IsEmpty() const
{
return Length() == 0;
}
inline void CUtlBinaryBlock::Clear()
{
SetLength( 0 );
}
inline void CUtlBinaryBlock::Purge()
{
SetLength( 0 );
m_Memory.Purge();
}
#endif // UTLBINARYBLOCK_H

52
public/tier1/utlpair.h Normal file
View File

@ -0,0 +1,52 @@
//========= Copyright, Valve Corporation, All rights reserved. ================//
//
// std::pair style container; exists to work easily in our CUtlMap/CUtlHashMap classes
//
//=============================================================================//
#ifndef UTLPAIR_H
#define UTLPAIR_H
#ifdef _WIN32
#pragma once
#endif
// std::pair style container; exists to work easily in our CUtlMap/CUtlHashMap classes
template<typename T1, typename T2>
class CUtlPair
{
public:
CUtlPair() {}
CUtlPair( T1 t1, T2 t2 ) : first( t1 ), second( t2 ) {}
bool operator<( const CUtlPair<T1,T2> &rhs ) const {
if ( first != rhs.first )
return first < rhs.first;
return second < rhs.second;
}
bool operator==( const CUtlPair<T1,T2> &rhs ) const {
return first == rhs.first && second == rhs.second;
}
T1 first;
T2 second;
};
// utility to make a CUtlPair without having to specify template parameters
template<typename T1, typename T2>
inline CUtlPair<T1,T2> MakeUtlPair( T1 t1, T2 t2 )
{
return CUtlPair<T1,T2>(t1, t2);
}
//// HashItem() overload that works automatically with our hash containers
//template<typename T1, typename T2>
//inline uint32 HashItem( const CUtlPair<T1,T2> &item )
//{
// return HashItem( (uint64)HashItem( item.first ) + ((uint64)HashItem( item.second ) << 32) );
//}
#endif // UTLPAIR_H

116
tier1/utlbinaryblock.cpp Normal file
View File

@ -0,0 +1,116 @@
//====== Copyright 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#include "tier1/utlbinaryblock.h"
//-----------------------------------------------------------------------------
// Base class, containing simple memory management
//-----------------------------------------------------------------------------
CUtlBinaryBlock::CUtlBinaryBlock( int growSize, int initSize ) : m_Memory( growSize, initSize )
{
m_nActualLength = 0;
}
CUtlBinaryBlock::CUtlBinaryBlock( void* pMemory, int nSizeInBytes, int nInitialLength ) : m_Memory( (unsigned char*)pMemory, nSizeInBytes )
{
m_nActualLength = nInitialLength;
}
CUtlBinaryBlock::CUtlBinaryBlock( const void* pMemory, int nSizeInBytes ) : m_Memory( (const unsigned char*)pMemory, nSizeInBytes )
{
m_nActualLength = nSizeInBytes;
}
CUtlBinaryBlock::CUtlBinaryBlock( const CUtlBinaryBlock& src )
{
Set( src.Get(), src.Length() );
}
void CUtlBinaryBlock::Get( void *pValue, int nLen ) const
{
Assert( nLen > 0 );
if ( m_nActualLength < nLen )
{
nLen = m_nActualLength;
}
if ( nLen > 0 )
{
memcpy( pValue, m_Memory.Base(), nLen );
}
}
void CUtlBinaryBlock::SetLength( int nLength )
{
Assert( !m_Memory.IsReadOnly() );
m_nActualLength = nLength;
if ( nLength > m_Memory.NumAllocated() )
{
int nOverFlow = nLength - m_Memory.NumAllocated();
m_Memory.Grow( nOverFlow );
// If the reallocation failed, clamp length
if ( nLength > m_Memory.NumAllocated() )
{
m_nActualLength = m_Memory.NumAllocated();
}
}
#ifdef _DEBUG
if ( m_Memory.NumAllocated() > m_nActualLength )
{
memset( ( ( char * )m_Memory.Base() ) + m_nActualLength, 0xEB, m_Memory.NumAllocated() - m_nActualLength );
}
#endif
}
void CUtlBinaryBlock::Set( const void *pValue, int nLen )
{
Assert( !m_Memory.IsReadOnly() );
if ( !pValue )
{
nLen = 0;
}
SetLength( nLen );
if ( m_nActualLength )
{
if ( ( ( const char * )m_Memory.Base() ) >= ( ( const char * )pValue ) + nLen ||
( ( const char * )m_Memory.Base() ) + m_nActualLength <= ( ( const char * )pValue ) )
{
memcpy( m_Memory.Base(), pValue, m_nActualLength );
}
else
{
memmove( m_Memory.Base(), pValue, m_nActualLength );
}
}
}
CUtlBinaryBlock &CUtlBinaryBlock::operator=( const CUtlBinaryBlock &src )
{
Assert( !m_Memory.IsReadOnly() );
Set( src.Get(), src.Length() );
return *this;
}
bool CUtlBinaryBlock::operator==( const CUtlBinaryBlock &src ) const
{
if ( src.Length() != Length() )
return false;
return !memcmp( src.Get(), Get(), Length() );
}

View File

@ -0,0 +1,66 @@
// /analyze specific settings. Placed here so that they can be changed without triggering rebuilds of the entire world.
$Configuration
{
$Compiler
{
// When using /analyze (triggered with /define:ANALYZE on the vpc command line) we want to forcibly disable lots
// of warnings.
// warning C6308: 'realloc' might return null pointer, cause the original memory block to be leaked
// warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
// warning C6387: 'argument 1' might be '0': this does not adhere to the specification for the function 'GetProcAddress'
// warning C6309: Argument '1' is null: this does not adhere to function specification of 'GetProcAddress'
// warning C6011: Dereferencing NULL pointer 'm_ppTestCases'
// warning C6211: Leaking memory 'newKeyValue' due to an exception. Consider using a local catch block to clean up memory
// These warnings are because /analyze doesn't like our use of constants, especially things like IsPC()
// warning C6326: Potential comparison of a constant with another constant
// warning C6239: (<non-zero constant> && <expression>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?
// warning C6285: (<non-zero constant> || <non-zero constant>) is always a non-zero constant. Did you intend to use the bitwise-and operator?
// warning C6237: (<zero> && <expression>) is always zero. <expression> is never evaluated and might have side effects
// warning C6235: (<non-zero constant> || <expression>) is always a non-zero constant
// warning C6240: (<expression> && <non-zero constant>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?
// These warnings aren't really important:
// warning C6323: Use of arithmetic operator on Boolean type(s)
// /analyze doesn't like GCOMPILER_ASSERT's implementation of compile-time asserts
// warning C6326: Potential comparison of a constant with another constant
// warning C6335: Leaking process information handle 'pi.hThread'
// warning C6320: Exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER. This might mask exceptions that were not intended to be handled
// warning C6250: Calling 'VirtualFree' without the MEM_RELEASE flag might free memory but not address descriptors (VADs). This causes address space leaks
// warning C6384: Dividing sizeof a pointer by another value
// warning C6318: Ill-defined __try/__except: use of the constant EXCEPTION_CONTINUE_SEARCH -- bogus
// warning C6322: Empty _except block
// Set the stack size threshold to 100,000 to avoid noisy warnings on functions with modest stack usage
// Note that /analyze for VS 2010 only works with the 32-bit compiler, but for VS 2012 it works on 64-bit
// as well.
$DisableSpecificWarnings "$BASE;6308;6255;6387;6309;6011;6211;6326;6239;6285;6237;6235;6240;6323;6326;6335;6320;6250;6384;6318;6322" [$ANALYZE]
// See http://randomascii.wordpress.com/2011/10/04/analyzecommand-line-options/ for details on these options.
// /analyze:only may result in fewer warnings being reported, but the warnings it misses should show up in the regular build.
$AdditionalOptions "$BASE /analyze /analyze:stacksize100000" [$ANALYZE]
$AdditionalOptions "$BASE /analyze:only" [$ANALYZE && $ANALYZE_MACHINE] // /analyze:only makes builds faster on buildbot but is terrible for incremental /analyze on developer machines
// Specify /define:ALLOWSHADOWING to suppress variable shadowing warnings
$DisableSpecificWarnings "$BASE;6244;6246" [$ANALYZE && $ALLOWSHADOWING]
// New warnings in VS 2012 that we want to ignore.
// warning C4005: 'DXGI_STATUS_OCCLUDED' : macro redefinition
// warning C6014: Leaking memory 'pThinkParams'.
// warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days.
// warning C28182: Dereferencing NULL pointer. 'pPropMesh' contains the same NULL value as '(CMesh *)=(pPropMesh)' did.
// warning C28183: 'entropy->ac_count_ptrs[actbl]' could be '0', and is a copy of the value found in 'entropy->dc_count_ptrs[dctbl]': this does not adhere to the specification for the function 'memset'.
// warning C28197: Possibly leaking memory 'pInfo'.
// warning C28198: Possibly leaking memory 'kvFrame1' due to an exception. Is a local catch block needed to clean up memory?
// warning C28204: 'QueryInterface' : Only one of this overload and the one at c:\program files (x86)\windows kits\8.0\include\um\unknwnbase.h(114) are annotated for _Param_(2): both or neither must be annotated.
// warning C28247: Model file annotation for function '_vsnprintf': annotation on _Param_(1)/SAL_post, 'RequiresZeroTermination' duplicates header file annotation 'SAL_nullTerminated'. Remove the duplicated annotations from the model file. (Header: c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h(349).)
// warning C28251: Inconsistent annotation for 'WinMain': this instance has no annotations. See c:\program files (x86)\windows kits\8.0\include\um\winbase.h(2286).
// warning C28301: No annotations for first declaration of 'InitializeCriticalSection'. See d:\clients\tf3\staging\src\public\tier0\threadtools.h(1373).
// warning C28195: The function was declared as acquiring memory in 'return' and exited without doing so.
// warning C6340: Mismatch on sign: 'unsigned short' passed as parameter '6' when some signed type is required in call to 'V_snprintf'.
// This warning only applies to Windows XP in low-memory situations:
// warning C28125: The function 'InitializeCriticalSection' must be called from within a try\except block
// warning C28160: Error annotation: Calling VirtualFreeEx without the MEM_RELEASE flag frees memory but not address descriptors (VADs); results in address space leaks.
// warning C6248: Setting a SECURITY_DESCRIPTOR's DACL to NULL will result in an unprotected object.
// warning C6102: Using value from failed function call
$DisableSpecificWarnings "$BASE;6014;28159;28182;28183;28197;28198;28204;28247;28251;28301;28195;6340;28125;28160;6248;6102" [$ANALYZE && ($VS2012 || $VS2013)]
}
}