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