Commit a3897183 authored by Sam Lantinga's avatar Sam Lantinga

Updated for embedded Visual C++ 4.0

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40454
parent a1233598
...@@ -39,6 +39,7 @@ EXTRA_DIST = \ ...@@ -39,6 +39,7 @@ EXTRA_DIST = \
Borland.zip \ Borland.zip \
VisualC.html \ VisualC.html \
VisualC.zip \ VisualC.zip \
VisualCE.zip \
MPWmake.sea.bin \ MPWmake.sea.bin \
CWprojects.sea.bin \ CWprojects.sea.bin \
PBProjects.tar.gz \ PBProjects.tar.gz \
......
NOTE: Project files for embedded Visual C++ 4.0 can be found in VisualCE.zip
SDL is NOT SUPPORTED on the WinCE platform! This is for experimental
purposes only.
NOTE:
There are several SDL features not available in the WinCE port of SDL. There are several SDL features not available in the WinCE port of SDL.
- DirectX is not yet available - DirectX is not yet available
......
File added
...@@ -30,9 +30,10 @@ static char rcsid = ...@@ -30,9 +30,10 @@ static char rcsid =
/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */ /* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \ #if defined(WIN32) || defined(_WIN32) || \
defined(macintosh) || defined(__APPLE__) || defined(__SYMBIAN32__) || \ (defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(QWS) defined(macintosh) || defined(__APPLE__) || \
defined(__SYMBIAN32__) || defined(QWS)
#ifdef __cplusplus #ifdef __cplusplus
#define C_LINKAGE "C" #define C_LINKAGE "C"
......
...@@ -63,7 +63,7 @@ static int Audio_Available(void) ...@@ -63,7 +63,7 @@ static int Audio_Available(void)
/* Version check DSOUND.DLL (Is DirectX okay?) */ /* Version check DSOUND.DLL (Is DirectX okay?) */
dsound_ok = 0; dsound_ok = 0;
DSoundDLL = LoadLibrary("DSOUND.DLL"); DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
if ( DSoundDLL != NULL ) { if ( DSoundDLL != NULL ) {
/* We just use basic DirectSound, we're okay */ /* We just use basic DirectSound, we're okay */
/* Yay! */ /* Yay! */
...@@ -95,7 +95,7 @@ static int Audio_Available(void) ...@@ -95,7 +95,7 @@ static int Audio_Available(void)
* to fall back to the DIB driver. */ * to fall back to the DIB driver. */
if (dsound_ok) { if (dsound_ok) {
/* DirectSoundCaptureCreate was added in DX5 */ /* DirectSoundCaptureCreate was added in DX5 */
if (!GetProcAddress(DSoundDLL, "DirectSoundCaptureCreate")) if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate")))
dsound_ok = 0; dsound_ok = 0;
} }
...@@ -121,10 +121,10 @@ static int DX5_Load(void) ...@@ -121,10 +121,10 @@ static int DX5_Load(void)
int status; int status;
DX5_Unload(); DX5_Unload();
DSoundDLL = LoadLibrary("DSOUND.DLL"); DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
if ( DSoundDLL != NULL ) { if ( DSoundDLL != NULL ) {
DSoundCreate = (void *)GetProcAddress(DSoundDLL, DSoundCreate = (void *)GetProcAddress(DSoundDLL,
"DirectSoundCreate"); TEXT("DirectSoundCreate"));
} }
if ( DSoundDLL && DSoundCreate ) { if ( DSoundDLL && DSoundCreate ) {
status = 0; status = 0;
...@@ -189,7 +189,7 @@ AudioBootStrap DSOUND_bootstrap = { ...@@ -189,7 +189,7 @@ AudioBootStrap DSOUND_bootstrap = {
static void SetDSerror(const char *function, int code) static void SetDSerror(const char *function, int code)
{ {
static const char *error; static const char *error;
static char errbuf[BUFSIZ]; static char errbuf[1024];
errbuf[0] = 0; errbuf[0] = 0;
switch (code) { switch (code) {
......
...@@ -225,6 +225,9 @@ int console_main(int argc, char *argv[]) ...@@ -225,6 +225,9 @@ int console_main(int argc, char *argv[])
/* Exit cleanly, calling atexit() functions */ /* Exit cleanly, calling atexit() functions */
exit(0); exit(0);
/* Hush little compiler, don't you cry... */
return(0);
} }
/* This is where execution begins [windowed apps] */ /* This is where execution begins [windowed apps] */
......
...@@ -33,8 +33,8 @@ static char rcsid = ...@@ -33,8 +33,8 @@ static char rcsid =
#include "SDL_error.h" #include "SDL_error.h"
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
#define USE_GETTICKCOUNT //#define USE_GETTICKCOUNT
#define USE_SETTIMER //#define USE_SETTIMER
#endif #endif
#define TIME_WRAP_VALUE (~(DWORD)0) #define TIME_WRAP_VALUE (~(DWORD)0)
......
...@@ -42,6 +42,7 @@ static char rcsid = ...@@ -42,6 +42,7 @@ static char rcsid =
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
#define HAVE_OPENGL #define HAVE_OPENGL
#endif #endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#endif #endif
......
...@@ -53,7 +53,11 @@ static char rcsid = ...@@ -53,7 +53,11 @@ static char rcsid =
#define DINPUT_FULLSCREEN() DDRAW_FULLSCREEN() #define DINPUT_FULLSCREEN() DDRAW_FULLSCREEN()
/* The main window -- and a function to set it for the audio */ /* The main window -- and a function to set it for the audio */
extern const char *SDL_Appname; #ifdef _WIN32_WCE
extern LPWSTR SDL_Appname;
#else
extern LPSTR SDL_Appname;
#endif
extern HINSTANCE SDL_Instance; extern HINSTANCE SDL_Instance;
extern HWND SDL_Window; extern HWND SDL_Window;
extern const char *SDL_windowid; extern const char *SDL_windowid;
......
...@@ -47,10 +47,15 @@ static char rcsid = ...@@ -47,10 +47,15 @@ static char rcsid =
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
#define NO_GETKEYBOARDSTATE #define NO_GETKEYBOARDSTATE
#define NO_CHANGEDISPLAYSETTINGS
#endif #endif
/* The window we use for everything... */ /* The window we use for everything... */
const char *SDL_Appname = NULL; #ifdef _WIN32_WCE
LPWSTR SDL_Appname = NULL;
#else
LPSTR SDL_Appname = NULL;
#endif
HINSTANCE SDL_Instance = NULL; HINSTANCE SDL_Instance = NULL;
HWND SDL_Window = NULL; HWND SDL_Window = NULL;
RECT SDL_bounds = {0, 0, 0, 0}; RECT SDL_bounds = {0, 0, 0, 0};
...@@ -580,19 +585,20 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst) ...@@ -580,19 +585,20 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
{ {
/* WinCE uses the UNICODE version */ /* WinCE uses the UNICODE version */
int nLen = strlen(name)+1; int nLen = strlen(name)+1;
LPWSTR lpszW = alloca(nLen*2); SDL_Appname = malloc(nLen*2);
MultiByteToWideChar(CP_ACP, 0, name, -1, lpszW, nLen); MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
class.hIcon = LoadImage(hInst, lpszW, IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
class.lpszMenuName = NULL;
class.lpszClassName = lpszW;
} }
#else #else
class.hIcon = LoadImage(hInst, name, IMAGE_ICON, {
0, 0, LR_DEFAULTCOLOR); int nLen = strlen(name)+1;
class.lpszMenuName = "(none)"; SDL_Appname = malloc(nLen);
class.lpszClassName = name; strcpy(SDL_Appname, name);
}
#endif /* _WIN32_WCE */ #endif /* _WIN32_WCE */
class.hIcon = LoadImage(hInst, SDL_Appname, IMAGE_ICON,
0, 0, LR_DEFAULTCOLOR);
class.lpszMenuName = NULL;
class.lpszClassName = SDL_Appname;
class.hbrBackground = NULL; class.hbrBackground = NULL;
class.hInstance = hInst; class.hInstance = hInst;
class.style = style; class.style = style;
...@@ -606,7 +612,6 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst) ...@@ -606,7 +612,6 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
SDL_SetError("Couldn't register application class"); SDL_SetError("Couldn't register application class");
return(-1); return(-1);
} }
SDL_Appname = name;
SDL_Instance = hInst; SDL_Instance = hInst;
#ifdef WM_MOUSELEAVE #ifdef WM_MOUSELEAVE
......
...@@ -27,7 +27,9 @@ static char rcsid = ...@@ -27,7 +27,9 @@ static char rcsid =
/* WGL implementation of SDL OpenGL support */ /* WGL implementation of SDL OpenGL support */
#ifdef HAVE_OPENGL
#include "SDL_opengl.h" #include "SDL_opengl.h"
#endif
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_lowvideo.h" #include "SDL_lowvideo.h"
#include "SDL_wingl_c.h" #include "SDL_wingl_c.h"
...@@ -264,10 +266,6 @@ void WIN_GL_SwapBuffers(_THIS) ...@@ -264,10 +266,6 @@ void WIN_GL_SwapBuffers(_THIS)
SwapBuffers(GL_hdc); SwapBuffers(GL_hdc);
} }
#endif /* HAVE_OPENGL */
#ifdef HAVE_OPENGL
void WIN_GL_UnloadLibrary(_THIS) void WIN_GL_UnloadLibrary(_THIS)
{ {
if ( this->gl_config.driver_loaded ) { if ( this->gl_config.driver_loaded ) {
......
...@@ -333,28 +333,9 @@ static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, in ...@@ -333,28 +333,9 @@ static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, in
int DIB_CreateWindow(_THIS) int DIB_CreateWindow(_THIS)
{ {
#ifdef _WIN32_WCE #ifndef CS_BYTEALIGNCLIENT
/* WinCE uses the UNICODE version */ #define CS_BYTEALIGNCLIENT 0
int nLen; #endif
LPWSTR lpszW;
if ( SDL_RegisterApp("SDL_app", 0, 0) != 0 ) {
return -1;
}
nLen = strlen(SDL_Appname) + 1;
lpszW = alloca(nLen * 2);
MultiByteToWideChar(CP_ACP, 0, "SDL_App", -1, lpszW, nLen);
SDL_Window = CreateWindow(lpszW, lpszW, WS_VISIBLE,
0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't create window");
return(-1);
}
ShowWindow(SDL_Window, SW_HIDE);
#else
SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
if ( SDL_windowid ) { if ( SDL_windowid ) {
SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
...@@ -376,8 +357,6 @@ int DIB_CreateWindow(_THIS) ...@@ -376,8 +357,6 @@ int DIB_CreateWindow(_THIS)
} }
ShowWindow(SDL_Window, SW_HIDE); ShowWindow(SDL_Window, SW_HIDE);
} }
#endif /* _WIN32_WCE */
return(0); return(0);
} }
......
...@@ -53,6 +53,15 @@ static char rcsid = ...@@ -53,6 +53,15 @@ static char rcsid =
#define NO_CHANGEDISPLAYSETTINGS #define NO_CHANGEDISPLAYSETTINGS
#define NO_GAMMA_SUPPORT #define NO_GAMMA_SUPPORT
#endif #endif
#ifndef WS_MAXIMIZE
#define WS_MAXIMIZE 0
#endif
#ifndef SWP_NOCOPYBITS
#define SWP_NOCOPYBITS 0
#endif
#ifndef PC_NOCOLLAPSE
#define PC_NOCOLLAPSE 0
#endif
/* Initialization/Query functions */ /* Initialization/Query functions */
static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat); static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat);
...@@ -440,10 +449,8 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -440,10 +449,8 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
(WS_POPUP); (WS_POPUP);
const DWORD windowstyle = const DWORD windowstyle =
(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
#ifndef _WIN32_WCE
const DWORD resizestyle = const DWORD resizestyle =
(WS_THICKFRAME|WS_MAXIMIZEBOX); (WS_THICKFRAME|WS_MAXIMIZEBOX);
#endif
int binfo_size; int binfo_size;
BITMAPINFO *binfo; BITMAPINFO *binfo;
HDC hdc; HDC hdc;
...@@ -455,12 +462,10 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -455,12 +462,10 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
/* See whether or not we should center the window */ /* See whether or not we should center the window */
was_visible = IsWindowVisible(SDL_Window); was_visible = IsWindowVisible(SDL_Window);
#ifdef HAVE_OPENGL
/* Clean up any GL context that may be hanging around */ /* Clean up any GL context that may be hanging around */
if ( current->flags & SDL_OPENGL ) { if ( current->flags & SDL_OPENGL ) {
WIN_GL_ShutDown(this); WIN_GL_ShutDown(this);
} }
#endif /* HAVE_OPENGL */
/* Recalculate the bitmasks if necessary */ /* Recalculate the bitmasks if necessary */
if ( bpp == current->format->BitsPerPixel ) { if ( bpp == current->format->BitsPerPixel ) {
...@@ -542,9 +547,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -542,9 +547,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
} }
style = GetWindowLong(SDL_Window, GWL_STYLE); style = GetWindowLong(SDL_Window, GWL_STYLE);
#ifndef _WIN32_WCE
style &= ~(resizestyle|WS_MAXIMIZE); style &= ~(resizestyle|WS_MAXIMIZE);
#endif
if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
style &= ~windowstyle; style &= ~windowstyle;
style |= directstyle; style |= directstyle;
...@@ -562,13 +565,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -562,13 +565,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
style &= ~directstyle; style &= ~directstyle;
style |= windowstyle; style |= windowstyle;
if ( flags & SDL_RESIZABLE ) { if ( flags & SDL_RESIZABLE ) {
#ifndef _WIN32_WCE
style |= resizestyle; style |= resizestyle;
#endif
video->flags |= SDL_RESIZABLE; video->flags |= SDL_RESIZABLE;
} }
} }
#ifndef _WIN32_WCE #if WS_MAXIMIZE
if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif #endif
} }
...@@ -659,11 +660,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -659,11 +660,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
bounds.top = 0; bounds.top = 0;
bounds.right = video->w; bounds.right = video->w;
bounds.bottom = video->h; bounds.bottom = video->h;
#ifndef _WIN32_WCE AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
#else
AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE,0);
#endif
width = bounds.right-bounds.left; width = bounds.right-bounds.left;
height = bounds.bottom-bounds.top; height = bounds.bottom-bounds.top;
x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
...@@ -671,11 +668,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -671,11 +668,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
if ( y < 0 ) { /* Cover up title bar for more client area */ if ( y < 0 ) { /* Cover up title bar for more client area */
y -= GetSystemMetrics(SM_CYCAPTION)/2; y -= GetSystemMetrics(SM_CYCAPTION)/2;
} }
#ifndef _WIN32_WCE
swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW); swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
#else
swp_flags = (SWP_FRAMECHANGED | SWP_SHOWWINDOW);
#endif
if ( was_visible && !(flags & SDL_FULLSCREEN) ) { if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
swp_flags |= SWP_NOMOVE; swp_flags |= SWP_NOMOVE;
} }
...@@ -689,7 +682,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -689,7 +682,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
SetForegroundWindow(SDL_Window); SetForegroundWindow(SDL_Window);
} }
#ifdef HAVE_OPENGL
/* Set up for OpenGL */ /* Set up for OpenGL */
if ( flags & SDL_OPENGL ) { if ( flags & SDL_OPENGL ) {
if ( WIN_GL_SetupWindow(this) < 0 ) { if ( WIN_GL_SetupWindow(this) < 0 ) {
...@@ -697,7 +689,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -697,7 +689,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
} }
video->flags |= SDL_OPENGL; video->flags |= SDL_OPENGL;
} }
#endif /* HAVE_OPENGL */
/* We're live! */ /* We're live! */
return(video); return(video);
...@@ -760,11 +751,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ...@@ -760,11 +751,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
entries[i].peRed = colors[i].r; entries[i].peRed = colors[i].r;
entries[i].peGreen = colors[i].g; entries[i].peGreen = colors[i].g;
entries[i].peBlue = colors[i].b; entries[i].peBlue = colors[i].b;
#ifndef _WIN32_WCE
entries[i].peFlags = PC_NOCOLLAPSE; entries[i].peFlags = PC_NOCOLLAPSE;
#else
entries[i].peFlags = 0;
#endif
} }
SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); SetPaletteEntries(screen_pal, firstcolor, ncolors, entries);
SelectPalette(hdc, screen_pal, FALSE); SelectPalette(hdc, screen_pal, FALSE);
...@@ -917,11 +904,9 @@ void DIB_VideoQuit(_THIS) ...@@ -917,11 +904,9 @@ void DIB_VideoQuit(_THIS)
ShowWindow(SDL_Window, SW_HIDE); ShowWindow(SDL_Window, SW_HIDE);
} }
#endif #endif
#ifdef HAVE_OPENGL
if ( this->screen->flags & SDL_OPENGL ) { if ( this->screen->flags & SDL_OPENGL ) {
WIN_GL_ShutDown(this); WIN_GL_ShutDown(this);
} }
#endif /* HAVE_OPENGL */
this->screen->pixels = NULL; this->screen->pixels = NULL;
} }
if ( screen_bmp ) { if ( screen_bmp ) {
......
...@@ -43,6 +43,10 @@ static char rcsid = ...@@ -43,6 +43,10 @@ static char rcsid =
#define WM_APP 0x8000 #define WM_APP 0x8000
#endif #endif
#ifdef _WIN32_WCE
#define NO_GETKEYBOARDSTATE
#endif
/* The keyboard and mouse device input */ /* The keyboard and mouse device input */
#define MAX_INPUTS 16 /* Maximum of 16-1 input devices */ #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */
#define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */
...@@ -67,7 +71,7 @@ static WNDPROC userWindowProc = NULL; ...@@ -67,7 +71,7 @@ static WNDPROC userWindowProc = NULL;
static void SetDIerror(char *function, int code) static void SetDIerror(char *function, int code)
{ {
static char *error; static char *error;
static char errbuf[BUFSIZ]; static char errbuf[1024];
errbuf[0] = 0; errbuf[0] = 0;
switch (code) { switch (code) {
...@@ -449,6 +453,7 @@ LONG ...@@ -449,6 +453,7 @@ LONG
DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
switch (msg) { switch (msg) {
#ifdef WM_ACTIVATEAPP
case WM_ACTIVATEAPP: { case WM_ACTIVATEAPP: {
int i, active; int i, active;
...@@ -467,7 +472,9 @@ LONG ...@@ -467,7 +472,9 @@ LONG
} }
} }
break; break;
#endif /* WM_ACTIVATEAPP */
#ifdef WM_DISPLAYCHANGE
case WM_DISPLAYCHANGE: { case WM_DISPLAYCHANGE: {
WORD BitsPerPixel; WORD BitsPerPixel;
WORD SizeX, SizeY; WORD SizeX, SizeY;
...@@ -479,6 +486,7 @@ LONG ...@@ -479,6 +486,7 @@ LONG
/* We cause this message when we go fullscreen */ /* We cause this message when we go fullscreen */
} }
break; break;
#endif /* WM_DISPLAYCHANGE */
/* The keyboard is handled via DirectInput */ /* The keyboard is handled via DirectInput */
case WM_SYSKEYUP: case WM_SYSKEYUP:
...@@ -489,6 +497,7 @@ LONG ...@@ -489,6 +497,7 @@ LONG
} }
return(0); return(0);
#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
/* Don't allow screen savers or monitor power downs. /* Don't allow screen savers or monitor power downs.
This is because they quietly clear DirectX surfaces. This is because they quietly clear DirectX surfaces.
It would be better to allow the application to It would be better to allow the application to
...@@ -501,11 +510,11 @@ LONG ...@@ -501,11 +510,11 @@ LONG
(wParam&0xFFF0)==SC_MONITORPOWER) (wParam&0xFFF0)==SC_MONITORPOWER)
return(0); return(0);
} }
goto custom_processing; /* Fall through to default processing */
break;
#endif /* SC_SCREENSAVE || SC_MONITORPOWER */
default: { default: {
custom_processing:
/* Only post the event if we're watching for it */ /* Only post the event if we're watching for it */
if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
SDL_SysWMmsg wmmsg; SDL_SysWMmsg wmmsg;
...@@ -759,14 +768,21 @@ static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed) ...@@ -759,14 +768,21 @@ static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed)
keysym->unicode = 0; keysym->unicode = 0;
if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
UINT vkey; UINT vkey;
#ifndef NO_GETKEYBOARDSTATE
BYTE keystate[256]; BYTE keystate[256];
BYTE chars[2]; BYTE chars[2];
#endif
vkey = MapVirtualKey(scancode, 1); vkey = MapVirtualKey(scancode, 1);
#ifdef NO_GETKEYBOARDSTATE
/* Uh oh, better hope the vkey is close enough.. */
keysym->unicode = vkey;
#else
GetKeyboardState(keystate); GetKeyboardState(keystate);
if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
keysym->unicode = chars[0]; keysym->unicode = chars[0];
} }
#endif
} }
return(keysym); return(keysym);
} }
...@@ -782,7 +798,9 @@ int DX5_CreateWindow(_THIS) ...@@ -782,7 +798,9 @@ int DX5_CreateWindow(_THIS)
SDL_DIfun[i] = NULL; SDL_DIfun[i] = NULL;
} }
/* Create the SDL window */ #ifndef CS_BYTEALIGNCLIENT
#define CS_BYTEALIGNCLIENT 0
#endif
SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
if ( SDL_windowid ) { if ( SDL_windowid ) {
SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
......
...@@ -51,10 +51,23 @@ static char rcsid = ...@@ -51,10 +51,23 @@ static char rcsid =
#include "SDL_dx5yuv_c.h" #include "SDL_dx5yuv_c.h"
#include "SDL_wingl_c.h" #include "SDL_wingl_c.h"
#ifdef _WIN32_WCE
#define NO_CHANGEDISPLAYSETTINGS
#endif
#ifndef WS_MAXIMIZE
#define WS_MAXIMIZE 0
#endif
#ifndef SWP_NOCOPYBITS
#define SWP_NOCOPYBITS 0
#endif
#ifndef PC_NOCOLLAPSE
#define PC_NOCOLLAPSE 0
#endif
/* DirectX function pointers for video and events */ /* DirectX function pointers for video and events */
HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter);
/* This is the rect EnumModes2 uses */ /* This is the rect EnumModes2 uses */
struct DX5EnumRect { struct DX5EnumRect {
...@@ -443,19 +456,19 @@ static int DX5_Available(void) ...@@ -443,19 +456,19 @@ static int DX5_Available(void)
/* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */ /* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */
dinput_ok = 0; dinput_ok = 0;
DInputDLL = LoadLibrary("DINPUT.DLL"); DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
if ( DInputDLL != NULL ) { if ( DInputDLL != NULL ) {
dinput_ok = 1; dinput_ok = 1;
FreeLibrary(DInputDLL); FreeLibrary(DInputDLL);
} }
ddraw_ok = 0; ddraw_ok = 0;
DDrawDLL = LoadLibrary("DDRAW.DLL"); DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
if ( DDrawDLL != NULL ) { if ( DDrawDLL != NULL ) {
HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *); HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *);
LPDIRECTDRAW DDraw; LPDIRECTDRAW DDraw;
/* Try to create a valid DirectDraw object */ /* Try to create a valid DirectDraw object */
DDrawCreate = (void *)GetProcAddress(DDrawDLL, "DirectDrawCreate"); DDrawCreate = (void *)GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate"));
if ( (DDrawCreate != NULL) if ( (DDrawCreate != NULL)
&& !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) { && !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) {
if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw, if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw,
...@@ -511,15 +524,15 @@ static int DX5_Load(void) ...@@ -511,15 +524,15 @@ static int DX5_Load(void)
int status; int status;
DX5_Unload(); DX5_Unload();
DDrawDLL = LoadLibrary("DDRAW.DLL"); DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
if ( DDrawDLL != NULL ) { if ( DDrawDLL != NULL ) {
DDrawCreate = (void *)GetProcAddress(DDrawDLL, DDrawCreate = (void *)GetProcAddress(DDrawDLL,
"DirectDrawCreate"); TEXT("DirectDrawCreate"));
} }
DInputDLL = LoadLibrary("DINPUT.DLL"); DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
if ( DInputDLL != NULL ) { if ( DInputDLL != NULL ) {
DInputCreate = (void *)GetProcAddress(DInputDLL, DInputCreate = (void *)GetProcAddress(DInputDLL,
"DirectInputCreateA"); TEXT("DirectInputCreateA"));
} }
if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) { if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) {
status = 0; status = 0;
...@@ -670,7 +683,7 @@ static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata) ...@@ -670,7 +683,7 @@ static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata)
void SetDDerror(const char *function, int code) void SetDDerror(const char *function, int code)
{ {
static char *error; static char *error;
static char errbuf[BUFSIZ]; static char errbuf[1024];
errbuf[0] = 0; errbuf[0] = 0;
switch (code) { switch (code) {
...@@ -994,11 +1007,13 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -994,11 +1007,13 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
SDL_primary = NULL; SDL_primary = NULL;
} }
#ifndef NO_CHANGEDISPLAYSETTINGS
/* Unset any previous OpenGL fullscreen mode */ /* Unset any previous OpenGL fullscreen mode */
if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) == if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
(SDL_OPENGL|SDL_FULLSCREEN) ) { (SDL_OPENGL|SDL_FULLSCREEN) ) {
ChangeDisplaySettings(NULL, 0); ChangeDisplaySettings(NULL, 0);
} }
#endif
/* Clean up any GL context that may be hanging around */ /* Clean up any GL context that may be hanging around */
if ( current->flags & SDL_OPENGL ) { if ( current->flags & SDL_OPENGL ) {
...@@ -1057,6 +1072,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1057,6 +1072,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
video->h = height; video->h = height;
video->pitch = SDL_CalculatePitch(video); video->pitch = SDL_CalculatePitch(video);
#ifndef NO_CHANGEDISPLAYSETTINGS
/* Set fullscreen mode if appropriate. /* Set fullscreen mode if appropriate.
Ugh, since our list of valid video modes comes from Ugh, since our list of valid video modes comes from
the DirectX driver, we may not actually be able to the DirectX driver, we may not actually be able to
...@@ -1077,6 +1093,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1077,6 +1093,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
SDL_fullscreen_mode = settings; SDL_fullscreen_mode = settings;
} }
} }
#endif /* !NO_CHANGEDISPLAYSETTINGS */
style = GetWindowLong(SDL_Window, GWL_STYLE); style = GetWindowLong(SDL_Window, GWL_STYLE);
style &= ~(resizestyle|WS_MAXIMIZE); style &= ~(resizestyle|WS_MAXIMIZE);
...@@ -1096,7 +1113,9 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1096,7 +1113,9 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
video->flags |= SDL_RESIZABLE; video->flags |= SDL_RESIZABLE;
} }
} }
#if WS_MAXIMIZE
if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
} }
SetWindowLong(SDL_Window, GWL_STYLE, style); SetWindowLong(SDL_Window, GWL_STYLE, style);
...@@ -1110,7 +1129,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1110,7 +1129,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
bounds.top = 0; bounds.top = 0;
bounds.right = video->w; bounds.right = video->w;
bounds.bottom = video->h; bounds.bottom = video->h;
AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE); AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
width = bounds.right-bounds.left; width = bounds.right-bounds.left;
height = bounds.bottom-bounds.top; height = bounds.bottom-bounds.top;
x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
...@@ -1157,7 +1176,9 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1157,7 +1176,9 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
style |= resizestyle; style |= resizestyle;
} }
} }
#if WS_MAXIMIZE
if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
} }
SetWindowLong(SDL_Window, GWL_STYLE, style); SetWindowLong(SDL_Window, GWL_STYLE, style);
...@@ -1466,8 +1487,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -1466,8 +1487,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
bounds.top = 0; bounds.top = 0;
bounds.right = video->w; bounds.right = video->w;
bounds.bottom = video->h; bounds.bottom = video->h;
AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
FALSE);
width = bounds.right-bounds.left; width = bounds.right-bounds.left;
height = bounds.bottom-bounds.top; height = bounds.bottom-bounds.top;
x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
...@@ -2235,11 +2255,13 @@ void DX5_VideoQuit(_THIS) ...@@ -2235,11 +2255,13 @@ void DX5_VideoQuit(_THIS)
/* If we're fullscreen GL, we need to reset the display */ /* If we're fullscreen GL, we need to reset the display */
if ( this->screen != NULL ) { if ( this->screen != NULL ) {
#ifndef NO_CHANGEDISPLAYSETTINGS
if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) == if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
(SDL_OPENGL|SDL_FULLSCREEN) ) { (SDL_OPENGL|SDL_FULLSCREEN) ) {
ChangeDisplaySettings(NULL, 0); ChangeDisplaySettings(NULL, 0);
ShowWindow(SDL_Window, SW_HIDE); ShowWindow(SDL_Window, SW_HIDE);
} }
#endif
if ( this->screen->flags & SDL_OPENGL ) { if ( this->screen->flags & SDL_OPENGL ) {
WIN_GL_ShutDown(this); WIN_GL_ShutDown(this);
} }
......
...@@ -57,7 +57,7 @@ struct SDL_PrivateVideoData { ...@@ -57,7 +57,7 @@ struct SDL_PrivateVideoData {
/* DirectX function pointers for video and events */ /* DirectX function pointers for video and events */
extern HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); extern HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter);
/* DirectDraw error reporting function */ /* DirectDraw error reporting function */
extern void SetDDerror(const char *function, int code); extern void SetDDerror(const char *function, int code);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment