1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 // winquake.h: Win32-specific Quake header file
21 
22 #pragma warning( disable : 4229 )  // mgraph gets this
23 
24 #include <windows.h>
25 #define WM_MOUSEWHEEL                   0x020A
26 
27 #ifndef SERVERONLY
28 #include <ddraw.h>
29 #include <dsound.h>
30 #ifndef GLQUAKE
31 #include <mgraph.h>
32 #endif
33 #endif
34 
35 extern	HINSTANCE	global_hInstance;
36 extern	int			global_nCmdShow;
37 
38 #ifndef SERVERONLY
39 
40 extern LPDIRECTDRAW		lpDD;
41 extern qboolean			DDActive;
42 extern LPDIRECTDRAWSURFACE	lpPrimary;
43 extern LPDIRECTDRAWSURFACE	lpFrontBuffer;
44 extern LPDIRECTDRAWSURFACE	lpBackBuffer;
45 extern LPDIRECTDRAWPALETTE	lpDDPal;
46 extern LPDIRECTSOUND pDS;
47 extern LPDIRECTSOUNDBUFFER pDSBuf;
48 
49 extern DWORD gSndBufSize;
50 //#define SNDBUFSIZE 65536
51 
52 void	VID_LockBuffer (void);
53 void	VID_UnlockBuffer (void);
54 
55 #endif
56 
57 typedef enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT} modestate_t;
58 
59 extern modestate_t	modestate;
60 
61 extern HWND			mainwindow;
62 extern qboolean		ActiveApp, Minimized;
63 
64 extern qboolean	WinNT;
65 
66 int VID_ForceUnlockedAndReturnState (void);
67 void VID_ForceLockState (int lk);
68 
69 void IN_ShowMouse (void);
70 void IN_DeactivateMouse (void);
71 void IN_HideMouse (void);
72 void IN_ActivateMouse (void);
73 void IN_RestoreOriginalMouseState (void);
74 void IN_SetQuakeMouseState (void);
75 void IN_MouseEvent (int mstate);
76 
77 extern qboolean	winsock_lib_initialized;
78 
79 extern cvar_t		_windowed_mouse;
80 
81 extern int		window_center_x, window_center_y;
82 extern RECT		window_rect;
83 
84 extern qboolean	mouseinitialized;
85 extern HWND		hwnd_dialog;
86 
87 extern HANDLE	hinput, houtput;
88 
89 void IN_UpdateClipCursor (void);
90 void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify);
91 
92 void S_BlockSound (void);
93 void S_UnblockSound (void);
94 
95 void VID_SetDefaultMode (void);
96 
97 int (PASCAL FAR *pWSAStartup)(WORD wVersionRequired, LPWSADATA lpWSAData);
98 int (PASCAL FAR *pWSACleanup)(void);
99 int (PASCAL FAR *pWSAGetLastError)(void);
100 SOCKET (PASCAL FAR *psocket)(int af, int type, int protocol);
101 int (PASCAL FAR *pioctlsocket)(SOCKET s, long cmd, u_long FAR *argp);
102 int (PASCAL FAR *psetsockopt)(SOCKET s, int level, int optname,
103 							  const char FAR * optval, int optlen);
104 int (PASCAL FAR *precvfrom)(SOCKET s, char FAR * buf, int len, int flags,
105 							struct sockaddr FAR *from, int FAR * fromlen);
106 int (PASCAL FAR *psendto)(SOCKET s, const char FAR * buf, int len, int flags,
107 						  const struct sockaddr FAR *to, int tolen);
108 int (PASCAL FAR *pclosesocket)(SOCKET s);
109 int (PASCAL FAR *pgethostname)(char FAR * name, int namelen);
110 struct hostent FAR * (PASCAL FAR *pgethostbyname)(const char FAR * name);
111 struct hostent FAR * (PASCAL FAR *pgethostbyaddr)(const char FAR * addr,
112 												  int len, int type);
113 int (PASCAL FAR *pgetsockname)(SOCKET s, struct sockaddr FAR *name,
114 							   int FAR * namelen);
115