comparison src/video/win32/SDL_win32events.c @ 3770:81b649bad6d2 gsoc2008_manymouse

Implementation finished
author Szymon Wilczek <kazeuser@gmail.com>
date Thu, 31 Jul 2008 14:41:48 +0000
parents 1b87a8beab9d
children 8cc36a399a12
comparison
equal deleted inserted replaced
3769:fe32943f86ec 3770:81b649bad6d2
60 #endif 60 #endif
61 61
62 extern HCTX* g_hCtx; 62 extern HCTX* g_hCtx;
63 extern HANDLE* mice; 63 extern HANDLE* mice;
64 extern int total_mice; 64 extern int total_mice;
65 extern int tablet;
65 66
66 int pressure=0; 67 int pressure=0;
67 68
68 static WPARAM 69 static WPARAM
69 RemapVKEY(WPARAM wParam, LPARAM lParam) 70 RemapVKEY(WPARAM wParam, LPARAM lParam)
144 } 145 }
145 break; 146 break;
146 case WT_PROXIMITY: 147 case WT_PROXIMITY:
147 { 148 {
148 int h_context=LOWORD(lParam); 149 int h_context=LOWORD(lParam);
150 LPPOINT point;
151 GetCursorPos(&point);
152 ScreenToClient(hwnd, &point);
149 if(h_context==0) 153 if(h_context==0)
150 { 154 {
151 SDL_SendProximity(0, 0, 0, SDL_PROXIMITYOUT); 155 SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYOUT);
152 } 156 }
153 else 157 else
154 { 158 {
155 SDL_SendProximity(0, 0, 0, SDL_PROXIMITYIN); 159 SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYIN);
156 } 160 }
157 } 161 }
158 break; 162 break;
159 case WM_SHOWWINDOW: 163 case WM_SHOWWINDOW:
160 { 164 {
200 } 204 }
201 } 205 }
202 return (0); 206 return (0);
203 } 207 }
204 break; 208 break;
205 case WT_CTXOPEN:
206 {
207 SDL_SendMouseMotion(0,1,1,0,0);
208 SDL_SendMouseMotion(0,1,-1,0,0);
209 }
210 /*case WM_MOUSEMOVE:
211 {
212 LPBYTE lpb;
213 const RAWINPUTHEADER *header;
214 int index;
215 int i;
216 int size=0;
217 SDL_Mouse *mouse;
218 int x, y;
219
220 //index = data->videodata->mouse;
221 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER));
222 lpb = SDL_malloc(size*sizeof(LPBYTE));
223 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
224 raw = (RAWINPUT *) lpb;
225 header = &raw->header;
226 for(i=0;i<total_mice;++i)
227 {
228 if(mice[i]==header->hDevice)
229 {
230 index=i;
231 break;
232 }
233 }
234 mouse = SDL_GetMouse(index);
235
236 if (mouse->focus != data->windowID) {
237 TRACKMOUSEEVENT tme;
238
239 tme.cbSize = sizeof(tme);
240 tme.dwFlags = TME_LEAVE;
241 tme.hwndTrack = hwnd;
242 TrackMouseEvent(&tme);
243
244 SDL_SetMouseFocus(index, data->windowID);
245 }
246
247 /* mouse has moved within the window */
248 //x = LOWORD(lParam);
249 //y = HIWORD(lParam);
250 //printf("index: %d\n",index);
251 /*if (WTPacketsPeek(g_hCtx[data->windowID],1,&packet))
252 {
253 pressure=(int)packet.pkNormalPressure;
254 }*/
255 /*if (mouse->relative_mode) {
256 int w, h;
257 POINT center;
258 SDL_GetWindowSize(data->windowID, &w, &h);
259 center.x = (w / 2);
260 center.y = (h / 2);
261 x -= center.x;
262 y -= center.y;
263 if (x || y) {
264 ClientToScreen(hwnd, &center);
265 SetCursorPos(center.x, center.y);
266 SDL_SendMouseMotion(index, 1, x, y,pressure);
267 }
268 } else {
269 SDL_SendMouseMotion(index, 0, x, y,pressure);
270 }
271 }
272 return (0);*/
273 case WM_INPUT: 209 case WM_INPUT:
274 { 210 {
275 LPBYTE lpb; 211 LPBYTE lpb;
276 int w, h; 212 int w, h;
277 const RAWINPUTHEADER *header; 213 const RAWINPUTHEADER *header;
285 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER)); 221 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER));
286 lpb = SDL_malloc(size*sizeof(LPBYTE)); 222 lpb = SDL_malloc(size*sizeof(LPBYTE));
287 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER)); 223 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
288 raw = (RAWINPUT *) lpb; 224 raw = (RAWINPUT *) lpb;
289 header = &raw->header; 225 header = &raw->header;
290 //raw_mouse=&raw->data.mouse;
291 flags=raw->data.mouse.usButtonFlags; 226 flags=raw->data.mouse.usButtonFlags;
292 for(i=0;i<total_mice;++i) 227 for(i=0;i<total_mice;++i)
293 { 228 {
294 if(mice[i]==header->hDevice) 229 if(mice[i]==header->hDevice)
295 { 230 {
300 mouse = SDL_GetMouse(index); 235 mouse = SDL_GetMouse(index);
301 GetCursorPos(&point); 236 GetCursorPos(&point);
302 ScreenToClient(hwnd, &point); 237 ScreenToClient(hwnd, &point);
303 SDL_GetWindowSize(data->windowID, &w, &h); 238 SDL_GetWindowSize(data->windowID, &w, &h);
304 SDL_UpdateCoordinates(w,h); 239 SDL_UpdateCoordinates(w,h);
305 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure); 240 if(i==tablet)
241 {
242 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure);
243 }
244 else
245 {
246 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),0);
247 }
306 if(flags & RI_MOUSE_BUTTON_1_DOWN) 248 if(flags & RI_MOUSE_BUTTON_1_DOWN)
307 { 249 {
308 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT); 250 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT);
309 } 251 }
310 else if(flags & RI_MOUSE_BUTTON_1_UP) 252 else if(flags & RI_MOUSE_BUTTON_1_UP)
324 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_RIGHT); 266 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_RIGHT);
325 } 267 }
326 else if(flags & RI_MOUSE_BUTTON_3_UP) 268 else if(flags & RI_MOUSE_BUTTON_3_UP)
327 { 269 {
328 SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_RIGHT); 270 SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_RIGHT);
271 }
272 if(flags & RI_MOUSE_WHEEL)
273 {
274 if(raw->data.mouse.usButtonData!=0)
275 {
276 SDL_SendMouseWheel(index, 0, raw->data.mouse.usButtonData);
277 }
329 } 278 }
330 } 279 }
331 return(0); 280 return(0);
332 case WM_MOUSELEAVE: 281 case WM_MOUSELEAVE:
333 { 282 {
340 if (mouse->focus == data->windowID) { 289 if (mouse->focus == data->windowID) {
341 SDL_SetMouseFocus(index, 0); 290 SDL_SetMouseFocus(index, 0);
342 } 291 }
343 } 292 }
344 return (0); 293 return (0);
345
346
347
348 /* case WM_MOUSEWHEEL:
349 {
350 int index;
351 int motion = (short) HIWORD(wParam);
352
353 index = data->videodata->mouse;
354 SDL_SendMouseWheel(index, 0, motion);
355 }
356 return (0);*/
357
358 case WM_SYSKEYDOWN: 294 case WM_SYSKEYDOWN:
359 case WM_KEYDOWN: 295 case WM_KEYDOWN:
360 { 296 {
361 int index; 297 int index;
362 298
741 SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ":" : "", message); 677 SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ":" : "", message);
742 SDL_free(message); 678 SDL_free(message);
743 } 679 }
744 680
745 /* vi: set ts=4 sw=4 expandtab: */ 681 /* vi: set ts=4 sw=4 expandtab: */
682