diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /vgui2/src/vgui_key_translation.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'vgui2/src/vgui_key_translation.cpp')
| -rw-r--r-- | vgui2/src/vgui_key_translation.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vgui2/src/vgui_key_translation.cpp b/vgui2/src/vgui_key_translation.cpp new file mode 100644 index 0000000..0377a5d --- /dev/null +++ b/vgui2/src/vgui_key_translation.cpp @@ -0,0 +1,42 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//===========================================================================// + +#if defined( WIN32 ) && !defined( _X360 ) +#include <wtypes.h> +#include <winuser.h> +#include "xbox/xboxstubs.h" +#endif +#include "tier0/dbg.h" +#include "vgui_key_translation.h" +#if defined( _X360 ) +#include "xbox/xbox_win32stubs.h" +#endif +#ifdef POSIX +#define VK_RETURN -1 +#endif + +#include "tier2/tier2.h" +#include "inputsystem/iinputsystem.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +vgui::KeyCode KeyCode_VirtualKeyToVGUI( int key ) +{ + // Some tools load vgui for localization and never use input + if ( !g_pInputSystem ) + return KEY_NONE; + return g_pInputSystem->VirtualKeyToButtonCode( key ); +} + +int KeyCode_VGUIToVirtualKey( vgui::KeyCode code ) +{ + // Some tools load vgui for localization and never use input + if ( !g_pInputSystem ) + return VK_RETURN; + + return g_pInputSystem->ButtonCodeToVirtualKey( code ); +} |