Skip to content
Permalink
Browse files

Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at

 activekitten.com.
  • Loading branch information
icculus committed Sep 29, 2005
1 parent b77cfd6 commit 3d4ca0e69006f3989deb1e28d5b0c1875c5dd4da
BIN +17.2 KB (290%) VisualCE.zip
Binary file not shown.
@@ -25,6 +25,10 @@ static char rcsid =
"@(#) $Id$";
#endif

#ifdef _WIN32_WCE
#define NO_SIGNAL_H
#endif

/* General fatal signal handling code for SDL */

#ifdef NO_SIGNAL_H
@@ -31,7 +31,7 @@ static char rcsid =
#include <stdio.h>
#if defined(USE_DLOPEN)
# include <dlfcn.h>
#elif defined(WIN32)
#elif defined(WIN32) || defined(_WIN32_WCE)
# include <windows.h>
#elif defined(__BEOS__)
# include <be/kernel/image.h>
@@ -60,6 +60,30 @@ void *SDL_LoadObject(const char *sofile)
/* * */
handle = dlopen(sofile, RTLD_NOW);
loaderror = (char *)dlerror();
#elif defined(_WIN32_WCE)
/* * */
char errbuf[512];

wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t));
wchar_t *sofile_t = malloc((MAX_PATH+1) * sizeof(wchar_t));

MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH);
handle = (void *)LoadLibrary(sofile_t);

/* Generate an error message if all loads failed */
if ( handle == NULL ) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_TABLESIZE(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf;
}

free(sofile_t);
free(errbuf_t);

#elif defined(WIN32)
/* * */
char errbuf[512];
@@ -139,6 +163,30 @@ void *SDL_LoadFunction(void *handle, const char *name)
if ( symbol == NULL ) {
loaderror = (char *)dlerror();
}
#elif defined(_WIN32_WCE)
/* * */
char errbuf[512];
int length = strlen(name);

wchar_t *name_t = malloc((length + 1) * sizeof(wchar_t));
wchar_t *errbuf_t = malloc(512 * sizeof(wchar_t));

MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);

symbol = (void *)GetProcAddress((HMODULE)handle, name_t);
if ( symbol == NULL ) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_TABLESIZE(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf;
}

free(name_t);
free(errbuf_t);

#elif defined(WIN32)
/* * */
char errbuf[512];
@@ -40,3 +40,7 @@ void SDL_SYS_CDQuit(void)
return;
}

int SDL_CDROMInit(void)
{
return 0;
}
@@ -101,7 +101,7 @@ CPUid by definition. But it's nice to be able to prove it. :) */
:
: "%rax", "%rcx"
);
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_))
__asm {
pushfd ; Get original EFLAGS
pop eax
@@ -140,7 +140,7 @@ static __inline__ int CPU_getCPUIDFeatures()
:
: "%eax", "%ecx", "%edx", "%edi"
);
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_))
__asm {
xor eax, eax ; Set up for CPUID instruction
cpuid ; Get and save vendor ID
@@ -175,7 +175,7 @@ static __inline__ int CPU_getCPUIDFeaturesExt()
:
: "%eax", "%ecx", "%edx", "%edi"
);
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_X86_))
__asm {
mov eax,80000000h ; Query for extended functions
cpuid ; Get extended function limit
@@ -27,6 +27,10 @@ static char rcsid =

/* General quit handling code for SDL */

#if defined (_WIN32_WCE)
#define NO_SIGNAL_H
#endif

#include <stdio.h>
#ifndef NO_SIGNAL_H
#include <signal.h>
@@ -34,6 +34,8 @@ static char rcsid =
#include "SDL_sysjoystick.h"
#include "SDL_joystick_c.h"

Uint8 SDL_numjoysticks = 0;

/* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available
* joysticks. Joystick 0 should be the system default joystick.
@@ -40,6 +40,7 @@ static char rcsid =
#include "SDL_lowvideo.h"
#include "SDL_syswm_c.h"
#include "SDL_main.h"
#include "SDL_loadso.h"

#ifdef WMMSG_DEBUG
#include "wmmsg.h"
@@ -71,13 +72,37 @@ WORD *gamma_saved = NULL;


/* Functions called by the message processing function */
LONG
(*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL;
LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL;
void (*WIN_RealizePalette)(_THIS);
void (*WIN_PaletteChanged)(_THIS, HWND window);
void (*WIN_WinPAINT)(_THIS, HDC hdc);
extern void DIB_SwapGamma(_THIS);

#if defined(_WIN32_WCE)

// dynamically load aygshell dll because we want SDL to work on HPC and be300
HINSTANCE aygshell = NULL;
BOOL (WINAPI *SHFullScreen)(HWND hwndRequester, DWORD dwState) = 0;

#define SHFS_SHOWTASKBAR 0x0001
#define SHFS_HIDETASKBAR 0x0002
#define SHFS_SHOWSIPBUTTON 0x0004
#define SHFS_HIDESIPBUTTON 0x0008
#define SHFS_SHOWSTARTICON 0x0010
#define SHFS_HIDESTARTICON 0x0020

static void LoadAygshell(void)
{
if( !aygshell )
aygshell = SDL_LoadObject("aygshell.dll");
if( aygshell )
{
SHFullScreen = (int (WINAPI *)(struct HWND__ *,unsigned long)) SDL_LoadFunction(aygshell, "SHFullScreen");
}
}

#endif

static void SDL_RestoreGameMode(void)
{
#ifndef NO_CHANGEDISPLAYSETTINGS
@@ -213,6 +238,18 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_RestoreGameMode();
}
}
#if defined(_WIN32_WCE)
if ( WINDIB_FULLSCREEN() )
{
LoadAygshell();
if( aygshell )
SHFullScreen(SDL_Window, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON);
else
ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE);

}
#endif

