Soft-link GameController.framework.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Sep 2016 18:44:14 +0000 (18:44 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Sep 2016 18:44:14 +0000 (18:44 +0000)
<rdar://problem/28219953> and https://bugs.webkit.org/show_bug.cgi?id=161802

Reviewed by Brian Burg.

No new tests (No change in behavior).

* Configurations/WebCore.xcconfig:
* WebCore.xcodeproj/project.pbxproj:
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
(WebCore::GameControllerGamepadProvider::startMonitoringGamepads):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205756 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm

index 21c616c..6b996fc 100644 (file)
@@ -1,3 +1,17 @@
+2016-09-09  Brady Eidson  <beidson@apple.com>
+
+        Soft-link GameController.framework.
+        <rdar://problem/28219953> and https://bugs.webkit.org/show_bug.cgi?id=161802
+
+        Reviewed by Brian Burg.
+
+        No new tests (No change in behavior).
+
+        * Configurations/WebCore.xcconfig:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
+        (WebCore::GameControllerGamepadProvider::startMonitoringGamepads):
+
 2016-09-09  Jiewen Tan  <jiewen_tan@apple.com>
 
         Rename Key to CryptoKey
index 07a34f7..d69a8d5 100644 (file)
@@ -65,11 +65,7 @@ WK_IOS_BINCOMPAT_LDFLAGS_V9_0 = -Wl,-reexport_library,$(BUILT_PRODUCTS_DIR)/Deri
 WK_IOS_BINCOMPAT_LDFLAGS_V9_3 = $(WK_IOS_BINCOMPAT_LDFLAGS_V9_0);
 WK_IOS_BINCOMPAT_LDFLAGS_V10_0 = $(WK_IOS_BINCOMPAT_LDFLAGS_V9_3);
 
-WK_GAMECONTROLLER_LDFLAGS = $(WK_GAMECONTROLLER_LDFLAGS_$(ENABLE_GAMEPAD));
-WK_GAMECONTROLLER_LDFLAGS_ENABLE_GAMEPAD = -framework GameController;
-WK_GAMECONTROLLER_LDFLAGS_ENABLE_GAMEPAD[sdk=macosx*] = -weak_framework GameController;
-
-OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_PLATFORM) $(WK_GAMECONTROLLER_LDFLAGS);
+OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_PLATFORM)
 OTHER_LDFLAGS_BASE = -lsqlite3 -lobjc -lANGLE;
 OTHER_LDFLAGS_BASE_ios = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework MobileCoreServices -framework OpenGLES -lMobileGestalt $(WK_IOS_BINCOMPAT_LDFLAGS);
 OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = $(OTHER_LDFLAGS_BASE_ios) -framework IOSurface;
index 009c064..e8a74de 100644 (file)
                51ABAE1C103C1913008C5260 /* SocketStreamHandleImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandleImpl.h; sourceTree = "<group>"; };
                51ABAE1D103C1913008C5260 /* SocketStreamHandleImplCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleImplCFNet.cpp; sourceTree = "<group>"; };
                51ABF64C16392E2800132A7A /* LoaderStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoaderStrategy.cpp; sourceTree = "<group>"; };
-               51AEA4C81D6E3CC100E0269D /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = ../../../../../../System/Library/Frameworks/GameController.framework; sourceTree = "<group>"; };
                51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderTypes.h; sourceTree = "<group>"; };
                51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; };
                51B454E91B4DAE7D0085EAA6 /* PingHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PingHandle.h; sourceTree = "<group>"; };
                                FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */,
                                FD2DBF0F12B048A300ED98C6 /* AudioToolbox.framework */,
                                AA5F3B9016CC5BEB00455EB0 /* CoreFoundation.framework */,
-                               51AEA4C81D6E3CC100E0269D /* GameController.framework */,
                                1AB33DA412551E320024457A /* IOKit.framework */,
                                F8216299029F4FB501000131 /* JavaScriptCore.framework */,
                                93F1D31A0558CC5C00821BC0 /* libicucore.dylib */,
index 20a7fed..6a53f12 100644 (file)
 #import "GameControllerGamepad.h"
 #import "GamepadProviderClient.h"
 #import "Logging.h"
+#import "SoftLinking.h"
 #import <GameController/GameController.h>
 
+SOFT_LINK_FRAMEWORK_OPTIONAL(GameController)
+SOFT_LINK_CLASS_OPTIONAL(GameController, GCController);
+SOFT_LINK_CONSTANT_MAY_FAIL(GameController, GCControllerDidConnectNotification, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(GameController, GCControllerDidDisconnectNotification, NSString *)
+
 namespace WebCore {
 
 static const std::chrono::milliseconds InputNotificationDelay = 16ms;
@@ -98,15 +104,19 @@ void GameControllerGamepadProvider::startMonitoringGamepads(GamepadProviderClien
     if (m_connectObserver)
         return;
 
-    m_connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:nil usingBlock:^(NSNotification *notification) {
-        GameControllerGamepadProvider::singleton().controllerDidConnect(notification.object, ConnectionVisibility::Visible);
-    }];
+    if (canLoadGCControllerDidConnectNotification()) {
+        m_connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:getGCControllerDidConnectNotification() object:nil queue:nil usingBlock:^(NSNotification *notification) {
+            GameControllerGamepadProvider::singleton().controllerDidConnect(notification.object, ConnectionVisibility::Visible);
+        }];
+    }
 
-    m_disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:nil usingBlock:^(NSNotification *notification) {
-        GameControllerGamepadProvider::singleton().controllerDidDisconnect(notification.object);
-    }];
+    if (canLoadGCControllerDidDisconnectNotification()) {
+        m_disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:getGCControllerDidDisconnectNotification() object:nil queue:nil usingBlock:^(NSNotification *notification) {
+            GameControllerGamepadProvider::singleton().controllerDidDisconnect(notification.object);
+        }];
+    }
 
-    for (GCController *controller in [GCController controllers])
+    for (GCController *controller in [getGCControllerClass() controllers])
         controllerDidConnect(controller, ConnectionVisibility::Invisible);
 }