summaryrefslogtreecommitdiff
path: root/gameui/Sys_Utils.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /gameui/Sys_Utils.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'gameui/Sys_Utils.cpp')
-rw-r--r--gameui/Sys_Utils.cpp180
1 files changed, 180 insertions, 0 deletions
diff --git a/gameui/Sys_Utils.cpp b/gameui/Sys_Utils.cpp
new file mode 100644
index 0000000..44f77fe
--- /dev/null
+++ b/gameui/Sys_Utils.cpp
@@ -0,0 +1,180 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "winlite.h"
+#include "Sys_Utils.h"
+#include "EngineInterface.h"
+#include "tier0/vcrmode.h"
+
+#if defined( _X360 )
+#include "xbox/xbox_win32stubs.h"
+#endif
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+#ifdef WIN32
+const unsigned int SYS_NO_ERROR = NO_ERROR;
+const unsigned int SYS_ERROR_INVALID_HANDLE = ERROR_INVALID_HANDLE;
+
+void Sys_SetLastError(unsigned long error)
+{
+ ::SetLastError(error);
+}
+
+unsigned long Sys_GetLastError()
+{
+ return ::GetLastError();
+}
+
+
+WHANDLE Sys_CreateMutex(const char *mutexName)
+{
+ return (WHANDLE)::CreateMutex(NULL, FALSE, TEXT(mutexName));
+}
+
+void Sys_ReleaseMutex(WHANDLE mutexHandle)
+{
+ ::ReleaseMutex((HANDLE)mutexHandle);
+}
+
+
+const unsigned int SYS_WAIT_OBJECT_0 = WAIT_OBJECT_0;
+const unsigned int SYS_WAIT_ABANDONED = WAIT_ABANDONED;
+
+unsigned int Sys_WaitForSingleObject(WHANDLE mutexHandle, int milliseconds)
+{
+ return VCRHook_WaitForSingleObject((HANDLE)mutexHandle, milliseconds);
+}
+
+unsigned int Sys_RegisterWindowMessage(const char *msgName)
+{
+ return ::RegisterWindowMessage(msgName);
+}
+
+WHANDLE Sys_FindWindow(const char *className, const char *windowName)
+{
+ return (WHANDLE)::FindWindow(className, windowName);
+}
+
+void Sys_EnumWindows(void *callbackFunction, int lparam)
+{
+ ::EnumWindows((WNDENUMPROC)callbackFunction, lparam);
+}
+
+#ifndef _XBOX
+void Sys_GetWindowText(WHANDLE wnd, char *buffer, int bufferSize)
+{
+ ::GetWindowText((HWND)wnd, buffer, bufferSize - 1);
+}
+#endif
+
+void Sys_PostMessage(WHANDLE wnd, unsigned int msg, unsigned int wParam, unsigned int lParam)
+{
+ ::PostMessageA((HWND)wnd, msg, wParam, lParam);
+}
+
+#ifndef _XBOX
+void Sys_SetCursorPos(int x, int y)
+{
+ ::SetCursorPos(x, y);
+// engine->SetCursorPos(x,y); // SRC version
+}
+#endif
+
+#ifndef _XBOX
+static ATOM staticWndclassAtom = 0;
+static WNDCLASS staticWndclass = { NULL };
+#endif
+
+static LRESULT CALLBACK staticProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
+{
+ return DefWindowProc(hwnd,msg,wparam,lparam);
+}
+
+WHANDLE Sys_CreateWindowEx(const char *windowName)
+{
+ /*
+ if (!staticWndclassAtom)
+ {
+ memset( &staticWndclass,0,sizeof(staticWndclass) );
+ staticWndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+ staticWndclass.lpfnWndProc = staticProc;
+ staticWndclass.hInstance = GetModuleHandle(NULL);
+ staticWndclass.hIcon = 0;
+ staticWndclass.lpszClassName = windowName;
+ staticWndclassAtom = ::RegisterClass( &staticWndclass );
+
+ DWORD error = ::GetLastError();
+ }
+
+ return (WHANDLE)::CreateWindow(windowName, windowName, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(NULL), 0);
+ */
+ return (WHANDLE)1;
+}
+
+void Sys_DestroyWindow(WHANDLE wnd)
+{
+ //::DestroyWindow((HWND)wnd);
+}
+
+#elif defined( POSIX )
+const unsigned int SYS_NO_ERROR = 0;
+const unsigned int SYS_ERROR_INVALID_HANDLE = 0;
+const unsigned int SYS_WAIT_OBJECT_0 = 0;
+const unsigned int SYS_WAIT_ABANDONED = 0;
+
+
+void Sys_SetLastError(unsigned long error)
+{
+ errno = error;
+}
+
+unsigned long Sys_GetLastError()
+{
+ return errno;
+}
+
+
+WHANDLE Sys_CreateMutex(const char *mutexName)
+{
+ Assert( !"Implement me" );
+ return 0;
+}
+
+void Sys_ReleaseMutex(WHANDLE mutexHandle)
+{
+ Assert( !"Implement me" );
+}
+
+void Sys_PostMessage(WHANDLE wnd, unsigned int msg, unsigned int wParam, unsigned int lParam)
+{
+ Assert( !"Implement me" );
+}
+
+unsigned int Sys_RegisterWindowMessage(const char *msgName)
+{
+ Assert( !"Implement me" );
+ return 0;
+}
+
+unsigned int Sys_WaitForSingleObject(WHANDLE mutexHandle, int milliseconds)
+{
+ return SYS_WAIT_ABANDONED;
+}
+
+void Sys_EnumWindows(void *callbackFunction, int lparam)
+{
+ Assert( !"Implement me" );
+}
+
+
+#else
+#error
+#endif
+