From d061adfbd666857bf861739e4232e18e44295621 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 9 Nov 2014 11:18:20 +0200 Subject: [PATCH] Fixed all compilation issues with 10.4 SDK except for HID Utilities --- src/cocoa/i_backend_cocoa.mm | 99 ++++++++++++++++++++++++++++++++---- src/sdl/iwadpicker_cocoa.mm | 6 +++ src/sdl/sdlvideo.cpp | 7 +++ 3 files changed, 103 insertions(+), 9 deletions(-) diff --git a/src/cocoa/i_backend_cocoa.mm b/src/cocoa/i_backend_cocoa.mm index c9ef6b9da..859fcc495 100644 --- a/src/cocoa/i_backend_cocoa.mm +++ b/src/cocoa/i_backend_cocoa.mm @@ -45,6 +45,80 @@ #include #include +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 + +// Missing definitions for 10.4 and earlier + +typedef unsigned int NSUInteger; +typedef int NSInteger; + +typedef float CGFloat; + +// From HIToolbox/Events.h +enum +{ + kVK_Return = 0x24, + kVK_Tab = 0x30, + kVK_Space = 0x31, + kVK_Delete = 0x33, + kVK_Escape = 0x35, + kVK_Command = 0x37, + kVK_Shift = 0x38, + kVK_CapsLock = 0x39, + kVK_Option = 0x3A, + kVK_Control = 0x3B, + kVK_RightShift = 0x3C, + kVK_RightOption = 0x3D, + kVK_RightControl = 0x3E, + kVK_Function = 0x3F, + kVK_F17 = 0x40, + kVK_VolumeUp = 0x48, + kVK_VolumeDown = 0x49, + kVK_Mute = 0x4A, + kVK_F18 = 0x4F, + kVK_F19 = 0x50, + kVK_F20 = 0x5A, + kVK_F5 = 0x60, + kVK_F6 = 0x61, + kVK_F7 = 0x62, + kVK_F3 = 0x63, + kVK_F8 = 0x64, + kVK_F9 = 0x65, + kVK_F11 = 0x67, + kVK_F13 = 0x69, + kVK_F16 = 0x6A, + kVK_F14 = 0x6B, + kVK_F10 = 0x6D, + kVK_F12 = 0x6F, + kVK_F15 = 0x71, + kVK_Help = 0x72, + kVK_Home = 0x73, + kVK_PageUp = 0x74, + kVK_ForwardDelete = 0x75, + kVK_F4 = 0x76, + kVK_End = 0x77, + kVK_F2 = 0x78, + kVK_PageDown = 0x79, + kVK_F1 = 0x7A, + kVK_LeftArrow = 0x7B, + kVK_RightArrow = 0x7C, + kVK_DownArrow = 0x7D, + kVK_UpArrow = 0x7E +}; + +@interface NSView(SupportOutdatedOSX) +- (NSPoint)convertPointFromBase:(NSPoint)aPoint; +@end + +@implementation NSView(SupportOutdatedOSX) +- (NSPoint)convertPointFromBase:(NSPoint)aPoint +{ + return [self convertPoint:aPoint fromView:nil]; +} +@end + +#endif // prior to 10.5 + #include // Avoid collision between DObject class and Objective-C @@ -272,7 +346,7 @@ void I_ProcessJoysticks(); void I_GetEvent() { - [[NSRunLoop mainRunLoop] limitDateForMode:NSDefaultRunLoopMode]; + [[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode]; } void I_StartTic() @@ -634,6 +708,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent) case NSLeftMouseUp: event.subtype = EV_GUI_LButtonUp; break; case NSRightMouseUp: event.subtype = EV_GUI_RButtonUp; break; case NSOtherMouseUp: event.subtype = EV_GUI_MButtonUp; break; + default: break; } NSEventToGameMousePosition(theEvent, &event); @@ -655,6 +730,9 @@ void ProcessMouseButtonEvent(NSEvent* theEvent) case NSOtherMouseUp: event.type = EV_KeyUp; break; + + default: + break; } event.data1 = std::min(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8)); @@ -1011,8 +1089,8 @@ static ApplicationController* appCtrl; selector:@selector(processEvents:) userInfo:nil repeats:YES]; - [[NSRunLoop mainRunLoop] addTimer:timer - forMode:NSDefaultRunLoopMode]; + [[NSRunLoop currentRunLoop] addTimer:timer + forMode:NSDefaultRunLoopMode]; exit(SDL_main(s_argc, s_argv)); } @@ -1106,22 +1184,22 @@ static ApplicationController* appCtrl; attributes[i++] = NSOpenGLPFADoubleBuffer; attributes[i++] = NSOpenGLPFAColorSize; - attributes[i++] = 32; + attributes[i++] = NSOpenGLPixelFormatAttribute(32); attributes[i++] = NSOpenGLPFADepthSize; - attributes[i++] = 24; + attributes[i++] = NSOpenGLPixelFormatAttribute(24); attributes[i++] = NSOpenGLPFAStencilSize; - attributes[i++] = 8; + attributes[i++] = NSOpenGLPixelFormatAttribute(8); if (m_multisample) { attributes[i++] = NSOpenGLPFAMultisample; attributes[i++] = NSOpenGLPFASampleBuffers; - attributes[i++] = 1; + attributes[i++] = NSOpenGLPixelFormatAttribute(1); attributes[i++] = NSOpenGLPFASamples; - attributes[i++] = m_multisample; + attributes[i++] = NSOpenGLPixelFormatAttribute(m_multisample); } - attributes[i] = 0; + attributes[i] = NSOpenGLPixelFormatAttribute(0); NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; @@ -1344,6 +1422,9 @@ static ApplicationController* appCtrl; case NSFlagsChanged: ProcessKeyboardFlagsEvent(event); break; + + default: + break; } [NSApp sendEvent:event]; diff --git a/src/sdl/iwadpicker_cocoa.mm b/src/sdl/iwadpicker_cocoa.mm index 51e0ea0c8..57a4ce7f4 100644 --- a/src/sdl/iwadpicker_cocoa.mm +++ b/src/sdl/iwadpicker_cocoa.mm @@ -48,6 +48,12 @@ #include #include +#include + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +// Missing type definition for 10.4 and earlier +typedef unsigned int NSUInteger; +#endif // prior to 10.5 CVAR(String, osx_additional_parameters, "", CVAR_ARCHIVE | CVAR_NOSET | CVAR_GLOBALCONFIG); diff --git a/src/sdl/sdlvideo.cpp b/src/sdl/sdlvideo.cpp index c869545ab..6753169f0 100644 --- a/src/sdl/sdlvideo.cpp +++ b/src/sdl/sdlvideo.cpp @@ -550,6 +550,13 @@ void SDLFB::SetVSync (bool vsync) { // Apply vsync for native backend only (where OpenGL context is set) +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 + // Inconsistency between 10.4 and 10.5 SDKs: + // third argument of CGLSetParameter() is const long* on 10.4 and const GLint* on 10.5 + // So, GLint typedef'ed to long instead of int to workaround this issue + typedef long GLint; +#endif // prior to 10.5 + const GLint value = vsync ? 1 : 0; CGLSetParameter(context, kCGLCPSwapInterval, &value); }