some stuff
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "gamesystem.h"
|
||||
#include "networkbase.h"
|
||||
#include "icvar.h"
|
||||
#include "tier1/interface.h"
|
||||
|
||||
struct EngineConsts_t
|
||||
{
|
||||
|
||||
118
public/icvar.h
118
public/icvar.h
@@ -5,6 +5,7 @@
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/interface.h"
|
||||
|
||||
class ConVar;
|
||||
class ConCommand;
|
||||
@@ -32,12 +33,10 @@ public:
|
||||
|
||||
virtual void AddCommand( const char *psz ) = 0;
|
||||
virtual void InsertCommand( const char *psz ) = 0;
|
||||
|
||||
CUtlVector<ConVar*> m_convars;
|
||||
CUtlVector<ConCommand*> m_commands;
|
||||
};
|
||||
|
||||
IConsole *Console();
|
||||
#define CONSOLE_INTERFACE_VERSION "Console001"
|
||||
|
||||
|
||||
#define FCVAR_NONE 0
|
||||
@@ -91,6 +90,92 @@ private:
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags )
|
||||
: ConVar(pName, pDefaultValue, flags, 0)
|
||||
{
|
||||
|
||||
}
|
||||
inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString )
|
||||
: ConVar(pName, pDefaultValue, flags, pHelpString, 0)
|
||||
{
|
||||
}
|
||||
inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
const char *pHelpString, ConCommandFn callback )
|
||||
{
|
||||
m_szName = pName;
|
||||
m_flags = flags;
|
||||
SetValue(pDefaultValue);
|
||||
}
|
||||
|
||||
inline bool ConVar::IsFlagSet( int flag )
|
||||
{
|
||||
return (m_flags & flag) > 0;
|
||||
}
|
||||
inline const char *ConVar::GetHelpText( void )
|
||||
{
|
||||
return m_szHelpString;
|
||||
}
|
||||
inline bool ConVar::IsRegistered( void )
|
||||
{
|
||||
|
||||
}
|
||||
inline const char *ConVar::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
inline void ConVar::AddFlags( int flags )
|
||||
{
|
||||
|
||||
}
|
||||
inline bool ConVar::IsCommand( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void ConVar::InstallChangeCallback( ConCommandFn )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline float ConVar::GetFloat( void )
|
||||
{
|
||||
return m_fValue;
|
||||
}
|
||||
inline int ConVar::GetInt( void )
|
||||
{
|
||||
return m_nValue;
|
||||
}
|
||||
inline bool ConVar::GetBool( void )
|
||||
{
|
||||
return m_nValue;
|
||||
}
|
||||
inline const char *ConVar::GetString( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void ConVar::SetValue( const char *szValue )
|
||||
{
|
||||
if (!szValue)
|
||||
return;
|
||||
m_szValue = szValue;
|
||||
m_fValue = V_atof(szValue);
|
||||
m_nValue = V_atoi(szValue);
|
||||
}
|
||||
inline void ConVar::SetValue( float fValue )
|
||||
{
|
||||
m_fValue = fValue;
|
||||
m_nValue = fValue;
|
||||
m_szValue = CUtlString("%f\n",fValue);
|
||||
}
|
||||
inline void ConVar::SetValue( int iValue )
|
||||
{
|
||||
m_fValue = iValue;
|
||||
m_nValue = iValue;
|
||||
m_szValue = CUtlString("%i\n",iValue);
|
||||
}
|
||||
|
||||
|
||||
class ConCommand
|
||||
{
|
||||
@@ -109,11 +194,28 @@ private:
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
#undef V_printf
|
||||
#define V_printf(...) Msg(CUtlString(__VA_ARGS__).GetString())
|
||||
inline ConCommand::ConCommand(const char *pName, ConCommandFn callback,
|
||||
const char *pHelpString, int flags)
|
||||
{
|
||||
m_szName = pName;
|
||||
m_callback = callback;
|
||||
m_flags = flags;
|
||||
Console()->RegisterCommand(this);
|
||||
};
|
||||
|
||||
void Msg( const char* message );
|
||||
void Warning( const char* message );
|
||||
void Error( const char* message );
|
||||
inline const char *ConCommand::GetHelpText( void )
|
||||
{
|
||||
return m_szHelpString;
|
||||
}
|
||||
|
||||
inline const char *ConCommand::GetName( void )
|
||||
{
|
||||
return m_szName;
|
||||
}
|
||||
|
||||
inline ConCommandFn ConCommand::GetCallback( void )
|
||||
{
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
44
public/ihumandevice.h
Normal file
44
public/ihumandevice.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef KEYBINDINGS_H
|
||||
#define KEYBINDINGS_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "materialsystem/humandevice_enums.h"
|
||||
|
||||
|
||||
abstract_class IHumanDeviceInput
|
||||
{
|
||||
public:
|
||||
virtual EInputType GetInputType() = 0;
|
||||
|
||||
virtual void OnGameButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) = 0;
|
||||
virtual void OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) = 0;
|
||||
virtual void OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) = 0;
|
||||
|
||||
virtual void OnButton( EInputDeviceType eDevice, EInputButton eScancode, bool bIsPressed ) = 0;
|
||||
virtual void OnAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue) = 0;
|
||||
virtual void OnAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) = 0;
|
||||
|
||||
virtual void OnTextWriteUTF8( uint32_t uCode ) = 0;
|
||||
};
|
||||
|
||||
abstract_class IHumanDeviceManager
|
||||
{
|
||||
public:
|
||||
virtual void Frame() = 0;
|
||||
|
||||
virtual void SetDefaultInput( IHumanDeviceInput *pInput ) = 0;
|
||||
virtual void PushInput( IHumanDeviceInput *pInput ) = 0;
|
||||
virtual void PopInput() = 0;
|
||||
virtual IHumanDeviceInput *GetCurrentInput() = 0;
|
||||
|
||||
virtual void SetButtonPressed( EInputButton eButton ) = 0;
|
||||
virtual void SetButtonUnpressed( EInputButton eButton ) = 0;
|
||||
|
||||
virtual void WriteUTF8( uint32_t uCode ) = 0;
|
||||
};
|
||||
|
||||
#define HUMAN_DEVICE_MANAGER_INTERFACE_VERSION "HumanDeviceMgr001"
|
||||
|
||||
extern IHumanDeviceManager *g_pHumanDeviceManager;
|
||||
|
||||
#endif
|
||||
108
public/materialsystem/humandevice_enums.h
Normal file
108
public/materialsystem/humandevice_enums.h
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef HD_ENUMS_H
|
||||
#define HD_ENUMS_H
|
||||
|
||||
enum EInputButton
|
||||
{
|
||||
k_EInputButton_NONE = 0,
|
||||
|
||||
k_EInputButton_Mouse_Left,
|
||||
k_EInputButton_Mouse_Right,
|
||||
k_EInputButton_Mouse_3,
|
||||
k_EInputButton_Mouse_4,
|
||||
k_EInputButton_Mouse_ScrollUp,
|
||||
k_EInputButton_Mouse_ScrollDown,
|
||||
|
||||
k_EInputButton_ESCAPE,
|
||||
k_EInputButton_TAB,
|
||||
k_EInputButton_TILDE,
|
||||
k_EInputButton_CAPSLOCK,
|
||||
k_EInputButton_CONTROL,
|
||||
k_EInputButton_SHIFT,
|
||||
k_EInputButton_WIN,
|
||||
k_EInputButton_ALT,
|
||||
k_EInputButton_SPACE,
|
||||
|
||||
k_EInputButton_BACKSPACE,
|
||||
k_EInputButton_LBRACKET,
|
||||
k_EInputButton_RBRACKET,
|
||||
k_EInputButton_BACKSLASH,
|
||||
k_EInputButton_SEMICOLON,
|
||||
k_EInputButton_APOSTROPHE,
|
||||
k_EInputButton_SLASH,
|
||||
k_EInputButton_ENTER,
|
||||
|
||||
k_EInputButton_F1,
|
||||
k_EInputButton_F2,
|
||||
k_EInputButton_F3,
|
||||
k_EInputButton_F4,
|
||||
k_EInputButton_F5,
|
||||
k_EInputButton_F6,
|
||||
k_EInputButton_F7,
|
||||
k_EInputButton_F8,
|
||||
k_EInputButton_F9,
|
||||
k_EInputButton_F10,
|
||||
k_EInputButton_F11,
|
||||
k_EInputButton_F12,
|
||||
|
||||
k_EInputButton_1,
|
||||
k_EInputButton_2,
|
||||
k_EInputButton_3,
|
||||
k_EInputButton_4,
|
||||
k_EInputButton_5,
|
||||
k_EInputButton_6,
|
||||
k_EInputButton_7,
|
||||
k_EInputButton_8,
|
||||
k_EInputButton_9,
|
||||
k_EInputButton_0,
|
||||
|
||||
k_EInputButton_A,
|
||||
k_EInputButton_B,
|
||||
k_EInputButton_C,
|
||||
k_EInputButton_D,
|
||||
k_EInputButton_E,
|
||||
k_EInputButton_F,
|
||||
k_EInputButton_G,
|
||||
k_EInputButton_H,
|
||||
k_EInputButton_I,
|
||||
k_EInputButton_J,
|
||||
k_EInputButton_K,
|
||||
k_EInputButton_L,
|
||||
k_EInputButton_M,
|
||||
k_EInputButton_N,
|
||||
k_EInputButton_O,
|
||||
k_EInputButton_P,
|
||||
k_EInputButton_Q,
|
||||
k_EInputButton_R,
|
||||
k_EInputButton_S,
|
||||
k_EInputButton_T,
|
||||
k_EInputButton_U,
|
||||
k_EInputButton_V,
|
||||
k_EInputButton_W,
|
||||
k_EInputButton_X,
|
||||
k_EInputButton_Y,
|
||||
k_EInputButton_Z,
|
||||
k_EInputButton_MAX,
|
||||
k_EInputButton_Count = k_EInputButton_MAX - 1,
|
||||
};
|
||||
|
||||
enum EInputAxis
|
||||
{
|
||||
k_EInputAxis_MouseX,
|
||||
k_EInputAxis_MouseY,
|
||||
};
|
||||
|
||||
enum EInputType
|
||||
{
|
||||
k_EInput_Game,
|
||||
k_EInput_Menu,
|
||||
k_EInput_InputBox,
|
||||
};
|
||||
|
||||
enum EInputDeviceType
|
||||
{
|
||||
k_EInputDevice_Keyboard,
|
||||
k_EInputDevice_Mouse,
|
||||
k_EInputDevice_Gamepad,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier2/iappsystem.h"
|
||||
#include "materialsystem/humandevice_enums.h"
|
||||
|
||||
typedef void ( *KeyCallbackFn )( EInputDeviceType eDevice, EInputButton eButton, bool bIsPressed );
|
||||
typedef void ( *AxisCallbackFn )( EInputDeviceType eDevice, EInputAxis eAxis, float fd );
|
||||
|
||||
class IImage;
|
||||
abstract_class IGameWindow: public IAppSystem
|
||||
@@ -17,6 +21,9 @@ public:
|
||||
virtual void SetOutputImage( IImage *pImage ) = 0;
|
||||
virtual IImage *GetOutputImage() = 0;
|
||||
|
||||
virtual void SetKeyCallback( KeyCallbackFn fn ) = 0;
|
||||
virtual void SetAxisCallback( AxisCallbackFn fn ) = 0;
|
||||
|
||||
virtual void *CreateVulkanSurface( void *pInstance ) = 0;
|
||||
virtual void DestroyVulkanSurface( void *pInstance ) = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user