Commit f2d9ddec authored by Ryan C. Gordon's avatar Ryan C. Gordon

Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,

 updated project files, VS2005 support, VGA mode, more device support, etc,
 etc, etc.

Fixes Bugzilla #47 and #28.

--ryan.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401254
parent e691b061
Project files for embedded Visual C++ 4.0 can be found in VisualCE.zip Project files for embedded Visual C++ 3.0, 4.0 and
Visual Studio 2005 can be found in VisualCE.zip
SDL supports GAPI and WinDib output for Windows CE.
GAPI driver supports:
- all possible WinCE devices (Pocket PC, Smartphones, HPC)
with different orientations of video memory and resolutions.
- 4, 8 and 16 bpp devices
- special handling of 8bpp on 8bpp devices
- VGA mode, you can even switch between VGA and GAPI in runtime
(between 240x320 and 480x640 for example). On VGA devices you can
use either GAPI or VGA.
- Landscape mode and automatic rotation of buttons and stylus coordinates.
To enable landscape mode make width of video screen bigger than height.
For example:
SDL_SetVideoMode(320,240,16,SDL_FULLSCREEN)
- WM2005
- SDL_ListModes
NOTE: 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.
......
No preview for this file type
...@@ -3140,6 +3140,7 @@ src/video/vgl/Makefile ...@@ -3140,6 +3140,7 @@ src/video/vgl/Makefile
src/video/wincommon/Makefile src/video/wincommon/Makefile
src/video/windib/Makefile src/video/windib/Makefile
src/video/windx5/Makefile src/video/windx5/Makefile
src/video/gapi/Makefile
src/video/x11/Makefile src/video/x11/Makefile
src/video/xbios/Makefile src/video/xbios/Makefile
src/video/XFree86/Makefile src/video/XFree86/Makefile
......
...@@ -30,7 +30,10 @@ static char rcsid = ...@@ -30,7 +30,10 @@ static char rcsid =
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h> #include <windows.h>
#ifndef _WIN32_WCE
#include <process.h> #include <process.h>
#endif
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_thread.h" #include "SDL_thread.h"
...@@ -53,9 +56,14 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) ...@@ -53,9 +56,14 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
* have to use _beginthreadex if we want the returned handle * have to use _beginthreadex if we want the returned handle
* to be accessible after the thread exits * to be accessible after the thread exits
* threads created with _beginthread auto-close the handle * threads created with _beginthread auto-close the handle
* Windows CE still use CreateThread.
*/ */
#ifdef _WIN32_WCE
thread->handle = CreateThread(NULL, 0, RunThread, args, 0, &threadid);
#else
thread->handle = (SYS_ThreadHandle) _beginthreadex(NULL, 0, RunThread, thread->handle = (SYS_ThreadHandle) _beginthreadex(NULL, 0, RunThread,
args, 0, &threadid); args, 0, &threadid);
#endif
if (thread->handle == NULL) { if (thread->handle == NULL) {
SDL_SetError("Not enough resources to create thread"); SDL_SetError("Not enough resources to create thread");
return(-1); return(-1);
......
...@@ -201,9 +201,9 @@ static SYNCHHANDLE CleanUp (SYNCHHANDLE hSynch, DWORD Flags) ...@@ -201,9 +201,9 @@ static SYNCHHANDLE CleanUp (SYNCHHANDLE hSynch, DWORD Flags)
BOOL ok = TRUE; BOOL ok = TRUE;
if (hSynch == NULL) return NULL; if (hSynch == NULL) return NULL;
if (Flags & 4 == 1 && hSynch->hEvent == NULL) ok = FALSE; if ((Flags & 4) == 1 && (hSynch->hEvent == NULL)) ok = FALSE;
if (Flags & 2 == 1 && hSynch->hMutex == NULL) ok = FALSE; if ((Flags & 2) == 1 && (hSynch->hMutex == NULL)) ok = FALSE;
if (Flags & 1 == 1 && hSynch->hEvent == NULL) ok = FALSE; if ((Flags & 1) == 1 && (hSynch->hEvent == NULL)) ok = FALSE;
if (!ok) if (!ok)
{ {
CloseSynchHandle (hSynch); CloseSynchHandle (hSynch);
......
...@@ -9,7 +9,7 @@ DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \ ...@@ -9,7 +9,7 @@ DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
wincommon windib windx5 \ wincommon windib windx5 \
maccommon macdsp macrom riscos quartz \ maccommon macdsp macrom riscos quartz \
bwindow ps2gs photon cybergfx epoc picogui \ bwindow ps2gs photon cybergfx epoc picogui \
ataricommon xbios gem dc qtopia XFree86 wscons \ ataricommon xbios gem dc qtopia XFree86 wscons gapi \
ipod os2fslib ipod os2fslib
DRIVERS = @VIDEO_DRIVERS@ DRIVERS = @VIDEO_DRIVERS@
......
...@@ -39,6 +39,7 @@ static char rcsid = ...@@ -39,6 +39,7 @@ static char rcsid =
#include "SDL_memops.h" #include "SDL_memops.h"
#include "SDL_leaks.h" #include "SDL_leaks.h"
/* Public routines */ /* Public routines */
/* /*
* Create an empty RGB surface of the appropriate depth * Create an empty RGB surface of the appropriate depth
......
...@@ -365,6 +365,9 @@ extern VideoBootStrap SVGALIB_bootstrap; ...@@ -365,6 +365,9 @@ extern VideoBootStrap SVGALIB_bootstrap;
#ifdef ENABLE_AALIB #ifdef ENABLE_AALIB
extern VideoBootStrap AALIB_bootstrap; extern VideoBootStrap AALIB_bootstrap;
#endif #endif
#ifdef ENABLE_GAPI
extern VideoBootStrap GAPI_bootstrap;
#endif
#ifdef ENABLE_WINDIB #ifdef ENABLE_WINDIB
extern VideoBootStrap WINDIB_bootstrap; extern VideoBootStrap WINDIB_bootstrap;
#endif #endif
......
...@@ -87,6 +87,9 @@ static VideoBootStrap *bootstrap[] = { ...@@ -87,6 +87,9 @@ static VideoBootStrap *bootstrap[] = {
#ifdef ENABLE_AALIB #ifdef ENABLE_AALIB
&AALIB_bootstrap, &AALIB_bootstrap,
#endif #endif
#ifdef ENABLE_GAPI
&GAPI_bootstrap,
#endif
#ifdef ENABLE_WINDIB #ifdef ENABLE_WINDIB
&WINDIB_bootstrap, &WINDIB_bootstrap,
#endif #endif
......
Makefile.in
Makefile
.libs
*.o
*.lo
*.la
## Makefile.am for SDL using the PocketPC GAPI video driver
noinst_LTLIBRARIES = libvideo_gapi.la
libvideo_gapi_la_SOURCES = $(GAPI_SRCS)
# The SDL GAPI driver sources
GAPI_SRCS = \
SDL_gapivideo.c \
SDL_gapivideo.h
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#ifndef _SDL_gapivideo_h
#define _SDL_gapivideo_h
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
#include "SDL_mutex.h"
/* 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;
};
#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
typedef enum
{
SDL_ORIENTATION_UP,
SDL_ORIENTATION_DOWN,
SDL_ORIENTATION_LEFT,
SDL_ORIENTATION_RIGHT
} SDL_ScreenOrientation;
/* GAPI video mode */
typedef enum {
GAPI_NONE = 0,
GAPI_DIRECT_565,
GAPI_DIRECT_555,
GAPI_MONO,
GAPI_PALETTE
} GAPIVideoMode;
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
typedef unsigned short PIXEL;
/* Private display data
begin with DIB private structure to allow DIB events code sharing
*/
struct SDL_PrivateVideoData {
HBITMAP screen_bmp;
HPALETTE screen_pal;
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS];
enum SDL_ScreenOrientation userOrientation;
int invert;
char hiresFix; // using hires mode without defining hires resource
// --------------
int w, h;
enum SDL_ScreenOrientation gapiOrientation;
void *buffer; // may be 8, 16, 24, 32 bpp
PIXEL *videoMem;
BOOL needUpdate;
struct GXKeyList keyList;
struct GapiFunc gxFunc;
struct GXDisplayProperties gxProperties;
enum GAPIVideoMode videoMode;
int colorscale;
int dstLineStep; // in bytes
int dstPixelStep; // in bytes
int startOffset; // in bytes
int useVga;
};
#define gapiBuffer this->hidden->buffer
#define gapi this->hidden
#endif /* _SDL_gapivideo_h */
...@@ -40,7 +40,8 @@ static char rcsid = ...@@ -40,7 +40,8 @@ static char rcsid =
SDL_VideoSurface && \ SDL_VideoSurface && \
((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \ ((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \
(((SDL_VideoSurface->flags & SDL_OPENGL ) == SDL_OPENGL ) || \ (((SDL_VideoSurface->flags & SDL_OPENGL ) == SDL_OPENGL ) || \
(strcmp(this->name, "windib") == 0)) \ ((strcmp(this->name, "windib") == 0) || \
(strcmp(this->name, "gapi") == 0))) \
) )
#define DDRAW_FULLSCREEN() \ #define DDRAW_FULLSCREEN() \
( \ ( \
......
...@@ -47,6 +47,7 @@ static char rcsid = ...@@ -47,6 +47,7 @@ static char rcsid =
#endif #endif
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
#include "SDL_gapivideo.h"
#define NO_GETKEYBOARDSTATE #define NO_GETKEYBOARDSTATE
#define NO_CHANGEDISPLAYSETTINGS #define NO_CHANGEDISPLAYSETTINGS
#endif #endif
...@@ -101,6 +102,38 @@ static void LoadAygshell(void) ...@@ -101,6 +102,38 @@ static void LoadAygshell(void)
} }
} }
/* for gapi landscape mode */
static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) {
Sint16 rotatedX;
Sint16 rotatedY;
if (hires) {
*x = *x * 2;
*y = *y * 2;
}
switch(rotate) {
case SDL_ORIENTATION_UP:
break;
case SDL_ORIENTATION_RIGHT:
if (!SDL_VideoSurface)
break;
rotatedX = SDL_VideoSurface->w - *y;
rotatedY = *x;
*x = rotatedX;
*y = rotatedY;
break;
case SDL_ORIENTATION_LEFT:
if (!SDL_VideoSurface)
break;
rotatedX = *y;
rotatedY = SDL_VideoSurface->h - *x;
*x = rotatedX;
*y = rotatedY;
break;
}
}
#endif #endif
static void SDL_RestoreGameMode(void) static void SDL_RestoreGameMode(void)
...@@ -319,6 +352,10 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -319,6 +352,10 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
posted = SDL_PrivateMouseMotion(0, 1, x, y); posted = SDL_PrivateMouseMotion(0, 1, x, y);
} }
} else { } else {
#ifdef _WIN32_WCE
if (SDL_VideoSurface)
GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y);
#endif
posted = SDL_PrivateMouseMotion(0, 0, x, y); posted = SDL_PrivateMouseMotion(0, 0, x, y);
} }
} }
...@@ -407,6 +444,10 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -407,6 +444,10 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} else { } else {
x = (Sint16)LOWORD(lParam); x = (Sint16)LOWORD(lParam);
y = (Sint16)HIWORD(lParam); y = (Sint16)HIWORD(lParam);
#ifdef _WIN32_WCE
if (SDL_VideoSurface)
GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &x, &y);
#endif
} }
posted = SDL_PrivateMouseButton( posted = SDL_PrivateMouseButton(
state, button, x, y); state, button, x, y);
......
...@@ -251,6 +251,7 @@ void WIN_UpdateMouse(_THIS) ...@@ -251,6 +251,7 @@ void WIN_UpdateMouse(_THIS)
/* Check to see if we need to enter or leave mouse relative mode */ /* Check to see if we need to enter or leave mouse relative mode */
void WIN_CheckMouseMode(_THIS) void WIN_CheckMouseMode(_THIS)
{ {
#ifndef _WIN32_WCE
/* If the mouse is hidden and input is grabbed, we use relative mode */ /* If the mouse is hidden and input is grabbed, we use relative mode */
if ( !(SDL_cursorstate & CURSOR_VISIBLE) && if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
(this->input_grab != SDL_GRAB_OFF) ) { (this->input_grab != SDL_GRAB_OFF) ) {
...@@ -258,4 +259,7 @@ void WIN_CheckMouseMode(_THIS) ...@@ -258,4 +259,7 @@ void WIN_CheckMouseMode(_THIS)
} else { } else {
mouse_relative = 0; mouse_relative = 0;
} }
#else
mouse_relative = 0;
#endif
} }
...@@ -59,6 +59,31 @@ static BOOL prev_shiftstates[2]; ...@@ -59,6 +59,31 @@ static BOOL prev_shiftstates[2];
and give him a chance to handle some messages. */ and give him a chance to handle some messages. */
static WNDPROC userWindowProc = NULL; static WNDPROC userWindowProc = NULL;
#ifdef _WIN32_WCE
WPARAM rotateKey(WPARAM key,SDL_ScreenOrientation direction)
{
if (direction != SDL_ORIENTATION_LEFT)
return key;
switch (key) {
case 0x26: /* up */
return 0x27;
case 0x27: /* right */
return 0x28;
case 0x28: /* down */
return 0x25;
case 0x25: /* left */
return 0x26;
}
return key;
}
#endif
/* The main Win32 event handler */ /* The main Win32 event handler */
LONG LONG
DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
...@@ -70,6 +95,15 @@ LONG ...@@ -70,6 +95,15 @@ LONG
case WM_KEYDOWN: { case WM_KEYDOWN: {
SDL_keysym keysym; SDL_keysym keysym;
#ifdef _WIN32_WCE
// Drop GAPI artefacts
if (wParam == 0x84 || wParam == 0x5B)
return 0;
// Rotate key if necessary
if (this->hidden->orientation != SDL_ORIENTATION_UP)
wParam = rotateKey(wParam, this->hidden->orientation);
#endif
/* Ignore repeated keys */ /* Ignore repeated keys */
if ( lParam&REPEATED_KEYMASK ) { if ( lParam&REPEATED_KEYMASK ) {
return(0); return(0);
...@@ -127,6 +161,16 @@ LONG ...@@ -127,6 +161,16 @@ LONG
case WM_KEYUP: { case WM_KEYUP: {
SDL_keysym keysym; SDL_keysym keysym;
#ifdef _WIN32_WCE
// Drop GAPI artefacts
if (wParam == 0x84 || wParam == 0x5B)
return 0;
// Rotate key if necessary
if (this->hidden->orientation != SDL_ORIENTATION_UP)
wParam = rotateKey(wParam, this->hidden->orientation);
#endif
switch (wParam) { switch (wParam) {
case VK_CONTROL: case VK_CONTROL:
if ( lParam&EXTENDED_KEYMASK ) if ( lParam&EXTENDED_KEYMASK )
......
...@@ -768,14 +768,15 @@ static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) ...@@ -768,14 +768,15 @@ static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
ReleaseDC(SDL_Window, hdc); ReleaseDC(SDL_Window, hdc);
} }
int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{ {
RGBQUAD *pal; RGBQUAD *pal;
int i; int i;
#ifndef _WIN32_WCE #if (_WIN32_WCE < 400 )
HDC hdc, mdc;
#else
HDC hdc; HDC hdc;
#else
HDC hdc, mdc;
#endif #endif
/* Update the display palette */ /* Update the display palette */
...@@ -805,7 +806,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ...@@ -805,7 +806,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
} }
/* Set the DIB palette and update the display */ /* Set the DIB palette and update the display */
#ifndef _WIN32_WCE #if ( _WIN32_WCE >= 400 )
mdc = CreateCompatibleDC(hdc); mdc = CreateCompatibleDC(hdc);
SelectObject(mdc, screen_bmp); SelectObject(mdc, screen_bmp);
SetDIBColorTable(mdc, firstcolor, ncolors, pal); SetDIBColorTable(mdc, firstcolor, ncolors, pal);
...@@ -817,6 +818,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ...@@ -817,6 +818,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
return(1); return(1);
} }
static void DIB_CheckGamma(_THIS) static void DIB_CheckGamma(_THIS)
{ {
#ifndef NO_GAMMA_SUPPORT #ifndef NO_GAMMA_SUPPORT
......
...@@ -30,6 +30,15 @@ static char rcsid = ...@@ -30,6 +30,15 @@ static char rcsid =
#include <windows.h> #include <windows.h>
/* for PDA */
typedef enum
{
SDL_ORIENTATION_UP,
SDL_ORIENTATION_DOWN,
SDL_ORIENTATION_LEFT,
SDL_ORIENTATION_RIGHT
} SDL_ScreenOrientation;
/* Private display data */ /* Private display data */
struct SDL_PrivateVideoData { struct SDL_PrivateVideoData {
HBITMAP screen_bmp; HBITMAP screen_bmp;
...@@ -38,6 +47,10 @@ struct SDL_PrivateVideoData { ...@@ -38,6 +47,10 @@ struct SDL_PrivateVideoData {
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ #define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS]; int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS]; SDL_Rect **SDL_modelist[NUM_MODELISTS];
SDL_ScreenOrientation orientation;
int invert;
char hiresFix; // using hires mode without defining hires resource
}; };
/* Old variable names */ /* Old variable names */
#define screen_bmp (this->hidden->screen_bmp) #define screen_bmp (this->hidden->screen_bmp)
......
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