4 Mac OS X OpenGL and input module, using Carbon and AGL
6 Copyright (C) 2005-2006 Mathieu Olivier
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <OpenGL/OpenGL.h>
28 #include <Carbon/Carbon.h>
29 #include "vid_agl_mackeys.h" // this is SDL/src/video/maccommon/SDL_mackeys.h
32 #ifndef kCGLCEMPEngine
33 #define kCGLCEMPEngine 313
36 // Tell startup code that we have a client
37 int cl_available = true;
39 qboolean vid_supportrefreshrate = true;
42 AGLPixelFormat (*qaglChoosePixelFormat) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList);
43 AGLContext (*qaglCreateContext) (AGLPixelFormat pix, AGLContext share);
44 GLboolean (*qaglDestroyContext) (AGLContext ctx);
45 void (*qaglDestroyPixelFormat) (AGLPixelFormat pix);
46 const GLubyte* (*qaglErrorString) (GLenum code);
47 GLenum (*qaglGetError) (void);
48 GLboolean (*qaglSetCurrentContext) (AGLContext ctx);
49 GLboolean (*qaglSetDrawable) (AGLContext ctx, AGLDrawable draw);
50 GLboolean (*qaglSetFullScreen) (AGLContext ctx, GLsizei width, GLsizei height, GLsizei freq, GLint device);
51 GLboolean (*qaglSetInteger) (AGLContext ctx, GLenum pname, const GLint *params);
52 void (*qaglSwapBuffers) (AGLContext ctx);
53 CGLError (*qCGLEnable) (CGLContextObj ctx, CGLContextEnable pname);
54 CGLError (*qCGLDisable) (CGLContextObj ctx, CGLContextEnable pname);
55 CGLContextObj (*qCGLGetCurrentContext) (void);
57 static qboolean multithreadedgl;
58 static qboolean mouse_avail = true;
59 static qboolean vid_usingmouse = false;
60 static float mouse_x, mouse_y;
62 static qboolean vid_isfullscreen = false;
63 static qboolean vid_usingvsync = false;
65 static qboolean sound_active = true;
67 static int scr_width, scr_height;
69 static cvar_t apple_multithreadedgl = {CVAR_SAVE, "apple_multithreadedgl", "0", "makes use of a second thread for the OpenGL driver (if possible) rather than using the engine thread (note: this is done automatically on most other operating systems)"};
71 static AGLContext context;
72 static WindowRef window;
75 void VID_GetWindowSize (int *x, int *y, int *width, int *height)
82 static void IN_Activate( qboolean grab )
86 if (!vid_usingmouse && mouse_avail && window)
92 CGDisplayHideCursor(CGMainDisplayID());
94 // Put the mouse cursor at the center of the window
95 GetWindowBounds (window, kWindowContentRgn, &winBounds);
96 winCenter.x = (winBounds.left + winBounds.right) / 2;
97 winCenter.y = (winBounds.top + winBounds.bottom) / 2;
98 CGWarpMouseCursorPosition(winCenter);
100 // Lock the mouse pointer at its current position
101 CGAssociateMouseAndMouseCursorPosition(false);
103 mouse_x = mouse_y = 0;
104 vid_usingmouse = true;
111 CGAssociateMouseAndMouseCursorPosition(true);
112 CGDisplayShowCursor(CGMainDisplayID());
114 vid_usingmouse = false;
119 #define GAMMA_TABLE_SIZE 256
120 void VID_Finish (qboolean allowmousegrab)
122 qboolean vid_usemouse;
123 qboolean vid_usevsync;
125 // handle the mouse state when windowed if that's changed
126 vid_usemouse = false;
127 if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback))
129 if (!vid_activewindow)
130 vid_usemouse = false;
131 if (vid_isfullscreen)
133 IN_Activate(vid_usemouse);
135 // handle changes of the vsync option
136 vid_usevsync = (vid_vsync.integer && !cls.timedemo);
137 if (vid_usingvsync != vid_usevsync)
139 GLint sync = (vid_usevsync ? 1 : 0);
141 if (qaglSetInteger(context, AGL_SWAP_INTERVAL, &sync) == GL_TRUE)
143 vid_usingvsync = vid_usevsync;
144 Con_DPrintf("Vsync %s\n", vid_usevsync ? "activated" : "deactivated");
147 Con_Printf("ERROR: can't %s vsync\n", vid_usevsync ? "activate" : "deactivate");
150 if (r_render.integer)
153 if (r_speeds.integer || gl_finish.integer)
155 qglFinish();CHECKGLERROR
157 qaglSwapBuffers(context);
159 VID_UpdateGamma(false, GAMMA_TABLE_SIZE);
161 if (apple_multithreadedgl.integer)
163 if (!multithreadedgl)
165 if(qCGLGetCurrentContext && qCGLEnable && qCGLDisable)
167 CGLContextObj ctx = qCGLGetCurrentContext();
168 CGLError e = qCGLEnable(ctx, kCGLCEMPEngine);
170 multithreadedgl = true;
173 Con_Printf("WARNING: can't enable multithreaded GL, error %d\n", (int) e);
174 Cvar_SetValueQuick(&apple_multithreadedgl, 0);
179 Con_Printf("WARNING: can't enable multithreaded GL, CGL functions not present\n");
180 Cvar_SetValueQuick(&apple_multithreadedgl, 0);
188 if(qCGLGetCurrentContext && qCGLEnable && qCGLDisable)
190 CGLContextObj ctx = qCGLGetCurrentContext();
191 qCGLDisable(ctx, kCGLCEMPEngine);
192 multithreadedgl = false;
198 int VID_SetGamma(unsigned short *ramps, int rampsize)
200 CGGammaValue table_red [GAMMA_TABLE_SIZE];
201 CGGammaValue table_green [GAMMA_TABLE_SIZE];
202 CGGammaValue table_blue [GAMMA_TABLE_SIZE];
205 // Convert the unsigned short table into 3 float tables
206 for (i = 0; i < rampsize; i++)
207 table_red[i] = (float)ramps[i] / 65535.0f;
208 for (i = 0; i < rampsize; i++)
209 table_green[i] = (float)ramps[i + rampsize] / 65535.0f;
210 for (i = 0; i < rampsize; i++)
211 table_blue[i] = (float)ramps[i + 2 * rampsize] / 65535.0f;
213 if (CGSetDisplayTransferByTable(CGMainDisplayID(), rampsize, table_red, table_green, table_blue) != CGDisplayNoErr)
215 Con_Print("VID_SetGamma: ERROR: CGSetDisplayTransferByTable failed!\n");
222 int VID_GetGamma(unsigned short *ramps, int rampsize)
224 CGGammaValue table_red [GAMMA_TABLE_SIZE];
225 CGGammaValue table_green [GAMMA_TABLE_SIZE];
226 CGGammaValue table_blue [GAMMA_TABLE_SIZE];
227 CGTableCount actualsize = 0;
230 // Get the gamma ramps from the system
231 if (CGGetDisplayTransferByTable(CGMainDisplayID(), rampsize, table_red, table_green, table_blue, &actualsize) != CGDisplayNoErr)
233 Con_Print("VID_GetGamma: ERROR: CGGetDisplayTransferByTable failed!\n");
236 if (actualsize != (unsigned int)rampsize)
238 Con_Printf("VID_GetGamma: ERROR: invalid gamma table size (%u != %u)\n", actualsize, rampsize);
242 // Convert the 3 float tables into 1 unsigned short table
243 for (i = 0; i < rampsize; i++)
244 ramps[i] = table_red[i] * 65535.0f;
245 for (i = 0; i < rampsize; i++)
246 ramps[i + rampsize] = table_green[i] * 65535.0f;
247 for (i = 0; i < rampsize; i++)
248 ramps[i + 2 * rampsize] = table_blue[i] * 65535.0f;
253 void signal_handler(int sig)
255 printf("Received signal %d, exiting...\n", sig);
256 VID_RestoreSystemGamma();
262 signal(SIGHUP, signal_handler);
263 signal(SIGINT, signal_handler);
264 signal(SIGQUIT, signal_handler);
265 signal(SIGILL, signal_handler);
266 signal(SIGTRAP, signal_handler);
267 signal(SIGIOT, signal_handler);
268 signal(SIGBUS, signal_handler);
269 signal(SIGFPE, signal_handler);
270 signal(SIGSEGV, signal_handler);
271 signal(SIGTERM, signal_handler);
276 InitSig(); // trap evil signals
277 Cvar_RegisterVariable(&apple_multithreadedgl);
278 // COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar)
279 if (COM_CheckParm ("-nomouse"))
283 static void *prjobj = NULL;
284 static void *cglobj = NULL;
286 static void GL_CloseLibrary(void)
297 gl_platformextensions = "";
300 static int GL_OpenLibrary(void)
302 const char *name = "/System/Library/Frameworks/AGL.framework/AGL";
303 const char *name2 = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
305 Con_Printf("Loading OpenGL driver %s\n", name);
307 if (!(prjobj = dlopen(name, RTLD_LAZY)))
309 Con_Printf("Unable to open symbol list for %s\n", name);
312 strlcpy(gl_driver, name, sizeof(gl_driver));
314 Con_Printf("Loading OpenGL driver %s\n", name2);
315 if (!(cglobj = dlopen(name2, RTLD_LAZY)))
316 Con_Printf("Unable to open symbol list for %s; multithreaded GL disabled\n", name);
321 void *GL_GetProcAddress(const char *name)
323 return dlsym(prjobj, name);
326 static void *CGL_GetProcAddress(const char *name)
330 return dlsym(cglobj, name);
333 void VID_Shutdown(void)
335 if (context == NULL && window == NULL)
339 VID_RestoreSystemGamma();
343 qaglDestroyContext(context);
347 if (vid_isfullscreen)
348 CGReleaseAllDisplays();
352 DisposeWindow(window);
357 vid_isfullscreen = false;
363 // Since the event handler can be called at any time, we store the events for later processing
364 static qboolean AsyncEvent_Quitting = false;
365 static qboolean AsyncEvent_Collapsed = false;
366 static OSStatus MainWindowEventHandler (EventHandlerCallRef nextHandler, EventRef event, void *userData)
368 OSStatus err = noErr;
370 switch (GetEventKind (event))
372 case kEventWindowClosed:
373 AsyncEvent_Quitting = true;
377 case kEventWindowCollapsing:
378 AsyncEvent_Collapsed = true;
381 // Undocked / restored (end)
382 case kEventWindowExpanded:
383 AsyncEvent_Collapsed = false;
387 err = eventNotHandledErr;
394 static void VID_AppFocusChanged(qboolean windowIsActive)
396 if (vid_activewindow != windowIsActive)
398 vid_activewindow = windowIsActive;
399 if (!vid_activewindow)
400 VID_RestoreSystemGamma();
403 if (sound_active != windowIsActive)
405 sound_active = windowIsActive;
413 static void VID_ProcessPendingAsyncEvents (void)
415 // Collapsed / expanded
416 if (AsyncEvent_Collapsed != vid_hidden)
418 vid_hidden = !vid_hidden;
419 VID_AppFocusChanged(!vid_hidden);
423 if (AsyncEvent_Quitting)
427 static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscreen, qboolean stereobuffer)
429 *attrib++ = AGL_RGBA;
430 *attrib++ = AGL_RED_SIZE;*attrib++ = 1;
431 *attrib++ = AGL_GREEN_SIZE;*attrib++ = 1;
432 *attrib++ = AGL_BLUE_SIZE;*attrib++ = 1;
433 *attrib++ = AGL_DOUBLEBUFFER;
434 *attrib++ = AGL_DEPTH_SIZE;*attrib++ = 1;
436 // if stencil is enabled, ask for alpha too
439 *attrib++ = AGL_STENCIL_SIZE;*attrib++ = 8;
440 *attrib++ = AGL_ALPHA_SIZE;*attrib++ = 1;
443 *attrib++ = AGL_FULLSCREEN;
445 *attrib++ = AGL_STEREO;
446 *attrib++ = AGL_NONE;
449 int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
451 const EventTypeSpec winEvents[] =
453 { kEventClassWindow, kEventWindowClosed },
454 { kEventClassWindow, kEventWindowCollapsing },
455 { kEventClassWindow, kEventWindowExpanded },
457 OSStatus carbonError;
459 CFStringRef windowTitle;
460 AGLPixelFormat pixelFormat;
461 GLint attributes [32];
464 if (!GL_OpenLibrary())
466 Con_Printf("Unable to load GL driver\n");
470 if ((qaglChoosePixelFormat = (AGLPixelFormat (*) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList))GL_GetProcAddress("aglChoosePixelFormat")) == NULL
471 || (qaglCreateContext = (AGLContext (*) (AGLPixelFormat pix, AGLContext share))GL_GetProcAddress("aglCreateContext")) == NULL
472 || (qaglDestroyContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglDestroyContext")) == NULL
473 || (qaglDestroyPixelFormat = (void (*) (AGLPixelFormat pix))GL_GetProcAddress("aglDestroyPixelFormat")) == NULL
474 || (qaglErrorString = (const GLubyte* (*) (GLenum code))GL_GetProcAddress("aglErrorString")) == NULL
475 || (qaglGetError = (GLenum (*) (void))GL_GetProcAddress("aglGetError")) == NULL
476 || (qaglSetCurrentContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglSetCurrentContext")) == NULL
477 || (qaglSetDrawable = (GLboolean (*) (AGLContext ctx, AGLDrawable draw))GL_GetProcAddress("aglSetDrawable")) == NULL
478 || (qaglSetFullScreen = (GLboolean (*) (AGLContext ctx, GLsizei width, GLsizei height, GLsizei freq, GLint device))GL_GetProcAddress("aglSetFullScreen")) == NULL
479 || (qaglSetInteger = (GLboolean (*) (AGLContext ctx, GLenum pname, const GLint *params))GL_GetProcAddress("aglSetInteger")) == NULL
480 || (qaglSwapBuffers = (void (*) (AGLContext ctx))GL_GetProcAddress("aglSwapBuffers")) == NULL
483 Con_Printf("AGL functions not found\n");
484 ReleaseWindow(window);
488 qCGLEnable = (CGLError (*) (CGLContextObj ctx, CGLContextEnable pname)) CGL_GetProcAddress("CGLEnable");
489 qCGLDisable = (CGLError (*) (CGLContextObj ctx, CGLContextEnable pname)) CGL_GetProcAddress("CGLDisable");
490 qCGLGetCurrentContext = (CGLContextObj (*) (void)) CGL_GetProcAddress("CGLGetCurrentContext");
491 if(!qCGLEnable || !qCGLDisable || !qCGLGetCurrentContext)
492 Con_Printf("CGL functions not found; disabling multithreaded OpenGL\n");
494 // Ignore the events from the previous window
495 AsyncEvent_Quitting = false;
496 AsyncEvent_Collapsed = false;
498 // Create the window, a bit towards the center of the screen
499 windowBounds.left = 100;
500 windowBounds.top = 100;
501 windowBounds.right = width + 100;
502 windowBounds.bottom = height + 100;
503 carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window);
504 if (carbonError != noErr || window == NULL)
506 Con_Printf("Unable to create window (error %u)\n", (unsigned)carbonError);
510 // Set the window title
511 windowTitle = CFSTR("DarkPlaces AGL");
512 SetWindowTitleWithCFString(window, windowTitle);
514 // Install the callback function for the window events we can't get
515 // through ReceiveNextEvent (i.e. close, collapse, and expand)
516 InstallWindowEventHandler (window, NewEventHandlerUPP (MainWindowEventHandler),
517 GetEventTypeCount(winEvents), winEvents, window, NULL);
519 // Create the desired attribute list
520 VID_BuildAGLAttrib(attributes, bpp == 32, fullscreen, stereobuffer);
525 pixelFormat = qaglChoosePixelFormat(NULL, 0, attributes);
526 error = qaglGetError();
527 if (error != AGL_NO_ERROR)
529 Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
530 (char *)qaglErrorString(error));
531 ReleaseWindow(window);
535 else // Output is fullScreen
537 CGDirectDisplayID mainDisplay;
538 CFDictionaryRef refDisplayMode;
541 // Get the mainDisplay and set resolution to current
542 mainDisplay = CGMainDisplayID();
543 CGDisplayCapture(mainDisplay);
545 // TOCHECK: not sure whether or not it's necessary to change the resolution
546 // "by hand", or if aglSetFullscreen does the job anyway
547 refDisplayMode = CGDisplayBestModeForParametersAndRefreshRate(mainDisplay, bpp, width, height, refreshrate, NULL);
548 CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
549 DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
551 // Set pixel format with built attribs
552 // Note: specifying a device is *required* for AGL_FullScreen
553 pixelFormat = qaglChoosePixelFormat(&gdhDisplay, 1, attributes);
554 error = qaglGetError();
555 if (error != AGL_NO_ERROR)
557 Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
558 (char *)qaglErrorString(error));
559 ReleaseWindow(window);
564 // Create a context using the pform
565 context = qaglCreateContext(pixelFormat, NULL);
566 error = qaglGetError();
567 if (error != AGL_NO_ERROR)
569 Con_Printf("qaglCreateContext FAILED: %s\n",
570 (char *)qaglErrorString(error));
573 // Make the context the current one ('enable' it)
574 qaglSetCurrentContext(context);
575 error = qaglGetError();
576 if (error != AGL_NO_ERROR)
578 Con_Printf("qaglSetCurrentContext FAILED: %s\n",
579 (char *)qaglErrorString(error));
580 ReleaseWindow(window);
585 qaglDestroyPixelFormat(pixelFormat);
587 // Attempt fullscreen if requested
590 qaglSetFullScreen (context, width, height, refreshrate, 0);
591 error = qaglGetError();
592 if (error != AGL_NO_ERROR)
594 Con_Printf("qaglSetFullScreen FAILED: %s\n",
595 (char *)qaglErrorString(error));
601 // Set Window as Drawable
602 qaglSetDrawable(context, GetWindowPort(window));
603 error = qaglGetError();
604 if (error != AGL_NO_ERROR)
606 Con_Printf("qaglSetDrawable FAILED: %s\n",
607 (char *)qaglErrorString(error));
608 ReleaseWindow(window);
616 if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
617 Sys_Error("glGetString not found in %s", gl_driver);
619 gl_renderer = (const char *)qglGetString(GL_RENDERER);
620 gl_vendor = (const char *)qglGetString(GL_VENDOR);
621 gl_version = (const char *)qglGetString(GL_VERSION);
622 gl_extensions = (const char *)qglGetString(GL_EXTENSIONS);
624 gl_videosyncavailable = true;
626 multithreadedgl = false;
627 vid_isfullscreen = fullscreen;
628 vid_usingmouse = false;
630 vid_activewindow = true;
634 SelectWindow(window);
640 static void Handle_KeyMod(UInt32 keymod)
642 const struct keymod_to_event_s { UInt32 keybit; keynum_t event; } keymod_events [] =
645 { shiftKey, K_SHIFT },
646 { alphaLock, K_CAPSLOCK },
647 { optionKey, K_ALT },
648 { controlKey, K_CTRL },
649 { kEventKeyModifierNumLockMask, K_NUMLOCK },
650 { kEventKeyModifierFnMask, K_AUX2 }
652 static UInt32 prev_keymod = 0;
656 modChanges = prev_keymod ^ keymod;
660 for (i = 0; i < sizeof(keymod_events) / sizeof(keymod_events[0]); i++)
662 UInt32 keybit = keymod_events[i].keybit;
664 if ((modChanges & keybit) != 0)
665 Key_Event(keymod_events[i].event, '\0', (keymod & keybit) != 0);
668 prev_keymod = keymod;
671 static void Handle_Key(unsigned char charcode, UInt32 mackeycode, qboolean keypressed)
673 unsigned int keycode = 0;
718 keycode = K_SCROLLOCK;
724 keycode = K_BACKSPACE;
739 keycode = K_KP_EQUALS;
742 keycode = K_KP_DIVIDE;
745 keycode = K_KP_MULTIPLY;
769 keycode = K_KP_MINUS;
772 keycode = K_CAPSLOCK;
800 keycode = K_KP_ENTER;
806 keycode = K_KP_PERIOD;
811 case kUpArrowCharCode:
814 case kLeftArrowCharCode:
815 keycode = K_LEFTARROW;
817 case kDownArrowCharCode:
818 keycode = K_DOWNARROW;
820 case kRightArrowCharCode:
821 keycode = K_RIGHTARROW;
825 // characters 0 and 191 are sent by the mouse buttons (?!)
828 if ('A' <= charcode && charcode <= 'Z')
830 keycode = charcode + ('a' - 'A'); // lowercase it
833 else if (charcode >= 32)
839 Con_Printf(">> UNKNOWN char/keycode: %d/%u <<\n", charcode, (unsigned) mackeycode);
844 Key_Event(keycode, ascii, keypressed);
847 void Sys_SendKeyEvents(void)
850 EventTargetRef theTarget;
852 // Start by processing the asynchronous events we received since the previous frame
853 VID_ProcessPendingAsyncEvents();
855 theTarget = GetEventDispatcherTarget();
856 while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &theEvent) == noErr)
858 UInt32 eventClass = GetEventClass(theEvent);
859 UInt32 eventKind = GetEventKind(theEvent);
863 case kEventClassMouse:
865 EventMouseButton theButton;
870 case kEventMouseDown:
872 GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(theButton), NULL, &theButton);
876 case kEventMouseButtonPrimary:
879 case kEventMouseButtonSecondary:
882 case kEventMouseButtonTertiary:
886 Key_Event(key, '\0', eventKind == kEventMouseDown);
889 // Note: These two events are mutual exclusives
890 // Treat MouseDragged in the same statement, so we don't block MouseMoved while a mousebutton is held
891 case kEventMouseMoved:
892 case kEventMouseDragged:
896 GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(deltaPos), NULL, &deltaPos);
898 mouse_x += deltaPos.x;
899 mouse_y += deltaPos.y;
903 case kEventMouseWheelMoved:
906 unsigned int wheelEvent;
908 GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(delta), NULL, &delta);
910 wheelEvent = (delta > 0) ? K_MWHEELUP : K_MWHEELDOWN;
911 Key_Event(wheelEvent, 0, true);
912 Key_Event(wheelEvent, 0, false);
917 Con_Printf (">> kEventClassMouse (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
922 case kEventClassKeyboard:
929 case kEventRawKeyDown:
930 GetEventParameter(theEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(charcode), NULL, &charcode);
931 GetEventParameter(theEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(keycode), NULL, &keycode);
932 Handle_Key(charcode, keycode, true);
935 case kEventRawKeyRepeat:
939 GetEventParameter(theEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(charcode), NULL, &charcode);
940 GetEventParameter(theEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(keycode), NULL, &keycode);
941 Handle_Key(charcode, keycode, false);
944 case kEventRawKeyModifiersChanged:
947 GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(keymod), NULL, &keymod);
948 Handle_KeyMod(keymod);
952 case kEventHotKeyPressed:
955 case kEventHotKeyReleased:
958 case kEventMouseWheelMoved:
962 Con_Printf (">> kEventClassKeyboard (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
968 case kEventClassTextInput:
969 Con_Printf(">> kEventClassTextInput (%d) <<\n", (int)eventKind);
972 case kEventClassApplication:
975 case kEventAppActivated :
976 VID_AppFocusChanged(true);
978 case kEventAppDeactivated:
979 VID_AppFocusChanged(false);
984 case kEventAppActiveWindowChanged:
987 Con_Printf(">> kEventClassApplication (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
992 case kEventClassAppleEvent:
995 case kEventAppleEvent :
998 Con_Printf(">> kEventClassAppleEvent (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
1003 case kEventClassWindow:
1006 case kEventWindowUpdate :
1009 Con_Printf(">> kEventClassWindow (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
1014 case kEventClassControl:
1018 /*Con_Printf(">> UNKNOWN eventClass: %c%c%c%c, eventKind: %d <<\n",
1019 eventClass >> 24, (eventClass >> 16) & 0xFF,
1020 (eventClass >> 8) & 0xFF, eventClass & 0xFF,
1025 SendEventToEventTarget (theEvent, theTarget);
1026 ReleaseEvent(theEvent);
1034 in_mouse_x = mouse_x;
1035 in_mouse_y = mouse_y;