comparison src/video/quartz/SDL_QuartzEvents.m @ 172:37e3ca9254c7

Date: Sat, 8 Sep 2001 04:42:23 +0200 From: Max Horn <max@quendi.de> Subject: SDL/OSX: Joystick; Better key handling I just finished implementing improved keyhandling for OS X (in fact the code should be easily ported to the "normal" MacOS part of SDL, I just had no chance yet). Works like this: First init the mapping table statically like before. Them, it queries the OS for the "official" key table, then iterates over all 127 scancode and gets the associates ascii code. It ignores everythng below 32 (has to, as it would lead to many problems if we did not... e.g. both ESC and NUM LOCk produce an ascii code 27 on my keyboard), and all stuff above 127 is mapped to SDLK_WORLD_* simply in the order it is encountered. In addition, caps lock is now working, too. The code work flawless for me, but since I only have one keyboard, I may have not encountered some serious problem... but I am pretty confident that it is better than the old code in most cases. The joystick driver works fine for me, too. I think it can be added to CVS already. It would simply be helpful if more people would test it. Hm, I wonder if Maelstrom or GLTron has Joystick support? That would be a wonderful test application :) I also took the liberty of modifying some text files like BUGS, README.CVS, README.MacOSX (which now contains the OS X docs I long promised)
author Sam Lantinga <slouken@libsdl.org>
date Tue, 11 Sep 2001 19:00:18 +0000
parents e92aa316c517
children e8157fcb3114
comparison
equal deleted inserted replaced
171:02e27b705645 172:37e3ca9254c7
1 /* 1 /*
2 SDL - Simple DirectMedia Layer 2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga 3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public 15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free 16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@devolution.com 20 slouken@devolution.com
21 */ 21 */
22 22
23 #include "SDL_QuartzKeys.h" 23 #include "SDL_QuartzKeys.h"
24 24
25 static int last_virtual_button = 0; // Last virtual mouse button pressed 25 static SDLKey keymap[256];
26 26 static unsigned int currentMods = 0; /* Current keyboard modifiers, to track modifier state */
27 static void QZ_InitOSKeymap (_THIS) { 27 static int last_virtual_button = 0; /* Last virtual mouse button pressed */
28
29 static void QZ_InitOSKeymap (_THIS) {
30 const void *KCHRPtr;
31 UInt32 state;
32 UInt32 value;
28 int i; 33 int i;
29 34 int world = SDLK_WORLD_0;
35
30 for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) 36 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
31 keymap[i] = SDLK_UNKNOWN; 37 keymap[i] = SDLK_UNKNOWN;
32 38
33 // This keymap is almost exactly the same as the OS 9 one 39 /* This keymap is almost exactly the same as the OS 9 one */
34 keymap[QZ_ESCAPE] = SDLK_ESCAPE; 40 keymap[QZ_ESCAPE] = SDLK_ESCAPE;
35 keymap[QZ_F1] = SDLK_F1; 41 keymap[QZ_F1] = SDLK_F1;
36 keymap[QZ_F2] = SDLK_F2; 42 keymap[QZ_F2] = SDLK_F2;
37 keymap[QZ_F3] = SDLK_F3; 43 keymap[QZ_F3] = SDLK_F3;
38 keymap[QZ_F4] = SDLK_F4; 44 keymap[QZ_F4] = SDLK_F4;
39 keymap[QZ_F5] = SDLK_F5; 45 keymap[QZ_F5] = SDLK_F5;
133 keymap[QZ_KP0] = SDLK_KP0; 139 keymap[QZ_KP0] = SDLK_KP0;
134 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD; 140 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
135 keymap[QZ_IBOOK_ENTER] = SDLK_KP_ENTER; 141 keymap[QZ_IBOOK_ENTER] = SDLK_KP_ENTER;
136 keymap[QZ_IBOOK_RIGHT] = SDLK_RIGHT; 142 keymap[QZ_IBOOK_RIGHT] = SDLK_RIGHT;
137 keymap[QZ_IBOOK_DOWN] = SDLK_DOWN; 143 keymap[QZ_IBOOK_DOWN] = SDLK_DOWN;
138 keymap[QZ_IBOOK_UP] = SDLK_UP; 144 keymap[QZ_IBOOK_UP] = SDLK_UP;
139 keymap[QZ_IBOOK_LEFT] = SDLK_LEFT; 145 keymap[QZ_IBOOK_LEFT] = SDLK_LEFT;
146
147 /* Up there we setup a static scancode->keysym map. However, it will not
148 * work very well on international keyboard. Hence we now query MacOS
149 * for its own keymap to adjust our own mapping table. However, this is
150 * bascially only useful for ascii char keys. This is also the reason
151 * why we keep the static table, too.
152 */
153
154 /* Get a pointer to the systems cached KCHR */
155 KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache);
156 if (KCHRPtr)
157 {
158 /* Loop over all 127 possible scan codes */
159 for (i = 0; i < 0x7F; i++)
160 {
161 /* We pretend a clean start to begin with (i.e. no dead keys active */
162 state = 0;
163
164 /* Now translate the key code to a key value */
165 value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
166
167 /* If the state become 0, it was a dead key. We need to translate again,
168 passing in the new state, to get the actual key value */
169 if (state != 0)
170 value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
171
172 /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */
173 if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */
174 keymap[i] = world++;
175 else if (value >= 32) /* non-control ASCII char */
176 keymap[i] = value;
177 }
178 }
179
180 /* The keypad codes are re-setup here, because the loop above cannot
181 * distinguish between a key on the keypad and a regular key. We maybe
182 * could get around this problem in another fashion: NSEvent's flags
183 * include a "NSNumericPadKeyMask" bit; we could check that and modify
184 * the symbol we return on the fly. However, this flag seems to exhibit
185 * some weird behaviour related to the num lock key
186 */
187 keymap[QZ_KP0] = SDLK_KP0;
188 keymap[QZ_KP1] = SDLK_KP1;
189 keymap[QZ_KP2] = SDLK_KP2;
190 keymap[QZ_KP3] = SDLK_KP3;
191 keymap[QZ_KP4] = SDLK_KP4;
192 keymap[QZ_KP5] = SDLK_KP5;
193 keymap[QZ_KP6] = SDLK_KP6;
194 keymap[QZ_KP7] = SDLK_KP7;
195 keymap[QZ_KP8] = SDLK_KP8;
196 keymap[QZ_KP9] = SDLK_KP9;
197 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS;
198 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
199 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
200 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS;
201 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE;
202 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
203 keymap[QZ_KP_ENTER] = SDLK_KP_ENTER;
140 } 204 }
141 205
142 static void QZ_DoKey (int state, NSEvent *event) { 206 static void QZ_DoKey (int state, NSEvent *event) {
143 207
144 NSString *chars; 208 NSString *chars;
145 int i; 209 int i;
146 SDL_keysym key; 210 SDL_keysym key;
147 211
148 /* An event can contain multiple characters */ 212 /* An event can contain multiple characters */
149 /* I'll ignore this fact for now, since there is only one virtual key code per event */ 213 /* I'll ignore this fact for now, since there is only one virtual key code per event */
150 chars = [ event characters ]; 214 chars = [ event characters ];
151 for (i =0; i < 1 /*[ chars length ] */; i++) { 215 for (i =0; i < 1 /*[ chars length ] */; i++) {
152 216
153 key.scancode = [ event keyCode ]; 217 key.scancode = [ event keyCode ];
154 key.sym = keymap [ key.scancode ]; 218 key.sym = keymap [ key.scancode ];
155 key.unicode = [ chars characterAtIndex:i]; 219 key.unicode = [ chars characterAtIndex:i];
156 key.mod = KMOD_NONE; 220 key.mod = KMOD_NONE;
157 221
158 SDL_PrivateKeyboard (state, &key); 222 SDL_PrivateKeyboard (state, &key);
159 } 223 }
160 } 224 }
161 225
162 static void QZ_DoModifiers (unsigned int newMods) { 226 static void QZ_DoModifiers (unsigned int newMods) {
163 227
164 const int offset = 18; 228 const int mapping[] = { SDLK_CAPSLOCK, SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA } ;
165 const int mapping[] = { SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, 0, SDLK_LMETA } ; 229
166 230 int i;
167 int bit; 231 int bit;
168 SDL_keysym key; 232 SDL_keysym key;
169 key.scancode = 0; 233
170 key.sym = SDLK_UNKNOWN; 234 key.scancode = 0;
171 key.unicode = 0; 235 key.sym = SDLK_UNKNOWN;
172 key.mod = KMOD_NONE; 236 key.unicode = 0;
173 237 key.mod = KMOD_NONE;
174 /* Iterate through the bits, testing each against the current modifiers */ 238
175 for (bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1) { 239 /* Iterate through the bits, testing each against the current modifiers */
176 240 for (i = 0, bit = NSAlphaShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) {
177 unsigned int currentMask, newMask; 241
178 242 unsigned int currentMask, newMask;
179 currentMask = currentMods & bit; 243
180 newMask = newMods & bit; 244 currentMask = currentMods & bit;
181 245 newMask = newMods & bit;
182 if ( currentMask && 246
183 currentMask != newMask ) { /* modifier up event */ 247 if ( currentMask &&
184 248 currentMask != newMask ) { /* modifier up event */
185 key.sym = mapping[ currentMask >> offset ]; 249
186 SDL_PrivateKeyboard (SDL_RELEASED, &key); 250 key.sym = mapping[i];
187 } 251 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
188 else 252 if (bit == NSAlphaShiftKeyMask)
189 if ( newMask && 253 SDL_PrivateKeyboard (SDL_PRESSED, &key);
190 currentMask != newMask ) { /* modifier down event */ 254 SDL_PrivateKeyboard (SDL_RELEASED, &key);
191 255 }
192 key.sym = mapping [ newMask >> offset ]; 256 else
193 SDL_PrivateKeyboard (SDL_PRESSED, &key); 257 if ( newMask &&
194 } 258 currentMask != newMask ) { /* modifier down event */
195 } 259
196 260 key.sym = mapping[i];
197 currentMods = newMods; 261 SDL_PrivateKeyboard (SDL_PRESSED, &key);
262 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
263 if (bit == NSAlphaShiftKeyMask)
264 SDL_PrivateKeyboard (SDL_RELEASED, &key);
265 }
266 }
267
268 currentMods = newMods;
198 } 269 }
199 270
200 static void QZ_DoActivate (_THIS) 271 static void QZ_DoActivate (_THIS)
201 { 272 {
202 inForeground = YES; 273 inForeground = YES;
203 274
204 /* Regrab the mouse */ 275 /* Regrab the mouse */
205 if (currentGrabMode == SDL_GRAB_ON) { 276 if (currentGrabMode == SDL_GRAB_ON) {
206 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2); 277 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
207 CGAssociateMouseAndMouseCursorPosition (0); 278 CGAssociateMouseAndMouseCursorPosition (0);
208 } 279 }
209 280
210 /* Hide the mouse cursor if inside the app window */ 281 /* Hide the mouse cursor if inside the app window */
211 // FIXME 282 if (!QZ_cursor_visible) {
212 if (!QZ_cursor_visible) { 283 HideCursor ();
213 HideCursor (); 284 }
214 } 285
215 286 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
216 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
217 } 287 }
218 288
219 static void QZ_DoDeactivate (_THIS) { 289 static void QZ_DoDeactivate (_THIS) {
220 290
221 inForeground = NO; 291 inForeground = NO;
222 292
223 /* Ungrab mouse if it is grabbed */ 293 /* Ungrab mouse if it is grabbed */
224 if (currentGrabMode == SDL_GRAB_ON) { 294 if (currentGrabMode == SDL_GRAB_ON) {
225 CGAssociateMouseAndMouseCursorPosition (1); 295 CGAssociateMouseAndMouseCursorPosition (1);
226 } 296 }
227 297
228 /* Show the mouse cursor */ 298 /* Show the mouse cursor */
229 // FIXME 299 if (!QZ_cursor_visible) {
230 if (!QZ_cursor_visible) { 300 ShowCursor ();
231 ShowCursor (); 301 }
232 } 302
233 303 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
234 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
235 } 304 }
236 305
237 static void QZ_PumpEvents (_THIS) 306 static void QZ_PumpEvents (_THIS)
238 { 307 {
239 NSDate *distantPast; 308 NSDate *distantPast;
240 NSEvent *event; 309 NSEvent *event;
241 NSRect winRect; 310 NSRect winRect;
242 NSRect titleBarRect; 311 NSRect titleBarRect;
243 NSAutoreleasePool *pool; 312 NSAutoreleasePool *pool;
244 313
245 distantPast = [ [ NSDate distantPast ] retain ]; 314 pool = [ [ NSAutoreleasePool alloc ] init ];
246 315 distantPast = [ NSDate distantPast ];
247 pool = [ [ NSAutoreleasePool alloc ] init ]; 316
248 317 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w + 1, SDL_VideoSurface->h + 1);
249 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w + 1, SDL_VideoSurface->h + 1); 318 titleBarRect = NSMakeRect ( 0, SDL_VideoSurface->h, SDL_VideoSurface->w,
250 titleBarRect = NSMakeRect ( 0, SDL_VideoSurface->h, SDL_VideoSurface->w, 319 SDL_VideoSurface->h + 22 );
251 SDL_VideoSurface->h + 22 ); 320
252 321 do {
253 do { 322
254 323 /* Poll for an event. This will not block */
255 /* Poll for an event. This will not block */ 324 event = [ NSApp nextEventMatchingMask:NSAnyEventMask
256 event = [ NSApp nextEventMatchingMask:NSAnyEventMask 325 untilDate:distantPast
257 untilDate:distantPast 326 inMode: NSDefaultRunLoopMode dequeue:YES ];
258 inMode: NSDefaultRunLoopMode dequeue:YES ]; 327
259 328 if (event != nil) {
260 if (event != nil) { 329 unsigned int type;
261 unsigned int type; 330 BOOL isForGameWin;
262 BOOL isForGameWin; 331
263 332 #define DO_MOUSE_DOWN(button, sendToWindow) do { \
264 #define DO_MOUSE_DOWN(button, sendToWindow) do { \ 333 if ( inForeground ) { \
265 if ( inForeground ) { \ 334 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
266 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \ 335 NSPointInRect([event locationInWindow], winRect) ) \
267 NSPointInRect([event locationInWindow], winRect) ) \ 336 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
268 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \ 337 } \
269 } \ 338 else { \
270 else { \ 339 QZ_DoActivate (this); \
271 QZ_DoActivate (this); \ 340 } \
272 } \ 341 [ NSApp sendEvent:event ]; \
273 [ NSApp sendEvent:event ]; \ 342 } while(0)
274 } while(0) 343
275 344 #define DO_MOUSE_UP(button, sendToWindow) do { \
276 #define DO_MOUSE_UP(button, sendToWindow) do { \ 345 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
277 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \ 346 !NSPointInRect([event locationInWindow], titleBarRect) )\
278 !NSPointInRect([event locationInWindow], titleBarRect) )\ 347 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
279 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \ 348 [ NSApp sendEvent:event ]; \
280 [ NSApp sendEvent:event ]; \ 349 } while(0)
281 } while(0) 350
282 351 type = [ event type ];
283 type = [ event type ]; 352 isForGameWin = (qz_window == [ event window ]);
284 isForGameWin = (qz_window == [ event window ]); 353 switch (type) {
285 switch (type) { 354
286 355 case NSLeftMouseDown:
287 case NSLeftMouseDown: 356 if ( NSCommandKeyMask & currentMods ) {
288 if ( NSCommandKeyMask & currentMods ) { 357 last_virtual_button = 3;
289 last_virtual_button = 3; 358 DO_MOUSE_DOWN (3, 0);
290 DO_MOUSE_DOWN (3, 0); 359 }
291 } 360 else if ( NSAlternateKeyMask & currentMods ) {
292 else if ( NSAlternateKeyMask & currentMods ) { 361 last_virtual_button = 2;
293 last_virtual_button = 2; 362 DO_MOUSE_DOWN (2, 0);
294 DO_MOUSE_DOWN (2, 0); 363 }
295 } 364 else {
296 else { 365 DO_MOUSE_DOWN (1, 1);
297 DO_MOUSE_DOWN (1, 1); 366 }
298 } 367 break;
299 break; 368 case 25: DO_MOUSE_DOWN (2, 0); break;
300 case 25: DO_MOUSE_DOWN (2, 0); break; 369 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break;
301 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break; 370 case NSLeftMouseUp:
302 case NSLeftMouseUp: 371
303 372 if ( last_virtual_button != 0 ) {
304 if ( last_virtual_button != 0 ) { 373 DO_MOUSE_UP (last_virtual_button, 0);
305 DO_MOUSE_UP (last_virtual_button, 0); 374 last_virtual_button = 0;
306 last_virtual_button = 0; 375 }
307 } 376 else {
308 else { 377 DO_MOUSE_UP (1, 1);
309 DO_MOUSE_UP (1, 1); 378 }
310 } 379 break;
311 break; 380 case 26: DO_MOUSE_UP (2, 0); break;
312 case 26: DO_MOUSE_UP (2, 0); break; 381 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break;
313 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break; 382 case NSSystemDefined:
314 case NSSystemDefined: 383 //if ([event subtype] == 7) {
315 //if ([event subtype] == 7) { 384 // unsigned int buttons; // up to 32 mouse button states!
316 // unsigned int buttons; // up to 32 mouse button states! 385 // buttons = [ event data2 ];
317 // buttons = [ event data2 ]; 386 //}
318 //} 387 break;
319 break; 388 case NSLeftMouseDragged:
320 case NSLeftMouseDragged: 389 case NSRightMouseDragged:
321 case NSRightMouseDragged: 390 case 27:
322 case 27: 391 case NSMouseMoved:
323 case NSMouseMoved: 392 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN)
324 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) 393 || NSPointInRect([event locationInWindow], winRect) )
325 || NSPointInRect([event locationInWindow], winRect) ) 394 {
326 { 395 static int moves = 0;
327 static int moves = 0; 396 NSPoint p;
328 NSPoint p; 397
329 398 if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) {
330 if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) { 399 p = [ NSEvent mouseLocation ];
331 p = [ NSEvent mouseLocation ]; 400 p.y = [[NSScreen mainScreen] frame].size.height - p.y;
332 p.y = [[NSScreen mainScreen] frame].size.height - p.y; 401 } else {
333 } else { 402 p = [ event locationInWindow ];
334 p = [ event locationInWindow ]; 403 p.y = SDL_VideoSurface->h - p.y;
335 p.y = SDL_VideoSurface->h - p.y; 404 }
336 } 405
337 406 if ( (moves % 10) == 0 ) {
338 if ( (moves % 10) == 0 ) { 407 SDL_PrivateMouseMotion (0, 0, p.x, p.y);
339 SDL_PrivateMouseMotion (0, 0, p.x, p.y); 408 }
340 } 409 else {
341 else { 410 CGMouseDelta dx, dy;
342 CGMouseDelta dx, dy; 411 CGGetLastMouseDelta (&dx, &dy);
343 CGGetLastMouseDelta (&dx, &dy); 412 SDL_PrivateMouseMotion (0, 1, dx, dy);
344 SDL_PrivateMouseMotion (0, 1, dx, dy); 413 }
345 } 414 moves++;
346 moves++; 415 }
347 } 416 break;
348 break; 417 case NSScrollWheel:
349 case NSScrollWheel: 418 {
350 { 419 if (NSPointInRect([ event locationInWindow ], winRect)) {
351 if (NSPointInRect([ event locationInWindow ], winRect)) { 420 float dy;
352 float dy; 421 dy = [ event deltaY ];
353 dy = [ event deltaY ]; 422 if ( dy > 0.0 ) /* Scroll up */
354 if ( dy > 0.0 ) /* Scroll up */ 423 SDL_PrivateMouseButton (SDL_PRESSED, 4, 0, 0);
355 SDL_PrivateMouseButton (SDL_PRESSED, 4, 0, 0); 424 else /* Scroll down */
356 else /* Scroll down */ 425 SDL_PrivateMouseButton (SDL_PRESSED, 5, 0, 0);
357 SDL_PrivateMouseButton (SDL_PRESSED, 5, 0, 0); 426 }
358 } 427 }
359 } 428 break;
360 break; 429 case NSKeyUp:
361 case NSKeyUp: 430 QZ_DoKey (SDL_RELEASED, event);
362 QZ_DoKey (SDL_RELEASED, event); 431 break;
363 break; 432 case NSKeyDown:
364 case NSKeyDown: 433 QZ_DoKey (SDL_PRESSED, event);
365 QZ_DoKey (SDL_PRESSED, event); 434 break;
366 break; 435 case NSFlagsChanged:
367 case NSFlagsChanged: 436 QZ_DoModifiers( [ event modifierFlags ] );
368 QZ_DoModifiers( [ event modifierFlags ] ); 437 break;
369 break; 438 /* case NSMouseEntered: break; */
370 // case NSMouseEntered: break; 439 /* case NSMouseExited: break; */
371 // case NSMouseExited: break; 440 case NSAppKitDefined:
372 case NSAppKitDefined: 441 switch ( [ event subtype ] ) {
373 switch ( [ event subtype ] ) { 442 case NSApplicationActivatedEventType:
374 case NSApplicationActivatedEventType: 443 QZ_DoActivate (this);
375 QZ_DoActivate (this); 444 break;
376 break; 445 case NSApplicationDeactivatedEventType:
377 case NSApplicationDeactivatedEventType: 446 QZ_DoDeactivate (this);
378 QZ_DoDeactivate (this); 447 break;
379 break; 448 }
380 } 449 [ NSApp sendEvent:event ];
381 [ NSApp sendEvent:event ]; 450 break;
382 break; 451 /* case NSApplicationDefined: break; */
383 // case NSApplicationDefined: break; 452 /* case NSPeriodic: break; */
384 // case NSPeriodic: break; 453 /* case NSCursorUpdate: break; */
385 // case NSCursorUpdate: break; 454 default:
386 default: 455 [ NSApp sendEvent:event ];
387 [ NSApp sendEvent:event ]; 456 }
388 } 457 }
389 } 458 } while (event != nil);
390 } while (event != nil); 459
391 460 [ pool release ];
392 [ pool release ]; 461 }
393 [ distantPast release ]; 462
394 }
395