Mercurial > sdl-ios-xcode
comparison src/video/windib/SDL_dibevents.c @ 4220:cf958451fd8d SDL-1.2
Fixed bug #795
Andrey 2009-09-14 21:16:53 PDT
WinCE GetCursorPos fixed
I'm using iPAQ HP rx5919, with Windows Mobile 5.
And I also use mingw32ce 0.59.1 toolchain.
I fixed this, see attachment patch.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 21 Sep 2009 09:58:43 +0000 |
parents | 0a7481888fd1 |
children | 29605c881b29 |
comparison
equal
deleted
inserted
replaced
4219:0a7481888fd1 | 4220:cf958451fd8d |
---|---|
86 } | 86 } |
87 | 87 |
88 return key; | 88 return key; |
89 } | 89 } |
90 | 90 |
91 /* for gapi landscape mode */ | 91 static void GapiTransform(GapiInfo *gapiInfo, LONG *x, LONG *y) { |
92 static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) { | |
93 Sint16 rotatedX; | 92 Sint16 rotatedX; |
94 Sint16 rotatedY; | 93 Sint16 rotatedY; |
95 | 94 |
96 if (hires) { | 95 if(gapiInfo->userOrientation == SDL_ORIENTATION_UP && |
97 *x = *x * 2; | 96 gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT) |
98 *y = *y * 2; | 97 { |
98 rotatedX = *x; | |
99 rotatedY = *y; | |
100 *x = rotatedX; | |
101 *y = rotatedY; | |
102 } | |
103 else | |
104 if(gapiInfo->userOrientation == SDL_ORIENTATION_RIGHT && | |
105 gapiInfo->gapiOrientation == SDL_ORIENTATION_RIGHT) | |
106 { | |
107 rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ | |
108 SDL_VideoSurface->format->BytesPerPixel)) | |
109 + SDL_VideoSurface->w - *y; | |
110 rotatedY = *x; | |
111 *x = rotatedX; | |
112 *y = rotatedY; | |
99 } | 113 } |
100 | 114 else |
101 switch(rotate) { | 115 { |
102 case SDL_ORIENTATION_UP: | 116 rotatedX = SDL_VideoSurface->w - *y; |
103 { | 117 rotatedY = *x; |
104 /* this code needs testing on a real device! | 118 *y = rotatedY; |
105 So it will be enabled later */ | 119 *x = rotatedX; |
106 /* | |
107 #ifdef _WIN32_WCE | |
108 #if _WIN32_WCE >= 420 | |
109 // test device orientation | |
110 // FIXME: do not check every mouse message | |
111 DEVMODE settings; | |
112 SDL_memset(&settings, 0, sizeof(DEVMODE)); | |
113 settings.dmSize = sizeof(DEVMODE); | |
114 settings.dmFields = DM_DISPLAYORIENTATION; | |
115 ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); | |
116 if( settings.dmOrientation == DMDO_90 ) | |
117 { | |
118 rotatedX = SDL_VideoSurface->h - *x; | |
119 rotatedY = *y; | |
120 *x = rotatedX; | |
121 *y = rotatedY; | |
122 } | |
123 #endif | |
124 #endif */ | |
125 } | |
126 break; | |
127 // FIXME: Older version used just SDL_VideoSurface->(w, h) | |
128 // w and h are "clipped" while x and y are "raw", which caused | |
129 // x in former and y in latter case to be clipped in a wrong direction, | |
130 // thus offsetting the coordinate on 2 x clip pixels | |
131 // (like, 128 for 640 -> 512 clipping). | |
132 // We will now try to extract and use raw values. | |
133 // The way to do that RIGHT is do (orientation-dependent) clipping before | |
134 // doing this transform, but it's hardly possible. | |
135 | |
136 // SEE SDL_mouse.c /ClipOffset to understand these calculations. | |
137 case SDL_ORIENTATION_RIGHT: | |
138 if (!SDL_VideoSurface) | |
139 break; | |
140 rotatedX = (2 * ((SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/ | |
141 SDL_VideoSurface->format->BytesPerPixel)) | |
142 + SDL_VideoSurface->w - *y; | |
143 rotatedY = *x; | |
144 *x = rotatedX; | |
145 *y = rotatedY; | |
146 break; | |
147 case SDL_ORIENTATION_LEFT: | |
148 if (!SDL_VideoSurface) | |
149 break; | |
150 rotatedX = *y; | |
151 rotatedY = (2 * (SDL_VideoSurface->offset/SDL_VideoSurface->pitch)) | |
152 + SDL_VideoSurface->h - *x; | |
153 *x = rotatedX; | |
154 *y = rotatedY; | |
155 break; | |
156 } | 120 } |
157 } | 121 } |
158 | |
159 #endif | 122 #endif |
160 | 123 |
161 | 124 |
162 /* The main Win32 event handler */ | 125 /* The main Win32 event handler */ |
163 LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 126 LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
337 break; | 300 break; |
338 } | 301 } |
339 return(DefWindowProc(hwnd, msg, wParam, lParam)); | 302 return(DefWindowProc(hwnd, msg, wParam, lParam)); |
340 } | 303 } |
341 | 304 |
305 #ifdef _WIN32_WCE | |
306 static BOOL GetLastStylusPos(POINT* ptLast) | |
307 { | |
308 BOOL bResult = FALSE; | |
309 UINT nRet; | |
310 GetMouseMovePoints(ptLast, 1, &nRet); | |
311 if ( nRet == 1 ) { | |
312 ptLast->x /= 4; | |
313 ptLast->y /= 4; | |
314 bResult = TRUE; | |
315 } | |
316 return bResult; | |
317 } | |
318 #endif | |
319 | |
342 static void DIB_GenerateMouseMotionEvent(_THIS) | 320 static void DIB_GenerateMouseMotionEvent(_THIS) |
343 { | 321 { |
344 extern int mouse_relative; | 322 extern int mouse_relative; |
345 extern int posted; | 323 extern int posted; |
346 | 324 |
347 POINT mouse; | 325 POINT mouse; |
348 GetCursorPos( &mouse ); | 326 if(!GetCursorPos( &mouse ) && !GetLastStylusPos( &mouse )) return; |
349 | 327 |
350 if ( mouse_relative ) { | 328 if ( mouse_relative ) { |
351 POINT center; | 329 POINT center; |
352 center.x = (SDL_VideoSurface->w/2); | 330 center.x = (SDL_VideoSurface->w/2); |
353 center.y = (SDL_VideoSurface->h/2); | 331 center.y = (SDL_VideoSurface->h/2); |
361 } | 339 } |
362 } else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { | 340 } else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { |
363 ScreenToClient(SDL_Window, &mouse); | 341 ScreenToClient(SDL_Window, &mouse); |
364 #ifdef SDL_VIDEO_DRIVER_GAPI | 342 #ifdef SDL_VIDEO_DRIVER_GAPI |
365 if (SDL_VideoSurface && this->hidden->gapiInfo) | 343 if (SDL_VideoSurface && this->hidden->gapiInfo) |
366 GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y); | 344 GapiTransform(this->hidden->gapiInfo, &mouse.x, &mouse.y); |
367 #endif | 345 #endif |
368 posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y); | 346 posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y); |
369 } | 347 } |
370 } | 348 } |
371 | 349 |