# HG changeset patch # User Sam Lantinga # Date 1241700016 0 # Node ID d7294b7c732d5592c9ac6a981b2be7c9f50fc36c # Parent 2dc6c9f343c85b7fda6225c79d459b56437b4d84 Date: Fri, 24 Apr 2009 17:47:07 +0200 From: Stefan Klug Subject: Re: [SDL] SVN doesn't compile for wince the patch applied for Revision 4483 was seemingly not checked for side effects. It broke the WinCE build. The attached patch should fix these problems. I'm not using SDL 1.2 on CE anymore, and therefore haven't tested the patch... but at least it compiles ;-) Regards Stefan diff -r 2dc6c9f343c8 -r d7294b7c732d src/video/wincommon/SDL_sysevents.c --- a/src/video/wincommon/SDL_sysevents.c Thu May 07 12:03:51 2009 +0000 +++ b/src/video/wincommon/SDL_sysevents.c Thu May 07 12:40:16 2009 +0000 @@ -131,74 +131,6 @@ } } -/* 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: - { -/* this code needs testing on a real device! - So it will be enabled later */ -/* -#ifdef _WIN32_WCE -#if _WIN32_WCE >= 420 - // test device orientation - // FIXME: do not check every mouse message - DEVMODE settings; - SDL_memset(&settings, 0, sizeof(DEVMODE)); - settings.dmSize = sizeof(DEVMODE); - settings.dmFields = DM_DISPLAYORIENTATION; - ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); - if( settings.dmOrientation == DMDO_90 ) - { - rotatedX = SDL_VideoSurface->h - *x; - rotatedY = *y; - *x = rotatedX; - *y = rotatedY; - } -#endif -#endif */ - } - break; - // FIXME: Older version used just SDL_VideoSurface->(w, h) - // w and h are "clipped" while x and y are "raw", which caused - // x in former and y in latter case to be clipped in a wrong direction, - // thus offsetting the coordinate on 2 x clip pixels - // (like, 128 for 640 -> 512 clipping). - // We will now try to extract and use raw values. - // The way to do that RIGHT is do (orientation-dependent) clipping before - // doing this transform, but it's hardly possible. - - // SEE SDL_mouse.c /ClipOffset to understand these calculations. - case SDL_ORIENTATION_RIGHT: - if (!SDL_VideoSurface) - break; - rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ - SDL_VideoSurface->format->BytesPerPixel)) - + SDL_VideoSurface->w - *y; - rotatedY = *x; - *x = rotatedX; - *y = rotatedY; - break; - case SDL_ORIENTATION_LEFT: - if (!SDL_VideoSurface) - break; - rotatedX = *y; - rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch)) - + SDL_VideoSurface->h - *x; - *x = rotatedX; - *y = rotatedY; - break; - } -} - #endif /* JC 14 Mar 2006 diff -r 2dc6c9f343c8 -r d7294b7c732d src/video/windib/SDL_dibevents.c --- a/src/video/windib/SDL_dibevents.c Thu May 07 12:03:51 2009 +0000 +++ b/src/video/windib/SDL_dibevents.c Thu May 07 12:40:16 2009 +0000 @@ -88,6 +88,74 @@ return key; } +/* 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: + { +/* this code needs testing on a real device! + So it will be enabled later */ +/* +#ifdef _WIN32_WCE +#if _WIN32_WCE >= 420 + // test device orientation + // FIXME: do not check every mouse message + DEVMODE settings; + SDL_memset(&settings, 0, sizeof(DEVMODE)); + settings.dmSize = sizeof(DEVMODE); + settings.dmFields = DM_DISPLAYORIENTATION; + ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); + if( settings.dmOrientation == DMDO_90 ) + { + rotatedX = SDL_VideoSurface->h - *x; + rotatedY = *y; + *x = rotatedX; + *y = rotatedY; + } +#endif +#endif */ + } + break; + // FIXME: Older version used just SDL_VideoSurface->(w, h) + // w and h are "clipped" while x and y are "raw", which caused + // x in former and y in latter case to be clipped in a wrong direction, + // thus offsetting the coordinate on 2 x clip pixels + // (like, 128 for 640 -> 512 clipping). + // We will now try to extract and use raw values. + // The way to do that RIGHT is do (orientation-dependent) clipping before + // doing this transform, but it's hardly possible. + + // SEE SDL_mouse.c /ClipOffset to understand these calculations. + case SDL_ORIENTATION_RIGHT: + if (!SDL_VideoSurface) + break; + rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ + SDL_VideoSurface->format->BytesPerPixel)) + + SDL_VideoSurface->w - *y; + rotatedY = *x; + *x = rotatedX; + *y = rotatedY; + break; + case SDL_ORIENTATION_LEFT: + if (!SDL_VideoSurface) + break; + rotatedX = *y; + rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch)) + + SDL_VideoSurface->h - *x; + *x = rotatedX; + *y = rotatedY; + break; + } +} + #endif @@ -271,7 +339,7 @@ return(DefWindowProc(hwnd, msg, wParam, lParam)); } -static void DIB_GenerateMouseMotionEvent(void) +static void DIB_GenerateMouseMotionEvent(_THIS) { extern int mouse_relative; extern int posted; @@ -293,9 +361,9 @@ } } else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { ScreenToClient(SDL_Window, &mouse); -#ifdef _WIN32_WCE - if (SDL_VideoSurface) - GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &mouse.x, &mouse.y); +#ifdef SDL_VIDEO_DRIVER_GAPI + if (SDL_VideoSurface && this->hidden->gapiInfo) + GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y); #endif posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y); } @@ -312,7 +380,7 @@ } if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { - DIB_GenerateMouseMotionEvent( ); + DIB_GenerateMouseMotionEvent( this ); } }