src/video/windib/SDL_dibevents.c
branchSDL-1.2
changeset 4220 cf958451fd8d
parent 4219 0a7481888fd1
child 4232 29605c881b29
     1.1 --- a/src/video/windib/SDL_dibevents.c	Mon Sep 21 09:54:33 2009 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Mon Sep 21 09:58:43 2009 +0000
     1.3 @@ -88,74 +88,37 @@
     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 +static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y) {
    1.10      Sint16 rotatedX;
    1.11      Sint16 rotatedY;
    1.12  
    1.13 -    if (hires) {
    1.14 -        *x = *x * 2;
    1.15 -        *y = *y * 2;
    1.16 +    if(gapiInfo->userOrientation == SDL_ORIENTATION_UP &&
    1.17 +       gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
    1.18 +    {
    1.19 +        rotatedX = *x;
    1.20 +        rotatedY = *y;
    1.21 +        *x = rotatedX;
    1.22 +        *y = rotatedY;
    1.23 +     }
    1.24 +    else
    1.25 +    if(gapiInfo->userOrientation == SDL_ORIENTATION_RIGHT &&
    1.26 +       gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT)
    1.27 +    {
    1.28 +        rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
    1.29 +                    SDL_VideoSurface->format->BytesPerPixel))
    1.30 +                    + SDL_VideoSurface->w - *y;
    1.31 +        rotatedY = *x;
    1.32 +        *x = rotatedX;
    1.33 +        *y = rotatedY;
    1.34      }
    1.35 -
    1.36 -    switch(rotate) {
    1.37 -        case SDL_ORIENTATION_UP:
    1.38 -            {
    1.39 -/* this code needs testing on a real device!
    1.40 -   So it will be enabled later */
    1.41 -/*
    1.42 -#ifdef _WIN32_WCE
    1.43 -#if _WIN32_WCE >= 420
    1.44 -                // test device orientation
    1.45 -                // FIXME: do not check every mouse message
    1.46 -                DEVMODE settings;
    1.47 -                SDL_memset(&settings, 0, sizeof(DEVMODE));
    1.48 -                settings.dmSize = sizeof(DEVMODE);
    1.49 -                settings.dmFields = DM_DISPLAYORIENTATION;
    1.50 -                ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL);
    1.51 -                if( settings.dmOrientation == DMDO_90 )
    1.52 -                {
    1.53 -                    rotatedX = SDL_VideoSurface->h - *x;
    1.54 -                    rotatedY = *y;
    1.55 -                    *x = rotatedX;
    1.56 -                    *y = rotatedY;
    1.57 -                }
    1.58 -#endif
    1.59 -#endif */
    1.60 -            }
    1.61 -            break;
    1.62 -               // FIXME: Older version used just SDL_VideoSurface->(w, h)
    1.63 -               // w and h are "clipped" while x and y are "raw", which caused
    1.64 -               // x in former and y in latter case to be clipped in a wrong direction,
    1.65 -               // thus offsetting the coordinate on 2 x clip pixels
    1.66 -               //     (like, 128 for 640 -> 512 clipping).
    1.67 -               // We will now try to extract and use raw values.
    1.68 -               // The way to do that RIGHT is do (orientation-dependent) clipping before
    1.69 -               // doing this transform, but it's hardly possible.
    1.70 -
    1.71 -               // SEE SDL_mouse.c /ClipOffset to understand these calculations.
    1.72 -        case SDL_ORIENTATION_RIGHT:
    1.73 -            if (!SDL_VideoSurface)
    1.74 -                break;
    1.75 -                       rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
    1.76 -                               SDL_VideoSurface->format->BytesPerPixel))
    1.77 -                               + SDL_VideoSurface->w - *y;
    1.78 -            rotatedY = *x;
    1.79 -            *x = rotatedX;
    1.80 -            *y = rotatedY;
    1.81 -            break;
    1.82 -        case SDL_ORIENTATION_LEFT:
    1.83 -            if (!SDL_VideoSurface)
    1.84 -                break;
    1.85 -            rotatedX = *y;
    1.86 -                       rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch))
    1.87 -                               + SDL_VideoSurface->h - *x;
    1.88 -            *x = rotatedX;
    1.89 -            *y = rotatedY;
    1.90 -            break;
    1.91 +    else
    1.92 +    {
    1.93 +        rotatedX = SDL_VideoSurface->w - *y;
    1.94 +        rotatedY = *x;
    1.95 +        *y = rotatedY;
    1.96 +        *x = rotatedX;
    1.97      }
    1.98  }
    1.99 -
   1.100  #endif 
   1.101  
   1.102  
   1.103 @@ -339,13 +302,28 @@
   1.104  	return(DefWindowProc(hwnd, msg, wParam, lParam));
   1.105  }
   1.106  
   1.107 +#ifdef _WIN32_WCE
   1.108 +static BOOL GetLastStylusPos(POINT* ptLast)
   1.109 +{
   1.110 +    BOOL bResult = FALSE;
   1.111 +    UINT nRet;
   1.112 +    GetMouseMovePoints(ptLast, 1, &nRet);
   1.113 +    if ( nRet == 1 ) {
   1.114 +        ptLast->x /= 4;
   1.115 +        ptLast->y /= 4;
   1.116 +        bResult = TRUE;
   1.117 +    }
   1.118 +    return bResult;
   1.119 +}
   1.120 +#endif
   1.121 +
   1.122  static void DIB_GenerateMouseMotionEvent(_THIS)
   1.123  {
   1.124  	extern int mouse_relative;
   1.125  	extern int posted;
   1.126  
   1.127  	POINT mouse;
   1.128 -	GetCursorPos( &mouse );
   1.129 +	if(!GetCursorPos( &mouse ) && !GetLastStylusPos( &mouse )) return;
   1.130  
   1.131  	if ( mouse_relative ) {
   1.132  		POINT center;
   1.133 @@ -363,7 +341,7 @@
   1.134  		ScreenToClient(SDL_Window, &mouse);
   1.135  #ifdef SDL_VIDEO_DRIVER_GAPI
   1.136         if (SDL_VideoSurface && this->hidden->gapiInfo)
   1.137 -			GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y);
   1.138 +			GapiTransform(this->hidden->gapiInfo, &mouse.x, &mouse.y);
   1.139  #endif
   1.140  		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
   1.141  	}