comparison src/video/win32/SDL_win32events.c @ 3767:abc8acb8e3d7 gsoc2008_manymouse

Proximity events, Pressure detection for multiple windows. Tablet button detection on the way.
author Szymon Wilczek <kazeuser@gmail.com>
date Wed, 23 Jul 2008 16:12:43 +0000
parents 3202e4826c57
children 1b87a8beab9d
comparison
equal deleted inserted replaced
3766:24db5d326f57 3767:abc8acb8e3d7
23 23
24 #include "SDL_win32video.h" 24 #include "SDL_win32video.h"
25 #include "SDL_syswm.h" 25 #include "SDL_syswm.h"
26 #include "SDL_vkeys.h" 26 #include "SDL_vkeys.h"
27 #include "../../events/SDL_events_c.h" 27 #include "../../events/SDL_events_c.h"
28 #include <wintab.h>
29 #define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE)
30 #define PACKETMODE 0
31 #include <pktdef.h>
28 32
29 /*#define WMMSG_DEBUG*/ 33 /*#define WMMSG_DEBUG*/
30 #ifdef WMMSG_DEBUG 34 #ifdef WMMSG_DEBUG
31 #include <stdio.h> 35 #include <stdio.h>
32 #include "wmmsg.h" 36 #include "wmmsg.h"
47 #endif 51 #endif
48 #ifndef GET_XBUTTON_WPARAM 52 #ifndef GET_XBUTTON_WPARAM
49 #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) 53 #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
50 #endif 54 #endif
51 55
56 #define pi 1.0
57
58 int first=1;
59
60 LOGCONTEXT lc;
61
52 static WPARAM 62 static WPARAM
53 RemapVKEY(WPARAM wParam, LPARAM lParam) 63 RemapVKEY(WPARAM wParam, LPARAM lParam)
54 { 64 {
55 int i; 65 int i;
56 BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF); 66 BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF);
83 LRESULT CALLBACK 93 LRESULT CALLBACK
84 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 94 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
85 { 95 {
86 SDL_WindowData *data; 96 SDL_WindowData *data;
87 97
88 /* Send a SDL_SYSWMEVENT if the application wants them */ 98 PACKET packet;
99
100 /* Send a SDL_SYSWMEVENT if the application wants them */
89 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { 101 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
90 SDL_SysWMmsg wmmsg; 102 SDL_SysWMmsg wmmsg;
91 103
92 SDL_VERSION(&wmmsg.version); 104 SDL_VERSION(&wmmsg.version);
93 wmmsg.hwnd = hwnd; 105 wmmsg.hwnd = hwnd;
99 111
100 /* Get the window data for the window */ 112 /* Get the window data for the window */
101 data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData")); 113 data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData"));
102 if (!data) { 114 if (!data) {
103 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); 115 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
104 } 116 }
105 #ifdef WMMSG_DEBUG 117 #ifdef WMMSG_DEBUG
106 { 118 {
107 FILE *log = fopen("wmmsg.txt", "a"); 119 FILE *log = fopen("wmmsg.txt", "a");
108 fprintf(log, "Received windows message: %p ", hwnd); 120 fprintf(log, "Received windows message: %p ", hwnd);
109 if (msg > MAX_WMMSG) { 121 if (msg > MAX_WMMSG) {
115 fclose(log); 127 fclose(log);
116 } 128 }
117 #endif 129 #endif
118 130
119 switch (msg) { 131 switch (msg) {
120 132 case WT_PACKET:
133 {
134 if (WTPacket((HCTX)lParam, wParam, &packet))
135 {
136 SDL_SendMouseMotion(0,0,(int)packet.pkX,(int)packet.pkY,(int)packet.pkNormalPressure);
137 }
138 }
139 break;
140 case WT_PROXIMITY:
141 {
142 int h_context=LOWORD(lParam);
143 if(h_context==0)
144 {
145 SDL_SendProximity(0, 0, 0, SDL_PROXIMITYOUT);
146 }
147 else
148 {
149 SDL_SendProximity(0, 0, 0, SDL_PROXIMITYIN);
150 }
151 }
152 break;
121 case WM_SHOWWINDOW: 153 case WM_SHOWWINDOW:
122 { 154 {
123 if (wParam) { 155 if (wParam) {
124 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 156 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0,
125 0); 157 0);
162 } 194 }
163 } 195 }
164 return (0); 196 return (0);
165 } 197 }
166 break; 198 break;
167 199 case WT_CTXOPEN:
200 {
201 SDL_SendMouseMotion(0,1,1,0,0);
202 SDL_SendMouseMotion(0,1,-1,0,0);
203 }
168 case WM_MOUSEMOVE: 204 case WM_MOUSEMOVE:
169 { 205 {
170 int index; 206 int index;
171 SDL_Mouse *mouse; 207 SDL_Mouse *mouse;
172 int x, y; 208 int x, y;
186 } 222 }
187 223
188 /* mouse has moved within the window */ 224 /* mouse has moved within the window */
189 x = LOWORD(lParam); 225 x = LOWORD(lParam);
190 y = HIWORD(lParam); 226 y = HIWORD(lParam);
227 //printf("index: %d\n",index);
191 if (mouse->relative_mode) { 228 if (mouse->relative_mode) {
192 int w, h; 229 int w, h;
193 POINT center; 230 POINT center;
194 SDL_GetWindowSize(data->windowID, &w, &h); 231 SDL_GetWindowSize(data->windowID, &w, &h);
195 center.x = (w / 2); 232 center.x = (w / 2);
197 x -= center.x; 234 x -= center.x;
198 y -= center.y; 235 y -= center.y;
199 if (x || y) { 236 if (x || y) {
200 ClientToScreen(hwnd, &center); 237 ClientToScreen(hwnd, &center);
201 SetCursorPos(center.x, center.y); 238 SetCursorPos(center.x, center.y);
202 SDL_SendMouseMotion(index, 1, x, y); 239 SDL_SendMouseMotion(index, 1, x, y,0);
203 } 240 }
204 } else { 241 } else {
205 SDL_SendMouseMotion(index, 0, x, y); 242 SDL_SendMouseMotion(index, 0, x, y,0);
206 } 243 }
207 } 244 }
208 return (0); 245 return (0);
209 246
210 case WM_MOUSELEAVE: 247 case WM_MOUSELEAVE:
300 337
301 if (!mouse->relative_mode) { 338 if (!mouse->relative_mode) {
302 int x, y; 339 int x, y;
303 x = LOWORD(lParam); 340 x = LOWORD(lParam);
304 y = HIWORD(lParam); 341 y = HIWORD(lParam);
305 SDL_SendMouseMotion(index, 0, x, y); 342 SDL_SendMouseMotion(index, 0, x, y,0);
306 } 343 }
307 SDL_SendMouseButton(index, state, button); 344 SDL_SendMouseButton(index, state, button);
308 345
309 /* 346 /*
310 * MSDN says: 347 * MSDN says:
623 660
624 void 661 void
625 WIN_PumpEvents(_THIS) 662 WIN_PumpEvents(_THIS)
626 { 663 {
627 MSG msg; 664 MSG msg;
665
628 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { 666 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
629 TranslateMessage(&msg); 667 TranslateMessage(&msg);
630 DispatchMessage(&msg); 668 DispatchMessage(&msg);
631 } 669
670 }
671 /*while (GetMessage(&msg, NULL, 0, 0)) {
672 TranslateMessage(&msg);
673 DispatchMessage(&msg);
674 }*/
675 //WTClose(g_hCtx);
632 } 676 }
633 677
634 static int app_registered = 0; 678 static int app_registered = 0;
635 LPTSTR SDL_Appname = NULL; 679 LPTSTR SDL_Appname = NULL;
636 Uint32 SDL_Appstyle = 0; 680 Uint32 SDL_Appstyle = 0;