Date: Fri, 24 Apr 2009 17:47:07 +0200 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Thu, 07 May 2009 12:40:16 +0000
branchSDL-1.2
changeset 4179d7294b7c732d
parent 4178 2dc6c9f343c8
child 4180 0a9a29fc00c2
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
src/video/wincommon/SDL_sysevents.c
src/video/windib/SDL_dibevents.c
     1.1 --- a/src/video/wincommon/SDL_sysevents.c	Thu May 07 12:03:51 2009 +0000
     1.2 +++ b/src/video/wincommon/SDL_sysevents.c	Thu May 07 12:40:16 2009 +0000
     1.3 @@ -131,74 +131,6 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 -/* for gapi landscape mode */
     1.8 -static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) {
     1.9 -	Sint16 rotatedX;
    1.10 -	Sint16 rotatedY;
    1.11 -
    1.12 -	if (hires) {
    1.13 -		*x = *x * 2;
    1.14 -		*y = *y * 2;
    1.15 -	}
    1.16 -
    1.17 -	switch(rotate) {
    1.18 -		case SDL_ORIENTATION_UP:
    1.19 -			{
    1.20 -/* this code needs testing on a real device!
    1.21 -   So it will be enabled later */
    1.22 -/*
    1.23 -#ifdef _WIN32_WCE
    1.24 -#if _WIN32_WCE >= 420
    1.25 -				// test device orientation
    1.26 -				// FIXME: do not check every mouse message
    1.27 -				DEVMODE settings;
    1.28 -				SDL_memset(&settings, 0, sizeof(DEVMODE));
    1.29 -				settings.dmSize = sizeof(DEVMODE);
    1.30 -				settings.dmFields = DM_DISPLAYORIENTATION;
    1.31 -				ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL);
    1.32 -				if( settings.dmOrientation == DMDO_90 )
    1.33 -				{
    1.34 -					rotatedX = SDL_VideoSurface->h - *x;
    1.35 -					rotatedY = *y;
    1.36 -					*x = rotatedX;
    1.37 -					*y = rotatedY;
    1.38 -				}
    1.39 -#endif
    1.40 -#endif */
    1.41 -			}
    1.42 -			break;
    1.43 -               // FIXME: Older version used just SDL_VideoSurface->(w, h)
    1.44 -               // w and h are "clipped" while x and y are "raw", which caused
    1.45 -               // x in former and y in latter case to be clipped in a wrong direction,
    1.46 -               // thus offsetting the coordinate on 2 x clip pixels
    1.47 -               //     (like, 128 for 640 -> 512 clipping).
    1.48 -               // We will now try to extract and use raw values.
    1.49 -               // The way to do that RIGHT is do (orientation-dependent) clipping before
    1.50 -               // doing this transform, but it's hardly possible.
    1.51 -
    1.52 -               // SEE SDL_mouse.c /ClipOffset to understand these calculations.
    1.53 -		case SDL_ORIENTATION_RIGHT:
    1.54 -			if (!SDL_VideoSurface)
    1.55 -				break;
    1.56 -                       rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
    1.57 -                               SDL_VideoSurface->format->BytesPerPixel))
    1.58 -                               + SDL_VideoSurface->w - *y;
    1.59 -			rotatedY = *x;
    1.60 -			*x = rotatedX;
    1.61 -			*y = rotatedY;
    1.62 -			break;
    1.63 -		case SDL_ORIENTATION_LEFT:
    1.64 -			if (!SDL_VideoSurface)
    1.65 -				break;
    1.66 -			rotatedX = *y;
    1.67 -                       rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch))
    1.68 -                               + SDL_VideoSurface->h - *x;
    1.69 -			*x = rotatedX;
    1.70 -			*y = rotatedY;
    1.71 -			break;
    1.72 -	}
    1.73 -}
    1.74 -
    1.75  #endif
    1.76  
    1.77  /* JC 14 Mar 2006
     2.1 --- a/src/video/windib/SDL_dibevents.c	Thu May 07 12:03:51 2009 +0000
     2.2 +++ b/src/video/windib/SDL_dibevents.c	Thu May 07 12:40:16 2009 +0000
     2.3 @@ -88,6 +88,74 @@
     2.4  	return key;
     2.5  }
     2.6  
     2.7 +/* for gapi landscape mode */
     2.8 +static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) {
     2.9 +    Sint16 rotatedX;
    2.10 +    Sint16 rotatedY;
    2.11 +
    2.12 +    if (hires) {
    2.13 +        *x = *x * 2;
    2.14 +        *y = *y * 2;
    2.15 +    }
    2.16 +
    2.17 +    switch(rotate) {
    2.18 +        case SDL_ORIENTATION_UP:
    2.19 +            {
    2.20 +/* this code needs testing on a real device!
    2.21 +   So it will be enabled later */
    2.22 +/*
    2.23 +#ifdef _WIN32_WCE
    2.24 +#if _WIN32_WCE >= 420
    2.25 +                // test device orientation
    2.26 +                // FIXME: do not check every mouse message
    2.27 +                DEVMODE settings;
    2.28 +                SDL_memset(&settings, 0, sizeof(DEVMODE));
    2.29 +                settings.dmSize = sizeof(DEVMODE);
    2.30 +                settings.dmFields = DM_DISPLAYORIENTATION;
    2.31 +                ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL);
    2.32 +                if( settings.dmOrientation == DMDO_90 )
    2.33 +                {
    2.34 +                    rotatedX = SDL_VideoSurface->h - *x;
    2.35 +                    rotatedY = *y;
    2.36 +                    *x = rotatedX;
    2.37 +                    *y = rotatedY;
    2.38 +                }
    2.39 +#endif
    2.40 +#endif */
    2.41 +            }
    2.42 +            break;
    2.43 +               // FIXME: Older version used just SDL_VideoSurface->(w, h)
    2.44 +               // w and h are "clipped" while x and y are "raw", which caused
    2.45 +               // x in former and y in latter case to be clipped in a wrong direction,
    2.46 +               // thus offsetting the coordinate on 2 x clip pixels
    2.47 +               //     (like, 128 for 640 -> 512 clipping).
    2.48 +               // We will now try to extract and use raw values.
    2.49 +               // The way to do that RIGHT is do (orientation-dependent) clipping before
    2.50 +               // doing this transform, but it's hardly possible.
    2.51 +
    2.52 +               // SEE SDL_mouse.c /ClipOffset to understand these calculations.
    2.53 +        case SDL_ORIENTATION_RIGHT:
    2.54 +            if (!SDL_VideoSurface)
    2.55 +                break;
    2.56 +                       rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
    2.57 +                               SDL_VideoSurface->format->BytesPerPixel))
    2.58 +                               + SDL_VideoSurface->w - *y;
    2.59 +            rotatedY = *x;
    2.60 +            *x = rotatedX;
    2.61 +            *y = rotatedY;
    2.62 +            break;
    2.63 +        case SDL_ORIENTATION_LEFT:
    2.64 +            if (!SDL_VideoSurface)
    2.65 +                break;
    2.66 +            rotatedX = *y;
    2.67 +                       rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch))
    2.68 +                               + SDL_VideoSurface->h - *x;
    2.69 +            *x = rotatedX;
    2.70 +            *y = rotatedY;
    2.71 +            break;
    2.72 +    }
    2.73 +}
    2.74 +
    2.75  #endif 
    2.76  
    2.77  
    2.78 @@ -271,7 +339,7 @@
    2.79  	return(DefWindowProc(hwnd, msg, wParam, lParam));
    2.80  }
    2.81  
    2.82 -static void DIB_GenerateMouseMotionEvent(void)
    2.83 +static void DIB_GenerateMouseMotionEvent(_THIS)
    2.84  {
    2.85  	extern int mouse_relative;
    2.86  	extern int posted;
    2.87 @@ -293,9 +361,9 @@
    2.88  		}
    2.89  	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
    2.90  		ScreenToClient(SDL_Window, &mouse);
    2.91 -#ifdef _WIN32_WCE
    2.92 -		if (SDL_VideoSurface)
    2.93 -			GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &mouse.x, &mouse.y);
    2.94 +#ifdef SDL_VIDEO_DRIVER_GAPI
    2.95 +       if (SDL_VideoSurface && this->hidden->gapiInfo)
    2.96 +			GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y);
    2.97  #endif
    2.98  		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
    2.99  	}
   2.100 @@ -312,7 +380,7 @@
   2.101  	}
   2.102  
   2.103  	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
   2.104 -		DIB_GenerateMouseMotionEvent( );
   2.105 +		DIB_GenerateMouseMotionEvent( this );
   2.106  	}
   2.107  }
   2.108