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", (int) e);
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();
263 signal(SIGHUP, signal_handler);
264 signal(SIGINT, signal_handler);
265 signal(SIGQUIT, signal_handler);
266 signal(SIGILL, signal_handler);
267 signal(SIGTRAP, signal_handler);
268 signal(SIGIOT, signal_handler);
269 signal(SIGBUS, signal_handler);
270 signal(SIGFPE, signal_handler);
271 signal(SIGSEGV, signal_handler);
272 signal(SIGTERM, signal_handler);
277 InitSig(); // trap evil signals
278 Cvar_RegisterVariable(&apple_multithreadedgl);
279 // COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar)
280 if (COM_CheckParm ("-nomouse"))
284 static void *prjobj = NULL;
285 static void *cglobj = NULL;
287 static void GL_CloseLibrary(void)
298 gl_platformextensions = "";
301 static int GL_OpenLibrary(void)
303 const char *name = "/System/Library/Frameworks/AGL.framework/AGL";
304 const char *name2 = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
306 Con_Printf("Loading OpenGL driver %s\n", name);
308 if (!(prjobj = dlopen(name, RTLD_LAZY)))
310 Con_Printf("Unable to open symbol list for %s\n", name);
313 strlcpy(gl_driver, name, sizeof(gl_driver));
315 Con_Printf("Loading OpenGL driver %s\n", name2);
316 if (!(cglobj = dlopen(name2, RTLD_LAZY)))
317 Con_Printf("Unable to open symbol list for %s; multithreaded GL disabled\n", name);
322 void *GL_GetProcAddress(const char *name)
324 return dlsym(prjobj, name);
327 static void *CGL_GetProcAddress(const char *name)
331 return dlsym(cglobj, name);
334 void VID_Shutdown(void)
336 if (context == NULL && window == NULL)
340 VID_RestoreSystemGamma();
344 qaglDestroyContext(context);
348 if (vid_isfullscreen)
349 CGReleaseAllDisplays();
353 DisposeWindow(window);
358 vid_isfullscreen = false;
364 // Since the event handler can be called at any time, we store the events for later processing
365 static qboolean AsyncEvent_Quitting = false;
366 static qboolean AsyncEvent_Collapsed = false;
367 static OSStatus MainWindowEventHandler (EventHandlerCallRef nextHandler, EventRef event, void *userData)
369 OSStatus err = noErr;
371 switch (GetEventKind (event))
373 case kEventWindowClosed:
374 AsyncEvent_Quitting = true;
378 case kEventWindowCollapsing:
379 AsyncEvent_Collapsed = true;
382 // Undocked / restored (end)
383 case kEventWindowExpanded:
384 AsyncEvent_Collapsed = false;
388 err = eventNotHandledErr;
395 static void VID_AppFocusChanged(qboolean windowIsActive)
397 if (vid_activewindow != windowIsActive)
399 vid_activewindow = windowIsActive;
400 if (!vid_activewindow)
401 VID_RestoreSystemGamma();
404 if (sound_active != windowIsActive)
406 sound_active = windowIsActive;
414 static void VID_ProcessPendingAsyncEvents (void)
416 // Collapsed / expanded
417 if (AsyncEvent_Collapsed != vid_hidden)
419 vid_hidden = !vid_hidden;
420 VID_AppFocusChanged(!vid_hidden);
424 if (AsyncEvent_Quitting)
428 static void VID_BuildAGLAttrib(GLint *attrib, qboolean stencil, qboolean fullscreen, qboolean stereobuffer)
430 *attrib++ = AGL_RGBA;
431 *attrib++ = AGL_RED_SIZE;*attrib++ = 1;
432 *attrib++ = AGL_GREEN_SIZE;*attrib++ = 1;
433 *attrib++ = AGL_BLUE_SIZE;*attrib++ = 1;
434 *attrib++ = AGL_DOUBLEBUFFER;
435 *attrib++ = AGL_DEPTH_SIZE;*attrib++ = 1;
437 // if stencil is enabled, ask for alpha too
440 *attrib++ = AGL_STENCIL_SIZE;*attrib++ = 8;
441 *attrib++ = AGL_ALPHA_SIZE;*attrib++ = 1;
444 *attrib++ = AGL_FULLSCREEN;
446 *attrib++ = AGL_STEREO;
447 *attrib++ = AGL_NONE;
450 int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer)
452 const EventTypeSpec winEvents[] =
454 { kEventClassWindow, kEventWindowClosed },
455 { kEventClassWindow, kEventWindowCollapsing },
456 { kEventClassWindow, kEventWindowExpanded },
458 OSStatus carbonError;
460 CFStringRef windowTitle;
461 AGLPixelFormat pixelFormat;
462 GLint attributes [32];
465 if (!GL_OpenLibrary())
467 Con_Printf("Unable to load GL driver\n");
471 if ((qaglChoosePixelFormat = (AGLPixelFormat (*) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList))GL_GetProcAddress("aglChoosePixelFormat")) == NULL
472 || (qaglCreateContext = (AGLContext (*) (AGLPixelFormat pix, AGLContext share))GL_GetProcAddress("aglCreateContext")) == NULL
473 || (qaglDestroyContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglDestroyContext")) == NULL
474 || (qaglDestroyPixelFormat = (void (*) (AGLPixelFormat pix))GL_GetProcAddress("aglDestroyPixelFormat")) == NULL
475 || (qaglErrorString = (const GLubyte* (*) (GLenum code))GL_GetProcAddress("aglErrorString")) == NULL
476 || (qaglGetError = (GLenum (*) (void))GL_GetProcAddress("aglGetError")) == NULL
477 || (qaglSetCurrentContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglSetCurrentContext")) == NULL
478 || (qaglSetDrawable = (GLboolean (*) (AGLContext ctx, AGLDrawable draw))GL_GetProcAddress("aglSetDrawable")) == NULL
479 || (qaglSetFullScreen = (GLboolean (*) (AGLContext ctx, GLsizei width, GLsizei height, GLsizei freq, GLint device))GL_GetProcAddress("aglSetFullScreen")) == NULL
480 || (qaglSetInteger = (GLboolean (*) (AGLContext ctx, GLenum pname, const GLint *params))GL_GetProcAddress("aglSetInteger")) == NULL
481 || (qaglSwapBuffers = (void (*) (AGLContext ctx))GL_GetProcAddress("aglSwapBuffers")) == NULL
484 Con_Printf("AGL functions not found\n");
485 ReleaseWindow(window);
489 qCGLEnable = (CGLError (*) (CGLContextObj ctx, CGLContextEnable pname)) CGL_GetProcAddress("CGLEnable");
490 qCGLDisable = (CGLError (*) (CGLContextObj ctx, CGLContextEnable pname)) CGL_GetProcAddress("CGLDisable");
491 qCGLGetCurrentContext = (CGLContextObj (*) (void)) CGL_GetProcAddress("CGLGetCurrentContext");
492 if(!qCGLEnable || !qCGLDisable || !qCGLGetCurrentContext)
493 Con_Printf("CGL functions not found; disabling multithreaded OpenGL\n");
495 // Ignore the events from the previous window
496 AsyncEvent_Quitting = false;
497 AsyncEvent_Collapsed = false;
499 // Create the window, a bit towards the center of the screen
500 windowBounds.left = 100;
501 windowBounds.top = 100;
502 windowBounds.right = width + 100;
503 windowBounds.bottom = height + 100;
504 carbonError = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute, &windowBounds, &window);
505 if (carbonError != noErr || window == NULL)
507 Con_Printf("Unable to create window (error %u)\n", (unsigned)carbonError);
511 // Set the window title
512 windowTitle = CFSTR("DarkPlaces AGL");
513 SetWindowTitleWithCFString(window, windowTitle);
515 // Install the callback function for the window events we can't get
516 // through ReceiveNextEvent (i.e. close, collapse, and expand)
517 InstallWindowEventHandler (window, NewEventHandlerUPP (MainWindowEventHandler),
518 GetEventTypeCount(winEvents), winEvents, window, NULL);
520 // Create the desired attribute list
521 VID_BuildAGLAttrib(attributes, bpp == 32, fullscreen, stereobuffer);
526 pixelFormat = qaglChoosePixelFormat(NULL, 0, attributes);
527 error = qaglGetError();
528 if (error != AGL_NO_ERROR)
530 Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
531 (char *)qaglErrorString(error));
532 ReleaseWindow(window);
536 else // Output is fullScreen
538 CGDirectDisplayID mainDisplay;
539 CFDictionaryRef refDisplayMode;
542 // Get the mainDisplay and set resolution to current
543 mainDisplay = CGMainDisplayID();
544 CGDisplayCapture(mainDisplay);
546 // TOCHECK: not sure whether or not it's necessary to change the resolution
547 // "by hand", or if aglSetFullscreen does the job anyway
548 refDisplayMode = CGDisplayBestModeForParametersAndRefreshRate(mainDisplay, bpp, width, height, refreshrate, NULL);
549 CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
550 DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
552 // Set pixel format with built attribs
553 // Note: specifying a device is *required* for AGL_FullScreen
554 pixelFormat = qaglChoosePixelFormat(&gdhDisplay, 1, attributes);
555 error = qaglGetError();
556 if (error != AGL_NO_ERROR)
558 Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
559 (char *)qaglErrorString(error));
560 ReleaseWindow(window);
565 // Create a context using the pform
566 context = qaglCreateContext(pixelFormat, NULL);
567 error = qaglGetError();
568 if (error != AGL_NO_ERROR)
570 Con_Printf("qaglCreateContext FAILED: %s\n",
571 (char *)qaglErrorString(error));
574 // Make the context the current one ('enable' it)
575 qaglSetCurrentContext(context);
576 error = qaglGetError();
577 if (error != AGL_NO_ERROR)
579 Con_Printf("qaglSetCurrentContext FAILED: %s\n",
580 (char *)qaglErrorString(error));
581 ReleaseWindow(window);
586 qaglDestroyPixelFormat(pixelFormat);
588 // Attempt fullscreen if requested
591 qaglSetFullScreen (context, width, height, refreshrate, 0);
592 error = qaglGetError();
593 if (error != AGL_NO_ERROR)
595 Con_Printf("qaglSetFullScreen FAILED: %s\n",
596 (char *)qaglErrorString(error));
602 // Set Window as Drawable
603 qaglSetDrawable(context, GetWindowPort(window));
604 error = qaglGetError();
605 if (error != AGL_NO_ERROR)
607 Con_Printf("qaglSetDrawable FAILED: %s\n",
608 (char *)qaglErrorString(error));
609 ReleaseWindow(window);
617 if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
618 Sys_Error("glGetString not found in %s", gl_driver);
620 gl_renderer = (const char *)qglGetString(GL_RENDERER);
621 gl_vendor = (const char *)qglGetString(GL_VENDOR);
622 gl_version = (const char *)qglGetString(GL_VERSION);
623 gl_extensions = (const char *)qglGetString(GL_EXTENSIONS);
625 gl_videosyncavailable = true;
627 multithreadedgl = false;
628 vid_isfullscreen = fullscreen;
629 vid_usingmouse = false;
631 vid_activewindow = true;
635 SelectWindow(window);
641 static void Handle_KeyMod(UInt32 keymod)
643 const struct keymod_to_event_s { UInt32 keybit; keynum_t event; } keymod_events [] =
646 { shiftKey, K_SHIFT },
647 { alphaLock, K_CAPSLOCK },
648 { optionKey, K_ALT },
649 { controlKey, K_CTRL },
650 { kEventKeyModifierNumLockMask, K_NUMLOCK },
651 { kEventKeyModifierFnMask, K_AUX2 }
653 static UInt32 prev_keymod = 0;
657 modChanges = prev_keymod ^ keymod;
661 for (i = 0; i < sizeof(keymod_events) / sizeof(keymod_events[0]); i++)
663 UInt32 keybit = keymod_events[i].keybit;
665 if ((modChanges & keybit) != 0)
666 Key_Event(keymod_events[i].event, '\0', (keymod & keybit) != 0);
669 prev_keymod = keymod;
672 static void Handle_Key(unsigned char charcode, UInt32 mackeycode, qboolean keypressed)
674 unsigned int keycode = 0;
719 keycode = K_SCROLLOCK;
725 keycode = K_BACKSPACE;
740 keycode = K_KP_EQUALS;
743 keycode = K_KP_DIVIDE;
746 keycode = K_KP_MULTIPLY;
770 keycode = K_KP_MINUS;
773 keycode = K_CAPSLOCK;
801 keycode = K_KP_ENTER;
807 keycode = K_KP_PERIOD;
812 case kUpArrowCharCode:
815 case kLeftArrowCharCode:
816 keycode = K_LEFTARROW;
818 case kDownArrowCharCode:
819 keycode = K_DOWNARROW;
821 case kRightArrowCharCode:
822 keycode = K_RIGHTARROW;
826 // characters 0 and 191 are sent by the mouse buttons (?!)
829 if ('A' <= charcode && charcode <= 'Z')
831 keycode = charcode + ('a' - 'A'); // lowercase it
834 else if (charcode >= 32)
840 Con_Printf(">> UNKNOWN char/keycode: %d/%u <<\n", charcode, (unsigned) mackeycode);
845 Key_Event(keycode, ascii, keypressed);
848 void Sys_SendKeyEvents(void)
851 EventTargetRef theTarget;
853 // Start by processing the asynchronous events we received since the previous frame
854 VID_ProcessPendingAsyncEvents();
856 theTarget = GetEventDispatcherTarget();
857 while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &theEvent) == noErr)
859 UInt32 eventClass = GetEventClass(theEvent);
860 UInt32 eventKind = GetEventKind(theEvent);
864 case kEventClassMouse:
866 EventMouseButton theButton;
871 case kEventMouseDown:
873 GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(theButton), NULL, &theButton);
877 case kEventMouseButtonPrimary:
880 case kEventMouseButtonSecondary:
883 case kEventMouseButtonTertiary:
887 Key_Event(key, '\0', eventKind == kEventMouseDown);
890 // Note: These two events are mutual exclusives
891 // Treat MouseDragged in the same statement, so we don't block MouseMoved while a mousebutton is held
892 case kEventMouseMoved:
893 case kEventMouseDragged:
897 GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(deltaPos), NULL, &deltaPos);
899 mouse_x += deltaPos.x;
900 mouse_y += deltaPos.y;
904 case kEventMouseWheelMoved:
907 unsigned int wheelEvent;
909 GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(delta), NULL, &delta);
911 wheelEvent = (delta > 0) ? K_MWHEELUP : K_MWHEELDOWN;
912 Key_Event(wheelEvent, 0, true);
913 Key_Event(wheelEvent, 0, false);
918 Con_Printf (">> kEventClassMouse (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
923 case kEventClassKeyboard:
930 case kEventRawKeyDown:
931 GetEventParameter(theEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(charcode), NULL, &charcode);
932 GetEventParameter(theEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(keycode), NULL, &keycode);
933 Handle_Key(charcode, keycode, true);
936 case kEventRawKeyRepeat:
940 GetEventParameter(theEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(charcode), NULL, &charcode);
941 GetEventParameter(theEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(keycode), NULL, &keycode);
942 Handle_Key(charcode, keycode, false);
945 case kEventRawKeyModifiersChanged:
948 GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(keymod), NULL, &keymod);
949 Handle_KeyMod(keymod);
953 case kEventHotKeyPressed:
956 case kEventHotKeyReleased:
959 case kEventMouseWheelMoved:
963 Con_Printf (">> kEventClassKeyboard (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
969 case kEventClassTextInput:
970 Con_Printf(">> kEventClassTextInput (%d) <<\n", (int)eventKind);
973 case kEventClassApplication:
976 case kEventAppActivated :
977 VID_AppFocusChanged(true);
979 case kEventAppDeactivated:
980 VID_AppFocusChanged(false);
985 case kEventAppActiveWindowChanged:
988 Con_Printf(">> kEventClassApplication (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
993 case kEventClassAppleEvent:
996 case kEventAppleEvent :
999 Con_Printf(">> kEventClassAppleEvent (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
1004 case kEventClassWindow:
1007 case kEventWindowUpdate :
1010 Con_Printf(">> kEventClassWindow (UNKNOWN eventKind: %u) <<\n", (unsigned)eventKind);
1015 case kEventClassControl:
1019 /*Con_Printf(">> UNKNOWN eventClass: %c%c%c%c, eventKind: %d <<\n",
1020 eventClass >> 24, (eventClass >> 16) & 0xFF,
1021 (eventClass >> 8) & 0xFF, eventClass & 0xFF,
1026 SendEventToEventTarget (theEvent, theTarget);
1027 ReleaseEvent(theEvent);
1035 in_mouse_x = mouse_x;
1036 in_mouse_y = mouse_y;