comparison src/video/win32/SDL_win32events.c @ 3771:8cc36a399a12 gsoc2008_manymouse

comments added and improved code look(windows part)
author Szymon Wilczek <kazeuser@gmail.com>
date Sat, 02 Aug 2008 14:02:28 +0000
parents 81b649bad6d2
children 8b5b67000dc0
comparison
equal deleted inserted replaced
3770:81b649bad6d2 3771:8cc36a399a12
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 extern int tablet;
66 66
67 int pressure=0; 67 int pressure=0;/*the pressure reported by the tablet*/
68 68
69 static WPARAM 69 static WPARAM
70 RemapVKEY(WPARAM wParam, LPARAM lParam) 70 RemapVKEY(WPARAM wParam, LPARAM lParam)
71 { 71 {
72 int i; 72 int i;
136 #endif 136 #endif
137 137
138 switch (msg) { 138 switch (msg) {
139 case WT_PACKET: 139 case WT_PACKET:
140 { 140 {
141 /*if we receive such data we need to update the pressure*/
141 if (WTPacket((HCTX)lParam, wParam, &packet)) 142 if (WTPacket((HCTX)lParam, wParam, &packet))
142 { 143 {
143 pressure=(int)packet.pkNormalPressure; 144 pressure=(int)packet.pkNormalPressure;
144 } 145 }
145 } 146 }
146 break; 147 break;
147 case WT_PROXIMITY: 148 case WT_PROXIMITY:
148 { 149 {
150 /*checking where the proximity message showed up*/
149 int h_context=LOWORD(lParam); 151 int h_context=LOWORD(lParam);
150 LPPOINT point; 152 LPPOINT point;
151 GetCursorPos(&point); 153 GetCursorPos(&point);
152 ScreenToClient(hwnd, &point); 154 ScreenToClient(hwnd, &point);
155 /*are we in proximity or out of proximity*/
153 if(h_context==0) 156 if(h_context==0)
154 { 157 {
155 SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYOUT); 158 SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYOUT);
156 } 159 }
157 else 160 else
204 } 207 }
205 } 208 }
206 return (0); 209 return (0);
207 } 210 }
208 break; 211 break;
209 case WM_INPUT: 212 case WM_INPUT:/*mouse events*/
210 { 213 {
211 LPBYTE lpb; 214 LPBYTE lpb;
212 int w, h; 215 int w, h;
213 const RAWINPUTHEADER *header; 216 const RAWINPUTHEADER *header;
214 int index; 217 int index;
215 int i; 218 int i;
216 int size=0; 219 int size=0;
217 SDL_Mouse *mouse;
218 const RAWMOUSE *raw_mouse=NULL; 220 const RAWMOUSE *raw_mouse=NULL;
219 LPPOINT point; 221 LPPOINT point;
220 USHORT flags; 222 USHORT flags;
223
224 /*we're collecting data from the mouse*/
221 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER)); 225 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER));
222 lpb = SDL_malloc(size*sizeof(LPBYTE)); 226 lpb = SDL_malloc(size*sizeof(LPBYTE));
223 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER)); 227 GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
224 raw = (RAWINPUT *) lpb; 228 raw = (RAWINPUT *) lpb;
225 header = &raw->header; 229 header = &raw->header;
226 flags=raw->data.mouse.usButtonFlags; 230 flags=raw->data.mouse.usButtonFlags;
231
232 /*we're checking which mouse generated the event*/
227 for(i=0;i<total_mice;++i) 233 for(i=0;i<total_mice;++i)
228 { 234 {
229 if(mice[i]==header->hDevice) 235 if(mice[i]==header->hDevice)
230 { 236 {
231 index=i; 237 index=i;
232 break; 238 break;
233 } 239 }
234 } 240 }
235 mouse = SDL_GetMouse(index); 241
236 GetCursorPos(&point); 242 GetCursorPos(&point);
237 ScreenToClient(hwnd, &point); 243 ScreenToClient(hwnd, &point);
238 SDL_GetWindowSize(data->windowID, &w, &h); 244 SDL_GetWindowSize(data->windowID, &w, &h);
239 SDL_UpdateCoordinates(w,h); 245 SDL_UpdateCoordinates(w,h);/*we're updating the current window size*/
246
247 /*if the message was sent by a tablet we have to send also pressure*/
240 if(i==tablet) 248 if(i==tablet)
241 { 249 {
242 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure); 250 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure);
243 } 251 }
244 else 252 else
245 { 253 {
246 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),0); 254 SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),0);
247 } 255 }
256 /*we're sending mouse buttons messages to check up if sth changed*/
248 if(flags & RI_MOUSE_BUTTON_1_DOWN) 257 if(flags & RI_MOUSE_BUTTON_1_DOWN)
249 { 258 {
250 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT); 259 SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT);
251 } 260 }
252 else if(flags & RI_MOUSE_BUTTON_1_UP) 261 else if(flags & RI_MOUSE_BUTTON_1_UP)