FS2_Open
Open source remastering of the Freespace 2 engine
osapi.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #include <windows.h>
13 #include <windowsx.h>
14 #include <commctrl.h>
15 #include <stdio.h>
16 #include <io.h>
17 #include <fcntl.h>
18 #include <winsock.h>
19 #include <stdarg.h>
20 #include <direct.h>
21 
22 #include "globalincs/pstypes.h"
23 #include "io/key.h"
24 #include "palman/palman.h"
25 #include "io/mouse.h"
26 #include "osapi/outwnd.h"
27 #include "sound/sound.h"
29 #include "playerman/managepilot.h"
30 #include "io/joy.h"
31 #include "io/joy_ff.h"
33 #include "freespace2/freespace.h"
34 #include "osapi/osregistry.h"
35 #include "cmdline/cmdline.h"
36 #include "sound/voicerec.h"
37 #include "graphics/2d.h"
38 
39 #define THREADED // to use the proper set of macros
40 #include "osapi/osapi.h"
41 
42 
43 // used to be a THREADED define but only use multiple process threads if this is defined
44 // NOTE: may hang if set
45 //#define THREADED_PROCESS
46 
47 
48 // ----------------------------------------------------------------------------------------------------
49 // OSAPI DEFINES/VARS
50 //
51 
52 // os-wide globals
53 static HINSTANCE hInstApp;
54 static HWND hwndApp = NULL;
55 static HDC dcApp = NULL;
56 static int fAppActive = 0;
57 static int fOldAppActive = 0;
58 static int main_window_inited = 0;
59 static char szWinTitle[128];
60 static char szWinClass[128];
61 static HANDLE hThread=NULL;
62 static DWORD ThreadID;
63 static int WinX, WinY, WinW, WinH;
64 static int Os_inited = 0;
65 
66 static CRITICAL_SECTION Os_lock;
67 
69 
70 // ----------------------------------------------------------------------------------------------------
71 // OSAPI FORWARD DECLARATIONS
72 //
73 
74 #ifdef THREADED_PROCESS
75  // thread handler for the main message thread
76  DWORD win32_process(DWORD lparam);
77 #else
78  DWORD win32_process1(DWORD lparam);
79  DWORD win32_process2(DWORD lparam);
80 #endif
81 
82 // Fills in the Os_debugger_running with non-zero if debugger detected.
83 void os_check_debugger();
84 
85 // called at shutdown. Makes sure all thread processing terminates.
86 void os_deinit();
87 
88 // go through all windows and try and find the one that matches the search string
89 BOOL __stdcall os_enum_windows( HWND hwnd, char * search_string );
90 
91 // message handler for the main thread
93 
94 
95 // ----------------------------------------------------------------------------------------------------
96 // OSAPI FUNCTIONS
97 //
98 
99 // detect home/base directory (placeholder for possible future Win32 userdir support, just returns current directory for now)
101 const char *detect_home(void)
102 {
103  if ( strlen(Cfile_root_dir) )
104  return Cfile_root_dir;
105 
106  memset( Cur_path, 0, MAX_PATH_LEN );
108 
109  return Cur_path;
110 }
111 
112 // initialization/shutdown functions -----------------------------------------------
113 
115 {
116  HANDLE pHandle = GetCurrentProcess();
117  DWORD pMaskProcess = 0, pMaskSystem = 0;
118 
119  if ( GetProcessAffinityMask(pHandle, &pMaskProcess, &pMaskSystem) ) {
120  // only do this if we have at least 2 procs
121  if (pMaskProcess >= 3) {
122  // prefer running on the second processor by default
123  pMaskProcess = os_config_read_uint(NULL, "ProcessorAffinity", 2);
124 
125  if (pMaskProcess > 0) {
126  SetProcessAffinityMask(pHandle, pMaskProcess);
127  }
128  }
129  }
130 }
131 
132 // If app_name is NULL or ommited, then TITLE is used
133 // for the app name, which is where registry keys are stored.
134 void os_init(const char * wclass, const char * title, const char *app_name, const char *version_string )
135 {
136  os_init_registry_stuff(Osreg_company_name, title, version_string);
137 
138  strcpy_s( szWinTitle, title );
139  strcpy_s( szWinClass, wclass );
140 
141  INITIALIZE_CRITICAL_SECTION( Os_lock );
142 /*
143  #ifdef THREADED_PROCESS
144  // Create an even to signal that the window is created,
145  // so that we don't return from this function until
146  // the window is all properly created.
147  HANDLE Window_created = CreateEvent( NULL, FALSE, FALSE, NULL );
148  hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)win32_process, Window_created, 0, &ThreadID );
149  if ( WaitForSingleObject( Window_created, 5000 )==WAIT_TIMEOUT) { //INFINITE );
150  mprintf(( "Wait timeout!\n" ));
151  }
152  CloseHandle(Window_created);
153  Window_created = NULL;
154  #endif // THREADED
155 */
156  // initialized
157  Os_inited = 1;
158 
159  // check to see if we're running under msdev
161 
163  {
164  // deal with processor affinity
166  }
167 
168  atexit(os_deinit);
169 }
170 
171 // set the main window title
172 void os_set_title( const char * title )
173 {
174  strcpy_s( szWinTitle, title );
175  SetWindowText( hwndApp, szWinTitle );
176 }
177 
178 extern void gr_opengl_shutdown();
179 
180 // call at program end
182 {
183  if (gr_screen.mode == GR_OPENGL)
185 
186  if (dcApp != NULL) {
187  ReleaseDC( hwndApp, dcApp );
188  }
189 
190  // destroy the window (takes care of a lot of window related cleanup and sys messages)
191  DestroyWindow( hwndApp );
192 
193 #ifndef NDEBUG
194  outwnd_close();
195 #endif
196 }
197 
198 
199 // window management -----------------------------------------------------------------
200 
201 // Returns 1 if app is not the foreground app.
203 {
204  return fAppActive;
205 }
206 
207 // Returns the handle to the main window
209 {
210  return (uint)hwndApp;
211 }
212 
214 {
215  if (dcApp == NULL) {
216  dcApp = GetDC(hwndApp);
217  }
218 
219  return (uint)dcApp;
220 }
221 
222 // Returns the handle to the main window
223 void os_set_window(uint new_handle)
224 {
225  hwndApp = (HWND)new_handle;
226 }
227 
228 
229 // process management -----------------------------------------------------------------
230 
231 // Sleeps for n milliseconds or until app becomes active.
232 void os_sleep(int ms)
233 {
234  Sleep(ms);
235 }
236 
237 // Used to stop message processing
239 {
240  ENTER_CRITICAL_SECTION( Os_lock );
241 }
242 
243 // resume message processing
244 void os_resume()
245 {
246  LEAVE_CRITICAL_SECTION( Os_lock );
247 }
248 
249 
250 // ----------------------------------------------------------------------------------------------------
251 // OSAPI FORWARD DECLARATIONS
252 //
253 
254 #ifdef THREADED_PROCESS
255 
256 // thread handler for the main message thread
257 DWORD win32_process(DWORD lparam)
258 {
259 /* MSG msg;
260  HANDLE Window_created = (HANDLE)lparam;
261 
262  if ( !win32_create_window() )
263  return 0;
264 
265  // Let the app continue once the window is created
266  SetEvent(Window_created);
267 
268  while (1) {
269  if (WaitMessage() == TRUE) {
270  ENTER_CRITICAL_SECTION( Os_lock );
271  while(PeekMessage(&msg,0,0,0,PM_REMOVE)) {
272  if ( msg.message == WM_DESTROY ) {
273  LEAVE_CRITICAL_SECTION( Os_lock );
274 
275  // cleanup and exit this thread!!
276  DELETE_CRITICAL_SECTION( Os_lock );
277  return 0;
278  }
279  TranslateMessage(&msg);
280  DispatchMessage(&msg);
281  }
282  LEAVE_CRITICAL_SECTION( Os_lock );
283  }
284  }*/
285 
286  return 0;
287 }
288 
289 #else
290 
292 {
293  MSG msg;
294 
295  while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) ) {
296  TranslateMessage(&msg);
297  DispatchMessage(&msg);
298  }
299 
300  return 0;
301 }
302 #endif // THREADED_PROCESS
303 
304 // Fills in the Os_debugger_running with non-zero if debugger detected.
306 {
307  HMODULE hMod;
308  char search_string[256];
309  char myname[128];
310  int namelen;
311  char * p;
312 
313  Os_debugger_running = 0; // Assume its not
314 
315  // Find my EXE file name
316  hMod = GetModuleHandle(NULL);
317  if ( !hMod ) return;
318  namelen = GetModuleFileName( hMod, myname, 127 );
319  if ( namelen < 1 ) return;
320 
321  // Strip off the .EXE
322  p = strstr( myname, ".exe" );
323  if (!p) return;
324  *p = '\0';
325 
326  // Move p to point to first letter of EXE filename
327  while( (*p!='\\') && (*p!='/') && (*p!=':') )
328  p--;
329  p++;
330  if ( strlen(p) < 1 ) return;
331 
332  // Build what the debugger's window title would be if the debugger is running...
333  sprintf( search_string, "[run] - %s -", p );
334 
335  // ... and then search for it.
336  EnumWindows( (int (__stdcall *)(struct HWND__ *,long))os_enum_windows, (long)&search_string );
337 }
338 
339 // called at shutdown. Makes sure all thread processing terminates.
340 void os_deinit()
341 {
342  if (hThread) {
343  CloseHandle(hThread);
344  hThread = NULL;
345  }
346 }
347 
348 // go through all windows and try and find the one that matches the search string
349 BOOL __stdcall os_enum_windows( HWND hwnd, char * search_string )
350 {
351  char tmp[128];
352  int len;
353 
354  len = GetWindowText( hwnd, tmp, 127 );
355 
356  if ( len ) {
357  if ( strstr( tmp, search_string )) {
358  Os_debugger_running = 1; // found the search string!
359  return FALSE; // stop enumerating windows
360  }
361  }
362 
363  return TRUE; // continue enumeration
364 }
365 
367 {
368  if (fAppActive != fOldAppActive) {
369  if (fAppActive) {
370  // maximize it
372 
374  {
375  game_unpause();
376  }
377 
378 #ifdef THREADED_PROCESS
379  SetThreadPriority( hThread, THREAD_PRIORITY_HIGHEST );
380 #endif
381 
382  if ( !Is_standalone )
383  disableWindowsKey();
384 
385  if (!Cmdline_window)
386  {
387  SetWindowPos(hwndApp, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
388  }
389  }
390  else {
392 
393  if (Mouse_hidden)
394  Mouse_hidden = 0;
395 
397  {
398  // Pause sounds and put up pause screen if necessary
399  game_pause();
400  }
401 
402 #ifdef THREADED_PROCESS
403  SetThreadPriority( hThread, THREAD_PRIORITY_NORMAL );
404 #endif
405 
406  if ( !Is_standalone )
407  enableWindowsKey();
408 
409  if (!Cmdline_window)
410  {
411  SetWindowPos(hwndApp, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
412  }
413  }
414 
416  {
417  gr_activate(fAppActive);
418  }
419 
420  fOldAppActive = fAppActive;
421  }
422 }
423 
424 int Got_message = 0;
425 extern bool Messagebox_active;
426 // message handler for the main thread
428 {
429  // Got_message++;
430 
431  switch(msg) {
432 
433  case WM_QUERYNEWPALETTE:
434  // mprintf(( "WM: QueryNewPalette\n" ));
435  return TRUE; // Say that I've realized my own palette
436  break;
437  case WM_PALETTECHANGED:
438  // mprintf(( "WM: PaletteChanged\n" ));
439  break;
440  case WM_PALETTEISCHANGING:
441  // mprintf(( "WM: PaletteIsChanging\n" ));
442  break;
443 
444  case WM_DISPLAYCHANGE:
445  // mprintf(( "WM: DisplayChange\n" ));
446  break;
447 
448  case WM_LBUTTONDOWN:
450  break;
451 
452  case WM_LBUTTONUP:
454  break;
455 
456  case WM_RBUTTONDOWN:
458  break;
459 
460  case WM_RBUTTONUP:
462  break;
463 
464  case WM_MBUTTONDOWN:
466  break;
467 
468  case WM_MBUTTONUP:
470  break;
471 
472  case WM_TIMER:
473  break;
474 
475  case WM_SYSCHAR:
476  break;
477 
478  case WM_SYSKEYDOWN:
479  case WM_KEYDOWN: {
480  int nVirtKey;
481  uint lKeyData;
482 
483  int latency;
484  latency = timeGetTime() - GetMessageTime();
485  if ( latency < 0 )
486  latency=0;
487 
488  nVirtKey = (int)wParam; // virtual-key code
489  lKeyData = (lParam>>16) & 255; // key data
490  if ( (lParam>>16) & 256 ) lKeyData += 0x80;
491 
492  // Fix up print screen, whose OEM code is wrong under 95.
493  if ( nVirtKey == VK_SNAPSHOT ) {
494  lKeyData = KEY_PRINT_SCRN;
495  }
496 
497  if (lKeyData == KEY_RSHIFT) // either shift is just a shift to us..
498  lKeyData = KEY_LSHIFT;
499 
500  if (lKeyData == KEY_RALT) // Same with alt keys..
501  lKeyData = KEY_LALT;
502 
503 // mprintf(( "Key down = 0x%x|%x\n", lKeyData, nVirtKey ));
504  key_mark( lKeyData, 1, latency );
505 // mprintf(( "Key down = 0x%x\n", lKeyData ));
506  //Warning( LOCATION, "Key = 0x%x", lKeyData );
507  }
508  break;
509 
510  case WM_SYSKEYUP:
511  case WM_KEYUP: {
512  int nVirtKey;
513  uint lKeyData;
514 
515  int latency;
516  latency = timeGetTime() - GetMessageTime();
517  if ( latency < 0 )
518  latency=0;
519 
520  nVirtKey = (int) wParam; // virtual-key code
521  lKeyData = (lParam>>16) & 255; // key data
522  if ( (lParam>>16) & 256 ) lKeyData += 0x80;
523 
524  // Fix up print screen, whose OEM code is wrong under 95.
525  if ( nVirtKey == VK_SNAPSHOT ) {
526  lKeyData = KEY_PRINT_SCRN;
527  }
528 
529  if (lKeyData == KEY_RSHIFT) // either shift is just a shift to us..
530  lKeyData = KEY_LSHIFT;
531 
532  if (lKeyData == KEY_RALT) // Same with alt keys..
533  lKeyData = KEY_LALT;
534 
535 // mprintf(( "Key up = 0x%x|%x\n", lKeyData, nVirtKey ));
536  if ( lKeyData == 0xB7 ) {
537  // Hack for PrintScreen which only sends one up message!
538  key_mark( lKeyData, 1, latency );
539  key_mark( lKeyData, 0, latency );
540 
541  } else {
542  key_mark( lKeyData, 0, latency );
543  }
544  }
545  break;
546 
547  case WM_KILLFOCUS:
548  {
549  if (Messagebox_active)
550  break;
551 
552  key_lost_focus();
554  if ( !Is_standalone )
555  gr_activate(0);
556  break;
557  }
558 
559  case WM_SETFOCUS:
560  {
561  if (Messagebox_active)
562  break;
563 
564  key_got_focus();
565  mouse_got_focus();
566  if ( !Is_standalone )
567  gr_activate(1);
568  break;
569  }
570 
571 
572  case WM_ACTIVATE:
573  {
574  if (Messagebox_active)
575  break;
576 
577  int flag = LOWORD(wParam);
578  fAppActive = (( flag == WA_ACTIVE) || (flag==WA_CLICKACTIVE)) ? TRUE : FALSE;
580  break;
581  }
582 
583  case WM_ACTIVATEAPP:
584  if (Messagebox_active)
585  break;
586 
587  fAppActive = (BOOL)wParam;
589  break;
590 
591  case WM_DESTROY:
592  // mprintf(( "WM_DESTROY called\n" ));
593  PostQuitMessage(0);
594  break;
595 
596  case WM_CLOSE:
598  break;
599 
600  case WM_SYSCOMMAND:
601  // mprintf(( "Sys command called '%x'\n", wParam ));
602  if ( wParam != SC_SCREENSAVE ){
603  return DefWindowProc(hwnd, msg, wParam, lParam);
604  }
605  break;
606 
607 /*
608  case MM_WIM_DATA:
609  rtvoice_stream_data((uint)hwnd, (uint)wParam, (uint)lParam);
610  break;
611 */
612 #ifdef FS2_VOICER
613  case WM_RECOEVENT:
615  {
616  VOICEREC_process_event( hwnd );
617  }
618  break;
619 #endif
620 
621  // report back that we handle this ourselves (with gr_clear()) in order to
622  // prevent flickering (especially with movies)
623  case WM_ERASEBKGND:
624  return TRUE;
625 
626  default:
627  return DefWindowProc(hwnd, msg, wParam, lParam);
628  break;
629  }
630 
631  return 0;
632 }
633 
634 // create the main window
636 {
637  WNDCLASSEX wclass; // Huh?
638  HINSTANCE hInst = GetModuleHandle(NULL);
639 
640  if (hwndApp != NULL) {
641  if (dcApp != NULL) {
642  ReleaseDC( hwndApp, dcApp );
643  dcApp = NULL;
644  }
645 
646  DestroyWindow( hwndApp );
647  hwndApp = NULL;
648  }
649 
650  memset( &wclass, 0, sizeof(WNDCLASSEX) );
651 
652  wclass.hInstance = hInst;
653  wclass.lpszClassName = szWinClass;
654  wclass.lpfnWndProc = (WNDPROC)win32_message_handler;
655 
656 // if (Cmdline_window) {
657 // wclass.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
658 // } else {
659 // wclass.style = CS_BYTEALIGNCLIENT | CS_VREDRAW | CS_HREDRAW;
660 // }
661  wclass.style = CS_OWNDC; // using CS_OWNDC for better Win9x/WinME support (I think it's implied with WinNT+)
662 
663  wclass.cbSize = sizeof(WNDCLASSEX);
664  wclass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_APP_ICON) );
665  wclass.hCursor = LoadCursor(NULL, IDC_ARROW);
666  wclass.lpszMenuName = NULL; //"FreeSpaceMenu";
667  wclass.cbClsExtra = 0;
668  wclass.cbWndExtra = 0;
669  // set background to erase/clear with a black brush
670  // (NULL means that we had to do it ourselves, and created a white-screen problem)
671  wclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
672 
673  if ( !RegisterClassEx(&wclass) ) {
674  Error( LOCATION, "FATAL ERROR: Unable to register window class!!" );
675  }
676 
677  int style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE;
678 
679  if (Cmdline_window)
680  style |= (WS_CAPTION | WS_SYSMENU | WS_BORDER);
681 
682  int x_add, y_add;
683  int start_x, start_y;
684 
686  RECT my_rect;
687 
688  // make sure we adjust for the actual window border
689  if (Cmdline_window) {
690  x_add = GetSystemMetrics(SM_CXFIXEDFRAME) * 2;
691  y_add = 2 * GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION);
692  } else {
693  x_add = y_add = 0;
694  }
695 
696  GetWindowRect( GetDesktopWindow(), &my_rect );
697 
698  start_x = (my_rect.right - width - x_add) / 2;
699  start_y = (my_rect.bottom - height - y_add) / 2;
700 
701  if (start_x < 0)
702  start_x = 0;
703  if (start_y < 0)
704  start_y = 0;
705  } else {
706  x_add = y_add = 0;
707  start_x = start_y = 0;
708  }
709 
710  // we don't sicky TOPMOST for windowed mode since we wouldn't be able to bring
711  // the debug window (or anything else) to the true foreground otherwise
712  hwndApp = CreateWindowEx( (Cmdline_window || Cmdline_fullscreen_window) ? 0 : WS_EX_TOPMOST,
713  szWinClass, szWinTitle,
714  style,
715  start_x, // x
716  start_y, // y
717  width + x_add, // w
718  height + y_add, // h
719  NULL, (HMENU)NULL, hInst,
720  (LPSTR)NULL );
721 
722  if ( !hwndApp ) {
723  Error( LOCATION, "FATAL ERROR: Unable to create game window!!" );
724  }
725 
726  main_window_inited = 1;
727 
728  win32_process(0);
729 
730 #ifndef NDEBUG
731  extern void outwnd_init_debug_window(int);
733 #endif
734 
735  ShowWindow( hwndApp, SW_SHOWNORMAL );
736 
737  SetForegroundWindow( hwndApp );
738  SetActiveWindow( hwndApp );
739  SetFocus( hwndApp );
740 
741  // Hack!! Turn off Window's cursor.
742 // ShowCursor(false);
743 // ClipCursor(NULL);
744 
745  return;// TRUE;
746 }
747 
748 void os_poll()
749 {
750 #ifndef THREADED_PROCESS
751  win32_process(0);
752 #else
753  MSG msg;
754  ENTER_CRITICAL_SECTION( Os_lock );
755  while(PeekMessage(&msg,0,0,0,PM_NOREMOVE)) {
756  if ( msg.message == WM_DESTROY ) {
757  break;
758  }
759  if (PeekMessage(&msg,0,0,0,PM_REMOVE)) {
760  TranslateMessage(&msg);
761  DispatchMessage(&msg);
762  }
763  Got_message++;
764  }
765  LEAVE_CRITICAL_SECTION( Os_lock );
766 #endif
767 }
768 
769 void debug_int3(char *file, int line)
770 {
771  mprintf(("Int3(): From %s at line %d\n", file, line));
772 
773  gr_activate(0);
774 
775 #ifdef _WIN32
776 #if defined(_MSC_VER) && _MSC_VER >= 1400
777  __debugbreak( );
778 #elif defined(_MSC_VER)
779  _asm int 3;
780 #elif defined __GNUC__
781  asm("int $3");
782 #else
783 #error debug_int3: unknown compiler
784 #endif
785 
786 #else
787 #error debug_int3: unknown OS
788 #endif
789 
790  gr_activate(1);
791 
792 }
793 
794 
795 // Goober5000 - code provided by jr2 to disable windows key when FSO is in the foreground
796 
797 #ifdef _WIN32
798 
799 static HHOOK g_hKeyboardHook = NULL;
800 
801 // ugh
802 #ifndef WH_KEYBOARD_LL
803  #define WH_KEYBOARD_LL 13
804 #endif
805 
806 LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
807 {
808  if (nCode < 0 || nCode != HC_ACTION) // do not process message
809  return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
810 
811  // hack!
812  // this is because the KBDLLHOOKSTRUCT type requires a mess of #includes,
813  // but all we need from it is the first field
814  DWORD vkCode = *( (DWORD *) lParam );
815 
816  // determine key event
817  switch (wParam)
818  {
819  case WM_KEYDOWN:
820  case WM_KEYUP:
821  if ( (vkCode == VK_LWIN) || (vkCode == VK_RWIN) )
822  return 1;
823  }
824 
825  return CallNextHookEx( g_hKeyboardHook, nCode, wParam, lParam );
826 }
827 
828 void disableWindowsKey()
829 {
830  if (g_hKeyboardHook != NULL)
831  return;
832 
833  g_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );
834 }
835 
836 void enableWindowsKey()
837 {
838  if (g_hKeyboardHook == NULL)
839  return;
840 
841  UnhookWindowsHookEx( g_hKeyboardHook );
842  g_hKeyboardHook = NULL;
843 }
844 
845 #endif // _WIN32
void key_mark(uint code, int state, uint latency)
Definition: key.cpp:697
void * HWND
Definition: config.h:104
DWORD win32_process2(DWORD lparam)
uint os_config_read_uint(const char *section, const char *name, uint default_value)
Definition: osregistry.cpp:372
int os_foreground()
Definition: osapi.cpp:202
int Game_mode
Definition: systemvars.cpp:24
#define MOUSE_LEFT_BUTTON
Definition: mouse.h:43
bool Cmdline_no_unfocus_pause
Definition: cmdline.cpp:513
int mode
Definition: 2d.h:371
#define IDI_APP_ICON
DWORD win32_process1(DWORD lparam)
void * HINSTANCE
Definition: config.h:105
#define mprintf(args)
Definition: pstypes.h:238
#define MOUSE_MIDDLE_BUTTON
Definition: mouse.h:45
#define KEY_LSHIFT
Definition: key.h:134
void key_lost_focus()
Definition: key.cpp:917
void os_init_registry_stuff(const char *company, const char *app, const char *version)
Definition: osregistry.cpp:423
#define TRUE
Definition: pstypes.h:399
int Mouse_hidden
Definition: mouse.cpp:52
SDL_mutex * CRITICAL_SECTION
Definition: config.h:213
UINT WPARAM wParam
Definition: msacm.h:1064
UINT WPARAM LPARAM lParam
Definition: msacm.h:1064
unsigned int UINT
Definition: config.h:82
void outwnd_close()
Definition: outwnd.cpp:1316
const char * detect_home(void)
Definition: osapi.cpp:101
void os_deinit()
Definition: osapi.cpp:340
char Cur_path[MAX_PATH_LEN]
Definition: osapi.cpp:100
#define GR_OPENGL
Definition: 2d.h:648
long LPARAM
Definition: config.h:101
void os_set_title(const char *title)
Definition: osapi.cpp:172
GLint GLsizei width
Definition: Gl.h:1505
void joy_reacquire_ff()
Definition: joy_ff.cpp:539
uint os_get_window()
Definition: osapi.cpp:208
char * LPSTR
Definition: config.h:107
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int Os_debugger_running
Definition: osapi.cpp:68
void mouse_lost_focus()
Definition: mouse.cpp:74
unsigned int uint
Definition: pstypes.h:64
void change_window_active_state()
Definition: osapi.cpp:366
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
void os_resume()
Definition: osapi.cpp:244
#define ENTER_CRITICAL_SECTION(csc)
Definition: osapi.h:42
void win32_create_window(int width, int height)
Definition: osapi.cpp:635
void key_got_focus()
Definition: key.cpp:924
#define WM_RECOEVENT
Definition: voicerec.h:5
#define KEY_RALT
Definition: key.h:138
unsigned long DWORD
Definition: config.h:90
DWORD win32_process(DWORD lparam)
Definition: osapi.cpp:291
int Cmdline_window
Definition: cmdline.cpp:502
GLint namelen
Definition: Glext.h:6793
void os_init(const char *wclass, const char *title, const char *app_name, const char *version_string)
Definition: osapi.cpp:134
bool Messagebox_active
Definition: windebug.cpp:44
void os_poll()
Definition: osapi.cpp:748
int Cmdline_fullscreen_window
Definition: cmdline.cpp:503
#define GM_IN_MISSION
Definition: systemvars.h:23
#define KEY_PRINT_SCRN
Definition: key.h:184
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
void os_set_window(uint new_handle)
Definition: osapi.cpp:223
#define CALLBACK
Definition: config.h:75
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
int Cmdline_voice_recognition
Definition: cmdline.cpp:391
#define MAX_PATH_LEN
Definition: pstypes.h:325
LRESULT CALLBACK win32_message_handler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: osapi.cpp:427
int BOOL
Definition: config.h:80
const char * Osreg_company_name
Definition: osregistry.cpp:28
#define GetCurrentDirectory(i, s)
Definition: config.h:224
#define MOUSE_RIGHT_BUTTON
Definition: mouse.h:44
#define LEAVE_CRITICAL_SECTION(csc)
Definition: osapi.h:43
GLint GLsizei GLsizei height
Definition: Gl.h:1505
char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN]
Definition: cfile.cpp:38
void os_cleanup()
Definition: osapi.cpp:181
#define INITIALIZE_CRITICAL_SECTION(csc)
Definition: osapi.h:40
screen gr_screen
Definition: 2d.cpp:46
void os_check_debugger()
Definition: osapi.cpp:305
long LRESULT
Definition: config.h:100
void outwnd_init_debug_window(int display_under_freespace_window)
Definition: outwnd.cpp:1142
GLfloat GLfloat p
Definition: Glext.h:8373
void Sleep(int mili)
void game_unpause()
Definition: fredstubs.cpp:222
#define LOCATION
Definition: pstypes.h:245
#define KEY_LALT
Definition: key.h:137
uint os_get_dc()
Definition: osapi.cpp:213
BOOL __stdcall os_enum_windows(HWND hwnd, char *search_string)
Definition: osapi.cpp:349
bool Cmdline_set_cpu_affinity
Definition: cmdline.cpp:452
void debug_int3(char *file, int line)
Definition: osapi.cpp:769
GLenum GLsizei len
Definition: Glext.h:6283
#define __stdcall
Definition: config.h:73
void gr_activate(int)
Definition: 2d.cpp:1122
void os_set_process_affinity()
Definition: osapi.cpp:114
void joy_unacquire_ff()
Definition: joy_ff.cpp:549
int Got_message
Definition: osapi.cpp:424
void * HANDLE
Definition: config.h:106
void mouse_got_focus()
Definition: mouse.cpp:65
#define FALSE
Definition: pstypes.h:400
void gameseq_post_event(int event)
void game_pause()
Definition: fredstubs.cpp:221
void os_suspend()
Definition: osapi.cpp:238
void mouse_mark_button(uint flags, int set)
Definition: mouse.cpp:156
void gr_opengl_shutdown()
Definition: gropengl.cpp:1316
#define strcpy_s(...)
Definition: safe_strings.h:67
int Is_standalone
Definition: systemvars.cpp:59
void os_sleep(int ms)
Definition: osapi.cpp:232
void VOICEREC_process_event(HWND hWnd)
#define KEY_RSHIFT
Definition: key.h:135