summaryrefslogtreecommitdiff
path: root/vgui2/src/vgui_key_translation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vgui2/src/vgui_key_translation.cpp')
-rw-r--r--vgui2/src/vgui_key_translation.cpp42
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 );
+}