Diff
Modified: trunk/Source/WTF/ChangeLog (264768 => 264769)
--- trunk/Source/WTF/ChangeLog 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WTF/ChangeLog 2020-07-23 16:36:15 UTC (rev 264769)
@@ -1,3 +1,12 @@
+2020-07-23 Brady Eidson <[email protected]>
+
+ Add Gamepad tests that exercise the native frameworks
+ <rdar://problem/65343674> and https://bugs.webkit.org/show_bug.cgi?id=214188
+
+ Reviewed by Tim Horton.
+
+ * wtf/PlatformHave.h:
+
2020-07-23 Commit Queue <[email protected]>
Unreviewed, reverting r264745.
Modified: trunk/Source/WTF/wtf/PlatformHave.h (264768 => 264769)
--- trunk/Source/WTF/wtf/PlatformHave.h 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2020-07-23 16:36:15 UTC (rev 264769)
@@ -574,6 +574,10 @@
#define HAVE_MULTIGAMEPADPROVIDER_SUPPORT 1
#endif
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
+#define HAVE_HID_FRAMEWORK 1
+#endif
+
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
#define HAVE_GCEXTENDEDGAMEPAD_HOME_BUTTON 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (264768 => 264769)
--- trunk/Source/WebCore/ChangeLog 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebCore/ChangeLog 2020-07-23 16:36:15 UTC (rev 264769)
@@ -1,3 +1,16 @@
+2020-07-23 Brady Eidson <[email protected]>
+
+ Add Gamepad tests that exercise the native frameworks
+ <rdar://problem/65343674> and https://bugs.webkit.org/show_bug.cgi?id=214188
+
+ Reviewed by Tim Horton.
+
+ * platform/gamepad/mac/MultiGamepadProvider.h:
+ (WebCore::MultiGamepadProvider::setUsesOnlyHIDGamepadProvider):
+ * platform/gamepad/mac/MultiGamepadProvider.mm:
+ (WebCore::MultiGamepadProvider::startMonitoringGamepads):
+ (WebCore::MultiGamepadProvider::stopMonitoringGamepads):
+
2020-07-23 Xabier Rodriguez Calvar <[email protected]>
Unreviewed, build fix after r264762.
Modified: trunk/Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.h (264768 => 264769)
--- trunk/Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.h 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.h 2020-07-23 16:36:15 UTC (rev 264769)
@@ -40,6 +40,8 @@
WEBCORE_EXPORT static MultiGamepadProvider& singleton();
+ void setUsesOnlyHIDGamepadProvider(bool hidProviderOnly) { m_usesOnlyHIDProvider = hidProviderOnly; }
+
// GamepadProvider
void startMonitoringGamepads(GamepadProviderClient&) final;
void stopMonitoringGamepads(GamepadProviderClient&) final;
@@ -87,6 +89,7 @@
HashMap<PlatformGamepad*, std::unique_ptr<PlatformGamepadWrapper>> m_gamepadMap;
bool m_hidImportComplete { false };
+ bool m_usesOnlyHIDProvider { false };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.mm (264768 => 264769)
--- trunk/Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.mm 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebCore/platform/gamepad/mac/MultiGamepadProvider.mm 2020-07-23 16:36:15 UTC (rev 264769)
@@ -51,12 +51,15 @@
ASSERT(!m_clients.contains(&client));
m_clients.add(&client);
- HIDGamepadProvider::singleton().ignoreGameControllerFrameworkDevices();
- GameControllerGamepadProvider::singleton().prewarmGameControllerDevicesIfNecessary();
+ if (!m_usesOnlyHIDProvider) {
+ HIDGamepadProvider::singleton().ignoreGameControllerFrameworkDevices();
+ GameControllerGamepadProvider::singleton().prewarmGameControllerDevicesIfNecessary();
+ }
if (monitorOtherProviders) {
HIDGamepadProvider::singleton().startMonitoringGamepads(*this);
- GameControllerGamepadProvider::singleton().startMonitoringGamepads(*this);
+ if (!m_usesOnlyHIDProvider)
+ GameControllerGamepadProvider::singleton().startMonitoringGamepads(*this);
}
}
@@ -68,7 +71,8 @@
if (shouldStopMonitoringOtherProviders) {
HIDGamepadProvider::singleton().stopMonitoringGamepads(*this);
- GameControllerGamepadProvider::singleton().stopMonitoringGamepads(*this);
+ if (!m_usesOnlyHIDProvider)
+ GameControllerGamepadProvider::singleton().stopMonitoringGamepads(*this);
}
}
Modified: trunk/Source/WebKit/ChangeLog (264768 => 264769)
--- trunk/Source/WebKit/ChangeLog 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebKit/ChangeLog 2020-07-23 16:36:15 UTC (rev 264769)
@@ -1,3 +1,25 @@
+2020-07-23 Brady Eidson <[email protected]>
+
+ Add Gamepad tests that exercise the native frameworks
+ <rdar://problem/65343674> and https://bugs.webkit.org/show_bug.cgi?id=214188
+
+ Reviewed by Tim Horton.
+
+ Add some testing-only SPI for TestWebKitAPI.
+
+ * UIProcess/API/Cocoa/WKProcessPool.mm:
+ (-[WKProcessPool _numberOfConnectedGamepadsForTesting]):
+ (-[WKProcessPool _setUsesOnlyHIDGamepadProviderForTesting:]):
+ * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+
+ * UIProcess/Gamepad/UIGamepadProvider.h:
+ (WebKit::UIGamepadProvider::numberOfConnectedGamepads const):
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::numberOfConnectedGamepadsForTesting):
+ (WebKit::WebProcessPool::setUsesOnlyHIDGamepadProviderForTesting):
+ * UIProcess/WebProcessPool.h:
+
2020-07-22 Jer Noble <[email protected]>
[Cocoa] Add feature flag for WebM & VP9
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm (264768 => 264769)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm 2020-07-23 16:36:15 UTC (rev 264769)
@@ -651,4 +651,14 @@
_processPool->garbageCollectJavaScriptObjects();
}
+- (size_t)_numberOfConnectedGamepadsForTesting
+{
+ return _processPool->numberOfConnectedGamepadsForTesting();
+}
+
+- (void)_setUsesOnlyHIDGamepadProviderForTesting:(BOOL)usesHIDProvider
+{
+ _processPool->setUsesOnlyHIDGamepadProviderForTesting(usesHIDProvider);
+}
+
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h (264768 => 264769)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h 2020-07-23 16:36:15 UTC (rev 264769)
@@ -135,5 +135,6 @@
// Test only.
- (void)_seedResourceLoadStatisticsForTestingWithFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL shouldScheduleNotification:(BOOL)shouldScheduleNotification completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_garbageCollectJavaScriptObjectsForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
-
+- (size_t)_numberOfConnectedGamepadsForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_setUsesOnlyHIDGamepadProviderForTesting:(BOOL)usesHIDProvider WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@end
Modified: trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h (264768 => 264769)
--- trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h 2020-07-23 16:36:15 UTC (rev 264769)
@@ -57,6 +57,8 @@
Vector<GamepadData> snapshotGamepads();
+ size_t numberOfConnectedGamepads() const { return m_gamepads.size(); }
+
private:
friend NeverDestroyed<UIGamepadProvider>;
UIGamepadProvider();
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (264768 => 264769)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2020-07-23 16:36:15 UTC (rev 264769)
@@ -127,6 +127,8 @@
#if PLATFORM(COCOA)
#include "VersionChecks.h"
+#include <WebCore/HIDGamepadProvider.h>
+#include <WebCore/MultiGamepadProvider.h>
#include <WebCore/PowerSourceNotifier.h>
#endif
@@ -1972,6 +1974,22 @@
#endif // ENABLE(GAMEPAD)
+size_t WebProcessPool::numberOfConnectedGamepadsForTesting()
+{
+#if ENABLE(GAMEPAD)
+ return UIGamepadProvider::singleton().numberOfConnectedGamepads();
+#else
+ return 0;
+#endif
+}
+
+void WebProcessPool::setUsesOnlyHIDGamepadProviderForTesting(bool hidProviderOnly)
+{
+#if ENABLE(GAMEPAD) && HAVE(MULTIGAMEPADPROVIDER_SUPPORT)
+ MultiGamepadProvider::singleton().setUsesOnlyHIDGamepadProvider(hidProviderOnly);
+#endif
+}
+
void WebProcessPool::setJavaScriptConfigurationFileEnabled(bool flag)
{
m_javaScriptConfigurationFileEnabled = flag;
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (264768 => 264769)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2020-07-23 16:36:15 UTC (rev 264769)
@@ -370,6 +370,9 @@
void garbageCollectJavaScriptObjects();
void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
+ size_t numberOfConnectedGamepadsForTesting();
+ void setUsesOnlyHIDGamepadProviderForTesting(bool);
+
#if PLATFORM(COCOA)
static bool omitPDFSupport();
#endif
Modified: trunk/Tools/ChangeLog (264768 => 264769)
--- trunk/Tools/ChangeLog 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Tools/ChangeLog 2020-07-23 16:36:15 UTC (rev 264769)
@@ -1,3 +1,33 @@
+2020-07-23 Brady Eidson <[email protected]>
+
+ Add Gamepad tests that exercise the native frameworks
+ <rdar://problem/65343674> and https://bugs.webkit.org/show_bug.cgi?id=214188
+
+ Reviewed by Tim Horton.
+
+ For Internal builds, we can create HID devices that exercise the native gamepad providers.
+ E.g. Actually exercise the IOHID gamepad provider codepath.
+
+ Give the Internal TestWebKitAPI build some entitlements:
+ * TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements: Added.
+ * TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+ Add a very basic test that connects a device, presses a button, and verifies the web page sees it:
+ * TestWebKitAPI/Tests/mac/HIDGamepads.mm: Added.
+ (-[GamepadMessageHandler userContentController:didReceiveScriptMessage:]):
+ (TestWebKitAPI::handleGamepadConnect):
+
+ Add the beginnings of a VirtualGamepad device that reads in a HID descriptor (just like real gamepads):
+ * TestWebKitAPI/mac/VirtualGamepad.h: Added.
+ * TestWebKitAPI/mac/VirtualGamepad.mm: Added.
+ (TestWebKitAPI::VirtualGamepad::makeVirtualNimbus):
+ (TestWebKitAPI::VirtualGamepad::VirtualGamepad):
+ (TestWebKitAPI::VirtualGamepad::~VirtualGamepad):
+ (TestWebKitAPI::VirtualGamepad::setButtonValue):
+ (TestWebKitAPI::VirtualGamepad::setAxisValue):
+ (TestWebKitAPI::VirtualGamepad::publishReport):
+
2020-07-23 Xabier Rodriguez Calvar <[email protected]>
[GStreamer] gst_buffer_unmap: assertion 'GST_IS_BUFFER (buffer)' failed
Added: trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements (0 => 264769)
--- trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements (rev 0)
+++ trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI-macOS-internal.entitlements 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.hid.manager.user-access-device</key>
+ <true/>
+ <key>com.apple.private.hid.client.event-filter</key>
+ <true/>
+ <key>keychain-access-groups</key>
+ <array>
+ <string>com.apple.TestWebKitAPI</string>
+ </array>
+ <key>com.apple.security.temporary-exception.sbpl</key>
+ <array>
+ <string>(allow mach-issue-extension (require-all (extension-class "com.apple.webkit.extension.mach")))</string>
+ </array>
+</dict>
+</plist>
Modified: trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig (264768 => 264769)
--- trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig 2020-07-23 16:36:15 UTC (rev 264769)
@@ -61,7 +61,11 @@
WK_PDFKIT_LDFLAGS_iphoneos = -framework PDFKit;
WK_PDFKIT_LDFLAGS_iphonesimulator = -framework PDFKit;
-OTHER_LDFLAGS = $(inherited) $(UNEXPORTED_SYMBOL_LDFLAGS) -lgtest -force_load $(BUILT_PRODUCTS_DIR)/libTestWebKitAPI.a -framework _javascript_Core -framework WebKit -lWebCoreTestSupport $(WK_AUTHKIT_LDFLAGS) $(WK_NETWORK_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH));
+WK_HID_LDFLAGS = $(WK_HID_LDFLAGS_$(WK_PLATFORM_NAME));
+WK_HID_LDFLAGS_macosx = $(WK_HID_LDFLAGS$(WK_MACOS_1015));
+WK_HID_LDFLAGS_MACOS_SINCE_1015 = -framework HID;
+
+OTHER_LDFLAGS = $(inherited) $(UNEXPORTED_SYMBOL_LDFLAGS) -lgtest -force_load $(BUILT_PRODUCTS_DIR)/libTestWebKitAPI.a -framework _javascript_Core -framework WebKit -lWebCoreTestSupport $(WK_AUTHKIT_LDFLAGS) $(WK_NETWORK_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_HID_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH));
OTHER_LDFLAGS_PLATFORM_ = -framework Cocoa -framework Carbon;
// FIXME: This should not be built on iOS. Instead we should create and use a TestWebKitAPI application.
@@ -69,8 +73,12 @@
LD_RUNPATH_SEARCH_PATHS = "@loader_path";
+MAC_CODE_SIGN_ENTITLEMENTS = $(MAC_CODE_SIGN_ENTITLEMENTS_$(USE_INTERNAL_SDK));
+MAC_CODE_SIGN_ENTITLEMENTS_ = Configurations/TestWebKitAPI-macOS.entitlements;
+MAC_CODE_SIGN_ENTITLEMENTS_YES = Configurations/TestWebKitAPI-macOS-internal.entitlements;
+
CODE_SIGN_ENTITLEMENTS[sdk=embedded*] = Configurations/TestWebKitAPI-iOS.entitlements;
-CODE_SIGN_ENTITLEMENTS[sdk=macosx*] = Configurations/TestWebKitAPI-macOS.entitlements;
+CODE_SIGN_ENTITLEMENTS[sdk=macosx*] = $(MAC_CODE_SIGN_ENTITLEMENTS);
STRIP_STYLE = debugging;
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (264768 => 264769)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-07-23 16:36:15 UTC (rev 264769)
@@ -327,6 +327,8 @@
51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780371919AFF8001829A2 /* simple3.html */; };
51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */; };
51E6A8961D2F1CA700C004B6 /* LocalStorageClear.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */; };
+ 51EB125724C67257000CB030 /* VirtualGamepad.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51EB125624C66FE8000CB030 /* VirtualGamepad.mm */; };
+ 51EB125924C68592000CB030 /* HIDGamepads.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51EB125824C68589000CB030 /* HIDGamepads.mm */; };
51EB12941FDF052500A5A1BD /* ServiceWorkerBasic.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51EB12931FDF050500A5A1BD /* ServiceWorkerBasic.mm */; };
520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */; };
5245178721B9F57B0082CB34 /* RenderingProgressPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5D6BE21B9F1B20046ABA6 /* RenderingProgressPlugIn.mm */; };
@@ -2022,6 +2024,10 @@
51E780361919AFF8001829A2 /* simple2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple2.html; sourceTree = "<group>"; };
51E780371919AFF8001829A2 /* simple3.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple3.html; sourceTree = "<group>"; };
51E93016156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageGetScaleFactorNotZero.cpp; sourceTree = "<group>"; };
+ 51EB125324C66BCB000CB030 /* TestWebKitAPI-macOS-internal.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "TestWebKitAPI-macOS-internal.entitlements"; sourceTree = "<group>"; };
+ 51EB125424C66FE8000CB030 /* VirtualGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualGamepad.h; sourceTree = "<group>"; };
+ 51EB125624C66FE8000CB030 /* VirtualGamepad.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VirtualGamepad.mm; sourceTree = "<group>"; };
+ 51EB125824C68589000CB030 /* HIDGamepads.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HIDGamepads.mm; sourceTree = "<group>"; };
51EB12931FDF050500A5A1BD /* ServiceWorkerBasic.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ServiceWorkerBasic.mm; sourceTree = "<group>"; };
51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCanPasteURL.mm; sourceTree = "<group>"; };
520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebArchive_Bundle.cpp; sourceTree = "<group>"; };
@@ -3902,6 +3908,7 @@
A1B89B99221E029F00EB4CEA /* SDKVariant.xcconfig */,
5735F0251F3A4EA6000EE801 /* TestWebKitAPI-iOS.entitlements */,
7AB0173923FB2BF0002F8366 /* TestWebKitAPI-macOS.entitlements */,
+ 51EB125324C66BCB000CB030 /* TestWebKitAPI-macOS-internal.entitlements */,
BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */,
7CCE7EA31A4115CB00447C4C /* TestWebKitAPILibrary.xcconfig */,
7C83E0261D0A5B8D00FEBCF3 /* TestWTF.xcconfig */,
@@ -4266,6 +4273,8 @@
F4F5BB5121667BAA002D06B9 /* TestFontOptions.mm */,
F45D388F215A7B4B002A2979 /* TestInspectorBar.h */,
F45D3890215A7B4B002A2979 /* TestInspectorBar.mm */,
+ 51EB125424C66FE8000CB030 /* VirtualGamepad.h */,
+ 51EB125624C66FE8000CB030 /* VirtualGamepad.mm */,
C08587BE13FE956C001EF4E5 /* WebKitAgnosticTest.h */,
C08587BD13FE956C001EF4E5 /* WebKitAgnosticTest.mm */,
);
@@ -4320,6 +4329,7 @@
F456AB1B213EDBA300CB2CEF /* FontManagerTests.mm */,
1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */,
CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */,
+ 51EB125824C68589000CB030 /* HIDGamepads.mm */,
9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */,
C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
@@ -5094,6 +5104,7 @@
CD5FF49F2162E943004BD86F /* ISOBox.cpp in Sources */,
5C69BDD51F82A7EF000F4F4B /* _javascript_DuringNavigation.mm in Sources */,
7CCE7EA51A411A0800447C4C /* _javascript_TestMac.mm in Sources */,
+ 51EB125924C68592000CB030 /* HIDGamepads.mm in Sources */,
51820A4D22F4EE7F00DF0A01 /* _javascript_URLNavigation.mm in Sources */,
5C0160C121A132460077FA32 /* JITEnabled.mm in Sources */,
E35FC7B222B82A7300F32F98 /* JSLockTakesWebThreadLock.mm in Sources */,
@@ -5332,6 +5343,7 @@
CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */,
2D520635245A603D00338F88 /* ViewExposedRect.mm in Sources */,
115EB3431EE0BA03003C2C0A /* ViewportSizeForViewportUnits.mm in Sources */,
+ 51EB125724C67257000CB030 /* VirtualGamepad.mm in Sources */,
6356FB221EC4E0BA0044BF18 /* VisibleContentRect.mm in Sources */,
83779C381F82FECE007CDA8A /* VisitedLinkStore.mm in Sources */,
0F139E771A423A5B00F590F5 /* WeakObjCPtr.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/mac/HIDGamepads.mm (0 => 264769)
--- trunk/Tools/TestWebKitAPI/Tests/mac/HIDGamepads.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/HIDGamepads.mm 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if HAVE(HID_FRAMEWORK) && USE(APPLE_INTERNAL_SDK)
+
+#import "InstanceMethodSwizzler.h"
+#import "PlatformUtilities.h"
+#import "TestURLSchemeHandler.h"
+#import "TestWKWebView.h"
+#import "VirtualGamepad.h"
+#import <WebKit/WKProcessPoolPrivate.h>
+
+@interface GamepadMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+static bool didReceiveMessage = false;
+
+@implementation GamepadMessageHandler
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ EXPECT_TRUE([message.body isEqualToString:@"\"ffff-1420-Virtual Nimbus\""]);
+ didReceiveMessage = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+static const char* mainBytes = R"GAMEPADRESOURCE(
+<script>
+
+function handleGamepadConnect(evt)
+{
+ window.webkit.messageHandlers.gamepad.postMessage(JSON.stringify(evt.gamepad.id));
+}
+
+addEventListener("gamepadconnected", handleGamepadConnect);
+
+</script>
+)GAMEPADRESOURCE";
+
+static NSWindow *keyWindowForTesting;
+static NSWindow *getKeyWindowForTesting()
+{
+ return keyWindowForTesting;
+}
+
+TEST(Gamepad, Basic)
+{
+ auto keyWindowSwizzler = makeUnique<InstanceMethodSwizzler>([NSApplication class], @selector(keyWindow), reinterpret_cast<IMP>(getKeyWindowForTesting));
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ auto messageHandler = adoptNS([[GamepadMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"gamepad"];
+
+ auto schemeHandler = adoptNS([[TestURLSchemeHandler alloc] init]);
+ [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"gamepad"];
+
+ [schemeHandler setStartURLSchemeTaskHandler:^(WKWebView *, id<WKURLSchemeTask> task) {
+ auto response = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil]);
+ [task didReceiveResponse:response.get()];
+ [task didReceiveData:[NSData dataWithBytes:mainBytes length:strlen(mainBytes)]];
+ [task didFinish];
+ }];
+
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ keyWindowForTesting = [webView window];
+ [webView.get().configuration.processPool _setUsesOnlyHIDGamepadProviderForTesting:YES];
+
+ [webView synchronouslyLoadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"gamepad://host/main.html"]]];
+
+ [[webView window] makeFirstResponder:webView.get()];
+
+ // Resigning/reinstating the key window state triggers the "key window did change" notification that WKWebView currently
+ // needs to convince it to monitor gamepad devices
+ [[webView window] resignKeyWindow];
+ [[webView window] makeKeyWindow];
+
+ // Create a gamepad
+ auto gamepad = VirtualGamepad::makeVirtualNimbus();
+ while (![webView.get().configuration.processPool _numberOfConnectedGamepadsForTesting])
+ Util::sleep(0.1);
+
+ // Press a button on it, waiting for the web page to see it
+ gamepad->setButtonValue(0, 1.0);
+ gamepad->publishReport();
+
+ Util::run(&didReceiveMessage);
+ didReceiveMessage = false;
+}
+
+} // namespace TestWebKitAPI
+
+#endif // HAVE(HID_FRAMEWORK) && USE(APPLE_INTERNAL_SDK)
Added: trunk/Tools/TestWebKitAPI/mac/VirtualGamepad.h (0 => 264769)
--- trunk/Tools/TestWebKitAPI/mac/VirtualGamepad.h (rev 0)
+++ trunk/Tools/TestWebKitAPI/mac/VirtualGamepad.h 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE(HID_FRAMEWORK) && USE(APPLE_INTERNAL_SDK)
+
+#include <dispatch/dispatch.h>
+#include <wtf/FastMalloc.h>
+#include <wtf/OSObjectPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+
+
+OBJC_CLASS HIDDevice;
+OBJC_CLASS HIDUserDevice;
+OBJC_CLASS NSString;
+
+namespace TestWebKitAPI {
+
+class VirtualGamepad {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ static std::unique_ptr<VirtualGamepad> makeVirtualNimbus();
+ enum class Layout {
+ Nimbus,
+ };
+ VirtualGamepad(Layout);
+ ~VirtualGamepad();
+
+ size_t buttonCount() const;
+ size_t axisCount() const;
+
+ // Acceptable values are 0.0 to 1.0
+ void setButtonValue(size_t index, float value);
+
+ // Acceptable values are -1.0 to 1.0
+ void setAxisValue(size_t index, float value);
+
+ void publishReport();
+
+private:
+ RetainPtr<NSString> m_uniqueID;
+ RetainPtr<HIDUserDevice> m_userDevice;
+ RetainPtr<HIDDevice> m_device;
+ OSObjectPtr<dispatch_queue_t> m_dispatchQueue;
+
+ Layout m_layout;
+ Vector<float> m_buttonValues;
+ Vector<float> m_axisValues;
+
+};
+} // namespace TestWebKitAPI
+
+#endif // HAVE(HID_FRAMEWORK) && USE(APPLE_INTERNAL_SDK)
Added: trunk/Tools/TestWebKitAPI/mac/VirtualGamepad.mm (0 => 264769)
--- trunk/Tools/TestWebKitAPI/mac/VirtualGamepad.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/mac/VirtualGamepad.mm 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "VirtualGamepad.h"
+
+#if HAVE(HID_FRAMEWORK) && USE(APPLE_INTERNAL_SDK)
+
+#import <Foundation/Foundation.h>
+#import <HID/HIDBase.h>
+#import <HID/HIDDevice.h>
+#import <HID/HIDElement.h>
+#import <HID/HIDEvent.h>
+#import <HID/HIDManager.h>
+#import <HID/HIDUserDevice.h>
+#import <IOKit/hid/IOHIDDeviceKeys.h>
+
+namespace TestWebKitAPI {
+
+// HID descriptors are an interesting language.
+// This is the descriptor dumped from an MFi Nimbus controller, which is fairly representative of a modern controller.
+// I got this formatting by dumping the raw descriptor from my device into https://eleccelerator.com/usbdescreqparser/
+// In addition to the raw HID language, I've added commentary along the way to further document how this works.
+const uint8_t NimbusDescriptor[] = {
+ 0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
+ 0x09, 0x05, // Usage (Game Pad)
+ 0xA1, 0x01, // Collection (Application)
+ 0x09, 0x05, // Usage (Game Pad)
+ 0xA1, 0x02, // Collection (Logical)
+ 0x75, 0x08, // Report Size (8) - All reports past this point will be 1 byte per element until Report Size changes.
+ 0x95, 0x04, // Report Count (4) - The upcoming report will have 4 elements, 1 byte each.
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x35, 0x00, // Physical Minimum (0)
+ 0x46, 0xFF, 0x00, // Physical Maximum (255)
+ 0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
+ 0x09, 0x90, // Usage (D-pad Up) - These 4 d-pad elements will each be a button.
+ 0x09, 0x92, // Usage (D-pad Right)
+ 0x09, 0x91, // Usage (D-pad Down)
+ 0x09, 0x93, // Usage (D-pad Left)
+ 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - Lock in the above input report (4 bytes)
+ 0x95, 0x08, // Report Count (8) - The next report will have 8 elements, 1 byte each (cascaded from above)
+ 0x05, 0x09, // Usage Page (Button)
+ 0x19, 0x01, // Usage Minimum (0x01) - And it will be buttons...
+ 0x29, 0x08, // Usage Maximum (0x08) - 8 of them!
+ 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - Lock in the above input report (8 bytes)
+ 0x15, 0x00, // Logical Minimum (0) - The next elements are pure digital instead of 'analog'
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x35, 0x00, // Physical Minimum (0)
+ 0x45, 0x01, // Physical Maximum (1)
+ 0x75, 0x01, // Report Size (1) - The report size is 1 bit
+ 0x95, 0x01, // Report Count (1) - And there is one such element
+ 0x05, 0x0C, // Usage Page (Consumer)
+ 0x0A, 0x23, 0x02, // Usage (AC Home) - And it is an "AC Home" element, which is basically a fancy button
+ 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - Lock in the above input report (1 bit)
+ 0x95, 0x07, // Report Count (7) - The next report will have 7 elements (of 1 bit each)
+ 0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - And it's constant padding. Lock it in for (7 bits).
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x25, 0x01, // Logical Maximum (1)
+ 0x35, 0x00, // Physical Minimum (0)
+ 0x45, 0x01, // Physical Maximum (1)
+ 0x75, 0x01, // Report Size (1) - The next report will also be 1 bit each (like the AC Home button above)
+ 0x95, 0x04, // Report Count (4) - But there will be 4 of them
+ 0x05, 0x08, // Usage Page (LEDs) - And they are LEDs (This will probably be an output report)
+ 0x1A, 0x00, 0xFF, // Usage Minimum (0xFF00) 0 ...
+ 0x2A, 0x03, 0xFF, // Usage Maximum (0xFF03) ... to 3
+ 0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - Lock in the output report of (4 bits)
+ 0x75, 0x04, // Report Size (4) - Also 4 elements in the next report
+ 0x95, 0x01, // Report Count (1) - Also 1 bit each
+ 0x91, 0x01, // Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - Lock in the constant padding of (4 bits)
+ 0x15, 0x81, // Logical Minimum (-127) - The next elements will have a neg-to-pos output range
+ 0x25, 0x7F, // Logical Maximum (127)
+ 0x35, 0x81, // Physical Minimum (-127)
+ 0x45, 0x7F, // Physical Maximum (127)
+ 0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
+ 0x09, 0x01, // Usage (Pointer)
+ 0xA1, 0x00, // Collection (Physical)
+ 0x75, 0x08, // Report Size (8) - The report size is 1 byte per element (so that -127 to 127 maps to the 256 possible values)
+ 0x95, 0x04, // Report Count (4) - And there will be 4 of them
+ 0x09, 0x30, // Usage (X) - And they are the first 4 axis usages
+ 0x09, 0x31, // Usage (Y)
+ 0x09, 0x32, // Usage (Z)
+ 0x09, 0x35, // Usage (Rz)
+ 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - Lock in the above input report (4 bytes)
+ 0xC0, // End Collection
+ 0xC0, // End Collection
+ 0xC0, // End Collection
+};
+
+// The total input report size from the above descriptor is:
+// 4 bytes + 8 bytes + (1 bit + 7 bits) + 4 bytes = 17 bytes total.
+// The total output report size from the above descriptor is:
+// (4 bits + 4 bits) == 1 byte total
+const size_t NimbusDescriptorSize = sizeof(NimbusDescriptor);
+const size_t NimbusButtonCount = 13;
+const size_t NimbusAxisCount = 4;
+const size_t NimbusInputReportSize = 17;
+const uint16_t NimbusVID = 0xFFFF; // The actual Vendor ID for the Nimbus is either 0x1038 or 0x0111. Let's use a fake one for testing.
+const uint16_t NimbusPID = 0x1420;
+const char* NimbusName = "Virtual Nimbus";
+
+std::unique_ptr<VirtualGamepad> VirtualGamepad::makeVirtualNimbus()
+{
+ return makeUnique<VirtualGamepad>(Layout::Nimbus);
+}
+
+VirtualGamepad::VirtualGamepad(Layout layout)
+ : m_layout(layout)
+{
+ m_dispatchQueue = adoptOSObject(dispatch_queue_create(0, DISPATCH_QUEUE_SERIAL));
+ m_uniqueID = NSUUID.UUID.UUIDString;
+
+ const uint8_t* descriptorData;
+ size_t descriptorSize;
+ uint16_t vid, pid;
+ const char* name;
+
+ switch (m_layout) {
+ case Layout::Nimbus:
+ descriptorData = NimbusDescriptor;
+ descriptorSize = NimbusDescriptorSize;
+ vid = NimbusVID;
+ pid = NimbusPID;
+ name = NimbusName;
+ m_buttonValues = Vector<float>(NimbusButtonCount, 0.0);
+ m_axisValues = Vector<float>(NimbusAxisCount, 0.0);
+ }
+
+ auto descriptor = adoptNS([[NSData alloc] initWithBytes:descriptorData length:descriptorSize]);
+ auto properties = adoptNS([[NSMutableDictionary alloc] init]);
+
+ properties.get()[@kIOHIDReportDescriptorKey] = descriptor.get();
+ properties.get()[@kIOHIDVendorIDKey] = @(vid);
+ properties.get()[@kIOHIDProductIDKey] = @(pid);
+ properties.get()[@kIOHIDPhysicalDeviceUniqueIDKey] = m_uniqueID.get();
+ properties.get()[@kIOHIDTransportKey] = @"Bluetooth";
+ properties.get()[@"isVirtual"] = @(YES);
+ properties.get()[@(kIOHIDProductKey)] = @(name);
+
+ m_userDevice = adoptNS([[HIDUserDevice alloc] initWithProperties:properties.get()]);
+ [m_userDevice setDispatchQueue:m_dispatchQueue.get()];
+ [m_userDevice activate];
+
+ m_device = adoptNS([[HIDDevice alloc] initWithService:m_userDevice.get().service]);
+ [m_device setDispatchQueue:dispatch_get_main_queue()];
+ [m_device open];
+ [m_device activate];
+}
+
+VirtualGamepad::~VirtualGamepad()
+{
+ [m_device close];
+ [m_device cancel];
+ [m_userDevice cancel];
+}
+
+void VirtualGamepad::setButtonValue(size_t index, float value)
+{
+ RELEASE_ASSERT(index < m_buttonValues.size());
+ RELEASE_ASSERT(value >= 0.0 && value <= 1.0);
+ m_buttonValues[index] = value;
+}
+
+void VirtualGamepad::setAxisValue(size_t index, float value)
+{
+ RELEASE_ASSERT(index < m_axisValues.size());
+ RELEASE_ASSERT(value >= -1.0 && value <= 1.0);
+ m_axisValues[index] = value;
+}
+
+void VirtualGamepad::publishReport()
+{
+ uint8_t reportData[1024];
+ size_t reportLength;
+
+ switch (m_layout) {
+ case Layout::Nimbus:
+ reportLength = NimbusInputReportSize;
+ for (size_t i = 0; i < 12; ++i)
+ reportData[i] = (uint8_t)(m_buttonValues[i] * 255);
+ reportData[12] = m_buttonValues[12] == 0.0 ? 0x01 : 0x00;
+ for (size_t i = 13; i < 17; ++i)
+ reportData[i] = (uint8_t)((int8_t)(m_axisValues[i - 13] * 127));
+ break;
+ default:
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+
+ auto nsReportData = adoptNS([[NSData alloc] initWithBytes:reportData length:reportLength]);
+ [m_userDevice handleReport:nsReportData.get() error:nil];
+}
+
+} // namespace TestWebKitAPI
+
+#endif // HAVE(HID_FRAMEWORK) && USE(APPLE_INTERNAL_SDK)
Modified: trunk/WebKitLibraries/ChangeLog (264768 => 264769)
--- trunk/WebKitLibraries/ChangeLog 2020-07-23 16:34:30 UTC (rev 264768)
+++ trunk/WebKitLibraries/ChangeLog 2020-07-23 16:36:15 UTC (rev 264769)
@@ -1,3 +1,14 @@
+2020-07-23 Brady Eidson <[email protected]>
+
+ Add Gamepad tests that exercise the native frameworks
+ <rdar://problem/65343674> and https://bugs.webkit.org/show_bug.cgi?id=214188
+
+ Reviewed by Tim Horton.
+
+ * WebKitPrivateFrameworkStubs/Mac/101500/HID.framework/HID.tbd: Added.
+ * WebKitPrivateFrameworkStubs/Mac/101600/HID.framework/HID.tbd: Added.
+ * WebKitPrivateFrameworkStubs/Mac/110000/HID.framework/HID.tbd: Added.
+
2020-07-17 Jonathan Bedard <[email protected]>
Add WebKitPrivateFrameworkStubs for Big Sur
Added: trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101500/HID.framework/HID.tbd (0 => 264769)
--- trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101500/HID.framework/HID.tbd (rev 0)
+++ trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101500/HID.framework/HID.tbd 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,10 @@
+--- !tapi-tbd-v3
+archs: [ x86_64 ]
+uuids: [ 'x86_64: 2BD2731B-D160-3136-BA4B-402EBAA84E54' ]
+platform: macosx
+install-name: '/System/Library/PrivateFrameworks/HID.framework/Versions/A/HID'
+exports:
+ - archs: [ x86_64 ]
+ symbols: [ _HIDVersionNumber, _HIDVersionString, _kHIDUserDevicePropertyCreateInactiveKey ]
+ objc-classes: [ HIDEventSystemClient, HIDManager, HIDUserDevice, HIDVirtualEventService ]
+...
Added: trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101600/HID.framework/HID.tbd (0 => 264769)
--- trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101600/HID.framework/HID.tbd (rev 0)
+++ trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/101600/HID.framework/HID.tbd 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,12 @@
+--- !tapi-tbd
+tbd-version: 4
+targets: [ x86_64-macos ]
+uuids:
+ - target: x86_64-macos
+ value: DC29BC33-5745-3EC7-B955-1A75E9339FF0
+install-name: '/System/Library/PrivateFrameworks/HID.framework/Versions/A/HID'
+exports:
+ - targets: [ x86_64-macos ]
+ symbols: [ _HIDVersionNumber, _HIDVersionString, _kHIDUserDevicePropertyCreateInactiveKey ]
+ objc-classes: [ HIDEventSystemClient, HIDManager, HIDUserDevice, HIDVirtualEventService ]
+...
Added: trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/110000/HID.framework/HID.tbd (0 => 264769)
--- trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/110000/HID.framework/HID.tbd (rev 0)
+++ trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/Mac/110000/HID.framework/HID.tbd 2020-07-23 16:36:15 UTC (rev 264769)
@@ -0,0 +1,12 @@
+--- !tapi-tbd
+tbd-version: 4
+targets: [ x86_64-macos ]
+uuids:
+ - target: x86_64-macos
+ value: DC29BC33-5745-3EC7-B955-1A75E9339FF0
+install-name: '/System/Library/PrivateFrameworks/HID.framework/Versions/A/HID'
+exports:
+ - targets: [ x86_64-macos ]
+ symbols: [ _HIDVersionNumber, _HIDVersionString, _kHIDUserDevicePropertyCreateInactiveKey ]
+ objc-classes: [ HIDEventSystemClient, HIDManager, HIDUserDevice, HIDVirtualEventService ]
+...