comparison src/video/windib/SDL_dibevents.c @ 4179:d7294b7c732d SDL-1.2

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
author Sam Lantinga <slouken@libsdl.org>
date Thu, 07 May 2009 12:40:16 +0000
parents 092c0bc69155
children 0a7481888fd1
comparison
equal deleted inserted replaced
4178:2dc6c9f343c8 4179:d7294b7c732d
84 case 0x25: /* left */ 84 case 0x25: /* left */
85 return Arrows_keymap[(3 + direction) % 4]; 85 return Arrows_keymap[(3 + direction) % 4];
86 } 86 }
87 87
88 return key; 88 return key;
89 }
90
91 /* for gapi landscape mode */
92 static void GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 *x, Sint16 *y) {
93 Sint16 rotatedX;
94 Sint16 rotatedY;
95
96 if (hires) {
97 *x = *x * 2;
98 *y = *y * 2;
99 }
100
101 switch(rotate) {
102 case SDL_ORIENTATION_UP:
103 {
104 /* this code needs testing on a real device!
105 So it will be enabled later */
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 }
89 } 157 }
90 158
91 #endif 159 #endif
92 160
93 161
269 break; 337 break;
270 } 338 }
271 return(DefWindowProc(hwnd, msg, wParam, lParam)); 339 return(DefWindowProc(hwnd, msg, wParam, lParam));
272 } 340 }
273 341
274 static void DIB_GenerateMouseMotionEvent(void) 342 static void DIB_GenerateMouseMotionEvent(_THIS)
275 { 343 {
276 extern int mouse_relative; 344 extern int mouse_relative;
277 extern int posted; 345 extern int posted;
278 346
279 POINT mouse; 347 POINT mouse;
291 SetCursorPos(center.x, center.y); 359 SetCursorPos(center.x, center.y);
292 posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y); 360 posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y);
293 } 361 }
294 } else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { 362 } else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
295 ScreenToClient(SDL_Window, &mouse); 363 ScreenToClient(SDL_Window, &mouse);
296 #ifdef _WIN32_WCE 364 #ifdef SDL_VIDEO_DRIVER_GAPI
297 if (SDL_VideoSurface) 365 if (SDL_VideoSurface && this->hidden->gapiInfo)
298 GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &mouse.x, &mouse.y); 366 GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y);
299 #endif 367 #endif
300 posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y); 368 posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
301 } 369 }
302 } 370 }
303 371
310 DispatchMessage(&msg); 378 DispatchMessage(&msg);
311 } 379 }
312 } 380 }
313 381
314 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { 382 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
315 DIB_GenerateMouseMotionEvent( ); 383 DIB_GenerateMouseMotionEvent( this );
316 } 384 }
317 } 385 }
318 386
319 static HKL hLayoutUS = NULL; 387 static HKL hLayoutUS = NULL;
320 388