Updated for embedded Visual C++ 4.0
authorSam Lantinga <slouken@libsdl.org>
Tue, 20 Aug 2002 00:20:06 +0000
changeset 453a6fa62b1be09
parent 452 4c5c10383201
child 454 c4338ecf45f9
Updated for embedded Visual C++ 4.0
Makefile.am
README.WinCE
VisualCE.zip
include/SDL_main.h
src/audio/windx5/SDL_dx5audio.c
src/main/win32/SDL_main.c
src/timer/win32/SDL_systimer.c
src/video/SDL_sysvideo.h
src/video/wincommon/SDL_lowvideo.h
src/video/wincommon/SDL_sysevents.c
src/video/wincommon/SDL_wingl.c
src/video/windib/SDL_dibevents.c
src/video/windib/SDL_dibvideo.c
src/video/windx5/SDL_dx5events.c
src/video/windx5/SDL_dx5video.c
src/video/windx5/SDL_dx5video.h
     1.1 --- a/Makefile.am	Mon Aug 19 18:33:29 2002 +0000
     1.2 +++ b/Makefile.am	Tue Aug 20 00:20:06 2002 +0000
     1.3 @@ -39,6 +39,7 @@
     1.4  	Borland.zip	\
     1.5          VisualC.html	\
     1.6          VisualC.zip	\
     1.7 +	VisualCE.zip	\
     1.8          MPWmake.sea.bin	\
     1.9  	CWprojects.sea.bin \
    1.10  	PBProjects.tar.gz \
     2.1 --- a/README.WinCE	Mon Aug 19 18:33:29 2002 +0000
     2.2 +++ b/README.WinCE	Tue Aug 20 00:20:06 2002 +0000
     2.3 @@ -1,8 +1,7 @@
     2.4 +
     2.5 +Project files for embedded Visual C++ 4.0 can be found in VisualCE.zip
     2.6  
     2.7  NOTE:
     2.8 -SDL is NOT SUPPORTED on the WinCE platform!  This is for experimental
     2.9 -purposes only.
    2.10 -
    2.11  There are several SDL features not available in the WinCE port of SDL.
    2.12  
    2.13  - DirectX is not yet available
     3.1 Binary file VisualCE.zip has changed
     4.1 --- a/include/SDL_main.h	Mon Aug 19 18:33:29 2002 +0000
     4.2 +++ b/include/SDL_main.h	Tue Aug 20 00:20:06 2002 +0000
     4.3 @@ -30,9 +30,10 @@
     4.4  
     4.5  /* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
     4.6  
     4.7 -#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \
     4.8 -    defined(macintosh) || defined(__APPLE__) || defined(__SYMBIAN32__) || \
     4.9 -    defined(QWS)
    4.10 +#if defined(WIN32) || defined(_WIN32) || \
    4.11 +    (defined(__MWERKS__) && !defined(__BEOS__)) || \
    4.12 +    defined(macintosh) || defined(__APPLE__) || \
    4.13 +    defined(__SYMBIAN32__) || defined(QWS)
    4.14  
    4.15  #ifdef __cplusplus
    4.16  #define C_LINKAGE	"C"
     5.1 --- a/src/audio/windx5/SDL_dx5audio.c	Mon Aug 19 18:33:29 2002 +0000
     5.2 +++ b/src/audio/windx5/SDL_dx5audio.c	Tue Aug 20 00:20:06 2002 +0000
     5.3 @@ -63,7 +63,7 @@
     5.4  
     5.5  	/* Version check DSOUND.DLL (Is DirectX okay?) */
     5.6  	dsound_ok = 0;
     5.7 -	DSoundDLL = LoadLibrary("DSOUND.DLL");
     5.8 +	DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
     5.9  	if ( DSoundDLL != NULL ) {
    5.10  		/* We just use basic DirectSound, we're okay */
    5.11  		/* Yay! */
    5.12 @@ -95,7 +95,7 @@
    5.13  		 * to fall back to the DIB driver. */
    5.14  		if (dsound_ok) {
    5.15  			/* DirectSoundCaptureCreate was added in DX5 */
    5.16 -			if (!GetProcAddress(DSoundDLL, "DirectSoundCaptureCreate"))
    5.17 +			if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate")))
    5.18  				dsound_ok = 0;
    5.19  
    5.20  		}
    5.21 @@ -121,10 +121,10 @@
    5.22  	int status;
    5.23  
    5.24  	DX5_Unload();
    5.25 -	DSoundDLL = LoadLibrary("DSOUND.DLL");
    5.26 +	DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
    5.27  	if ( DSoundDLL != NULL ) {
    5.28  		DSoundCreate = (void *)GetProcAddress(DSoundDLL,
    5.29 -					"DirectSoundCreate");
    5.30 +					TEXT("DirectSoundCreate"));
    5.31  	}
    5.32  	if ( DSoundDLL && DSoundCreate ) {
    5.33  		status = 0;
    5.34 @@ -189,7 +189,7 @@
    5.35  static void SetDSerror(const char *function, int code)
    5.36  {
    5.37  	static const char *error;
    5.38 -	static char  errbuf[BUFSIZ];
    5.39 +	static char  errbuf[1024];
    5.40  
    5.41  	errbuf[0] = 0;
    5.42  	switch (code) {
     6.1 --- a/src/main/win32/SDL_main.c	Mon Aug 19 18:33:29 2002 +0000
     6.2 +++ b/src/main/win32/SDL_main.c	Tue Aug 20 00:20:06 2002 +0000
     6.3 @@ -225,6 +225,9 @@
     6.4  
     6.5  	/* Exit cleanly, calling atexit() functions */
     6.6  	exit(0);
     6.7 +
     6.8 +	/* Hush little compiler, don't you cry... */
     6.9 +	return(0);
    6.10  }
    6.11  
    6.12  /* This is where execution begins [windowed apps] */
     7.1 --- a/src/timer/win32/SDL_systimer.c	Mon Aug 19 18:33:29 2002 +0000
     7.2 +++ b/src/timer/win32/SDL_systimer.c	Tue Aug 20 00:20:06 2002 +0000
     7.3 @@ -33,8 +33,8 @@
     7.4  #include "SDL_error.h"
     7.5  
     7.6  #ifdef _WIN32_WCE
     7.7 -#define USE_GETTICKCOUNT
     7.8 -#define USE_SETTIMER
     7.9 +//#define USE_GETTICKCOUNT
    7.10 +//#define USE_SETTIMER
    7.11  #endif
    7.12  
    7.13  #define TIME_WRAP_VALUE	(~(DWORD)0)
     8.1 --- a/src/video/SDL_sysvideo.h	Mon Aug 19 18:33:29 2002 +0000
     8.2 +++ b/src/video/SDL_sysvideo.h	Tue Aug 20 00:20:06 2002 +0000
     8.3 @@ -42,6 +42,7 @@
     8.4  #ifndef _WIN32_WCE
     8.5  #define HAVE_OPENGL
     8.6  #endif
     8.7 +#define WIN32_LEAN_AND_MEAN
     8.8  #include <windows.h>
     8.9  #endif
    8.10  
     9.1 --- a/src/video/wincommon/SDL_lowvideo.h	Mon Aug 19 18:33:29 2002 +0000
     9.2 +++ b/src/video/wincommon/SDL_lowvideo.h	Tue Aug 20 00:20:06 2002 +0000
     9.3 @@ -53,7 +53,11 @@
     9.4  #define DINPUT_FULLSCREEN()	DDRAW_FULLSCREEN()
     9.5  
     9.6  /* The main window -- and a function to set it for the audio */
     9.7 -extern const char *SDL_Appname;
     9.8 +#ifdef _WIN32_WCE
     9.9 +extern LPWSTR SDL_Appname;
    9.10 +#else
    9.11 +extern LPSTR SDL_Appname;
    9.12 +#endif
    9.13  extern HINSTANCE SDL_Instance;
    9.14  extern HWND SDL_Window;
    9.15  extern const char *SDL_windowid;
    10.1 --- a/src/video/wincommon/SDL_sysevents.c	Mon Aug 19 18:33:29 2002 +0000
    10.2 +++ b/src/video/wincommon/SDL_sysevents.c	Tue Aug 20 00:20:06 2002 +0000
    10.3 @@ -47,10 +47,15 @@
    10.4  
    10.5  #ifdef _WIN32_WCE
    10.6  #define NO_GETKEYBOARDSTATE
    10.7 +#define NO_CHANGEDISPLAYSETTINGS
    10.8  #endif
    10.9  
   10.10  /* The window we use for everything... */
   10.11 -const char *SDL_Appname = NULL;
   10.12 +#ifdef _WIN32_WCE
   10.13 +LPWSTR SDL_Appname = NULL;
   10.14 +#else
   10.15 +LPSTR SDL_Appname = NULL;
   10.16 +#endif
   10.17  HINSTANCE SDL_Instance = NULL;
   10.18  HWND SDL_Window = NULL;
   10.19  RECT SDL_bounds = {0, 0, 0, 0};
   10.20 @@ -578,21 +583,22 @@
   10.21  	class.hCursor		= NULL;
   10.22  #ifdef _WIN32_WCE
   10.23      {
   10.24 -	/* WinCE uses the UNICODE version */
   10.25 -	int nLen = strlen(name)+1;
   10.26 -	LPWSTR lpszW = alloca(nLen*2);
   10.27 -	MultiByteToWideChar(CP_ACP, 0, name, -1, lpszW, nLen);
   10.28 -	class.hIcon		= LoadImage(hInst, lpszW, IMAGE_ICON,
   10.29 +		/* WinCE uses the UNICODE version */
   10.30 +		int nLen = strlen(name)+1;
   10.31 +		SDL_Appname = malloc(nLen*2);
   10.32 +		MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
   10.33 +    }
   10.34 +#else
   10.35 +	{
   10.36 +		int nLen = strlen(name)+1;
   10.37 +		SDL_Appname = malloc(nLen);
   10.38 +		strcpy(SDL_Appname, name);
   10.39 +	}
   10.40 +#endif /* _WIN32_WCE */
   10.41 +	class.hIcon		= LoadImage(hInst, SDL_Appname, IMAGE_ICON,
   10.42  	                                    0, 0, LR_DEFAULTCOLOR);
   10.43  	class.lpszMenuName	= NULL;
   10.44 -	class.lpszClassName	= lpszW;
   10.45 -    }
   10.46 -#else
   10.47 -	class.hIcon		= LoadImage(hInst, name, IMAGE_ICON,
   10.48 -	                                    0, 0, LR_DEFAULTCOLOR);
   10.49 -	class.lpszMenuName	= "(none)";
   10.50 -	class.lpszClassName	= name;
   10.51 -#endif /* _WIN32_WCE */
   10.52 +	class.lpszClassName	= SDL_Appname;
   10.53  	class.hbrBackground	= NULL;
   10.54  	class.hInstance		= hInst;
   10.55  	class.style		= style;
   10.56 @@ -606,7 +612,6 @@
   10.57  		SDL_SetError("Couldn't register application class");
   10.58  		return(-1);
   10.59  	}
   10.60 -	SDL_Appname = name;
   10.61  	SDL_Instance = hInst;
   10.62  
   10.63  #ifdef WM_MOUSELEAVE
    11.1 --- a/src/video/wincommon/SDL_wingl.c	Mon Aug 19 18:33:29 2002 +0000
    11.2 +++ b/src/video/wincommon/SDL_wingl.c	Tue Aug 20 00:20:06 2002 +0000
    11.3 @@ -27,7 +27,9 @@
    11.4  
    11.5  /* WGL implementation of SDL OpenGL support */
    11.6  
    11.7 +#ifdef HAVE_OPENGL
    11.8  #include "SDL_opengl.h"
    11.9 +#endif
   11.10  #include "SDL_error.h"
   11.11  #include "SDL_lowvideo.h"
   11.12  #include "SDL_wingl_c.h"
   11.13 @@ -264,10 +266,6 @@
   11.14  	SwapBuffers(GL_hdc);
   11.15  }
   11.16  
   11.17 -#endif /* HAVE_OPENGL */
   11.18 -
   11.19 -#ifdef HAVE_OPENGL
   11.20 -
   11.21  void WIN_GL_UnloadLibrary(_THIS)
   11.22  {
   11.23  	if ( this->gl_config.driver_loaded ) {
    12.1 --- a/src/video/windib/SDL_dibevents.c	Mon Aug 19 18:33:29 2002 +0000
    12.2 +++ b/src/video/windib/SDL_dibevents.c	Tue Aug 20 00:20:06 2002 +0000
    12.3 @@ -333,28 +333,9 @@
    12.4  
    12.5  int DIB_CreateWindow(_THIS)
    12.6  {
    12.7 -#ifdef _WIN32_WCE
    12.8 -	/* WinCE uses the UNICODE version */
    12.9 -	int nLen;
   12.10 -	LPWSTR lpszW;
   12.11 -
   12.12 -	if ( SDL_RegisterApp("SDL_app", 0, 0) != 0 ) {
   12.13 -		return -1;
   12.14 -	}
   12.15 -
   12.16 -	nLen = strlen(SDL_Appname) + 1;
   12.17 -	lpszW = alloca(nLen * 2);
   12.18 -
   12.19 -	MultiByteToWideChar(CP_ACP, 0, "SDL_App", -1, lpszW, nLen);
   12.20 -
   12.21 -	SDL_Window = CreateWindow(lpszW, lpszW, WS_VISIBLE,
   12.22 -                                  0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
   12.23 -	if ( SDL_Window == NULL ) {
   12.24 -		SDL_SetError("Couldn't create window");
   12.25 -		return(-1);
   12.26 -	}
   12.27 -	ShowWindow(SDL_Window, SW_HIDE);
   12.28 -#else
   12.29 +#ifndef CS_BYTEALIGNCLIENT
   12.30 +#define CS_BYTEALIGNCLIENT	0
   12.31 +#endif
   12.32  	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
   12.33  	if ( SDL_windowid ) {
   12.34  		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
   12.35 @@ -376,8 +357,6 @@
   12.36  		}
   12.37  		ShowWindow(SDL_Window, SW_HIDE);
   12.38  	}
   12.39 -#endif /* _WIN32_WCE */
   12.40 -
   12.41  	return(0);
   12.42  }
   12.43  
    13.1 --- a/src/video/windib/SDL_dibvideo.c	Mon Aug 19 18:33:29 2002 +0000
    13.2 +++ b/src/video/windib/SDL_dibvideo.c	Tue Aug 20 00:20:06 2002 +0000
    13.3 @@ -53,6 +53,15 @@
    13.4  #define NO_CHANGEDISPLAYSETTINGS
    13.5  #define NO_GAMMA_SUPPORT
    13.6  #endif
    13.7 +#ifndef WS_MAXIMIZE
    13.8 +#define WS_MAXIMIZE		0
    13.9 +#endif
   13.10 +#ifndef SWP_NOCOPYBITS
   13.11 +#define SWP_NOCOPYBITS	0
   13.12 +#endif
   13.13 +#ifndef PC_NOCOLLAPSE
   13.14 +#define PC_NOCOLLAPSE	0
   13.15 +#endif
   13.16  
   13.17  /* Initialization/Query functions */
   13.18  static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat);
   13.19 @@ -143,11 +152,11 @@
   13.20  	device->SetGammaRamp = DIB_SetGammaRamp;
   13.21  	device->GetGammaRamp = DIB_GetGammaRamp;
   13.22  #ifdef HAVE_OPENGL
   13.23 -        device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   13.24 -        device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   13.25 -        device->GL_GetAttribute = WIN_GL_GetAttribute;
   13.26 -        device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   13.27 -        device->GL_SwapBuffers = WIN_GL_SwapBuffers;
   13.28 +	device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   13.29 +	device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   13.30 +	device->GL_GetAttribute = WIN_GL_GetAttribute;
   13.31 +	device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   13.32 +	device->GL_SwapBuffers = WIN_GL_SwapBuffers;
   13.33  #endif
   13.34  	device->SetCaption = WIN_SetWMCaption;
   13.35  	device->SetIcon = WIN_SetWMIcon;
   13.36 @@ -440,10 +449,8 @@
   13.37  			(WS_POPUP);
   13.38  	const DWORD windowstyle = 
   13.39  			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
   13.40 -#ifndef _WIN32_WCE
   13.41  	const DWORD resizestyle =
   13.42  			(WS_THICKFRAME|WS_MAXIMIZEBOX);
   13.43 -#endif
   13.44  	int binfo_size;
   13.45  	BITMAPINFO *binfo;
   13.46  	HDC hdc;
   13.47 @@ -455,12 +462,10 @@
   13.48  	/* See whether or not we should center the window */
   13.49  	was_visible = IsWindowVisible(SDL_Window);
   13.50  
   13.51 -#ifdef HAVE_OPENGL
   13.52  	/* Clean up any GL context that may be hanging around */
   13.53  	if ( current->flags & SDL_OPENGL ) {
   13.54  		WIN_GL_ShutDown(this);
   13.55  	}
   13.56 -#endif /* HAVE_OPENGL */
   13.57  
   13.58  	/* Recalculate the bitmasks if necessary */
   13.59  	if ( bpp == current->format->BitsPerPixel ) {
   13.60 @@ -542,9 +547,7 @@
   13.61  	}
   13.62  
   13.63  	style = GetWindowLong(SDL_Window, GWL_STYLE);
   13.64 -#ifndef _WIN32_WCE
   13.65  	style &= ~(resizestyle|WS_MAXIMIZE);
   13.66 -#endif
   13.67  	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
   13.68  		style &= ~windowstyle;
   13.69  		style |= directstyle;
   13.70 @@ -562,13 +565,11 @@
   13.71  			style &= ~directstyle;
   13.72  			style |= windowstyle;
   13.73  			if ( flags & SDL_RESIZABLE ) {
   13.74 -#ifndef _WIN32_WCE
   13.75  				style |= resizestyle;
   13.76 -#endif
   13.77  				video->flags |= SDL_RESIZABLE;
   13.78  			}
   13.79  		}
   13.80 -#ifndef _WIN32_WCE
   13.81 +#if WS_MAXIMIZE
   13.82  		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
   13.83  #endif
   13.84  	}
   13.85 @@ -659,11 +660,7 @@
   13.86  		bounds.top = 0;
   13.87  		bounds.right = video->w;
   13.88  		bounds.bottom = video->h;
   13.89 -#ifndef _WIN32_WCE
   13.90 -		AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
   13.91 -#else
   13.92 -		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE,0);
   13.93 -#endif
   13.94 +		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
   13.95  		width = bounds.right-bounds.left;
   13.96  		height = bounds.bottom-bounds.top;
   13.97  		x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
   13.98 @@ -671,11 +668,7 @@
   13.99  		if ( y < 0 ) { /* Cover up title bar for more client area */
  13.100  			y -= GetSystemMetrics(SM_CYCAPTION)/2;
  13.101  		}
  13.102 -#ifndef _WIN32_WCE
  13.103  		swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
  13.104 -#else
  13.105 -		swp_flags = (SWP_FRAMECHANGED | SWP_SHOWWINDOW);
  13.106 -#endif
  13.107  		if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
  13.108  			swp_flags |= SWP_NOMOVE;
  13.109  		}
  13.110 @@ -689,7 +682,6 @@
  13.111  		SetForegroundWindow(SDL_Window);
  13.112  	}
  13.113  
  13.114 -#ifdef HAVE_OPENGL
  13.115  	/* Set up for OpenGL */
  13.116  	if ( flags & SDL_OPENGL ) {
  13.117  		if ( WIN_GL_SetupWindow(this) < 0 ) {
  13.118 @@ -697,7 +689,6 @@
  13.119  		}
  13.120  		video->flags |= SDL_OPENGL;
  13.121  	}
  13.122 -#endif /* HAVE_OPENGL */
  13.123  
  13.124  	/* We're live! */
  13.125  	return(video);
  13.126 @@ -760,11 +751,7 @@
  13.127  			entries[i].peRed   = colors[i].r;
  13.128  			entries[i].peGreen = colors[i].g;
  13.129  			entries[i].peBlue  = colors[i].b;
  13.130 -#ifndef _WIN32_WCE
  13.131  			entries[i].peFlags = PC_NOCOLLAPSE;
  13.132 -#else
  13.133 -			entries[i].peFlags = 0;
  13.134 -#endif
  13.135  		}
  13.136  		SetPaletteEntries(screen_pal, firstcolor, ncolors, entries);
  13.137  		SelectPalette(hdc, screen_pal, FALSE);
  13.138 @@ -917,11 +904,9 @@
  13.139  				ShowWindow(SDL_Window, SW_HIDE);
  13.140  			}
  13.141  #endif
  13.142 -#ifdef HAVE_OPENGL
  13.143  			if ( this->screen->flags & SDL_OPENGL ) {
  13.144  				WIN_GL_ShutDown(this);
  13.145  			}
  13.146 -#endif /* HAVE_OPENGL */
  13.147  			this->screen->pixels = NULL;
  13.148  		}
  13.149  		if ( screen_bmp ) {
    14.1 --- a/src/video/windx5/SDL_dx5events.c	Mon Aug 19 18:33:29 2002 +0000
    14.2 +++ b/src/video/windx5/SDL_dx5events.c	Tue Aug 20 00:20:06 2002 +0000
    14.3 @@ -43,6 +43,10 @@
    14.4  #define WM_APP	0x8000
    14.5  #endif
    14.6  
    14.7 +#ifdef _WIN32_WCE
    14.8 +#define NO_GETKEYBOARDSTATE
    14.9 +#endif
   14.10 +
   14.11  /* The keyboard and mouse device input */
   14.12  #define MAX_INPUTS	16		/* Maximum of 16-1 input devices */
   14.13  #define INPUT_QSIZE	32		/* Buffer up to 32 input messages */
   14.14 @@ -67,7 +71,7 @@
   14.15  static void SetDIerror(char *function, int code)
   14.16  {
   14.17  	static char *error;
   14.18 -	static char  errbuf[BUFSIZ];
   14.19 +	static char  errbuf[1024];
   14.20  
   14.21  	errbuf[0] = 0;
   14.22  	switch (code) {
   14.23 @@ -449,6 +453,7 @@
   14.24   DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
   14.25  {
   14.26  	switch (msg) {
   14.27 +#ifdef WM_ACTIVATEAPP
   14.28  		case WM_ACTIVATEAPP: {
   14.29  			int i, active;
   14.30  
   14.31 @@ -467,7 +472,9 @@
   14.32  			}
   14.33  		}
   14.34  		break;
   14.35 +#endif /* WM_ACTIVATEAPP */
   14.36  
   14.37 +#ifdef WM_DISPLAYCHANGE
   14.38  		case WM_DISPLAYCHANGE: {
   14.39  			WORD BitsPerPixel;
   14.40  			WORD SizeX, SizeY;
   14.41 @@ -479,6 +486,7 @@
   14.42  			/* We cause this message when we go fullscreen */
   14.43  		}
   14.44  		break;
   14.45 +#endif /* WM_DISPLAYCHANGE */
   14.46  
   14.47  		/* The keyboard is handled via DirectInput */
   14.48  		case WM_SYSKEYUP:
   14.49 @@ -489,6 +497,7 @@
   14.50  		}
   14.51  		return(0);
   14.52  
   14.53 +#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
   14.54  		/* Don't allow screen savers or monitor power downs.
   14.55  		   This is because they quietly clear DirectX surfaces.
   14.56  		   It would be better to allow the application to
   14.57 @@ -501,11 +510,11 @@
   14.58  			    (wParam&0xFFF0)==SC_MONITORPOWER)
   14.59  				return(0);
   14.60  		}
   14.61 -		goto custom_processing;
   14.62 -		break;
   14.63 +		/* Fall through to default processing */
   14.64 +
   14.65 +#endif /* SC_SCREENSAVE || SC_MONITORPOWER */
   14.66  
   14.67  		default: {
   14.68 -		custom_processing:
   14.69  			/* Only post the event if we're watching for it */
   14.70  			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
   14.71  			        SDL_SysWMmsg wmmsg;
   14.72 @@ -759,14 +768,21 @@
   14.73  	keysym->unicode = 0;
   14.74  	if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
   14.75  		UINT vkey;
   14.76 +#ifndef NO_GETKEYBOARDSTATE
   14.77  		BYTE keystate[256];
   14.78  		BYTE chars[2];
   14.79 +#endif
   14.80  
   14.81  		vkey = MapVirtualKey(scancode, 1);
   14.82 +#ifdef NO_GETKEYBOARDSTATE
   14.83 +		/* Uh oh, better hope the vkey is close enough.. */
   14.84 +		keysym->unicode = vkey;
   14.85 +#else
   14.86  		GetKeyboardState(keystate);
   14.87  		if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
   14.88  			keysym->unicode = chars[0];
   14.89  		}
   14.90 +#endif
   14.91  	}
   14.92  	return(keysym);
   14.93  }
   14.94 @@ -782,7 +798,9 @@
   14.95  		SDL_DIfun[i] = NULL;
   14.96  	}
   14.97  
   14.98 -	/* Create the SDL window */
   14.99 +#ifndef CS_BYTEALIGNCLIENT
  14.100 +#define CS_BYTEALIGNCLIENT	0
  14.101 +#endif
  14.102  	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
  14.103  	if ( SDL_windowid ) {
  14.104  		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
    15.1 --- a/src/video/windx5/SDL_dx5video.c	Mon Aug 19 18:33:29 2002 +0000
    15.2 +++ b/src/video/windx5/SDL_dx5video.c	Tue Aug 20 00:20:06 2002 +0000
    15.3 @@ -51,10 +51,23 @@
    15.4  #include "SDL_dx5yuv_c.h"
    15.5  #include "SDL_wingl_c.h"
    15.6  
    15.7 +#ifdef _WIN32_WCE
    15.8 +#define NO_CHANGEDISPLAYSETTINGS
    15.9 +#endif
   15.10 +#ifndef WS_MAXIMIZE
   15.11 +#define WS_MAXIMIZE		0
   15.12 +#endif
   15.13 +#ifndef SWP_NOCOPYBITS
   15.14 +#define SWP_NOCOPYBITS	0
   15.15 +#endif
   15.16 +#ifndef PC_NOCOLLAPSE
   15.17 +#define PC_NOCOLLAPSE	0
   15.18 +#endif
   15.19 +
   15.20  
   15.21  /* DirectX function pointers for video and events */
   15.22  HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
   15.23 -HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);
   15.24 +HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter);
   15.25  
   15.26  /* This is the rect EnumModes2 uses */
   15.27  struct DX5EnumRect {
   15.28 @@ -443,19 +456,19 @@
   15.29  
   15.30  	/* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */
   15.31  	dinput_ok = 0;
   15.32 -	DInputDLL = LoadLibrary("DINPUT.DLL");
   15.33 +	DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
   15.34  	if ( DInputDLL != NULL ) {
   15.35  		dinput_ok = 1;
   15.36  	  	FreeLibrary(DInputDLL);
   15.37  	}
   15.38  	ddraw_ok = 0;
   15.39 -	DDrawDLL = LoadLibrary("DDRAW.DLL");
   15.40 +	DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
   15.41  	if ( DDrawDLL != NULL ) {
   15.42  	  HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *);
   15.43  	  LPDIRECTDRAW DDraw;
   15.44  
   15.45  	  /* Try to create a valid DirectDraw object */
   15.46 -	  DDrawCreate = (void *)GetProcAddress(DDrawDLL, "DirectDrawCreate");
   15.47 +	  DDrawCreate = (void *)GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate"));
   15.48  	  if ( (DDrawCreate != NULL)
   15.49  			&& !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) {
   15.50  	    if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw,
   15.51 @@ -511,15 +524,15 @@
   15.52  	int status;
   15.53  
   15.54  	DX5_Unload();
   15.55 -	DDrawDLL = LoadLibrary("DDRAW.DLL");
   15.56 +	DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
   15.57  	if ( DDrawDLL != NULL ) {
   15.58  		DDrawCreate = (void *)GetProcAddress(DDrawDLL,
   15.59 -					"DirectDrawCreate");
   15.60 +					TEXT("DirectDrawCreate"));
   15.61  	}
   15.62 -	DInputDLL = LoadLibrary("DINPUT.DLL");
   15.63 +	DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
   15.64  	if ( DInputDLL != NULL ) {
   15.65  		DInputCreate = (void *)GetProcAddress(DInputDLL,
   15.66 -					"DirectInputCreateA");
   15.67 +					TEXT("DirectInputCreateA"));
   15.68  	}
   15.69  	if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) {
   15.70  		status = 0;
   15.71 @@ -596,11 +609,11 @@
   15.72  	device->SetGammaRamp = DX5_SetGammaRamp;
   15.73  	device->GetGammaRamp = DX5_GetGammaRamp;
   15.74  #ifdef HAVE_OPENGL
   15.75 -        device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   15.76 -        device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   15.77 -        device->GL_GetAttribute = WIN_GL_GetAttribute;
   15.78 -        device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   15.79 -        device->GL_SwapBuffers = WIN_GL_SwapBuffers;
   15.80 +	device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   15.81 +	device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   15.82 +	device->GL_GetAttribute = WIN_GL_GetAttribute;
   15.83 +	device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   15.84 +	device->GL_SwapBuffers = WIN_GL_SwapBuffers;
   15.85  #endif
   15.86  	device->SetCaption = WIN_SetWMCaption;
   15.87  	device->SetIcon = WIN_SetWMIcon;
   15.88 @@ -670,7 +683,7 @@
   15.89  void SetDDerror(const char *function, int code)
   15.90  {
   15.91  	static char *error;
   15.92 -	static char  errbuf[BUFSIZ];
   15.93 +	static char  errbuf[1024];
   15.94  
   15.95  	errbuf[0] = 0;
   15.96  	switch (code) {
   15.97 @@ -994,11 +1007,13 @@
   15.98  		SDL_primary = NULL;
   15.99  	}
  15.100  
  15.101 +#ifndef NO_CHANGEDISPLAYSETTINGS
  15.102  	/* Unset any previous OpenGL fullscreen mode */
  15.103  	if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
  15.104  	                       (SDL_OPENGL|SDL_FULLSCREEN) ) {
  15.105  		ChangeDisplaySettings(NULL, 0);
  15.106  	}
  15.107 +#endif
  15.108  
  15.109  	/* Clean up any GL context that may be hanging around */
  15.110  	if ( current->flags & SDL_OPENGL ) {
  15.111 @@ -1057,6 +1072,7 @@
  15.112  		video->h = height;
  15.113  		video->pitch = SDL_CalculatePitch(video);
  15.114  
  15.115 +#ifndef NO_CHANGEDISPLAYSETTINGS
  15.116  		/* Set fullscreen mode if appropriate.
  15.117  		   Ugh, since our list of valid video modes comes from
  15.118  		   the DirectX driver, we may not actually be able to
  15.119 @@ -1077,6 +1093,7 @@
  15.120  				SDL_fullscreen_mode = settings;
  15.121  			}
  15.122  		}
  15.123 +#endif /* !NO_CHANGEDISPLAYSETTINGS */
  15.124  
  15.125  		style = GetWindowLong(SDL_Window, GWL_STYLE);
  15.126  		style &= ~(resizestyle|WS_MAXIMIZE);
  15.127 @@ -1096,7 +1113,9 @@
  15.128  					video->flags |= SDL_RESIZABLE;
  15.129  				}
  15.130  			}
  15.131 +#if WS_MAXIMIZE
  15.132  			if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
  15.133 +#endif
  15.134  		}
  15.135  		SetWindowLong(SDL_Window, GWL_STYLE, style);
  15.136  
  15.137 @@ -1110,7 +1129,7 @@
  15.138  			bounds.top = 0;
  15.139  			bounds.right = video->w;
  15.140  			bounds.bottom = video->h;
  15.141 -			AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
  15.142 +			AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
  15.143  			width = bounds.right-bounds.left;
  15.144  			height = bounds.bottom-bounds.top;
  15.145  			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
  15.146 @@ -1157,7 +1176,9 @@
  15.147  				style |= resizestyle;
  15.148  			}
  15.149  		}
  15.150 +#if WS_MAXIMIZE
  15.151  		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
  15.152 +#endif
  15.153  	}
  15.154  	SetWindowLong(SDL_Window, GWL_STYLE, style);
  15.155  
  15.156 @@ -1466,8 +1487,7 @@
  15.157  		bounds.top = 0;
  15.158  		bounds.right = video->w;
  15.159  		bounds.bottom = video->h;
  15.160 -		AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE),
  15.161 -									FALSE);
  15.162 +		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
  15.163  		width = bounds.right-bounds.left;
  15.164  		height = bounds.bottom-bounds.top;
  15.165  		x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
  15.166 @@ -2235,11 +2255,13 @@
  15.167  
  15.168  	/* If we're fullscreen GL, we need to reset the display */
  15.169  	if ( this->screen != NULL ) {
  15.170 +#ifndef NO_CHANGEDISPLAYSETTINGS
  15.171  		if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
  15.172  		                            (SDL_OPENGL|SDL_FULLSCREEN) ) {
  15.173  			ChangeDisplaySettings(NULL, 0);
  15.174  			ShowWindow(SDL_Window, SW_HIDE);
  15.175  		}
  15.176 +#endif
  15.177  		if ( this->screen->flags & SDL_OPENGL ) {
  15.178  			WIN_GL_ShutDown(this);
  15.179  		}
    16.1 --- a/src/video/windx5/SDL_dx5video.h	Mon Aug 19 18:33:29 2002 +0000
    16.2 +++ b/src/video/windx5/SDL_dx5video.h	Tue Aug 20 00:20:06 2002 +0000
    16.3 @@ -57,7 +57,7 @@
    16.4  
    16.5  /* DirectX function pointers for video and events */
    16.6  extern HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
    16.7 -extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);
    16.8 +extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter);
    16.9  
   16.10  /* DirectDraw error reporting function */
   16.11  extern void SetDDerror(const char *function, int code);