From 9e4a262c87765018c706db5648b89bc093ba5e83 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 12 Nov 2014 23:03:59 +0200 Subject: [PATCH] Enabled building with SDK 10.4 Game controllers support will disabled in this case --- src/cocoa/HID_Config_Utilities.c | 7 +++ src/cocoa/HID_Error_Handler.c | 7 +++ src/cocoa/HID_Name_Lookup.c | 7 +++ src/cocoa/HID_Queue_Utilities.c | 7 +++ src/cocoa/HID_Utilities.c | 7 +++ src/cocoa/IOHIDDevice_.c | 7 +++ src/cocoa/IOHIDElement_.c | 7 +++ src/cocoa/ImmrHIDUtilAddOn.c | 7 +++ src/cocoa/i_backend_cocoa.mm | 74 ++++++++++++++++++++++++++++++++ src/cocoa/i_joystick.cpp | 38 ++++++++++++++++ src/sdl/iwadpicker_cocoa.mm | 5 +++ src/sdl/sdlvideo.cpp | 7 +++ 12 files changed, 180 insertions(+) diff --git a/src/cocoa/HID_Config_Utilities.c b/src/cocoa/HID_Config_Utilities.c index 6cd1ad56a3..18d4672d30 100644 --- a/src/cocoa/HID_Config_Utilities.c +++ b/src/cocoa/HID_Config_Utilities.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #define LOG_SCORING 0 #include // malloc @@ -917,3 +922,5 @@ int HIDGetElementConfig(HID_info_ptr inHIDInfoPtr, IOHIDDeviceRef *outIOHIDDevic return (inHIDInfoPtr->actionCookie); } } // HIDGetElementConfig + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/HID_Error_Handler.c b/src/cocoa/HID_Error_Handler.c index 8aaca7f363..0802a2ca72 100644 --- a/src/cocoa/HID_Error_Handler.c +++ b/src/cocoa/HID_Error_Handler.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #ifdef DEBUG // not used in release #if !defined (kBuildingLibrary) #define kVerboseErrors @@ -99,3 +104,5 @@ void HIDReportError(const char *strError) { } #endif // kVerboseErrors } // HIDReportError + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/HID_Name_Lookup.c b/src/cocoa/HID_Name_Lookup.c index 4e4b023bd7..c9a1ca2642 100644 --- a/src/cocoa/HID_Name_Lookup.c +++ b/src/cocoa/HID_Name_Lookup.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #pragma mark - includes & imports //***************************************************** #include "HID_Utilities_External.h" @@ -1201,3 +1206,5 @@ static Boolean hu_AddDeviceElementToUsageXML(IOHIDDeviceRef inIOHIDDeviceRef, IO return (results); } // hu_AddDeviceElementToUsageXML #endif + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/HID_Queue_Utilities.c b/src/cocoa/HID_Queue_Utilities.c index 586609d7fb..ab1d836671 100644 --- a/src/cocoa/HID_Queue_Utilities.c +++ b/src/cocoa/HID_Queue_Utilities.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #include "HID_Utilities_External.h" // ================================== @@ -352,3 +357,5 @@ unsigned char HIDGetEvent(IOHIDDeviceRef inIOHIDDeviceRef, IOHIDValueRef *pIOHID return (false); // did not get event } /* HIDGetEvent */ + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/HID_Utilities.c b/src/cocoa/HID_Utilities.c index 2beb6ca025..3152cfdd9e 100644 --- a/src/cocoa/HID_Utilities.c +++ b/src/cocoa/HID_Utilities.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //*************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #pragma mark - includes & imports //----------------------------------------------------- @@ -1059,3 +1064,5 @@ static CFMutableDictionaryRef hu_SetUpMatchingDictionary(UInt32 inUsagePage, UIn return (refHIDMatchDictionary); } // hu_SetUpMatchingDictionary + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/IOHIDDevice_.c b/src/cocoa/IOHIDDevice_.c index ab35c21e05..30c01dc7ce 100644 --- a/src/cocoa/IOHIDDevice_.c +++ b/src/cocoa/IOHIDDevice_.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #pragma mark - includes & imports //----------------------------------------------------- @@ -610,3 +615,5 @@ static void IOHIDDevice_SetPtrProperty(IOHIDDeviceRef inIOHIDDeviceRef, CFString } // IOHIDDevice_SetPtrProperty //***************************************************** + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/IOHIDElement_.c b/src/cocoa/IOHIDElement_.c index f4d8be9eb7..906d2926ac 100644 --- a/src/cocoa/IOHIDElement_.c +++ b/src/cocoa/IOHIDElement_.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #pragma mark - includes & imports //----------------------------------------------------- @@ -500,3 +505,5 @@ void IOHIDElement_SetLongProperty(IOHIDElementRef inElementRef, CFStringRef inKe } // IOHIDElement_SetLongProperty //***************************************************** + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/ImmrHIDUtilAddOn.c b/src/cocoa/ImmrHIDUtilAddOn.c index 07e6a31b14..4937d36876 100644 --- a/src/cocoa/ImmrHIDUtilAddOn.c +++ b/src/cocoa/ImmrHIDUtilAddOn.c @@ -43,6 +43,11 @@ // Copyright (C) 2009 Apple Inc. All Rights Reserved. // //***************************************************** + +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #include #include @@ -99,3 +104,5 @@ bool FreeHIDObject(io_service_t inHIDObject) { return (kIOReturnSuccess == kr); } // FreeHIDObject + +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 diff --git a/src/cocoa/i_backend_cocoa.mm b/src/cocoa/i_backend_cocoa.mm index 3f9a727b3f..39b6642e2c 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_MAX_ALLOWED < 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 diff --git a/src/cocoa/i_joystick.cpp b/src/cocoa/i_joystick.cpp index 4d983176df..bd2c59348d 100644 --- a/src/cocoa/i_joystick.cpp +++ b/src/cocoa/i_joystick.cpp @@ -33,6 +33,10 @@ #include "m_joy.h" +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + #include #include "HID_Utilities_External.h" @@ -788,3 +792,37 @@ void I_ProcessJoysticks() s_joystickManager->Update(); } } + +#else // prior to 10.5 + +void I_StartupJoysticks() +{ +} + +void I_ShutdownJoysticks() +{ +} + +void I_GetJoysticks(TArray& sticks) +{ + sticks.Clear(); +} + +void I_GetAxes(float axes[NUM_JOYAXIS]) +{ + for (size_t i = 0; i < NUM_JOYAXIS; ++i) + { + axes[i] = 0.0f; + } +} + +IJoystickConfig *I_UpdateDeviceList() +{ + return NULL; +} + +void I_ProcessJoysticks() +{ +} + +#endif // 10.5 or higher diff --git a/src/sdl/iwadpicker_cocoa.mm b/src/sdl/iwadpicker_cocoa.mm index 29b0454de0..c3b167c099 100644 --- a/src/sdl/iwadpicker_cocoa.mm +++ b/src/sdl/iwadpicker_cocoa.mm @@ -50,6 +50,11 @@ #include #include +#if MAC_OS_X_VERSION_MAX_ALLOWED < 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); enum diff --git a/src/sdl/sdlvideo.cpp b/src/sdl/sdlvideo.cpp index c869545abd..59587fc0b5 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_MAX_ALLOWED < 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); }