Mercurial > sdl-ios-xcode
annotate src/video/maccommon/SDL_macevents.c @ 1510:720f8bb49d7d
Win32 fixes
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 13 Mar 2006 02:06:33 +0000 |
parents | d910939febfa |
children | f12379c41042 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1133
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
198
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 #include <stdio.h> | |
25 | |
1133
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
26 #if defined(__APPLE__) && defined(__MACH__) |
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
27 #include <Carbon/Carbon.h> |
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
28 #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335) |
0 | 29 #include <Carbon.h> |
30 #else | |
31 #include <Script.h> | |
32 #include <LowMem.h> | |
33 #include <Devices.h> | |
34 #include <DiskInit.h> | |
35 #include <ToolUtils.h> | |
36 #endif | |
37 | |
38 #include "SDL_events.h" | |
39 #include "SDL_video.h" | |
40 #include "SDL_syswm.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
41 #include "../../events/SDL_events_c.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
42 #include "../../events/SDL_sysevents.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
43 #include "../SDL_cursor_c.h" |
0 | 44 #include "SDL_macevents_c.h" |
45 #include "SDL_mackeys.h" | |
46 #include "SDL_macmouse_c.h" | |
47 | |
48 /* Define this to be able to collapse SDL windows. | |
49 #define USE_APPEARANCE_MANAGER | |
50 */ | |
51 | |
52 /* Macintosh resource constants */ | |
53 #define mApple 128 /* Apple menu resource */ | |
54 #define iAbout 1 /* About menu item */ | |
55 | |
56 /* Functions to handle the About menu */ | |
57 static void Mac_DoAppleMenu(_THIS, long item); | |
58 | |
59 /* The translation table from a macintosh key scancode to a SDL keysym */ | |
60 static SDLKey MAC_keymap[256]; | |
61 static SDL_keysym *TranslateKey(int scancode, int modifiers, | |
62 SDL_keysym *keysym, int pressed); | |
63 | |
64 /* Handle activation and deactivation -- returns whether an event was posted */ | |
65 static int Mac_HandleActivate(int activate) | |
66 { | |
67 if ( activate ) { | |
68 /* Show the current SDL application cursor */ | |
69 SDL_SetCursor(NULL); | |
70 | |
71 /* put our mask back case it changed during context switch */ | |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
155
diff
changeset
|
72 SetEventMask(everyEvent & ~autoKeyMask); |
0 | 73 } else { |
74 #if TARGET_API_MAC_CARBON | |
75 { Cursor cursor; | |
76 SetCursor(GetQDGlobalsArrow(&cursor)); | |
77 } | |
78 #else | |
79 SetCursor(&theQD->arrow); | |
80 #endif | |
81 if ( ! Mac_cursor_showing ) { | |
82 ShowCursor(); | |
83 Mac_cursor_showing = 1; | |
84 } | |
85 } | |
86 return(SDL_PrivateAppActive(activate, SDL_APPINPUTFOCUS)); | |
87 } | |
88 | |
89 static void myGlobalToLocal(_THIS, Point *pt) | |
90 { | |
91 if ( SDL_VideoSurface && !(SDL_VideoSurface->flags&SDL_FULLSCREEN) ) { | |
92 GrafPtr saveport; | |
93 GetPort(&saveport); | |
94 #if TARGET_API_MAC_CARBON | |
95 SetPort(GetWindowPort(SDL_Window)); | |
96 #else | |
97 SetPort(SDL_Window); | |
98 #endif | |
99 GlobalToLocal(pt); | |
100 SetPort(saveport); | |
101 } | |
102 } | |
103 | |
104 /* The main MacOS event handler */ | |
105 static int Mac_HandleEvents(_THIS, int wait4it) | |
106 { | |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
107 static int mouse_button = 1; |
0 | 108 int i; |
109 EventRecord event; | |
110 | |
111 #if TARGET_API_MAC_CARBON | |
112 /* There's no GetOSEvent() in the Carbon API. *sigh* */ | |
113 #define cooperative_multitasking 1 | |
114 #else | |
115 int cooperative_multitasking; | |
116 /* If we're running fullscreen, we can hog the MacOS events, | |
117 otherwise we had better play nicely with the other apps. | |
118 */ | |
119 if ( this->screen && (this->screen->flags & SDL_FULLSCREEN) ) { | |
120 cooperative_multitasking = 0; | |
121 } else { | |
122 cooperative_multitasking = 1; | |
123 } | |
124 #endif | |
125 | |
126 /* If we call WaitNextEvent(), MacOS will check other processes | |
127 * and allow them to run, and perform other high-level processing. | |
128 */ | |
129 if ( cooperative_multitasking || wait4it ) { | |
130 UInt32 wait_time; | |
131 | |
132 /* Are we polling or not? */ | |
133 if ( wait4it ) { | |
134 wait_time = 2147483647; | |
135 } else { | |
136 wait_time = 0; | |
137 } | |
138 WaitNextEvent(everyEvent, &event, wait_time, nil); | |
139 } else { | |
140 #if ! TARGET_API_MAC_CARBON | |
141 GetOSEvent(everyEvent, &event); | |
142 #endif | |
143 } | |
144 | |
145 #if TARGET_API_MAC_CARBON | |
146 /* for some reason, event.where isn't set ? */ | |
147 GetGlobalMouse ( &event.where ); | |
148 #endif | |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
149 |
0 | 150 /* Check for mouse motion */ |
151 if ( (event.where.h != last_where.h) || | |
152 (event.where.v != last_where.v) ) { | |
153 Point pt; | |
154 pt = last_where = event.where; | |
155 myGlobalToLocal(this, &pt); | |
156 SDL_PrivateMouseMotion(0, 0, pt.h, pt.v); | |
157 } | |
158 | |
159 /* Check the current state of the keyboard */ | |
160 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
161 KeyMap keys; | |
162 | |
163 /* Check for special non-event keys */ | |
164 if ( event.modifiers != last_mods ) { | |
165 static struct { | |
166 EventModifiers mask; | |
167 SDLKey key; | |
168 } mods[] = { | |
169 { alphaLock, SDLK_CAPSLOCK }, | |
170 #if 0 /* These are handled below in the GetKeys() code */ | |
171 { cmdKey, SDLK_LMETA }, | |
172 { shiftKey, SDLK_LSHIFT }, | |
173 { rightShiftKey, SDLK_RSHIFT }, | |
174 { optionKey, SDLK_LALT }, | |
175 { rightOptionKey, SDLK_RALT }, | |
176 { controlKey, SDLK_LCTRL }, | |
177 { rightControlKey, SDLK_RCTRL }, | |
178 #endif /* 0 */ | |
179 { 0, 0 } | |
180 }; | |
181 SDL_keysym keysym; | |
182 Uint8 mode; | |
183 EventModifiers mod, mask; | |
184 | |
185 | |
186 /* Set up the keyboard event */ | |
187 keysym.scancode = 0; | |
188 keysym.sym = SDLK_UNKNOWN; | |
189 keysym.mod = KMOD_NONE; | |
190 keysym.unicode = 0; | |
191 | |
192 /* See what has changed, and generate events */ | |
193 mod = event.modifiers; | |
194 for ( i=0; mods[i].mask; ++i ) { | |
195 mask = mods[i].mask; | |
196 if ( (mod&mask) != (last_mods&mask) ) { | |
197 keysym.sym = mods[i].key; | |
198 if ( (mod&mask) || | |
199 (mods[i].key == SDLK_CAPSLOCK) ) { | |
200 mode = SDL_PRESSED; | |
201 } else { | |
202 mode = SDL_RELEASED; | |
203 } | |
204 SDL_PrivateKeyboard(mode, &keysym); | |
205 } | |
206 } | |
207 | |
208 /* Save state for next time */ | |
209 last_mods = mod; | |
210 } | |
211 | |
212 /* Check for normal event keys, but we have to scan the | |
213 actual keyboard state because on MacOS X a keydown event | |
214 is immediately followed by a keyup event. | |
215 */ | |
216 GetKeys(keys); | |
217 if ( (keys[0] != last_keys[0]) || (keys[1] != last_keys[1]) || | |
218 (keys[2] != last_keys[2]) || (keys[3] != last_keys[3]) ) { | |
219 SDL_keysym keysym; | |
220 int old_bit, new_bit; | |
221 | |
222 #ifdef DEBUG_KEYBOARD | |
223 fprintf(sterr, "New keys: 0x%x 0x%x 0x%x 0x%x\n", | |
224 new_keys[0], new_keys[1], | |
225 new_keys[2], new_keys[3]); | |
226 #endif | |
227 for ( i=0; i<128; ++i ) { | |
228 old_bit = (((Uint8 *)last_keys)[i/8]>>(i%8)) & 0x01; | |
229 new_bit = (((Uint8 *)keys)[i/8]>>(i%8)) & 0x01; | |
230 if ( old_bit != new_bit ) { | |
231 /* Post the keyboard event */ | |
232 #ifdef DEBUG_KEYBOARD | |
233 fprintf(stderr,"Scancode: 0x%2.2X\n",i); | |
234 #endif | |
235 SDL_PrivateKeyboard(new_bit, | |
236 TranslateKey(i, event.modifiers, | |
237 &keysym, new_bit)); | |
238 } | |
239 } | |
240 | |
241 /* Save state for next time */ | |
242 last_keys[0] = keys[0]; | |
243 last_keys[1] = keys[1]; | |
244 last_keys[2] = keys[2]; | |
245 last_keys[3] = keys[3]; | |
246 } | |
247 } | |
248 | |
249 /* Handle normal events */ | |
250 switch (event.what) { | |
251 case mouseDown: { | |
252 WindowRef win; | |
253 short area; | |
254 | |
255 area = FindWindow(event.where, &win); | |
256 /* Support switching between the SIOUX console | |
257 and SDL_Window by clicking in the window. | |
258 */ | |
259 if ( win && (win != FrontWindow()) ) { | |
260 SelectWindow(win); | |
261 } | |
262 switch (area) { | |
263 case inMenuBar: /* Only the apple menu exists */ | |
264 Mac_DoAppleMenu(this, MenuSelect(event.where)); | |
265 HiliteMenu(0); | |
266 break; | |
267 case inDrag: | |
268 #if TARGET_API_MAC_CARBON | |
269 DragWindow(win, event.where, NULL); | |
270 #else | |
271 DragWindow(win, event.where, &theQD->screenBits.bounds); | |
272 #endif | |
273 break; | |
274 case inGoAway: | |
275 if ( TrackGoAway(win, event.where) ) { | |
276 SDL_PrivateQuit(); | |
277 } | |
278 break; | |
279 case inContent: | |
280 myGlobalToLocal(this, &event.where); | |
281 /* Treat command-click as right mouse button */ | |
282 if ( event.modifiers & optionKey ) { | |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
283 mouse_button = 2; |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
284 } else if ( event.modifiers & cmdKey ) { |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
285 mouse_button = 3; |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
286 } else { |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
287 mouse_button = 1; |
0 | 288 } |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
289 SDL_PrivateMouseButton(SDL_PRESSED, |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
290 mouse_button, event.where.h, event.where.v); |
0 | 291 break; |
292 case inGrow: { | |
293 int newSize; | |
294 | |
295 /* Don't allow resize if video mode isn't resizable */ | |
296 if ( ! SDL_PublicSurface || | |
297 ! (SDL_PublicSurface->flags & SDL_RESIZABLE) ) { | |
298 break; | |
299 } | |
300 #if TARGET_API_MAC_CARBON | |
301 newSize = GrowWindow(win, event.where, NULL); | |
302 #else | |
303 newSize = GrowWindow(win, event.where, &theQD->screenBits.bounds); | |
304 #endif | |
305 if ( newSize ) { | |
306 #if !TARGET_API_MAC_CARBON | |
307 EraseRect ( &theQD->screenBits.bounds ); | |
308 #endif | |
309 SizeWindow ( win, LoWord (newSize), HiWord (newSize), 1 ); | |
310 SDL_PrivateResize ( LoWord (newSize), HiWord (newSize) ); | |
311 } | |
312 } break; | |
313 case inZoomIn: | |
314 case inZoomOut: | |
315 if ( TrackBox (win, event.where, area )) { | |
316 Rect rect; | |
317 #if !TARGET_API_MAC_CARBON | |
318 EraseRect ( &theQD->screenBits.bounds ); | |
319 #endif | |
320 ZoomWindow ( win, area, 0); | |
321 if ( area == inZoomIn ) { | |
322 GetWindowUserState(SDL_Window, &rect); | |
323 } else { | |
324 GetWindowStandardState(SDL_Window, &rect); | |
325 } | |
326 SDL_PrivateResize (rect.right-rect.left, | |
327 rect.bottom-rect.top); | |
328 } | |
329 break; | |
330 #if TARGET_API_MAC_CARBON | |
331 case inCollapseBox: | |
332 if ( TrackBox (win, event.where, area )) { | |
333 if ( IsWindowCollapsable(win) ) { | |
334 CollapseWindow (win, !IsWindowCollapsed(win)); | |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
335 /* There should be something done like in inGrow case, but... */ |
0 | 336 } |
337 } | |
338 break; | |
339 #endif /* TARGET_API_MAC_CARBON */ | |
340 case inSysWindow: | |
341 #if TARGET_API_MAC_CARBON | |
342 /* Never happens in Carbon? */ | |
343 #else | |
344 SystemClick(&event, win); | |
345 #endif | |
346 break; | |
347 default: | |
348 break; | |
349 } | |
350 } | |
351 break; | |
352 case mouseUp: { | |
353 myGlobalToLocal(this, &event.where); | |
155
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
354 /* Release the mouse button we simulated in the last press. |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
355 The drawback of this methos is we cannot press more than |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
356 one button. However, this doesn't matter, since there is |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
357 only a single logical mouse button, even if you have a |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
358 multi-button mouse, this doesn't matter at all. |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
359 */ |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
360 SDL_PrivateMouseButton(SDL_RELEASED, |
2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
10
diff
changeset
|
361 mouse_button, event.where.h, event.where.v); |
0 | 362 } |
363 break; | |
364 #if 0 /* Handled above the switch statement */ | |
365 case keyDown: { | |
366 SDL_keysym keysym; | |
367 | |
368 SDL_PrivateKeyboard(SDL_PRESSED, | |
369 TranslateKey((event.message&keyCodeMask)>>8 | |
370 event.modifiers, &keysym, 1)); | |
371 } | |
372 break; | |
373 case keyUp: { | |
374 SDL_keysym keysym; | |
375 | |
376 SDL_PrivateKeyboard(SDL_RELEASED, | |
377 TranslateKey((event.message&keyCodeMask)>>8 | |
378 event.modifiers, &keysym, 0)); | |
379 } | |
380 break; | |
381 #endif | |
382 case updateEvt: { | |
383 BeginUpdate(SDL_Window); | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
384 #if SDL_VIDEO_OPENGL |
774
0c3e00cc9580
Date: Mon, 5 Jan 2004 00:09:36 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
385 if (SDL_VideoSurface->flags & SDL_OPENGL) |
0c3e00cc9580
Date: Mon, 5 Jan 2004 00:09:36 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
386 SDL_GL_SwapBuffers(); |
0c3e00cc9580
Date: Mon, 5 Jan 2004 00:09:36 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
387 else |
0c3e00cc9580
Date: Mon, 5 Jan 2004 00:09:36 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
388 #endif |
0 | 389 if ( (SDL_VideoSurface->flags & SDL_HWSURFACE) == |
390 SDL_SWSURFACE ) { | |
391 SDL_UpdateRect(SDL_VideoSurface, 0, 0, 0, 0); | |
392 } | |
393 EndUpdate(SDL_Window); | |
394 } | |
395 /* If this was an update event for the SIOUX console, we return 0 | |
396 in order to stop an endless series of updates being triggered. | |
397 */ | |
398 if ( (WindowRef) event.message != SDL_Window ) { | |
399 return 0; | |
400 } | |
401 break; | |
402 case activateEvt: { | |
403 Mac_HandleActivate(!!(event.modifiers & activeFlag)); | |
404 } | |
405 break; | |
406 case diskEvt: { | |
407 #if TARGET_API_MAC_CARBON | |
408 /* What are we supposed to do? */; | |
409 #else | |
410 if ( ((event.message>>16)&0xFFFF) != noErr ) { | |
411 Point spot; | |
412 SetPt(&spot, 0x0070, 0x0050); | |
413 DIBadMount(spot, event.message); | |
414 } | |
415 #endif | |
416 } | |
417 break; | |
418 case osEvt: { | |
419 switch ((event.message>>24) & 0xFF) { | |
420 #if 0 /* Handled above the switch statement */ | |
421 case mouseMovedMessage: { | |
422 myGlobalToLocal(this, &event.where); | |
423 SDL_PrivateMouseMotion(0, 0, | |
424 event.where.h, event.where.v); | |
425 } | |
426 break; | |
427 #endif /* 0 */ | |
428 case suspendResumeMessage: { | |
429 Mac_HandleActivate(!!(event.message & resumeFlag)); | |
430 } | |
431 break; | |
432 } | |
433 } | |
434 break; | |
435 default: { | |
436 ; | |
437 } | |
438 break; | |
439 } | |
440 return (event.what != nullEvent); | |
441 } | |
442 | |
443 | |
444 void Mac_PumpEvents(_THIS) | |
445 { | |
446 /* Process pending MacOS events */ | |
447 while ( Mac_HandleEvents(this, 0) ) { | |
448 /* Loop and check again */; | |
449 } | |
450 } | |
451 | |
452 void Mac_InitOSKeymap(_THIS) | |
453 { | |
198
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
454 const void *KCHRPtr; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
455 UInt32 state; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
456 UInt32 value; |
0 | 457 int i; |
198
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
458 int world = SDLK_WORLD_0; |
0 | 459 |
460 /* Map the MAC keysyms */ | |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
461 for ( i=0; i<SDL_arraysize(MAC_keymap); ++i ) |
0 | 462 MAC_keymap[i] = SDLK_UNKNOWN; |
463 | |
464 /* Defined MAC_* constants */ | |
465 MAC_keymap[MK_ESCAPE] = SDLK_ESCAPE; | |
466 MAC_keymap[MK_F1] = SDLK_F1; | |
467 MAC_keymap[MK_F2] = SDLK_F2; | |
468 MAC_keymap[MK_F3] = SDLK_F3; | |
469 MAC_keymap[MK_F4] = SDLK_F4; | |
470 MAC_keymap[MK_F5] = SDLK_F5; | |
471 MAC_keymap[MK_F6] = SDLK_F6; | |
472 MAC_keymap[MK_F7] = SDLK_F7; | |
473 MAC_keymap[MK_F8] = SDLK_F8; | |
474 MAC_keymap[MK_F9] = SDLK_F9; | |
475 MAC_keymap[MK_F10] = SDLK_F10; | |
476 MAC_keymap[MK_F11] = SDLK_F11; | |
477 MAC_keymap[MK_F12] = SDLK_F12; | |
478 MAC_keymap[MK_PRINT] = SDLK_PRINT; | |
479 MAC_keymap[MK_SCROLLOCK] = SDLK_SCROLLOCK; | |
480 MAC_keymap[MK_PAUSE] = SDLK_PAUSE; | |
481 MAC_keymap[MK_POWER] = SDLK_POWER; | |
482 MAC_keymap[MK_BACKQUOTE] = SDLK_BACKQUOTE; | |
483 MAC_keymap[MK_1] = SDLK_1; | |
484 MAC_keymap[MK_2] = SDLK_2; | |
485 MAC_keymap[MK_3] = SDLK_3; | |
486 MAC_keymap[MK_4] = SDLK_4; | |
487 MAC_keymap[MK_5] = SDLK_5; | |
488 MAC_keymap[MK_6] = SDLK_6; | |
489 MAC_keymap[MK_7] = SDLK_7; | |
490 MAC_keymap[MK_8] = SDLK_8; | |
491 MAC_keymap[MK_9] = SDLK_9; | |
492 MAC_keymap[MK_0] = SDLK_0; | |
493 MAC_keymap[MK_MINUS] = SDLK_MINUS; | |
494 MAC_keymap[MK_EQUALS] = SDLK_EQUALS; | |
495 MAC_keymap[MK_BACKSPACE] = SDLK_BACKSPACE; | |
496 MAC_keymap[MK_INSERT] = SDLK_INSERT; | |
497 MAC_keymap[MK_HOME] = SDLK_HOME; | |
498 MAC_keymap[MK_PAGEUP] = SDLK_PAGEUP; | |
499 MAC_keymap[MK_NUMLOCK] = SDLK_NUMLOCK; | |
500 MAC_keymap[MK_KP_EQUALS] = SDLK_KP_EQUALS; | |
501 MAC_keymap[MK_KP_DIVIDE] = SDLK_KP_DIVIDE; | |
502 MAC_keymap[MK_KP_MULTIPLY] = SDLK_KP_MULTIPLY; | |
503 MAC_keymap[MK_TAB] = SDLK_TAB; | |
504 MAC_keymap[MK_q] = SDLK_q; | |
505 MAC_keymap[MK_w] = SDLK_w; | |
506 MAC_keymap[MK_e] = SDLK_e; | |
507 MAC_keymap[MK_r] = SDLK_r; | |
508 MAC_keymap[MK_t] = SDLK_t; | |
509 MAC_keymap[MK_y] = SDLK_y; | |
510 MAC_keymap[MK_u] = SDLK_u; | |
511 MAC_keymap[MK_i] = SDLK_i; | |
512 MAC_keymap[MK_o] = SDLK_o; | |
513 MAC_keymap[MK_p] = SDLK_p; | |
514 MAC_keymap[MK_LEFTBRACKET] = SDLK_LEFTBRACKET; | |
515 MAC_keymap[MK_RIGHTBRACKET] = SDLK_RIGHTBRACKET; | |
516 MAC_keymap[MK_BACKSLASH] = SDLK_BACKSLASH; | |
517 MAC_keymap[MK_DELETE] = SDLK_DELETE; | |
518 MAC_keymap[MK_END] = SDLK_END; | |
519 MAC_keymap[MK_PAGEDOWN] = SDLK_PAGEDOWN; | |
520 MAC_keymap[MK_KP7] = SDLK_KP7; | |
521 MAC_keymap[MK_KP8] = SDLK_KP8; | |
522 MAC_keymap[MK_KP9] = SDLK_KP9; | |
523 MAC_keymap[MK_KP_MINUS] = SDLK_KP_MINUS; | |
524 MAC_keymap[MK_CAPSLOCK] = SDLK_CAPSLOCK; | |
525 MAC_keymap[MK_a] = SDLK_a; | |
526 MAC_keymap[MK_s] = SDLK_s; | |
527 MAC_keymap[MK_d] = SDLK_d; | |
528 MAC_keymap[MK_f] = SDLK_f; | |
529 MAC_keymap[MK_g] = SDLK_g; | |
530 MAC_keymap[MK_h] = SDLK_h; | |
531 MAC_keymap[MK_j] = SDLK_j; | |
532 MAC_keymap[MK_k] = SDLK_k; | |
533 MAC_keymap[MK_l] = SDLK_l; | |
534 MAC_keymap[MK_SEMICOLON] = SDLK_SEMICOLON; | |
535 MAC_keymap[MK_QUOTE] = SDLK_QUOTE; | |
536 MAC_keymap[MK_RETURN] = SDLK_RETURN; | |
537 MAC_keymap[MK_KP4] = SDLK_KP4; | |
538 MAC_keymap[MK_KP5] = SDLK_KP5; | |
539 MAC_keymap[MK_KP6] = SDLK_KP6; | |
540 MAC_keymap[MK_KP_PLUS] = SDLK_KP_PLUS; | |
541 MAC_keymap[MK_LSHIFT] = SDLK_LSHIFT; | |
542 MAC_keymap[MK_z] = SDLK_z; | |
543 MAC_keymap[MK_x] = SDLK_x; | |
544 MAC_keymap[MK_c] = SDLK_c; | |
545 MAC_keymap[MK_v] = SDLK_v; | |
546 MAC_keymap[MK_b] = SDLK_b; | |
547 MAC_keymap[MK_n] = SDLK_n; | |
548 MAC_keymap[MK_m] = SDLK_m; | |
549 MAC_keymap[MK_COMMA] = SDLK_COMMA; | |
550 MAC_keymap[MK_PERIOD] = SDLK_PERIOD; | |
551 MAC_keymap[MK_SLASH] = SDLK_SLASH; | |
552 #if 0 /* These are the same as the left versions - use left by default */ | |
553 MAC_keymap[MK_RSHIFT] = SDLK_RSHIFT; | |
554 #endif | |
555 MAC_keymap[MK_UP] = SDLK_UP; | |
556 MAC_keymap[MK_KP1] = SDLK_KP1; | |
557 MAC_keymap[MK_KP2] = SDLK_KP2; | |
558 MAC_keymap[MK_KP3] = SDLK_KP3; | |
559 MAC_keymap[MK_KP_ENTER] = SDLK_KP_ENTER; | |
560 MAC_keymap[MK_LCTRL] = SDLK_LCTRL; | |
561 MAC_keymap[MK_LALT] = SDLK_LALT; | |
562 MAC_keymap[MK_LMETA] = SDLK_LMETA; | |
563 MAC_keymap[MK_SPACE] = SDLK_SPACE; | |
564 #if 0 /* These are the same as the left versions - use left by default */ | |
565 MAC_keymap[MK_RMETA] = SDLK_RMETA; | |
566 MAC_keymap[MK_RALT] = SDLK_RALT; | |
567 MAC_keymap[MK_RCTRL] = SDLK_RCTRL; | |
568 #endif | |
569 MAC_keymap[MK_LEFT] = SDLK_LEFT; | |
570 MAC_keymap[MK_DOWN] = SDLK_DOWN; | |
571 MAC_keymap[MK_RIGHT] = SDLK_RIGHT; | |
572 MAC_keymap[MK_KP0] = SDLK_KP0; | |
573 MAC_keymap[MK_KP_PERIOD] = SDLK_KP_PERIOD; | |
10
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
574 |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
575 #if defined(__APPLE__) && defined(__MACH__) |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
576 /* Wierd, these keys are on my iBook under MacOS X |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
577 Note that the left arrow keysym is the same as left ctrl!? |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
578 */ |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
579 MAC_keymap[MK_IBOOK_ENTER] = SDLK_KP_ENTER; |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
580 MAC_keymap[MK_IBOOK_RIGHT] = SDLK_RIGHT; |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
581 MAC_keymap[MK_IBOOK_DOWN] = SDLK_DOWN; |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
582 MAC_keymap[MK_IBOOK_UP] = SDLK_UP; |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
583 MAC_keymap[MK_IBOOK_LEFT] = SDLK_LEFT; |
ee3bb7cd06b5
Fixed left arrow on iBook keyboard under MacOS X
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
584 #endif /* MacOS X */ |
198
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
585 |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
586 /* Up there we setup a static scancode->keysym map. However, it will not |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
587 * work very well on international keyboard. Hence we now query MacOS |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
588 * for its own keymap to adjust our own mapping table. However, this is |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
589 * bascially only useful for ascii char keys. This is also the reason |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
590 * why we keep the static table, too. |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
591 */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
592 |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
593 /* Get a pointer to the systems cached KCHR */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
594 KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache); |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
595 if (KCHRPtr) |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
596 { |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
597 /* Loop over all 127 possible scan codes */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
598 for (i = 0; i < 0x7F; i++) |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
599 { |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
600 /* We pretend a clean start to begin with (i.e. no dead keys active */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
601 state = 0; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
602 |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
603 /* Now translate the key code to a key value */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
604 value = KeyTranslate(KCHRPtr, i, &state) & 0xff; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
605 |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
606 /* If the state become 0, it was a dead key. We need to translate again, |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
607 passing in the new state, to get the actual key value */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
608 if (state != 0) |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
609 value = KeyTranslate(KCHRPtr, i, &state) & 0xff; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
610 |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
611 /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
612 if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
613 MAC_keymap[i] = world++; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
614 else if (value >= 32) /* non-control ASCII char */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
615 MAC_keymap[i] = value; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
616 } |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
617 } |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
618 |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
619 /* The keypad codes are re-setup here, because the loop above cannot |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
620 * distinguish between a key on the keypad and a regular key. We maybe |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
621 * could get around this problem in another fashion: NSEvent's flags |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
622 * include a "NSNumericPadKeyMask" bit; we could check that and modify |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
623 * the symbol we return on the fly. However, this flag seems to exhibit |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
624 * some weird behaviour related to the num lock key |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
625 */ |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
626 MAC_keymap[MK_KP0] = SDLK_KP0; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
627 MAC_keymap[MK_KP1] = SDLK_KP1; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
628 MAC_keymap[MK_KP2] = SDLK_KP2; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
629 MAC_keymap[MK_KP3] = SDLK_KP3; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
630 MAC_keymap[MK_KP4] = SDLK_KP4; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
631 MAC_keymap[MK_KP5] = SDLK_KP5; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
632 MAC_keymap[MK_KP6] = SDLK_KP6; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
633 MAC_keymap[MK_KP7] = SDLK_KP7; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
634 MAC_keymap[MK_KP8] = SDLK_KP8; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
635 MAC_keymap[MK_KP9] = SDLK_KP9; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
636 MAC_keymap[MK_KP_MINUS] = SDLK_KP_MINUS; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
637 MAC_keymap[MK_KP_PLUS] = SDLK_KP_PLUS; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
638 MAC_keymap[MK_KP_PERIOD] = SDLK_KP_PERIOD; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
639 MAC_keymap[MK_KP_EQUALS] = SDLK_KP_EQUALS; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
640 MAC_keymap[MK_KP_DIVIDE] = SDLK_KP_DIVIDE; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
641 MAC_keymap[MK_KP_MULTIPLY] = SDLK_KP_MULTIPLY; |
49bf25403f5e
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
642 MAC_keymap[MK_KP_ENTER] = SDLK_KP_ENTER; |
0 | 643 } |
644 | |
645 static SDL_keysym *TranslateKey(int scancode, int modifiers, | |
646 SDL_keysym *keysym, int pressed) | |
647 { | |
648 /* Set the keysym information */ | |
649 keysym->scancode = scancode; | |
650 keysym->sym = MAC_keymap[keysym->scancode]; | |
651 keysym->mod = KMOD_NONE; | |
652 keysym->unicode = 0; | |
653 if ( pressed && SDL_TranslateUNICODE ) { | |
654 static unsigned long state = 0; | |
655 static Ptr keymap = nil; | |
656 Ptr new_keymap; | |
657 | |
658 /* Get the current keyboard map resource */ | |
659 new_keymap = (Ptr)GetScriptManagerVariable(smKCHRCache); | |
660 if ( new_keymap != keymap ) { | |
661 keymap = new_keymap; | |
662 state = 0; | |
663 } | |
664 keysym->unicode = KeyTranslate(keymap, | |
665 keysym->scancode|modifiers, &state) & 0xFFFF; | |
666 } | |
667 return(keysym); | |
668 } | |
669 | |
670 void Mac_InitEvents(_THIS) | |
671 { | |
672 /* Create apple menu bar */ | |
673 apple_menu = GetMenu(mApple); | |
674 if ( apple_menu != nil ) { | |
675 AppendResMenu(apple_menu, 'DRVR'); | |
676 InsertMenu(apple_menu, 0); | |
677 } | |
678 DrawMenuBar(); | |
679 | |
680 /* Get rid of spurious events at startup */ | |
681 FlushEvents(everyEvent, 0); | |
682 | |
683 /* Allow every event but keyrepeat */ | |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
155
diff
changeset
|
684 SetEventMask(everyEvent & ~autoKeyMask); |
0 | 685 } |
686 | |
687 void Mac_QuitEvents(_THIS) | |
688 { | |
689 ClearMenuBar(); | |
690 if ( apple_menu != nil ) { | |
691 ReleaseResource((char **)apple_menu); | |
692 } | |
693 | |
694 /* Clean up pending events */ | |
695 FlushEvents(everyEvent, 0); | |
696 } | |
697 | |
698 static void Mac_DoAppleMenu(_THIS, long choice) | |
699 { | |
700 #if !TARGET_API_MAC_CARBON /* No Apple menu in OS X */ | |
701 short menu, item; | |
702 | |
703 item = (choice&0xFFFF); | |
704 choice >>= 16; | |
705 menu = (choice&0xFFFF); | |
706 | |
707 switch (menu) { | |
708 case mApple: { | |
709 switch (item) { | |
710 case iAbout: { | |
711 /* Run the about box */; | |
712 } | |
713 break; | |
714 default: { | |
715 Str255 name; | |
716 | |
717 GetMenuItemText(apple_menu, item, name); | |
718 OpenDeskAcc(name); | |
719 } | |
720 break; | |
721 } | |
722 } | |
723 break; | |
724 default: { | |
725 /* Ignore other menus */; | |
726 } | |
727 } | |
728 #endif /* !TARGET_API_MAC_CARBON */ | |
729 } | |
730 | |
731 #if !TARGET_API_MAC_CARBON | |
732 /* Since we don't initialize QuickDraw, we need to get a pointer to qd */ | |
733 QDGlobals *theQD = NULL; | |
1133
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
734 #endif |
0 | 735 |
736 /* Exported to the macmain code */ | |
737 void SDL_InitQuickDraw(struct QDGlobals *the_qd) | |
738 { | |
1133
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
739 #if !TARGET_API_MAC_CARBON |
0 | 740 theQD = the_qd; |
1133
609c060fd2a2
The MacOSX Carbon/Cocoa/X11 all in one library patch. Relevant emails:
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
741 #endif |
0 | 742 } |