Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "winlite.h"
  8. #include "Sys_Utils.h"
  9. #include "EngineInterface.h"
  10. #if defined( _GAMECONSOLE )
  11. #include "xbox/xbox_win32stubs.h"
  12. #endif
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. const unsigned int SYS_NO_ERROR = NO_ERROR;
  16. const unsigned int SYS_ERROR_INVALID_HANDLE = ERROR_INVALID_HANDLE;
  17. void Sys_SetLastError(unsigned long error)
  18. {
  19. ::SetLastError(error);
  20. }
  21. unsigned long Sys_GetLastError()
  22. {
  23. return ::GetLastError();
  24. }
  25. WHANDLE Sys_CreateMutex(const char *mutexName)
  26. {
  27. return (WHANDLE)::CreateMutex(NULL, FALSE, TEXT(mutexName));
  28. }
  29. void Sys_ReleaseMutex(WHANDLE mutexHandle)
  30. {
  31. ::ReleaseMutex((HANDLE)mutexHandle);
  32. }
  33. const unsigned int SYS_WAIT_OBJECT_0 = WAIT_OBJECT_0;
  34. const unsigned int SYS_WAIT_ABANDONED = WAIT_ABANDONED;
  35. unsigned int Sys_WaitForSingleObject(WHANDLE mutexHandle, int milliseconds)
  36. {
  37. return WaitForSingleObject((HANDLE)mutexHandle, milliseconds);
  38. }
  39. unsigned int Sys_RegisterWindowMessage(const char *msgName)
  40. {
  41. return ::RegisterWindowMessage(msgName);
  42. }
  43. WHANDLE Sys_FindWindow(const char *className, const char *windowName)
  44. {
  45. return (WHANDLE)::FindWindow(className, windowName);
  46. }
  47. void Sys_EnumWindows(void *callbackFunction, int lparam)
  48. {
  49. ::EnumWindows((WNDENUMPROC)callbackFunction, lparam);
  50. }
  51. void Sys_GetWindowText(WHANDLE wnd, char *buffer, int bufferSize)
  52. {
  53. ::GetWindowText((HWND)wnd, buffer, bufferSize - 1);
  54. }
  55. void Sys_PostMessage(WHANDLE wnd, unsigned int msg, unsigned int wParam, unsigned int lParam)
  56. {
  57. ::PostMessageA((HWND)wnd, msg, wParam, lParam);
  58. }
  59. void Sys_SetCursorPos(int x, int y)
  60. {
  61. ::SetCursorPos(x, y);
  62. // engine->SetCursorPos(x,y); // SRC version
  63. }
  64. static ATOM staticWndclassAtom = 0;
  65. static WNDCLASS staticWndclass = { NULL };
  66. static LRESULT CALLBACK staticProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
  67. {
  68. return DefWindowProc(hwnd,msg,wparam,lparam);
  69. }
  70. WHANDLE Sys_CreateWindowEx(const char *windowName)
  71. {
  72. /*
  73. if (!staticWndclassAtom)
  74. {
  75. memset( &staticWndclass,0,sizeof(staticWndclass) );
  76. staticWndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
  77. staticWndclass.lpfnWndProc = staticProc;
  78. staticWndclass.hInstance = GetModuleHandle(NULL);
  79. staticWndclass.hIcon = 0;
  80. staticWndclass.lpszClassName = windowName;
  81. staticWndclassAtom = ::RegisterClass( &staticWndclass );
  82. DWORD error = ::GetLastError();
  83. }
  84. return (WHANDLE)::CreateWindow(windowName, windowName, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(NULL), 0);
  85. */
  86. return (WHANDLE)1;
  87. }
  88. void Sys_DestroyWindow(WHANDLE wnd)
  89. {
  90. //::DestroyWindow((HWND)wnd);
  91. }