posted = SDL_PrivateAppActive(1, appstate);
WIN_GetKeyboardState();
} else {
@@ -230,6 +267,14 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
if ( WINDIB_FULLSCREEN() ) {
SDL_RestoreDesktopMode();
#if defined(_WIN32_WCE)
LoadAygshell();
if( aygshell )
SHFullScreen(SDL_Window, SHFS_SHOWSTARTICON|SHFS_SHOWTASKBAR|SHFS_SHOWSIPBUTTON);
else
ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOW);

#endif
}
}
posted = SDL_PrivateAppActive(0, appstate);
@@ -36,6 +36,8 @@ static char rcsid =
#include "SDL_syswm_c.h"
#include "SDL_wingl_c.h"
#include "SDL_pixels_c.h"
#include "SDL_loadso.h"


#ifdef _WIN32_WCE
#define DISABLE_ICON_SUPPORT
@@ -48,6 +50,25 @@ static char rcsid =
/* The screen icon -- needs to be freed on SDL_VideoQuit() */
HICON screen_icn = NULL;

#ifdef _WIN32_WCE

BOOL (WINAPI *CoreCatchInput)(int flag) = NULL;
int input_catched = 0;
HINSTANCE coredll = NULL;

// the same API call that gx.dll does to catch the input
void LoadInputCatchFunc()
{
coredll = SDL_LoadObject("coredll.dll");
if( coredll )
{
CoreCatchInput = (int (WINAPI *)(int)) GetProcAddress(coredll, (const unsigned short *) 1453);
}
}

#endif


/* Win32 icon mask semantics are different from those of SDL:
SDL applies the mask to the icon and copies result to desktop.
Win32 applies the mask to the desktop and XORs the icon on.
@@ -245,6 +266,15 @@ SDL_GrabMode WIN_GrabInput(_THIS, SDL_GrabMode mode)
ClientToScreen(SDL_Window, &pt);
SetCursorPos(pt.x,pt.y);
}
#ifdef _WIN32_WCE
if( input_catched )
{
if( !CoreCatchInput ) LoadInputCatchFunc();

if( CoreCatchInput )
CoreCatchInput(0);
}
#endif
} else {
ClipCursor(&SDL_bounds);
if ( !(SDL_cursorstate & CURSOR_VISIBLE) ) {
@@ -257,6 +287,15 @@ SDL_GrabMode WIN_GrabInput(_THIS, SDL_GrabMode mode)
ClientToScreen(SDL_Window, &pt);
SetCursorPos(pt.x, pt.y);
}
#ifdef _WIN32_WCE
if( !input_catched )
{
if( !CoreCatchInput ) LoadInputCatchFunc();

if( CoreCatchInput )
CoreCatchInput(1);
}
#endif
}
return(mode);
}
@@ -360,12 +360,25 @@ static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, in

int DIB_CreateWindow(_THIS)
{
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
wchar_t *SDL_windowid_t;
#endif

#ifndef CS_BYTEALIGNCLIENT
#define CS_BYTEALIGNCLIENT 0
#endif
SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
if ( SDL_windowid ) {

// wince 2.1 does not have strtol
#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
SDL_windowid_t = malloc((strlen(SDL_windowid) + 1) * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, SDL_windowid, -1, SDL_windowid_t, strlen(SDL_windowid) + 1);
SDL_Window = (HWND)wcstol(SDL_windowid_t, NULL, 0);
free(SDL_windowid_t);
#else
SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
#endif
if ( SDL_Window == NULL ) {
SDL_SetError("Couldn't get user specified window");
return(-1);

0 comments on commit 3d4ca0e

Please sign in to comment.