src/video/windib/SDL_dibevents.c
branchSDL-1.2
changeset 4179 d7294b7c732d
parent 4170 092c0bc69155
child 4219 0a7481888fd1
     1.1 --- a/src/video/windib/SDL_dibevents.c	Thu May 07 12:03:51 2009 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Thu May 07 12:40:16 2009 +0000
     1.3 @@ -88,6 +88,74 @@
     1.4  	return key;
     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  
    1.78 @@ -271,7 +339,7 @@
    1.79  	return(DefWindowProc(hwnd, msg, wParam, lParam));
    1.80  }
    1.81  
    1.82 -static void DIB_GenerateMouseMotionEvent(void)
    1.83 +static void DIB_GenerateMouseMotionEvent(_THIS)
    1.84  {
    1.85  	extern int mouse_relative;
    1.86  	extern int posted;
    1.87 @@ -293,9 +361,9 @@
    1.88  		}
    1.89  	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
    1.90  		ScreenToClient(SDL_Window, &mouse);
    1.91 -#ifdef _WIN32_WCE
    1.92 -		if (SDL_VideoSurface)
    1.93 -			GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &mouse.x, &mouse.y);
    1.94 +#ifdef SDL_VIDEO_DRIVER_GAPI
    1.95 +       if (SDL_VideoSurface && this->hidden->gapiInfo)
    1.96 +			GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y);
    1.97  #endif
    1.98  		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
    1.99  	}
   1.100 @@ -312,7 +380,7 @@
   1.101  	}
   1.102  
   1.103  	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
   1.104 -		DIB_GenerateMouseMotionEvent( );
   1.105 +		DIB_GenerateMouseMotionEvent( this );
   1.106  	}
   1.107  }
   1.108