Commit 8d14ec12 authored by Sam Lantinga's avatar Sam Lantinga

Andrey A.

I made a video driver GAPI/RAW for WinCE (SDL-1.3).
RAW mode has a priority, and also, GAPI mode works with environment
"SDL_VIDEO_RENDERER=gapi" and for RAW mode "SDL_VIDEO_RENDERER=raw".

I checked the work on the screens of VGA, WVGA, QVGA, WQVGA, HVGA,
 + tested all modes with WindowsMobile Emulator.

Also, correctly draws the pointer position and the scale of the pointer
for VGA/WVGA modes,
correctly draws top left position for DM orientation screen, and
portrait/landscape/square geometry the screen also correct.

Also, I added a small fix for GDI fullscreen mode.

Patch for latest revision SDL-1.3 in an attachment.
Also added small path for mingw32ce build.
parent 4e19d730
......@@ -1917,7 +1917,7 @@ CheckWIN32()
AC_MSG_CHECKING(Windows CE)
have_wince=no
AC_TRY_COMPILE([
#ifndef _WIN32_WCE
#if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
#error This is not Windows CE
#endif
],[
......@@ -2388,6 +2388,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/atomic/win32/*.c"
have_atomic=yes
fi
# Set up dummy files for the joystick for now
if test x$enable_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_DUMMY)
SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
have_joystick=yes
fi
# Set up files for the thread library
if test x$enable_threads = xyes; then
AC_DEFINE(SDL_THREAD_WIN32)
......@@ -2411,10 +2417,20 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
fi
# Set up the system libraries we need
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer"
# mingw32ce library
case "$host" in
*-mingw32ce)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmingwex"
;;
*)
;;
esac
# 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"
EXTRA_CFLAGS="$EXTRA_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
EXTRA_LDFLAGS="-lSDLmain $EXTRA_LDFLAGS"
;;
*-*-cygwin* | *-*-mingw32*)
ARCH=win32
......
......@@ -387,9 +387,6 @@ extern VideoBootStrap PS3_bootstrap;
#if SDL_VIDEO_DRIVER_SVGALIB
extern VideoBootStrap SVGALIB_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_GAPI
extern VideoBootStrap GAPI_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_WIN32
extern VideoBootStrap WIN32_bootstrap;
#endif
......
......@@ -67,9 +67,6 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_SVGALIB
&SVGALIB_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_GAPI
&GAPI_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_WIN32
&WIN32_bootstrap,
#endif
......
......@@ -459,6 +459,8 @@ DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags)
}
data->ddraw = videodata->ddraw;
videodata->render = RENDER_DDRAW;
renderer->DisplayModeChanged = DDRAW_DisplayModeChanged;
renderer->CreateTexture = DDRAW_CreateTexture;
renderer->QueryTexturePixels = DDRAW_QueryTexturePixels;
......
......@@ -451,6 +451,8 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
}
data->d3d = videodata->d3d;
videodata->render = RENDER_D3D;
renderer->DisplayModeChanged = D3D_DisplayModeChanged;
renderer->CreateTexture = D3D_CreateTexture;
renderer->QueryTexturePixels = D3D_QueryTexturePixels;
......
This diff is collapsed.
......@@ -27,7 +27,11 @@
/* SDL surface based renderer implementation */
#if SDL_VIDEO_RENDER_GAPI
extern void GAPI_AddRenderDriver(_THIS);
extern void WINCE_AddRenderDriver(_THIS);
extern int WINCE_Available(void);
extern void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
extern int WINCE_GetDMOrientation(void);
extern int WINCE_SetDMOrientation(int orientation);
#endif
/* vi: set ts=4 sw=4 expandtab: */
......@@ -22,100 +22,3 @@
Stefan Klug
klug.stefan@gmx.de
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
/* hi res definitions */
typedef struct _RawFrameBufferInfo
{
WORD wFormat;
WORD wBPP;
VOID *pFramePointer;
int cxStride;
int cyStride;
int cxPixels;
int cyPixels;
} RawFrameBufferInfo;
#define GETRAWFRAMEBUFFER 0x00020001
#define FORMAT_565 1
#define FORMAT_555 2
#define FORMAT_OTHER 3
/* From gx.h, since it's not really C compliant */
struct GXDisplayProperties
{
DWORD cxWidth;
DWORD cyHeight; // notice lack of 'th' in the word height.
long cbxPitch; // number of bytes to move right one x pixel - can be negative.
long cbyPitch; // number of bytes to move down one y pixel - can be negative.
long cBPP; // # of bits in each pixel
DWORD ffFormat; // format flags.
};
struct GXKeyList
{
short vkUp; // key for up
POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates.
short vkDown;
POINT ptDown;
short vkLeft;
POINT ptLeft;
short vkRight;
POINT ptRight;
short vkA;
POINT ptA;
short vkB;
POINT ptB;
short vkC;
POINT ptC;
short vkStart;
POINT ptStart;
};
typedef int (*PFNGXOpenDisplay) (HWND hWnd, DWORD dwFlags);
typedef int (*PFNGXCloseDisplay) ();
typedef void *(*PFNGXBeginDraw) ();
typedef int (*PFNGXEndDraw) ();
typedef int (*PFNGXOpenInput) ();
typedef int (*PFNGXCloseInput) ();
typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties) ();
typedef struct GXKeyList (*PFNGXGetDefaultKeys) (int iOptions);
typedef int (*PFNGXSuspend) ();
typedef int (*PFNGXResume) ();
typedef int (*PFNGXSetViewport) (DWORD dwTop, DWORD dwHeight,
DWORD dwReserved1, DWORD dwReserved2);
typedef BOOL(*PFNGXIsDisplayDRAMBuffer) ();
struct GapiFunc
{
PFNGXOpenDisplay GXOpenDisplay;
PFNGXCloseDisplay GXCloseDisplay;
PFNGXBeginDraw GXBeginDraw;
PFNGXEndDraw GXEndDraw;
PFNGXOpenInput GXOpenInput;
PFNGXCloseInput GXCloseInput;
PFNGXGetDisplayProperties GXGetDisplayProperties;
PFNGXGetDefaultKeys GXGetDefaultKeys;
PFNGXSuspend GXSuspend;
PFNGXResume GXResume;
PFNGXSetViewport GXSetViewport;
PFNGXIsDisplayDRAMBuffer GXIsDisplayDRAMBuffer;
} gx;
#define kfLandscape 0x8 // Screen is rotated 270 degrees
#define kfPalette 0x10 // Pixel values are indexes into a palette
#define kfDirect 0x20 // Pixel values contain actual level information
#define kfDirect555 0x40 // 5 bits each for red, green and blue values in a pixel.
#define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits per pixel
#define kfDirect888 0x100 // 8 bits each for red, green and blue values in a pixel.
#define kfDirect444 0x200 // 4 red, 4 green, 4 blue
#define kfDirectInverted 0x400
#define GX_FULLSCREEN 0x01 // for OpenDisplay()
#define GX_NORMALKEYS 0x02
#define GX_LANDSCAPEKEYS 0x03
......@@ -184,6 +184,8 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
return NULL;
}
windowdata->videodata->render = RENDER_GDI;
renderer->DisplayModeChanged = GDI_DisplayModeChanged;
renderer->CreateTexture = GDI_CreateTexture;
renderer->QueryTexturePixels = GDI_QueryTexturePixels;
......@@ -267,6 +269,34 @@ GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
}
data->current_hbm = 0;
#ifdef _WIN32_WCE
// check size for GDI fullscreen and rotate
if((window->flags & SDL_WINDOW_FULLSCREEN) &&
GetSystemMetrics(SM_CXSCREEN) != GetSystemMetrics(SM_CYSCREEN) &&
((GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN) && window->w > window->h) ||
(GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) && window->w < window->h)))
{
int orientation = WINCE_GetDMOrientation();
switch(orientation)
{
case DMDO_0: orientation = DMDO_90; break;
case DMDO_270: orientation = DMDO_180; break;
case DMDO_90: orientation = DMDO_0; break;
case DMDO_180: orientation = DMDO_270; break;
default:
GDI_DestroyRenderer(renderer);
return NULL;
}
if(0 > WINCE_SetDMOrientation(orientation))
{
GDI_DestroyRenderer(renderer);
return NULL;
}
}
#endif
return renderer;
}
......@@ -416,6 +446,7 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
WIN_SetError("Couldn't create bitmap");
return -1;
}
return 0;
}
......
......@@ -95,7 +95,11 @@ WIN_SetClipboardText(_THIS, const char *text)
WIN_SetError("Couldn't set clipboard data");
result = -1;
}
#ifdef _WIN32_WCE
data->clipboard_count = 0;
#else
data->clipboard_count = GetClipboardSequenceNumber();
#endif
}
SDL_free(tstr);
......@@ -149,7 +153,11 @@ WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
{
DWORD count;
#ifdef _WIN32_WCE
count = 0;
#else
count = GetClipboardSequenceNumber();
#endif
if (count != data->clipboard_count) {
if (data->clipboard_count) {
SDL_SendClipboardUpdate();
......
......@@ -184,6 +184,22 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_MOUSEMOVE:
#ifdef _WIN32_WCE
/* transform coords for VGA, WVGA... */
{
SDL_VideoData *videodata = data->videodata;
if(videodata->CoordTransform &&
(videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
{
POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
videodata->CoordTransform(data->window, &pt);
SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
break;
}
}
#endif
SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam));
break;
......
......@@ -203,10 +203,18 @@ WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
{
SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
#ifdef _WIN32_WCE
// WINCE: DEVMODE.dmPosition not found, or may be mingw32ce bug
rect->x = 0;
rect->y = 0;
rect->w = display->windows->w;
rect->h = display->windows->h;
#else
rect->x = (int)data->DeviceMode.dmPosition.x;
rect->y = (int)data->DeviceMode.dmPosition.y;
rect->w = data->DeviceMode.dmPelsWidth;
rect->h = data->DeviceMode.dmPelsHeight;
#endif
return 0;
}
......
......@@ -30,6 +30,7 @@
#include "SDL_win32video.h"
#include "SDL_d3drender.h"
#include "SDL_gdirender.h"
#include "SDL_gapirender.h"
/* Initialization/Query functions */
static int WIN_VideoInit(_THIS);
......@@ -48,6 +49,7 @@ WIN_SetError(const char *prefix)
SDL_free(message);
}
/* WIN32 driver bootstrap functions */
static int
......@@ -73,6 +75,11 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
data->ddraw->lpVtbl->Release(data->ddraw);
FreeLibrary(data->ddrawDLL);
}
#endif
#ifdef _WIN32_WCE
if(data->hAygShell) {
FreeLibrary(data->hAygShell);
}
#endif
SDL_free(device->driverdata);
SDL_free(device);
......@@ -138,6 +145,15 @@ WIN_CreateDevice(int devindex)
}
#endif /* SDL_VIDEO_RENDER_DDRAW */
#ifdef _WIN32_WCE
data->hAygShell = LoadLibrary(TEXT("\\windows\\aygshell.dll"));
if(0 == data->hAygShell)
data->hAygShell = LoadLibrary(TEXT("aygshell.dll"));
data->SHFullScreen = (0 != data->hAygShell ?
(PFNSHFullScreen) GetProcAddress(data->hAygShell, TEXT("SHFullScreen")) : 0);
data->CoordTransform = NULL;
#endif
/* Set the function pointers */
device->VideoInit = WIN_VideoInit;
device->VideoQuit = WIN_VideoQuit;
......@@ -186,10 +202,13 @@ WIN_CreateDevice(int devindex)
}
VideoBootStrap WIN32_bootstrap = {
#ifdef _WIN32_WCE
"wince", "SDL WinCE video driver", WINCE_Available, WIN_CreateDevice
#else
"win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
#endif
};
int
WIN_VideoInit(_THIS)
{
......@@ -207,7 +226,7 @@ WIN_VideoInit(_THIS)
GDI_AddRenderDriver(_this);
#endif
#if SDL_VIDEO_RENDER_GAPI
GAPI_AddRenderDriver(_this);
WINCE_AddRenderDriver(_this);
#endif
WIN_InitKeyboard(_this);
......
......@@ -28,7 +28,9 @@
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef UNICODE
#define UNICODE
#endif
#undef WINVER
#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
#include <windows.h>
......@@ -63,10 +65,17 @@
#endif
extern void WIN_SetError(const char *prefix);
enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
typedef BOOL (*PFNSHFullScreen)(HWND, DWORD);
typedef void (*PFCoordTransform)(SDL_Window*, POINT*);
/* Private display data */
typedef struct SDL_VideoData
{
int render;
#if SDL_VIDEO_RENDER_D3D
HANDLE d3dDLL;
IDirect3D9 *d3d;
......@@ -75,6 +84,11 @@ typedef struct SDL_VideoData
HANDLE ddrawDLL;
IDirectDraw *ddraw;
#endif
#ifdef _WIN32_WCE
HMODULE hAygShell;
PFNSHFullScreen SHFullScreen;
PFCoordTransform CoordTransform;
#endif
DWORD clipboard_count;
......
......@@ -34,45 +34,13 @@
#include "../../events/SDL_keyboard_c.h"
#include "SDL_win32video.h"
#include "SDL_win32window.h"
/* This is included after SDL_win32video.h, which includes windows.h */
#include "SDL_syswm.h"
#include "SDL_gapirender.h"
#define SHFS_SHOWTASKBAR 0x0001
#define SHFS_HIDETASKBAR 0x0002
#define SHFS_SHOWSIPBUTTON 0x0004
#define SHFS_HIDESIPBUTTON 0x0008
#define SHFS_SHOWSTARTICON 0x0010
#define SHFS_HIDESTARTICON 0x0020
#ifdef _WIN32_WCE
// dynamically load aygshell dll because we want SDL to work on HPC and be300
int aygshell_loaded = 0;
BOOL(WINAPI * SHFullScreen) (HWND hwndRequester, DWORD dwState) = 0;
static BOOL
CE_SHFullScreen(HWND hwndRequester, DWORD dwState)
{
if (SHFullScreen == 0 && aygshell_loaded == 0) {
aygshell_loaded = 0;
void *lib = SDL_LoadObject("aygshell.dll");
if (lib) {
SHFullScreen =
(BOOL(WINAPI *) (HWND, DWORD)) SDL_LoadFunction(lib,
"SHFullScreen");
}
}
if (SHFullScreen) {
SHFullScreen(hwndRequester, dwState);
//printf("SHFullscreen(%i)\n",dwState);
}
}
#endif
/* Fake window to help with DirectInput events. */
HWND SDL_HelperWindow = NULL;
static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher");
......@@ -472,32 +440,22 @@ WIN_SetWindowSize(_THIS, SDL_Window * window)
void
WIN_ShowWindow(_THIS, SDL_Window * window)
{
#ifdef _WIN32_WCE
WINCE_ShowWindow(_this, window, 1);
#else
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
ShowWindow(hwnd, SW_SHOW);
#ifdef _WIN32_WCE
if (window->flags & SDL_WINDOW_FULLSCREEN) {
CE_SHFullScreen(hwnd,
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
SHFS_HIDESIPBUTTON);
}
#endif
}
void
WIN_HideWindow(_THIS, SDL_Window * window)
{
#ifdef _WIN32_WCE
WINCE_ShowWindow(_this, window, 0);
#else
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
ShowWindow(hwnd, SW_HIDE);
#ifdef _WIN32_WCE
if (window->flags & SDL_WINDOW_FULLSCREEN) {
CE_SHFullScreen(hwnd,
SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
SHFS_SHOWSIPBUTTON);
}
#endif
}
......@@ -513,45 +471,33 @@ WIN_RaiseWindow(_THIS, SDL_Window * window)
top = HWND_NOTOPMOST;
}
SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
#ifdef _WIN32_WCE
if (window->flags & SDL_WINDOW_FULLSCREEN) {
CE_SHFullScreen(hwnd,
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
SHFS_HIDESIPBUTTON);
}
#endif
}
void
WIN_MaximizeWindow(_THIS, SDL_Window * window)
{
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
ShowWindow(hwnd, SW_MAXIMIZE);
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
#ifdef _WIN32_WCE
if (window->flags & SDL_WINDOW_FULLSCREEN) {
CE_SHFullScreen(hwnd,
SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
SHFS_HIDESIPBUTTON);
}
if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen)
videodata->SHFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
#endif
ShowWindow(hwnd, SW_MAXIMIZE);
}
void
WIN_MinimizeWindow(_THIS, SDL_Window * window)
{
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
ShowWindow(hwnd, SW_MINIMIZE);
#ifdef _WIN32_WCE
if (window->flags & SDL_WINDOW_FULLSCREEN) {
CE_SHFullScreen(hwnd,
SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
SHFS_SHOWSIPBUTTON);
}
if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen)
videodata->SHFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
#endif
}
......@@ -586,6 +532,9 @@ WIN_DestroyWindow(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (data) {
#ifdef _WIN32_WCE
WINCE_ShowWindow(_this, window, 0);
#endif
ReleaseDC(data->hwnd, data->hdc);
if (data->created) {
DestroyWindow(data->hwnd);
......
......@@ -24,6 +24,15 @@
#ifndef _SDL_win32window_h
#define _SDL_win32window_h
#ifdef _WIN32_WCE
#define SHFS_SHOWTASKBAR 0x0001
#define SHFS_HIDETASKBAR 0x0002
#define SHFS_SHOWSIPBUTTON 0x0004
#define SHFS_HIDESIPBUTTON 0x0008
#define SHFS_SHOWSTARTICON 0x0010
#define SHFS_HIDESTARTICON 0x0020
#endif
typedef struct
{
SDL_Window *window;
......
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