Date: Thu, 05 Feb 2009 18:07:35 +0100
From: Stefan Klug Subject: [SDL] SDL 1.3 WinCE backend as promised, I've started to work on the WinCE backend of SDL 1.3 I've modified the win32 video backend and the gdi renderer, to work properly in WinCE. The results till now are great, but there is still some work to do. Attached are two patches with my changes. I would be happy if someone could review and propably commit them. The first one (configure.in.patch) should be straight forward without any side effects. The second one does the necessary changes to the win32 backend. I was really unhappy to start slicing this shiny new backend with #ifdef/#endif but I saw no other option. The most problematic issues are: - WinCe has no GetDIBits, so its practically impossible to fill a BITMAPINFO with correct values. I therefore removed the bmi member from the GDI_RenderData in SDL_gdirender.c to prevent usage of a not or not properly initialized bmi. - In SDL_win32window.c I exchanged some ASCII function by their general counterparts, (In CE only the Unicode versions are available). I don't know if this has a negative effect when running in win32 Cheers Stefan --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403564
This commit is contained in:
parent
e403bb296f
commit
d2d2e1c376
7 changed files with 166 additions and 13 deletions
71
configure.in
71
configure.in
|
@ -2531,6 +2531,71 @@ case "$host" in
|
|||
have_haptic=yes
|
||||
fi
|
||||
;;
|
||||
*-wince* | *-mingw32ce)
|
||||
ARCH=win32
|
||||
CheckDummyVideo
|
||||
CheckDiskAudio
|
||||
CheckDummyAudio
|
||||
CheckWIN32
|
||||
CheckNASM
|
||||
#SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
|
||||
#AC_DEFINE(SDL_VIDEO_DRIVER_GAPI)
|
||||
if test x$enable_video = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
|
||||
SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
|
||||
have_video=yes
|
||||
AC_ARG_ENABLE(render-gdi,
|
||||
AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
|
||||
, enable_render_gdi=yes)
|
||||
if test x$enable_render_gdi = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_RENDER_GDI)
|
||||
fi
|
||||
AC_ARG_ENABLE(render-d3d,
|
||||
AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
|
||||
, enable_render_d3d=yes)
|
||||
enable_render_d3d=no
|
||||
if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
|
||||
AC_DEFINE(SDL_VIDEO_RENDER_D3D)
|
||||
fi
|
||||
fi
|
||||
# Set up files for the audio library
|
||||
if test x$enable_audio = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
|
||||
SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
|
||||
if test x$have_dsound = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
|
||||
SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
|
||||
fi
|
||||
have_audio=yes
|
||||
fi
|
||||
# Set up files for the thread library
|
||||
if test x$enable_threads = xyes; then
|
||||
AC_DEFINE(SDL_THREAD_WIN32)
|
||||
SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
|
||||
SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
|
||||
SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
|
||||
SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
|
||||
have_threads=yes
|
||||
fi
|
||||
# Set up files for the timer library
|
||||
if test x$enable_timers = xyes; then
|
||||
AC_DEFINE(SDL_TIMER_WINCE)
|
||||
SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
|
||||
have_timers=yes
|
||||
fi
|
||||
# Set up files for the shared object loading library
|
||||
if test x$enable_loadso = xyes; then
|
||||
AC_DEFINE(SDL_LOADSO_WIN32)
|
||||
SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
|
||||
have_loadso=yes
|
||||
fi
|
||||
# Set up the system libraries we need
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer"
|
||||
# The Win32 platform requires special setup
|
||||
SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
|
||||
SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
|
||||
SDL_LIBS="-lSDLmain $SDL_LIBS"
|
||||
;;
|
||||
*-*-cygwin* | *-*-mingw32*)
|
||||
ARCH=win32
|
||||
if test "$build" != "$host"; then # cross-compiling
|
||||
|
@ -2850,10 +2915,10 @@ esac
|
|||
# Verify that we have all the platform specific files we need
|
||||
|
||||
if test x$enable_joystick = xyes; then
|
||||
if test x$have_joystick != xyes; then
|
||||
# Wants joystick subsystem, but doesn't have a platform-specific backend...
|
||||
if test x$have_joystick != xyes; then
|
||||
AC_DEFINE(SDL_JOYSTICK_DISABLED)
|
||||
fi
|
||||
SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
|
||||
fi
|
||||
fi
|
||||
if test x$have_haptic != xyes; then
|
||||
if test x$enable_haptic = xyes; then
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include "../SDL_yuv_sw_c.h"
|
||||
#include "../SDL_alphamult.h"
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#define NO_GETDIBBITS 1
|
||||
#endif
|
||||
|
||||
/* GDI renderer implementation */
|
||||
|
||||
static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags);
|
||||
|
@ -106,7 +110,9 @@ typedef struct
|
|||
HDC render_hdc;
|
||||
HDC memory_hdc;
|
||||
HDC current_hdc;
|
||||
#ifndef NO_GETDIBBITS
|
||||
LPBITMAPINFO bmi;
|
||||
#endif
|
||||
HBITMAP hbm[3];
|
||||
int current_hbm;
|
||||
SDL_DirtyRectList dirty;
|
||||
|
@ -197,6 +203,7 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
data->render_hdc = CreateCompatibleDC(data->window_hdc);
|
||||
data->memory_hdc = CreateCompatibleDC(data->window_hdc);
|
||||
|
||||
#ifndef NO_GETDIBBITS
|
||||
/* Fill in the compatible bitmap info */
|
||||
bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
|
||||
data->bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
|
||||
|
@ -211,6 +218,7 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
|
||||
GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
|
||||
DeleteObject(hbm);
|
||||
#endif
|
||||
|
||||
if (flags & SDL_RENDERER_SINGLEBUFFER) {
|
||||
renderer->info.flags |=
|
||||
|
@ -473,6 +481,7 @@ GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
/* Crap, we've lost the original pixel data... *sigh* */
|
||||
}
|
||||
return 0;
|
||||
#ifndef _WIN32_WCE /* WinCE has no alphablend */
|
||||
case SDL_BLENDMODE_MASK:
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
if (!data->premultiplied && data->pixels) {
|
||||
|
@ -504,6 +513,7 @@ GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
default:
|
||||
SDL_Unsupported();
|
||||
texture->blendMode = SDL_BLENDMODE_NONE;
|
||||
|
@ -585,12 +595,17 @@ GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
}
|
||||
}
|
||||
} else if (rect->w == texture->w && pitch == data->pitch) {
|
||||
#ifndef NO_GETDIBBITS
|
||||
if (!SetDIBits
|
||||
(renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels,
|
||||
renderdata->bmi, DIB_RGB_COLORS)) {
|
||||
WIN_SetError("SetDIBits()");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
SDL_SetError("FIXME: Update Texture");
|
||||
return -1;
|
||||
#endif
|
||||
} else {
|
||||
SDL_SetError
|
||||
("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time");
|
||||
|
@ -611,7 +626,10 @@ GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
|
||||
pitch);
|
||||
} else if (data->pixels) {
|
||||
#ifndef _WIN32_WCE
|
||||
/* WinCE has no GdiFlush */
|
||||
GdiFlush();
|
||||
#endif
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
|
@ -760,6 +778,10 @@ GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
RealizePalette(data->memory_hdc);
|
||||
}
|
||||
if (texture->blendMode & (SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND)) {
|
||||
#ifdef _WIN32_WCE
|
||||
SDL_SetError("Texture has blendmode not supported under WinCE");
|
||||
return -1;
|
||||
#else
|
||||
BLENDFUNCTION blendFunc = {
|
||||
AC_SRC_OVER,
|
||||
0,
|
||||
|
@ -773,6 +795,7 @@ GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
WIN_SetError("AlphaBlend()");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
|
||||
if (!BitBlt
|
||||
|
@ -851,9 +874,11 @@ GDI_DestroyRenderer(SDL_Renderer * renderer)
|
|||
if (data) {
|
||||
DeleteDC(data->render_hdc);
|
||||
DeleteDC(data->memory_hdc);
|
||||
#ifndef NO_GETDIBBITS
|
||||
if (data->bmi) {
|
||||
SDL_free(data->bmi);
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < SDL_arraysize(data->hbm); ++i) {
|
||||
if (data->hbm[i]) {
|
||||
DeleteObject(data->hbm[i]);
|
||||
|
|
|
@ -191,10 +191,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
0, 0);
|
||||
SDL_SendWindowEvent(data->windowID,
|
||||
SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||
#ifndef _WIN32_WCE /* WinCE misses IsZoomed() */
|
||||
if (IsZoomed(hwnd)) {
|
||||
SDL_SendWindowEvent(data->windowID,
|
||||
SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
|
||||
}
|
||||
#endif
|
||||
if (keyboard && keyboard->focus != data->windowID) {
|
||||
SDL_SetKeyboardFocus(index, data->windowID);
|
||||
}
|
||||
|
@ -211,6 +213,25 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
return (0);
|
||||
|
||||
/* WinCE has no RawInput, so we use the classic mouse events.
|
||||
In classic Win32 this is done by WM_INPUT
|
||||
*/
|
||||
#ifdef _WIN32_WCE
|
||||
case WM_MOUSEMOVE:
|
||||
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
|
||||
SDL_SendMouseButton(0, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
SDL_SendMouseMotion(0, 0, LOWORD(lParam), HIWORD(lParam), 0);
|
||||
SDL_SendMouseButton(0, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||
break;
|
||||
#else /* _WIN32_WCE */
|
||||
|
||||
case WM_INPUT: /* mouse events */
|
||||
{
|
||||
LPBYTE lpb;
|
||||
|
@ -223,7 +244,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
USHORT flags;
|
||||
int w, h;
|
||||
|
||||
/* we're collecting data from the mouse */
|
||||
/* we're collecting raw data to be able to identify the mouse (if there are several) */
|
||||
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size,
|
||||
sizeof(RAWINPUTHEADER));
|
||||
lpb = SDL_stack_alloc(BYTE, size);
|
||||
|
@ -240,7 +261,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
}
|
||||
}
|
||||
/* FIXME: Doesn't this defeat the point of using raw input? */
|
||||
|
||||
GetCursorPos(&point);
|
||||
ScreenToClient(hwnd, &point);
|
||||
|
||||
|
@ -292,7 +313,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
SDL_stack_free(lpb);
|
||||
}
|
||||
return (0);
|
||||
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
case WM_MOUSELEAVE:
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
int
|
||||
WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
|
||||
{
|
||||
#ifdef _WIN32_WCE
|
||||
return -1;
|
||||
#else
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
|
||||
HDC hdc;
|
||||
BOOL succeeded = FALSE;
|
||||
|
@ -40,11 +43,15 @@ WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
|
|||
DeleteDC(hdc);
|
||||
}
|
||||
return succeeded ? 0 : -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
|
||||
{
|
||||
#ifdef _WIN32_WCE
|
||||
return -1;
|
||||
#else
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
|
||||
HDC hdc;
|
||||
BOOL succeeded = FALSE;
|
||||
|
@ -58,6 +65,7 @@ WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
|
|||
DeleteDC(hdc);
|
||||
}
|
||||
return succeeded ? 0 : -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -53,7 +53,17 @@ WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
|||
mode->h = devmode.dmPelsHeight;
|
||||
mode->refresh_rate = devmode.dmDisplayFrequency;
|
||||
mode->driverdata = data;
|
||||
#ifdef _WIN32_WCE
|
||||
/* In WinCE EnumDisplaySettings(ENUM_CURRENT_SETTINGS) doesn't take the user defined orientation
|
||||
into account but GetSystemMetrixs does. */
|
||||
if(index == ENUM_CURRENT_SETTINGS) {
|
||||
mode->w = GetSystemMetrics(SM_CXSCREEN);
|
||||
mode->h = GetSystemMetrics(SM_CYSCREEN);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* WinCE has no GetDIBits, therefore we can't use it to get the display format */
|
||||
#ifndef _WIN32_WCE
|
||||
if (index == ENUM_CURRENT_SETTINGS
|
||||
&& (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) {
|
||||
char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
|
||||
|
@ -87,7 +97,10 @@ WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
|||
} else if (bmi->bmiHeader.biBitCount == 8) {
|
||||
mode->format = SDL_PIXELFORMAT_INDEX8;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif /* _WIN32_WCE */
|
||||
{
|
||||
|
||||
/* FIXME: Can we tell what this will be? */
|
||||
switch (devmode.dmBitsPerPel) {
|
||||
case 32:
|
||||
|
@ -198,6 +211,14 @@ WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
|
|||
{
|
||||
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
||||
LONG status;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
/* TODO: implement correctly.
|
||||
On my Asus MyPAL, if I execute the code below
|
||||
I get DISP_CHANGE_BADFLAGS and the Titlebar of the fullscreen window stays
|
||||
visible ... (SDL_RaiseWindow() would fix that one)*/
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
status =
|
||||
ChangeDisplaySettingsEx(data->DeviceName, &data->DeviceMode, NULL,
|
||||
|
|
|
@ -50,6 +50,13 @@ WIN_InitMouse(_THIS)
|
|||
const char *rdp = "rdp_mou";
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
/* WinCE has no RawInputDeviceList */
|
||||
#ifdef _WIN32_WCE
|
||||
SDL_Mouse mouse;
|
||||
SDL_zero(mouse);
|
||||
mouse.id = 0;
|
||||
SDL_AddMouse(&mouse, "Stylus", 0, 0, 1);
|
||||
#else
|
||||
/* we're checking for the number of rawinput devices */
|
||||
if (GetRawInputDeviceList(NULL, &devCount, sizeof(RAWINPUTDEVICELIST))) {
|
||||
return;
|
||||
|
@ -190,6 +197,7 @@ WIN_InitMouse(_THIS)
|
|||
}
|
||||
total_mice = index;
|
||||
SDL_free(deviceList);
|
||||
#endif /*_WIN32_WCE*/
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -243,12 +243,14 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE);
|
||||
}
|
||||
|
||||
#ifndef _WIN32_WCE /* has no RawInput */
|
||||
/* we're telling the window, we want it to report raw input events from mice */
|
||||
Rid.usUsagePage = 0x01;
|
||||
Rid.usUsage = 0x02;
|
||||
Rid.dwFlags = RIDEV_INPUTSINK;
|
||||
Rid.hwndTarget = hwnd;
|
||||
RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
||||
#endif
|
||||
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
|
@ -360,8 +362,11 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
|||
}
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
/* TODO: create the icon in WinCE (CreateIconFromResource isn't available) */
|
||||
#ifndef _WIN32_WCE
|
||||
hicon =
|
||||
CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
|
||||
#endif
|
||||
}
|
||||
SDL_RWclose(dst);
|
||||
SDL_stack_free(icon_bmp);
|
||||
|
@ -553,8 +558,8 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
|||
int
|
||||
SDL_HelperWindowCreate(void)
|
||||
{
|
||||
HINSTANCE hInstance = GetModuleHandleA(NULL);
|
||||
WNDCLASSEX wce;
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
WNDCLASS wce;
|
||||
|
||||
/* Make sure window isn't created twice. */
|
||||
if (SDL_HelperWindow != NULL) {
|
||||
|
@ -563,13 +568,12 @@ SDL_HelperWindowCreate(void)
|
|||
|
||||
/* Create the class. */
|
||||
SDL_zero(wce);
|
||||
wce.cbSize = sizeof(WNDCLASSEX);
|
||||
wce.lpfnWndProc = DefWindowProcA;
|
||||
wce.lpfnWndProc = DefWindowProc;
|
||||
wce.lpszClassName = (LPCWSTR) SDL_HelperWindowClassName;
|
||||
wce.hInstance = hInstance;
|
||||
|
||||
/* Register the class. */
|
||||
SDL_HelperWindowClass = RegisterClassEx(&wce);
|
||||
SDL_HelperWindowClass = RegisterClass(&wce);
|
||||
if (SDL_HelperWindowClass == 0) {
|
||||
SDL_SetError("Unable to create Helper Window Class: error %d.",
|
||||
GetLastError());
|
||||
|
@ -600,7 +604,7 @@ SDL_HelperWindowCreate(void)
|
|||
void
|
||||
SDL_HelperWindowDestroy(void)
|
||||
{
|
||||
HINSTANCE hInstance = GetModuleHandleA(NULL);
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
|
||||
/* Destroy the window. */
|
||||
if (SDL_HelperWindow != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue