<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[204178] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/204178">204178</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-08-05 11:27:49 -0700 (Fri, 05 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Create platform/gamepad directory, and make GamepadProvider pure virtual (with a default empty implementation).
https://bugs.webkit.org/show_bug.cgi?id=160599
Reviewed by Alex Christensen.
No new tests (No behavior change).
Except for the GamepadProvider/EmptyGamepadProvider split, this is just moving files around.
* CMakeLists.txt:
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* WebCore.xcodeproj/project.pbxproj:
* platform/Linux.cmake:
* platform/gamepad.h: Removed.
* platform/gamepad/EmptyGamepadProvider.cpp:
(WebCore::EmptyGamepadProvider::startMonitoringGamepads):
(WebCore::EmptyGamepadProvider::stopMonitoringGamepads):
(WebCore::EmptyGamepadProvider::platformGamepads):
* platform/gamepad/EmptyGamepadProvider.h:
* platform/gamepad/GamepadProvider.cpp: Renamed from Source/WebCore/platform/GamepadProvider.cpp.
(WebCore::GamepadProvider::singleton):
(WebCore::GamepadProvider::setSharedProvider):
* platform/gamepad/GamepadProvider.h: Renamed from Source/WebCore/platform/GamepadProvider.h.
(WebCore::GamepadProvider::~GamepadProvider):
* platform/gamepad/GamepadProviderClient.h: Renamed from Source/WebCore/platform/GamepadProviderClient.h.
(WebCore::GamepadProviderClient::~GamepadProviderClient):
* platform/gamepad/PlatformGamepad.h: Renamed from Source/WebCore/platform/PlatformGamepad.h.
(WebCore::PlatformGamepad::~PlatformGamepad):
(WebCore::PlatformGamepad::id):
(WebCore::PlatformGamepad::index):
(WebCore::PlatformGamepad::lastUpdateTime):
(WebCore::PlatformGamepad::connectTime):
(WebCore::PlatformGamepad::PlatformGamepad):
* platform/gamepad/deprecated/Gamepads.h: Renamed from Source/WebCore/platform/Gamepads.h.
* platform/gamepad/efl/GamepadsEfl.cpp: Renamed from Source/WebCore/platform/efl/GamepadsEfl.cpp.
(WebCore::GamepadDeviceEfl::resetFdHandler):
(WebCore::GamepadDeviceEfl::deviceFile):
(WebCore::GamepadDeviceEfl::GamepadDeviceEfl):
(WebCore::GamepadDeviceEfl::~GamepadDeviceEfl):
(WebCore::GamepadDeviceEfl::readCallback):
(WebCore::GamepadsEfl::onGamePadChange):
(WebCore::GamepadsEfl::GamepadsEfl):
(WebCore::GamepadsEfl::~GamepadsEfl):
(WebCore::GamepadsEfl::registerDevice):
(WebCore::GamepadsEfl::unregisterDevice):
(WebCore::GamepadsEfl::updateGamepadList):
(WebCore::sampleGamepads):
* platform/gamepad/glib/GamepadsGlib.cpp: Renamed from Source/WebCore/platform/glib/GamepadsGlib.cpp.
(WebCore::GamepadDeviceGlib::GamepadDeviceGlib):
(WebCore::GamepadDeviceGlib::~GamepadDeviceGlib):
(WebCore::GamepadDeviceGlib::readCallback):
(WebCore::GamepadsGlib::GamepadsGlib):
(WebCore::GamepadsGlib::~GamepadsGlib):
(WebCore::GamepadsGlib::registerDevice):
(WebCore::GamepadsGlib::unregisterDevice):
(WebCore::GamepadsGlib::updateGamepadList):
(WebCore::GamepadsGlib::onUEventCallback):
(WebCore::GamepadsGlib::isGamepadDevice):
(WebCore::sampleGamepads):
* platform/gamepad/linux/GamepadDeviceLinux.cpp: Renamed from Source/WebCore/platform/linux/GamepadDeviceLinux.cpp.
(WebCore::GamepadDeviceLinux::GamepadDeviceLinux):
(WebCore::GamepadDeviceLinux::~GamepadDeviceLinux):
(WebCore::GamepadDeviceLinux::updateForEvent):
(WebCore::GamepadDeviceLinux::normalizeAxisValue):
(WebCore::GamepadDeviceLinux::normalizeButtonValue):
* platform/gamepad/linux/GamepadDeviceLinux.h: Renamed from Source/WebCore/platform/linux/GamepadDeviceLinux.h.
(WebCore::GamepadDeviceLinux::connected):
(WebCore::GamepadDeviceLinux::id):
(WebCore::GamepadDeviceLinux::timestamp):
(WebCore::GamepadDeviceLinux::axesCount):
(WebCore::GamepadDeviceLinux::axesData):
(WebCore::GamepadDeviceLinux::buttonsCount):
(WebCore::GamepadDeviceLinux::buttonsData):
* platform/gamepad/mac/HIDGamepad.cpp: Renamed from Source/WebCore/platform/mac/HIDGamepad.cpp.
(WebCore::HIDGamepad::HIDGamepad):
(WebCore::HIDGamepad::getCurrentValueForElement):
(WebCore::HIDGamepad::initElements):
(WebCore::HIDGamepad::initElementsFromArray):
(WebCore::HIDGamepad::maybeAddButton):
(WebCore::HIDGamepad::maybeAddAxis):
(WebCore::HIDGamepad::valueChanged):
* platform/gamepad/mac/HIDGamepad.h: Renamed from Source/WebCore/platform/mac/HIDGamepad.h.
(WebCore::HIDGamepadElement::HIDGamepadElement):
(WebCore::HIDGamepadElement::~HIDGamepadElement):
(WebCore::HIDGamepadElement::isButton):
(WebCore::HIDGamepadElement::isAxis):
(WebCore::HIDGamepadButton::HIDGamepadButton):
(WebCore::HIDGamepadAxis::HIDGamepadAxis):
(WebCore::HIDGamepad::hidDevice):
* platform/gamepad/mac/HIDGamepadProvider.cpp: Renamed from Source/WebCore/platform/mac/HIDGamepadProvider.cpp.
(WebCore::deviceMatchingDictionary):
(WebCore::deviceAddedCallback):
(WebCore::deviceRemovedCallback):
(WebCore::deviceValuesChangedCallback):
(WebCore::HIDGamepadProvider::singleton):
(WebCore::HIDGamepadProvider::HIDGamepadProvider):
(WebCore::HIDGamepadProvider::indexForNewlyConnectedDevice):
(WebCore::HIDGamepadProvider::connectionDelayTimerFired):
(WebCore::HIDGamepadProvider::openAndScheduleManager):
(WebCore::HIDGamepadProvider::closeAndUnscheduleManager):
(WebCore::HIDGamepadProvider::startMonitoringGamepads):
(WebCore::HIDGamepadProvider::stopMonitoringGamepads):
(WebCore::HIDGamepadProvider::deviceAdded):
(WebCore::HIDGamepadProvider::deviceRemoved):
(WebCore::HIDGamepadProvider::valuesChanged):
(WebCore::HIDGamepadProvider::inputNotificationTimerFired):
(WebCore::HIDGamepadProvider::removeGamepadForDevice):
* platform/gamepad/mac/HIDGamepadProvider.h: Renamed from Source/WebCore/platform/mac/HIDGamepadProvider.h.
(WebCore::HIDGamepadProvider::platformGamepads):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformEflcmake">trunk/Source/WebCore/PlatformEfl.cmake</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformLinuxcmake">trunk/Source/WebCore/platform/Linux.cmake</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebCore/platform/gamepad/</li>
<li><a href="#trunkSourceWebCoreplatformgamepadEmptyGamepadProvidercpp">trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadEmptyGamepadProviderh">trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadGamepadProvidercpp">trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadGamepadProviderh">trunk/Source/WebCore/platform/gamepad/GamepadProvider.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadGamepadProviderClienth">trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadPlatformGamepadh">trunk/Source/WebCore/platform/gamepad/PlatformGamepad.h</a></li>
<li>trunk/Source/WebCore/platform/gamepad/deprecated/</li>
<li><a href="#trunkSourceWebCoreplatformgamepaddeprecatedGamepadsh">trunk/Source/WebCore/platform/gamepad/deprecated/Gamepads.h</a></li>
<li>trunk/Source/WebCore/platform/gamepad/efl/</li>
<li><a href="#trunkSourceWebCoreplatformgamepadeflGamepadsEflcpp">trunk/Source/WebCore/platform/gamepad/efl/GamepadsEfl.cpp</a></li>
<li>trunk/Source/WebCore/platform/gamepad/glib/</li>
<li><a href="#trunkSourceWebCoreplatformgamepadglibGamepadsGlibcpp">trunk/Source/WebCore/platform/gamepad/glib/GamepadsGlib.cpp</a></li>
<li>trunk/Source/WebCore/platform/gamepad/linux/</li>
<li><a href="#trunkSourceWebCoreplatformgamepadlinuxGamepadDeviceLinuxcpp">trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadlinuxGamepadDeviceLinuxh">trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.h</a></li>
<li>trunk/Source/WebCore/platform/gamepad/mac/</li>
<li><a href="#trunkSourceWebCoreplatformgamepadmacHIDGamepadcpp">trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadmacHIDGamepadh">trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadmacHIDGamepadProvidercpp">trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgamepadmacHIDGamepadProviderh">trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformGamepadProvidercpp">trunk/Source/WebCore/platform/GamepadProvider.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformGamepadProviderh">trunk/Source/WebCore/platform/GamepadProvider.h</a></li>
<li><a href="#trunkSourceWebCoreplatformGamepadProviderClienth">trunk/Source/WebCore/platform/GamepadProviderClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformGamepadsh">trunk/Source/WebCore/platform/Gamepads.h</a></li>
<li><a href="#trunkSourceWebCoreplatformPlatformGamepadh">trunk/Source/WebCore/platform/PlatformGamepad.h</a></li>
<li><a href="#trunkSourceWebCoreplatformeflGamepadsEflcpp">trunk/Source/WebCore/platform/efl/GamepadsEfl.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformglibGamepadsGlibcpp">trunk/Source/WebCore/platform/glib/GamepadsGlib.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformlinuxGamepadDeviceLinuxcpp">trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformlinuxGamepadDeviceLinuxh">trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacHIDGamepadcpp">trunk/Source/WebCore/platform/mac/HIDGamepad.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacHIDGamepadh">trunk/Source/WebCore/platform/mac/HIDGamepad.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacHIDGamepadProvidercpp">trunk/Source/WebCore/platform/mac/HIDGamepadProvider.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmacHIDGamepadProviderh">trunk/Source/WebCore/platform/mac/HIDGamepadProvider.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -72,6 +72,9 @@
</span><span class="cx"> "${WEBCORE_DIR}/platform/animation"
</span><span class="cx"> "${WEBCORE_DIR}/platform/audio"
</span><span class="cx"> "${WEBCORE_DIR}/platform/crypto"
</span><ins>+ "${WEBCORE_DIR}/platform/gamepad"
+ "${WEBCORE_DIR}/platform/gamepad/deprecated"
+ "${WEBCORE_DIR}/platform/gamepad/linux"
</ins><span class="cx"> "${WEBCORE_DIR}/platform/graphics"
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/cpu/arm"
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/cpu/arm/filters"
</span><span class="lines">@@ -2900,7 +2903,8 @@
</span><span class="cx"> Modules/gamepad/GamepadManager.cpp
</span><span class="cx"> Modules/gamepad/NavigatorGamepad.cpp
</span><span class="cx">
</span><del>- platform/GamepadProvider.cpp
</del><ins>+ platform/gamepad/EmptyGamepadProvider.cpp
+ platform/gamepad/GamepadProvider.cpp
</ins><span class="cx"> )
</span><span class="cx"> elseif (ENABLE_GAMEPAD_DEPRECATED)
</span><span class="cx"> list(APPEND WebCore_INCLUDE_DIRECTORIES
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/ChangeLog        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,3 +1,127 @@
</span><ins>+2016-08-05 Brady Eidson <beidson@apple.com>
+
+ Create platform/gamepad directory, and make GamepadProvider pure virtual (with a default empty implementation).
+ https://bugs.webkit.org/show_bug.cgi?id=160599
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No behavior change).
+
+ Except for the GamepadProvider/EmptyGamepadProvider split, this is just moving files around.
+
+ * CMakeLists.txt:
+ * PlatformEfl.cmake:
+ * PlatformGTK.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/Linux.cmake:
+
+ * platform/gamepad.h: Removed.
+
+ * platform/gamepad/EmptyGamepadProvider.cpp:
+ (WebCore::EmptyGamepadProvider::startMonitoringGamepads):
+ (WebCore::EmptyGamepadProvider::stopMonitoringGamepads):
+ (WebCore::EmptyGamepadProvider::platformGamepads):
+ * platform/gamepad/EmptyGamepadProvider.h:
+
+ * platform/gamepad/GamepadProvider.cpp: Renamed from Source/WebCore/platform/GamepadProvider.cpp.
+ (WebCore::GamepadProvider::singleton):
+ (WebCore::GamepadProvider::setSharedProvider):
+ * platform/gamepad/GamepadProvider.h: Renamed from Source/WebCore/platform/GamepadProvider.h.
+ (WebCore::GamepadProvider::~GamepadProvider):
+
+ * platform/gamepad/GamepadProviderClient.h: Renamed from Source/WebCore/platform/GamepadProviderClient.h.
+ (WebCore::GamepadProviderClient::~GamepadProviderClient):
+
+ * platform/gamepad/PlatformGamepad.h: Renamed from Source/WebCore/platform/PlatformGamepad.h.
+ (WebCore::PlatformGamepad::~PlatformGamepad):
+ (WebCore::PlatformGamepad::id):
+ (WebCore::PlatformGamepad::index):
+ (WebCore::PlatformGamepad::lastUpdateTime):
+ (WebCore::PlatformGamepad::connectTime):
+ (WebCore::PlatformGamepad::PlatformGamepad):
+
+ * platform/gamepad/deprecated/Gamepads.h: Renamed from Source/WebCore/platform/Gamepads.h.
+
+ * platform/gamepad/efl/GamepadsEfl.cpp: Renamed from Source/WebCore/platform/efl/GamepadsEfl.cpp.
+ (WebCore::GamepadDeviceEfl::resetFdHandler):
+ (WebCore::GamepadDeviceEfl::deviceFile):
+ (WebCore::GamepadDeviceEfl::GamepadDeviceEfl):
+ (WebCore::GamepadDeviceEfl::~GamepadDeviceEfl):
+ (WebCore::GamepadDeviceEfl::readCallback):
+ (WebCore::GamepadsEfl::onGamePadChange):
+ (WebCore::GamepadsEfl::GamepadsEfl):
+ (WebCore::GamepadsEfl::~GamepadsEfl):
+ (WebCore::GamepadsEfl::registerDevice):
+ (WebCore::GamepadsEfl::unregisterDevice):
+ (WebCore::GamepadsEfl::updateGamepadList):
+ (WebCore::sampleGamepads):
+
+ * platform/gamepad/glib/GamepadsGlib.cpp: Renamed from Source/WebCore/platform/glib/GamepadsGlib.cpp.
+ (WebCore::GamepadDeviceGlib::GamepadDeviceGlib):
+ (WebCore::GamepadDeviceGlib::~GamepadDeviceGlib):
+ (WebCore::GamepadDeviceGlib::readCallback):
+ (WebCore::GamepadsGlib::GamepadsGlib):
+ (WebCore::GamepadsGlib::~GamepadsGlib):
+ (WebCore::GamepadsGlib::registerDevice):
+ (WebCore::GamepadsGlib::unregisterDevice):
+ (WebCore::GamepadsGlib::updateGamepadList):
+ (WebCore::GamepadsGlib::onUEventCallback):
+ (WebCore::GamepadsGlib::isGamepadDevice):
+ (WebCore::sampleGamepads):
+
+ * platform/gamepad/linux/GamepadDeviceLinux.cpp: Renamed from Source/WebCore/platform/linux/GamepadDeviceLinux.cpp.
+ (WebCore::GamepadDeviceLinux::GamepadDeviceLinux):
+ (WebCore::GamepadDeviceLinux::~GamepadDeviceLinux):
+ (WebCore::GamepadDeviceLinux::updateForEvent):
+ (WebCore::GamepadDeviceLinux::normalizeAxisValue):
+ (WebCore::GamepadDeviceLinux::normalizeButtonValue):
+ * platform/gamepad/linux/GamepadDeviceLinux.h: Renamed from Source/WebCore/platform/linux/GamepadDeviceLinux.h.
+ (WebCore::GamepadDeviceLinux::connected):
+ (WebCore::GamepadDeviceLinux::id):
+ (WebCore::GamepadDeviceLinux::timestamp):
+ (WebCore::GamepadDeviceLinux::axesCount):
+ (WebCore::GamepadDeviceLinux::axesData):
+ (WebCore::GamepadDeviceLinux::buttonsCount):
+ (WebCore::GamepadDeviceLinux::buttonsData):
+
+ * platform/gamepad/mac/HIDGamepad.cpp: Renamed from Source/WebCore/platform/mac/HIDGamepad.cpp.
+ (WebCore::HIDGamepad::HIDGamepad):
+ (WebCore::HIDGamepad::getCurrentValueForElement):
+ (WebCore::HIDGamepad::initElements):
+ (WebCore::HIDGamepad::initElementsFromArray):
+ (WebCore::HIDGamepad::maybeAddButton):
+ (WebCore::HIDGamepad::maybeAddAxis):
+ (WebCore::HIDGamepad::valueChanged):
+ * platform/gamepad/mac/HIDGamepad.h: Renamed from Source/WebCore/platform/mac/HIDGamepad.h.
+ (WebCore::HIDGamepadElement::HIDGamepadElement):
+ (WebCore::HIDGamepadElement::~HIDGamepadElement):
+ (WebCore::HIDGamepadElement::isButton):
+ (WebCore::HIDGamepadElement::isAxis):
+ (WebCore::HIDGamepadButton::HIDGamepadButton):
+ (WebCore::HIDGamepadAxis::HIDGamepadAxis):
+ (WebCore::HIDGamepad::hidDevice):
+
+ * platform/gamepad/mac/HIDGamepadProvider.cpp: Renamed from Source/WebCore/platform/mac/HIDGamepadProvider.cpp.
+ (WebCore::deviceMatchingDictionary):
+ (WebCore::deviceAddedCallback):
+ (WebCore::deviceRemovedCallback):
+ (WebCore::deviceValuesChangedCallback):
+ (WebCore::HIDGamepadProvider::singleton):
+ (WebCore::HIDGamepadProvider::HIDGamepadProvider):
+ (WebCore::HIDGamepadProvider::indexForNewlyConnectedDevice):
+ (WebCore::HIDGamepadProvider::connectionDelayTimerFired):
+ (WebCore::HIDGamepadProvider::openAndScheduleManager):
+ (WebCore::HIDGamepadProvider::closeAndUnscheduleManager):
+ (WebCore::HIDGamepadProvider::startMonitoringGamepads):
+ (WebCore::HIDGamepadProvider::stopMonitoringGamepads):
+ (WebCore::HIDGamepadProvider::deviceAdded):
+ (WebCore::HIDGamepadProvider::deviceRemoved):
+ (WebCore::HIDGamepadProvider::valuesChanged):
+ (WebCore::HIDGamepadProvider::inputNotificationTimerFired):
+ (WebCore::HIDGamepadProvider::removeGamepadForDevice):
+ * platform/gamepad/mac/HIDGamepadProvider.h: Renamed from Source/WebCore/platform/mac/HIDGamepadProvider.h.
+ (WebCore::HIDGamepadProvider::platformGamepads):
+
</ins><span class="cx"> 2016-08-05 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r204147.
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformEflcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformEfl.cmake (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformEfl.cmake        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/PlatformEfl.cmake        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -29,6 +29,9 @@
</span><span class="cx"> "${WEBCORE_DIR}/page/efl"
</span><span class="cx"> "${WEBCORE_DIR}/platform/cairo"
</span><span class="cx"> "${WEBCORE_DIR}/platform/efl"
</span><ins>+ "${WEBCORE_DIR}/platform/gamepad"
+ "${WEBCORE_DIR}/platform/gamepad/deprecated"
+ "${WEBCORE_DIR}/platform/gamepad/efl"
</ins><span class="cx"> "${WEBCORE_DIR}/platform/geoclue"
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/cairo"
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/efl"
</span><span class="lines">@@ -98,7 +101,6 @@
</span><span class="cx"> platform/efl/ErrorsEfl.cpp
</span><span class="cx"> platform/efl/EventLoopEfl.cpp
</span><span class="cx"> platform/efl/FileSystemEfl.cpp
</span><del>- platform/efl/GamepadsEfl.cpp
</del><span class="cx"> platform/efl/LocalizedStringsEfl.cpp
</span><span class="cx"> platform/efl/MIMETypeRegistryEfl.cpp
</span><span class="cx"> platform/efl/MainThreadSharedTimerEfl.cpp
</span><span class="lines">@@ -113,6 +115,8 @@
</span><span class="cx"> platform/efl/UserAgentEfl.cpp
</span><span class="cx"> platform/efl/WidgetEfl.cpp
</span><span class="cx">
</span><ins>+ platform/gamepad/efl/GamepadsEfl.cpp
+
</ins><span class="cx"> platform/geoclue/GeolocationProviderGeoclue1.cpp
</span><span class="cx"> platform/geoclue/GeolocationProviderGeoclue2.cpp
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -34,6 +34,9 @@
</span><span class="cx"> "${WEBCORE_DIR}/editing/atk"
</span><span class="cx"> "${WEBCORE_DIR}/page/gtk"
</span><span class="cx"> "${WEBCORE_DIR}/platform/cairo"
</span><ins>+ "${WEBCORE_DIR}/platform/gamepad"
+ "${WEBCORE_DIR}/platform/gamepad/deprecated"
+ "${WEBCORE_DIR}/platform/gamepad/glib"
</ins><span class="cx"> "${WEBCORE_DIR}/platform/geoclue"
</span><span class="cx"> "${WEBCORE_DIR}/platform/gtk"
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/cairo"
</span><span class="lines">@@ -85,12 +88,13 @@
</span><span class="cx">
</span><span class="cx"> platform/crypto/gnutls/CryptoDigestGnuTLS.cpp
</span><span class="cx">
</span><ins>+ platform/gamepad/glib/GamepadsGlib.cpp
+
</ins><span class="cx"> platform/geoclue/GeolocationProviderGeoclue1.cpp
</span><span class="cx"> platform/geoclue/GeolocationProviderGeoclue2.cpp
</span><span class="cx">
</span><span class="cx"> platform/glib/EventLoopGlib.cpp
</span><span class="cx"> platform/glib/FileSystemGlib.cpp
</span><del>- platform/glib/GamepadsGlib.cpp
</del><span class="cx"> platform/glib/KeyedDecoderGlib.cpp
</span><span class="cx"> platform/glib/KeyedEncoderGlib.cpp
</span><span class="cx"> platform/glib/MainThreadSharedTimerGLib.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -2091,6 +2091,16 @@
</span><span class="cx">                 514C767D0CE923A1007EF3CD /* ResourceRequestBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C76680CE923A1007EF3CD /* ResourceRequestBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 514C767E0CE923A1007EF3CD /* ResourceResponseBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C76690CE923A1007EF3CD /* ResourceResponseBase.cpp */; };
</span><span class="cx">                 514C767F0CE923A1007EF3CD /* ResourceResponseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C766A0CE923A1007EF3CD /* ResourceResponseBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                515BE18F1D54F5FB00DD7C68 /* EmptyGamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1881D54F5F600DD7C68 /* EmptyGamepadProvider.cpp */; };
+                515BE1901D54F5FB00DD7C68 /* EmptyGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1891D54F5F600DD7C68 /* EmptyGamepadProvider.h */; };
+                515BE1911D54F5FB00DD7C68 /* GamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE18A1D54F5F600DD7C68 /* GamepadProvider.cpp */; };
+                515BE1921D54F5FB00DD7C68 /* GamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE18B1D54F5F600DD7C68 /* GamepadProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                515BE1931D54F5FB00DD7C68 /* GamepadProviderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE18C1D54F5F600DD7C68 /* GamepadProviderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                515BE1951D54F5FB00DD7C68 /* PlatformGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE18E1D54F5F600DD7C68 /* PlatformGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                515BE19B1D54F6C100DD7C68 /* HIDGamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1971D54F6BD00DD7C68 /* HIDGamepad.cpp */; };
+                515BE19C1D54F6C100DD7C68 /* HIDGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1981D54F6BD00DD7C68 /* HIDGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                515BE19D1D54F6C100DD7C68 /* HIDGamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1991D54F6BD00DD7C68 /* HIDGamepadProvider.cpp */; };
+                515BE19E1D54F6C100DD7C68 /* HIDGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE19A1D54F6BD00DD7C68 /* HIDGamepadProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 515F79531CFCA3D000CCED93 /* WebCoreCrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515F79511CFCA3C700CCED93 /* WebCoreCrossThreadCopier.cpp */; };
</span><span class="cx">                 515F79541CFCA3D500CCED93 /* WebCoreCrossThreadCopier.h in Headers */ = {isa = PBXBuildFile; fileRef = 515F79521CFCA3C700CCED93 /* WebCoreCrossThreadCopier.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 5160300B0CC4251200C8AC25 /* FileSystemPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5160300A0CC4251200C8AC25 /* FileSystemPOSIX.cpp */; };
</span><span class="lines">@@ -2136,11 +2146,6 @@
</span><span class="cx">                 5174E20A10A1F44F00F95E6F /* PopStateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 5174E20810A1F44F00F95E6F /* PopStateEvent.h */; };
</span><span class="cx">                 51771DFE1BDB485000CAE8E4 /* MemoryObjectStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51771DFC1BDB475600CAE8E4 /* MemoryObjectStore.cpp */; };
</span><span class="cx">                 51771DFF1BDB485000CAE8E4 /* MemoryObjectStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51771DFD1BDB475600CAE8E4 /* MemoryObjectStore.h */; };
</span><del>-                5179CE24195C81420019C198 /* GamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5179CE23195C81420019C198 /* GamepadProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
-                5179CE26195C821D0019C198 /* GamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5179CE25195C821D0019C198 /* GamepadProvider.cpp */; };
-                5179CE2A195C91860019C198 /* GamepadProviderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 5179CE29195C91860019C198 /* GamepadProviderClient.h */; };
-                5179CE36195CAC7E0019C198 /* HIDGamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5179CE34195CAC7E0019C198 /* HIDGamepadProvider.cpp */; };
-                5179CE37195CAC7E0019C198 /* HIDGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5179CE35195CAC7E0019C198 /* HIDGamepadProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">                 517A63C31B74318700E7DCDC /* KeyedDecoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */; };
</span><span class="cx">                 517A63C41B74318B00E7DCDC /* KeyedEncoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */; };
</span><span class="cx">                 517A63C51B74318F00E7DCDC /* KeyedDecoderCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2225,8 +2230,6 @@
</span><span class="cx">                 51A4BB101954D62700FA5C2E /* NavigatorGamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A4BB0D1954D62700FA5C2E /* NavigatorGamepad.cpp */; };
</span><span class="cx">                 51A9D9E9195B931F001B2B5C /* GamepadManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A9D9E7195B931F001B2B5C /* GamepadManager.cpp */; };
</span><span class="cx">                 51A9D9EA195B931F001B2B5C /* GamepadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A9D9E8195B931F001B2B5C /* GamepadManager.h */; };
</span><del>-                51A9D9F3195B9503001B2B5C /* HIDGamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A9D9EF195B9503001B2B5C /* HIDGamepad.cpp */; };
-                51A9D9F4195B9503001B2B5C /* HIDGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A9D9F0195B9503001B2B5C /* HIDGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">                 51AA3F6F0BD5AA9E00892971 /* ResourceLoaderMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51AA3F6E0BD5AA9E00892971 /* ResourceLoaderMac.mm */; };
</span><span class="cx">                 51ABAE1B103C18FF008C5260 /* SocketStreamError.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ABAE1A103C18FF008C5260 /* SocketStreamError.h */; };
</span><span class="cx">                 51ABAE1E103C1913008C5260 /* SocketStreamHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ABAE1C103C1913008C5260 /* SocketStreamHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2237,7 +2240,6 @@
</span><span class="cx">                 51B454EA1B4DAE7D0085EAA6 /* PingHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B454E91B4DAE7D0085EAA6 /* PingHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */; };
</span><span class="cx">                 51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E5FEF195101470086CA5E /* PlatformGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">                 51BA4AC31BBB5CD800DF3D6D /* IDBDatabaseInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */; };
</span><span class="cx">                 51BA4AC41BBB5CD800DF3D6D /* IDBDatabaseInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 51BA4ACA1BBC5BD900DF3D6D /* MemoryIDBBackingStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA4AC81BBC5B9E00DF3D6D /* MemoryIDBBackingStore.cpp */; };
</span><span class="lines">@@ -9419,7 +9421,16 @@
</span><span class="cx">                 514C76680CE923A1007EF3CD /* ResourceRequestBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceRequestBase.h; sourceTree = "<group>"; };
</span><span class="cx">                 514C76690CE923A1007EF3CD /* ResourceResponseBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceResponseBase.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 514C766A0CE923A1007EF3CD /* ResourceResponseBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceResponseBase.h; sourceTree = "<group>"; };
</span><del>-                515E5FEF195101470086CA5E /* PlatformGamepad.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformGamepad.h; sourceTree = "<group>"; };
</del><ins>+                515BE1881D54F5F600DD7C68 /* EmptyGamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmptyGamepadProvider.cpp; sourceTree = "<group>"; };
+                515BE1891D54F5F600DD7C68 /* EmptyGamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmptyGamepadProvider.h; sourceTree = "<group>"; };
+                515BE18A1D54F5F600DD7C68 /* GamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadProvider.cpp; sourceTree = "<group>"; };
+                515BE18B1D54F5F600DD7C68 /* GamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadProvider.h; sourceTree = "<group>"; };
+                515BE18C1D54F5F600DD7C68 /* GamepadProviderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadProviderClient.h; sourceTree = "<group>"; };
+                515BE18E1D54F5F600DD7C68 /* PlatformGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformGamepad.h; sourceTree = "<group>"; };
+                515BE1971D54F6BD00DD7C68 /* HIDGamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HIDGamepad.cpp; sourceTree = "<group>"; };
+                515BE1981D54F6BD00DD7C68 /* HIDGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIDGamepad.h; sourceTree = "<group>"; };
+                515BE1991D54F6BD00DD7C68 /* HIDGamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HIDGamepadProvider.cpp; sourceTree = "<group>"; };
+                515BE19A1D54F6BD00DD7C68 /* HIDGamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIDGamepadProvider.h; sourceTree = "<group>"; };
</ins><span class="cx">                 515F79511CFCA3C700CCED93 /* WebCoreCrossThreadCopier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreCrossThreadCopier.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 515F79521CFCA3C700CCED93 /* WebCoreCrossThreadCopier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreCrossThreadCopier.h; sourceTree = "<group>"; };
</span><span class="cx">                 5160300A0CC4251200C8AC25 /* FileSystemPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemPOSIX.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -9489,11 +9500,6 @@
</span><span class="cx">                 5174E20B10A1F49A00F95E6F /* PopStateEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PopStateEvent.idl; sourceTree = "<group>"; };
</span><span class="cx">                 51771DFC1BDB475600CAE8E4 /* MemoryObjectStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryObjectStore.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51771DFD1BDB475600CAE8E4 /* MemoryObjectStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryObjectStore.h; sourceTree = "<group>"; };
</span><del>-                5179CE23195C81420019C198 /* GamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadProvider.h; sourceTree = "<group>"; };
-                5179CE25195C821D0019C198 /* GamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadProvider.cpp; sourceTree = "<group>"; };
-                5179CE29195C91860019C198 /* GamepadProviderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadProviderClient.h; sourceTree = "<group>"; };
-                5179CE34195CAC7E0019C198 /* HIDGamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HIDGamepadProvider.cpp; sourceTree = "<group>"; };
-                5179CE35195CAC7E0019C198 /* HIDGamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIDGamepadProvider.h; sourceTree = "<group>"; };
</del><span class="cx">                 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedDecoderCF.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedDecoderCF.h; sourceTree = "<group>"; };
</span><span class="cx">                 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedEncoderCF.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -9540,8 +9546,6 @@
</span><span class="cx">                 51A4BB0F1954D62700FA5C2E /* NavigatorGamepad.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorGamepad.idl; sourceTree = "<group>"; };
</span><span class="cx">                 51A9D9E7195B931F001B2B5C /* GamepadManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadManager.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51A9D9E8195B931F001B2B5C /* GamepadManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadManager.h; sourceTree = "<group>"; };
</span><del>-                51A9D9EF195B9503001B2B5C /* HIDGamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HIDGamepad.cpp; sourceTree = "<group>"; };
-                51A9D9F0195B9503001B2B5C /* HIDGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HIDGamepad.h; sourceTree = "<group>"; };
</del><span class="cx">                 51AA3F6E0BD5AA9E00892971 /* ResourceLoaderMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceLoaderMac.mm; sourceTree = "<group>"; };
</span><span class="cx">                 51ABAE1A103C18FF008C5260 /* SocketStreamError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamError.h; sourceTree = "<group>"; };
</span><span class="cx">                 51ABAE1C103C1913008C5260 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandle.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -17485,6 +17489,31 @@
</span><span class="cx">                         path = cf;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="cx">                 };
</span><ins>+                515BE1871D54F5DB00DD7C68 /* gamepad */ = {
+                        isa = PBXGroup;
+                        children = (
+                                515BE1961D54F64500DD7C68 /* mac */,
+                                515BE1881D54F5F600DD7C68 /* EmptyGamepadProvider.cpp */,
+                                515BE1891D54F5F600DD7C68 /* EmptyGamepadProvider.h */,
+                                515BE18A1D54F5F600DD7C68 /* GamepadProvider.cpp */,
+                                515BE18B1D54F5F600DD7C68 /* GamepadProvider.h */,
+                                515BE18C1D54F5F600DD7C68 /* GamepadProviderClient.h */,
+                                515BE18E1D54F5F600DD7C68 /* PlatformGamepad.h */,
+                        );
+                        path = gamepad;
+                        sourceTree = "<group>";
+                };
+                515BE1961D54F64500DD7C68 /* mac */ = {
+                        isa = PBXGroup;
+                        children = (
+                                515BE1971D54F6BD00DD7C68 /* HIDGamepad.cpp */,
+                                515BE1981D54F6BD00DD7C68 /* HIDGamepad.h */,
+                                515BE1991D54F6BD00DD7C68 /* HIDGamepadProvider.cpp */,
+                                515BE19A1D54F6BD00DD7C68 /* HIDGamepadProvider.h */,
+                        );
+                        path = mac;
+                        sourceTree = "<group>";
+                };
</ins><span class="cx">                 516030090CC4245400C8AC25 /* posix */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="lines">@@ -17969,10 +17998,6 @@
</span><span class="cx">                                 E1BA66F01742BD8600C20251 /* DynamicLinkerInterposing.h */,
</span><span class="cx">                                 1CA19E030DC255950065A994 /* EventLoopMac.mm */,
</span><span class="cx">                                 514B3F750C722055000530DF /* FileSystemMac.mm */,
</span><del>-                                51A9D9EF195B9503001B2B5C /* HIDGamepad.cpp */,
-                                51A9D9F0195B9503001B2B5C /* HIDGamepad.h */,
-                                5179CE34195CAC7E0019C198 /* HIDGamepadProvider.cpp */,
-                                5179CE35195CAC7E0019C198 /* HIDGamepadProvider.h */,
</del><span class="cx">                                 935C476E09AC4D7300A6AAB4 /* KeyEventMac.mm */,
</span><span class="cx">                                 521D46F511AEC98100514613 /* KillRingMac.mm */,
</span><span class="cx">                                 06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
</span><span class="lines">@@ -22500,6 +22525,7 @@
</span><span class="cx">                                 1AE42F670AA4B8CB00C8612D /* cf */,
</span><span class="cx">                                 A5C974CE11485FDA0066F2AB /* cocoa */,
</span><span class="cx">                                 CE50D8CE1C8932ED0072EA5A /* crypto */,
</span><ins>+                                515BE1871D54F5DB00DD7C68 /* gamepad */,
</ins><span class="cx">                                 B2A015910AF6CD53006BCE0E /* graphics */,
</span><span class="cx">                                 A59E3C1B11580F340072928E /* ios */,
</span><span class="cx">                                 6582A14809999D6C00BEEB6D /* mac */,
</span><span class="lines">@@ -22555,9 +22581,6 @@
</span><span class="cx">                                 C57FEDE01212EE9C0097BE65 /* FileSystem.cpp */,
</span><span class="cx">                                 514B3F720C722047000530DF /* FileSystem.h */,
</span><span class="cx">                                 BC073BA90C399B1F000F5979 /* FloatConversion.h */,
</span><del>-                                5179CE25195C821D0019C198 /* GamepadProvider.cpp */,
-                                5179CE23195C81420019C198 /* GamepadProvider.h */,
-                                5179CE29195C91860019C198 /* GamepadProviderClient.h */,
</del><span class="cx">                                 CD4BE5291CE13425009D87DA /* GenericTaskQueue.cpp */,
</span><span class="cx">                                 CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */,
</span><span class="cx">                                 A8748BDF12CBF2DC001FBA41 /* HashTools.h */,
</span><span class="lines">@@ -22601,7 +22624,6 @@
</span><span class="cx">                                 A14978701ABAF3A500CEF7E4 /* PlatformContentFilter.h */,
</span><span class="cx">                                 BC5C76291497FE1400BC4775 /* PlatformEvent.h */,
</span><span class="cx">                                 A723F77A1484CA4C008C6DBE /* PlatformExportMacros.h */,
</span><del>-                                515E5FEF195101470086CA5E /* PlatformGamepad.h */,
</del><span class="cx">                                 935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */,
</span><span class="cx">                                 935C476709AC4D4300A6AAB4 /* PlatformMouseEvent.h */,
</span><span class="cx">                                 C5BAC16F14E30E4700008837 /* PlatformPasteboard.h */,
</span><span class="lines">@@ -24694,6 +24716,7 @@
</span><span class="cx">                                 29A8122C0FBB9C1D00510293 /* AccessibilityList.h in Headers */,
</span><span class="cx">                                 29A812430FBB9C1D00510293 /* AccessibilityListBox.h in Headers */,
</span><span class="cx">                                 29A812420FBB9C1D00510293 /* AccessibilityListBoxOption.h in Headers */,
</span><ins>+                                515BE19C1D54F6C100DD7C68 /* HIDGamepad.h in Headers */,
</ins><span class="cx">                                 07B0ABCF1032242200FBDC33 /* AccessibilityMathMLElement.h in Headers */,
</span><span class="cx">                                 07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */,
</span><span class="cx">                                 76CDD2F31103DA6600680521 /* AccessibilityMenuList.h in Headers */,
</span><span class="lines">@@ -24959,6 +24982,7 @@
</span><span class="cx">                                 E425A49A18292B840020CFCF /* CollectionIndexCache.h in Headers */,
</span><span class="cx">                                 46EBEA021B7D4D6500BE4941 /* CollectionTraversal.h in Headers */,
</span><span class="cx">                                 93C442000F813AE100C1A634 /* CollectionType.h in Headers */,
</span><ins>+                                515BE1901D54F5FB00DD7C68 /* EmptyGamepadProvider.h in Headers */,
</ins><span class="cx">                                 B27535670B053814002CE64F /* Color.h in Headers */,
</span><span class="cx">                                 C330A22313EC196B0000B45B /* ColorChooser.h in Headers */,
</span><span class="cx">                                 C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */,
</span><span class="lines">@@ -25661,8 +25685,6 @@
</span><span class="cx">                                 FD31600D12B0267600C1A359 /* GainNode.h in Headers */,
</span><span class="cx">                                 516C62211950D48700337E75 /* GamepadEvent.h in Headers */,
</span><span class="cx">                                 51A9D9EA195B931F001B2B5C /* GamepadManager.h in Headers */,
</span><del>-                                5179CE24195C81420019C198 /* GamepadProvider.h in Headers */,
-                                5179CE2A195C91860019C198 /* GamepadProviderClient.h in Headers */,
</del><span class="cx">                                 935C477509AC4D8E00A6AAB4 /* GapRects.h in Headers */,
</span><span class="cx">                                 1432E8470C51493800B1500F /* GCController.h in Headers */,
</span><span class="cx">                                 C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */,
</span><span class="lines">@@ -25707,8 +25729,6 @@
</span><span class="cx">                                 8482B7461198C35400BFB005 /* HashChangeEvent.h in Headers */,
</span><span class="cx">                                 A8748BE012CBF2DC001FBA41 /* HashTools.h in Headers */,
</span><span class="cx">                                 F55B3DC01251F12D003EF269 /* HiddenInputType.h in Headers */,
</span><del>-                                51A9D9F4195B9503001B2B5C /* HIDGamepad.h in Headers */,
-                                5179CE37195CAC7E0019C198 /* HIDGamepadProvider.h in Headers */,
</del><span class="cx">                                 BC94D1540C275C8B006BC617 /* History.h in Headers */,
</span><span class="cx">                                 97DCE20210807C750057D394 /* HistoryController.h in Headers */,
</span><span class="cx">                                 51741D110B07259A00ED442C /* HistoryItem.h in Headers */,
</span><span class="lines">@@ -26531,6 +26551,7 @@
</span><span class="cx">                                 65DF320409D1CC60000BE325 /* JSText.h in Headers */,
</span><span class="cx">                                 933A14B90B7D1D5200A53FFD /* JSTextEvent.h in Headers */,
</span><span class="cx">                                 BCEF45F60E687B5C001C1287 /* JSTextMetrics.h in Headers */,
</span><ins>+                                515BE1951D54F5FB00DD7C68 /* PlatformGamepad.h in Headers */,
</ins><span class="cx">                                 070756951422668D00414161 /* JSTextTrack.h in Headers */,
</span><span class="cx">                                 070756DE14239B4E00414161 /* JSTextTrackCue.h in Headers */,
</span><span class="cx">                                 070756E014239B4E00414161 /* JSTextTrackCueList.h in Headers */,
</span><span class="lines">@@ -27035,7 +27056,6 @@
</span><span class="cx">                                 26601EBF14B3B9AD0012C0FE /* PlatformEventFactoryIOS.h in Headers */,
</span><span class="cx">                                 BCAA487014A052530088FAC4 /* PlatformEventFactoryMac.h in Headers */,
</span><span class="cx">                                 A723F77B1484CA4C008C6DBE /* PlatformExportMacros.h in Headers */,
</span><del>-                                51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */,
</del><span class="cx">                                 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,
</span><span class="cx">                                 0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */,
</span><span class="cx">                                 F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */,
</span><span class="lines">@@ -27061,6 +27081,7 @@
</span><span class="cx">                                 072AE1E5183C0741000A5988 /* PluginReplacement.h in Headers */,
</span><span class="cx">                                 71E2183A17359FB8006E6E4D /* PlugInsResources.h in Headers */,
</span><span class="cx">                                 1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */,
</span><ins>+                                515BE1931D54F5FB00DD7C68 /* GamepadProviderClient.h in Headers */,
</ins><span class="cx">                                 0AFDAC3D10F5448C00E1F3D2 /* PluginViewBase.h in Headers */,
</span><span class="cx">                                 BCBB8AB913F1AFB000734DF0 /* PODInterval.h in Headers */,
</span><span class="cx">                                 BCBB8ABA13F1AFB000734DF0 /* PODIntervalTree.h in Headers */,
</span><span class="lines">@@ -27806,6 +27827,7 @@
</span><span class="cx">                                 83C1D432178D5AB500141E68 /* SVGPathSegLinetoRel.h in Headers */,
</span><span class="cx">                                 B2227A7D0D00BF220071B782 /* SVGPathSegLinetoVertical.h in Headers */,
</span><span class="cx">                                 83C1D433178D5AB500141E68 /* SVGPathSegLinetoVerticalAbs.h in Headers */,
</span><ins>+                                515BE19E1D54F6C100DD7C68 /* HIDGamepadProvider.h in Headers */,
</ins><span class="cx">                                 83C1D434178D5AB500141E68 /* SVGPathSegLinetoVerticalRel.h in Headers */,
</span><span class="cx">                                 B2227A810D00BF220071B782 /* SVGPathSegList.h in Headers */,
</span><span class="cx">                                 8476C9E611DF6A0B00555B02 /* SVGPathSegListBuilder.h in Headers */,
</span><span class="lines">@@ -27866,6 +27888,7 @@
</span><span class="cx">                                 080E49281255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h in Headers */,
</span><span class="cx">                                 08F0BFC61255C53C00075185 /* SVGTextMetrics.h in Headers */,
</span><span class="cx">                                 1A67BF731D4FE42300412AC7 /* DOMHTMLParagraphElement.h in Headers */,
</span><ins>+                                515BE1921D54F5FB00DD7C68 /* GamepadProvider.h in Headers */,
</ins><span class="cx">                                 7117445914BC34EC00EE5FC8 /* SVGTextMetricsBuilder.h in Headers */,
</span><span class="cx">                                 B2227ACE0D00BF220071B782 /* SVGTextPathElement.h in Headers */,
</span><span class="cx">                                 B2227AD10D00BF220071B782 /* SVGTextPositioningElement.h in Headers */,
</span><span class="lines">@@ -28661,6 +28684,7 @@
</span><span class="cx">                                 512DD8FA0D91E6AF000F89EE /* ArchiveFactory.cpp in Sources */,
</span><span class="cx">                                 512DD8FB0D91E6AF000F89EE /* ArchiveResource.cpp in Sources */,
</span><span class="cx">                                 512DD8F70D91E6AF000F89EE /* ArchiveResourceCollection.cpp in Sources */,
</span><ins>+                                515BE1911D54F5FB00DD7C68 /* GamepadProvider.cpp in Sources */,
</ins><span class="cx">                                 49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */,
</span><span class="cx">                                 FD5686C913AC180200B69C68 /* AsyncAudioDecoder.cpp in Sources */,
</span><span class="cx">                                 E1CDE92015018ED000862CC5 /* AsyncFileStream.cpp in Sources */,
</span><span class="lines">@@ -29037,6 +29061,7 @@
</span><span class="cx">                                 93309DDE099E64920056E581 /* DeleteFromTextNodeCommand.cpp in Sources */,
</span><span class="cx">                                 93309DE0099E64920056E581 /* DeleteSelectionCommand.cpp in Sources */,
</span><span class="cx">                                 A7C9ABF81357A3BF00F5503F /* DetailsMarkerControl.cpp in Sources */,
</span><ins>+                                515BE18F1D54F5FB00DD7C68 /* EmptyGamepadProvider.cpp in Sources */,
</ins><span class="cx">                                 A1ED778C1BE3294000DC1791 /* Device.cpp in Sources */,
</span><span class="cx">                                 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */,
</span><span class="cx">                                 31EAF97F121435A400E7C1BF /* DeviceMotionClientIOS.mm in Sources */,
</span><span class="lines">@@ -29418,7 +29443,6 @@
</span><span class="cx">                                 518F4FF6194CA4E60081BAAE /* GamepadButton.cpp in Sources */,
</span><span class="cx">                                 516C62201950D48700337E75 /* GamepadEvent.cpp in Sources */,
</span><span class="cx">                                 51A9D9E9195B931F001B2B5C /* GamepadManager.cpp in Sources */,
</span><del>-                                5179CE26195C821D0019C198 /* GamepadProvider.cpp in Sources */,
</del><span class="cx">                                 1432E8490C51493F00B1500F /* GCController.cpp in Sources */,
</span><span class="cx">                                 4FB390AD15EF61F3007AD51F /* GeneratedImage.cpp in Sources */,
</span><span class="cx">                                 830030F51B7D33B500ED3AAC /* GenericCachedHTMLCollection.cpp in Sources */,
</span><span class="lines">@@ -29447,8 +29471,6 @@
</span><span class="cx">                                 B2A015AA0AF6CD53006BCE0E /* GraphicsTypes.cpp in Sources */,
</span><span class="cx">                                 CDF7483E18FEBCEC0006ECC0 /* GridPositionsResolver.cpp in Sources */,
</span><span class="cx">                                 F55B3DBF1251F12D003EF269 /* HiddenInputType.cpp in Sources */,
</span><del>-                                51A9D9F3195B9503001B2B5C /* HIDGamepad.cpp in Sources */,
-                                5179CE36195CAC7E0019C198 /* HIDGamepadProvider.cpp in Sources */,
</del><span class="cx">                                 BC94D1530C275C8B006BC617 /* History.cpp in Sources */,
</span><span class="cx">                                 97DCE20110807C750057D394 /* HistoryController.cpp in Sources */,
</span><span class="cx">                                 51741D120B07259A00ED442C /* HistoryItem.cpp in Sources */,
</span><span class="lines">@@ -29476,6 +29498,7 @@
</span><span class="cx">                                 A8DF3FD1097FA0FC0052981B /* HTMLCollection.cpp in Sources */,
</span><span class="cx">                                 977B3864122883E900B81FF8 /* HTMLConstructionSite.cpp in Sources */,
</span><span class="cx">                                 7C3E510B18DF8F3500C112F7 /* HTMLConverter.mm in Sources */,
</span><ins>+                                515BE19D1D54F6C100DD7C68 /* HIDGamepadProvider.cpp in Sources */,
</ins><span class="cx">                                 83120C701C56F3F6001CB112 /* HTMLDataElement.cpp in Sources */,
</span><span class="cx">                                 F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */,
</span><span class="cx">                                 D359D789129CA2710006E5D2 /* HTMLDetailsElement.cpp in Sources */,
</span><span class="lines">@@ -30503,6 +30526,7 @@
</span><span class="cx">                                 1A4832B31A953BA6008B4DFE /* LocalizedStringsCocoa.mm in Sources */,
</span><span class="cx">                                 BCE1C41C0D982981003B02F2 /* Location.cpp in Sources */,
</span><span class="cx">                                 A8239E0009B3CF8A00B60641 /* Logging.cpp in Sources */,
</span><ins>+                                515BE19B1D54F6C100DD7C68 /* HIDGamepad.cpp in Sources */,
</ins><span class="cx">                                 1402645E0AFDC19B005919E2 /* LoggingMac.mm in Sources */,
</span><span class="cx">                                 1A0409F31A43675C009E47F3 /* MachSendRight.cpp in Sources */,
</span><span class="cx">                                 932AD70517EFA2C30038F8FF /* MainFrame.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformGamepadProvidercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/GamepadProvider.cpp (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/GamepadProvider.cpp        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/GamepadProvider.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,67 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-#include "config.h"
-#include "GamepadProvider.h"
-
-#if ENABLE(GAMEPAD)
-
-#include <wtf/NeverDestroyed.h>
-
-namespace WebCore {
-
-static GamepadProvider* sharedProvider = nullptr;
-
-GamepadProvider& GamepadProvider::singleton()
-{
- if (!sharedProvider) {
- static NeverDestroyed<GamepadProvider> defaultProvider;
- sharedProvider = &defaultProvider.get();
- }
-
- return *sharedProvider;
-}
-
-void GamepadProvider::setSharedProvider(GamepadProvider& newProvider)
-{
- sharedProvider = &newProvider;
-}
-
-void GamepadProvider::startMonitoringGamepads(GamepadProviderClient*)
-{
-}
-
-void GamepadProvider::stopMonitoringGamepads(GamepadProviderClient*)
-{
-}
-
-const Vector<PlatformGamepad*>& GamepadProvider::platformGamepads()
-{
- static NeverDestroyed<Vector<PlatformGamepad*>> defaultGamepads;
- return defaultGamepads;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformGamepadProviderh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/GamepadProvider.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/GamepadProvider.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/GamepadProvider.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,53 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#ifndef GamepadProvider_h
-#define GamepadProvider_h
-
-#if ENABLE(GAMEPAD)
-
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class GamepadProviderClient;
-class PlatformGamepad;
-
-class GamepadProvider {
-public:
- virtual ~GamepadProvider() { }
-
- WEBCORE_EXPORT static GamepadProvider& singleton();
- WEBCORE_EXPORT static void setSharedProvider(GamepadProvider&);
-
- virtual void startMonitoringGamepads(GamepadProviderClient*);
- virtual void stopMonitoringGamepads(GamepadProviderClient*);
- virtual const Vector<PlatformGamepad*>& platformGamepads();
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
-#endif // GamepadProvider_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformGamepadProviderClienth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/GamepadProviderClient.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/GamepadProviderClient.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/GamepadProviderClient.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,47 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#ifndef GamepadProviderClient_h
-#define GamepadProviderClient_h
-
-#if ENABLE(GAMEPAD)
-
-namespace WebCore {
-
-class PlatformGamepad;
-
-class GamepadProviderClient {
-public:
- virtual ~GamepadProviderClient() { }
-
- virtual void platformGamepadConnected(PlatformGamepad&) = 0;
- virtual void platformGamepadDisconnected(PlatformGamepad&) = 0;
- virtual void platformGamepadInputActivity() = 0;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
-#endif // GamepadProviderClient_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformGamepadsh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/Gamepads.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Gamepads.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/Gamepads.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,41 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011, Google 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.
- */
-
-#ifndef Gamepads_h
-#define Gamepads_h
-
-#if ENABLE(GAMEPAD_DEPRECATED)
-
-namespace WebCore {
-
-class GamepadList;
-
-void sampleGamepads(GamepadList* into);
-
-}
-
-#endif // ENABLE(GAMEPAD_DEPRECATED)
-
-#endif // Gamepads_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformLinuxcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Linux.cmake (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Linux.cmake        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/Linux.cmake        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,8 +1,9 @@
</span><span class="cx"> list(APPEND WebCore_INCLUDE_DIRECTORIES
</span><span class="cx"> "${WEBCORE_DIR}/platform/linux"
</span><ins>+ "${WEBCORE_DIR}/platform/gamepad/linux"
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> list(APPEND WebCore_SOURCES
</span><del>- platform/linux/GamepadDeviceLinux.cpp
</del><ins>+ platform/gamepad/linux/GamepadDeviceLinux.cpp
</ins><span class="cx"> platform/linux/MemoryPressureHandlerLinux.cpp
</span><span class="cx"> )
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPlatformGamepadh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/PlatformGamepad.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PlatformGamepad.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/PlatformGamepad.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,64 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#ifndef PlatformGamepad_h
-#define PlatformGamepad_h
-
-#if ENABLE(GAMEPAD)
-
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class PlatformGamepad {
-public:
- virtual ~PlatformGamepad() { }
-
- const String& id() const { return m_id; }
- unsigned index() const { return m_index; }
- double lastUpdateTime() const { return m_lastUpdateTime; }
- double connectTime() const { return m_connectTime; }
- virtual const Vector<double>& axisValues() const = 0;
- virtual const Vector<double>& buttonValues() const = 0;
-
-protected:
- explicit PlatformGamepad(unsigned index)
- : m_index(index)
- , m_lastUpdateTime(0.0)
- , m_connectTime(0.0)
- {
- }
-
- String m_id;
- unsigned m_index;
- double m_lastUpdateTime;
- double m_connectTime;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
-#endif // PlatformGamepad_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformeflGamepadsEflcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/efl/GamepadsEfl.cpp (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/efl/GamepadsEfl.cpp        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/efl/GamepadsEfl.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,241 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Intel Corporation. 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.
- */
-
-#include "config.h"
-#include "Gamepads.h"
-
-#if ENABLE(GAMEPAD_DEPRECATED)
-
-#include "GamepadDeviceLinux.h"
-#include "GamepadList.h"
-#include "Logging.h"
-#include <Ecore.h>
-#include <Eeze.h>
-#include <Eina.h>
-#include <unistd.h>
-#include <wtf/HashMap.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-
-namespace WebCore {
-
-static const char joystickPrefix[] = "/dev/input/js";
-
-class GamepadDeviceEfl : public GamepadDeviceLinux {
-public:
- explicit GamepadDeviceEfl(const String& deviceFile);
- ~GamepadDeviceEfl();
- void resetFdHandler() { m_fdHandler = 0; }
- const String& deviceFile() const { return m_deviceFile; }
-
-private:
- static Eina_Bool readCallback(void* userData, Ecore_Fd_Handler*);
-
- Ecore_Fd_Handler* m_fdHandler;
- String m_deviceFile;
-};
-
-GamepadDeviceEfl::GamepadDeviceEfl(const String& deviceFile)
- : GamepadDeviceLinux(deviceFile)
- , m_fdHandler(0)
- , m_deviceFile(deviceFile)
-{
- if (m_fileDescriptor < 0)
- return;
-
- m_fdHandler = ecore_main_fd_handler_add(m_fileDescriptor, ECORE_FD_READ, readCallback, this, 0, 0);
- if (!m_fdHandler)
- LOG_ERROR("Failed to create the Ecore_Fd_Handler.");
-}
-
-GamepadDeviceEfl::~GamepadDeviceEfl()
-{
- if (m_fdHandler)
- ecore_main_fd_handler_del(m_fdHandler);
-}
-
-Eina_Bool GamepadDeviceEfl::readCallback(void* userData, Ecore_Fd_Handler* fdHandler)
-{
- GamepadDeviceEfl* gamepadDevice = static_cast<GamepadDeviceEfl*>(userData);
-
- if (ecore_main_fd_handler_active_get(fdHandler, ECORE_FD_ERROR)) {
- LOG_ERROR("An error occurred while watching the joystick file descriptor at %s, aborting.", gamepadDevice->deviceFile().utf8().data());
- gamepadDevice->resetFdHandler();
- return ECORE_CALLBACK_CANCEL;
- }
-
- int fdDevice = ecore_main_fd_handler_fd_get(fdHandler);
- struct js_event event;
- const ssize_t len = read(fdDevice, &event, sizeof(event));
-
- if (len <= 0) {
- LOG_ERROR("Failed to read joystick file descriptor at %s, aborting.", gamepadDevice->deviceFile().utf8().data());
- gamepadDevice->resetFdHandler();
- return ECORE_CALLBACK_CANCEL;
- }
- if (len != sizeof(event)) {
- LOG_ERROR("Wrong js_event size read on file descriptor at %s, ignoring.", gamepadDevice->deviceFile().utf8().data());
- return ECORE_CALLBACK_RENEW;
- }
-
- gamepadDevice->updateForEvent(event);
- return ECORE_CALLBACK_RENEW;
-}
-
-class GamepadsEfl {
- friend class NeverDestroyed<GamepadsEfl>;
-public:
- GamepadsEfl(size_t length);
-
- void registerDevice(const String& syspath);
- void unregisterDevice(const String& syspath);
-
- void updateGamepadList(GamepadList*);
-
-private:
- ~GamepadsEfl();
- static void onGamePadChange(const char* syspath, Eeze_Udev_Event, void* userData, Eeze_Udev_Watch* watcher);
-
- Vector<std::unique_ptr<GamepadDeviceEfl>> m_slots;
- HashMap<String, GamepadDeviceEfl*> m_deviceMap;
-
- Eeze_Udev_Watch* m_gamepadsWatcher;
-};
-
-void GamepadsEfl::onGamePadChange(const char* syspath, Eeze_Udev_Event event, void* userData, Eeze_Udev_Watch*)
-{
- GamepadsEfl* gamepadsEfl = static_cast<GamepadsEfl*>(userData);
-
- switch (event) {
- case EEZE_UDEV_EVENT_ADD:
- gamepadsEfl->registerDevice(String::fromUTF8(syspath));
- break;
- case EEZE_UDEV_EVENT_REMOVE:
- gamepadsEfl->unregisterDevice(String::fromUTF8(syspath));
- break;
- default:
- break;
- }
-}
-
-GamepadsEfl::GamepadsEfl(size_t length)
- : m_slots(length)
- , m_gamepadsWatcher(0)
-{
- if (eeze_init() < 0) {
- LOG_ERROR("Failed to initialize eeze library.");
- return;
- }
-
- // Watch for gamepads additions / removals.
- m_gamepadsWatcher = eeze_udev_watch_add(EEZE_UDEV_TYPE_JOYSTICK, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), onGamePadChange, this);
-
- // List available gamepads.
- Eina_List* gamepads = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, 0);
- void* data;
- EINA_LIST_FREE(gamepads, data) {
- char* syspath = static_cast<char*>(data);
- registerDevice(String::fromUTF8(syspath));
- eina_stringshare_del(syspath);
- }
-}
-
-GamepadsEfl::~GamepadsEfl()
-{
- if (m_gamepadsWatcher)
- eeze_udev_watch_del(m_gamepadsWatcher);
- eeze_shutdown();
-}
-
-void GamepadsEfl::registerDevice(const String& syspath)
-{
- if (m_deviceMap.contains(syspath))
- return;
-
- // Make sure it is a valid joystick.
- const char* deviceFile = eeze_udev_syspath_get_devpath(syspath.utf8().data());
- if (!deviceFile || !eina_str_has_prefix(deviceFile, joystickPrefix))
- return;
-
- LOG(Gamepad, "Registering gamepad at %s", deviceFile);
-
- const size_t slotCount = m_slots.size();
- for (size_t index = 0; index < slotCount; ++index) {
- if (!m_slots[index]) {
- m_slots[index] = std::make_unique<GamepadDeviceEfl>(String::fromUTF8(deviceFile));
- LOG(Gamepad, "Gamepad device name is %s", m_slots[index]->id().utf8().data());
- m_deviceMap.add(syspath, m_slots[index].get());
- break;
- }
- }
-}
-
-void GamepadsEfl::unregisterDevice(const String& syspath)
-{
- if (!m_deviceMap.contains(syspath))
- return;
-
- GamepadDeviceEfl* gamepadDevice = m_deviceMap.take(syspath);
- LOG(Gamepad, "Unregistering gamepad at %s", gamepadDevice->deviceFile().utf8().data());
- const size_t index = m_slots.find(std::make_unique<GamepadDeviceEfl>(gamepadDevice->deviceFile()));
- ASSERT(index != notFound);
-
- m_slots[index] = nullptr;
-}
-
-void GamepadsEfl::updateGamepadList(GamepadList* into)
-{
- ASSERT(m_slots.size() == into->length());
-
- const size_t slotCount = m_slots.size();
- for (size_t i = 0; i < slotCount; ++i) {
- if (m_slots[i].get() && m_slots[i]->connected()) {
- GamepadDeviceEfl* gamepadDevice = m_slots[i].get();
- RefPtr<Gamepad> gamepad = into->item(i);
- if (!gamepad)
- gamepad = Gamepad::create();
-
- gamepad->index(i);
- gamepad->id(gamepadDevice->id());
- gamepad->timestamp(gamepadDevice->timestamp());
- gamepad->axes(gamepadDevice->axesCount(), gamepadDevice->axesData());
- gamepad->buttons(gamepadDevice->buttonsCount(), gamepadDevice->buttonsData());
-
- into->set(i, gamepad);
- } else
- into->set(i, 0);
- }
-}
-
-void sampleGamepads(GamepadList* into)
-{
- static NeverDestroyed<GamepadsEfl> gamepadsEfl(into->length());
- gamepadsEfl.get().updateGamepadList(into);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD_DEPRECATED)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadEmptyGamepadProvidercppfromrev204177trunkSourceWebCoreplatformGamepadProviderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.cpp (from rev 204177, trunk/Source/WebCore/platform/GamepadProviderClient.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "EmptyGamepadProvider.h"
+
+#if ENABLE(GAMEPAD)
+
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+void EmptyGamepadProvider::startMonitoringGamepads(GamepadProviderClient*)
+{
+}
+
+void EmptyGamepadProvider::stopMonitoringGamepads(GamepadProviderClient* )
+{
+}
+
+const Vector<PlatformGamepad*>& EmptyGamepadProvider::platformGamepads()
+{
+ static NeverDestroyed<Vector<PlatformGamepad*>> emptyGamepads;
+ return emptyGamepads;
+}
+
+}
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadEmptyGamepadProviderhfromrev204177trunkSourceWebCoreplatformGamepadProviderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.h (from rev 204177, trunk/Source/WebCore/platform/GamepadProviderClient.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/EmptyGamepadProvider.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include "GamepadProvider.h"
+
+namespace WebCore {
+
+class EmptyGamepadProvider : public GamepadProvider {
+public:
+ ~EmptyGamepadProvider() final { }
+
+ void startMonitoringGamepads(GamepadProviderClient*) final;
+ void stopMonitoringGamepads(GamepadProviderClient*) final;
+ const Vector<PlatformGamepad*>& platformGamepads() final;
+};
+
+}
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadGamepadProvidercppfromrev204177trunkSourceWebCoreplatformGamepadProvidercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp (from rev 204177, trunk/Source/WebCore/platform/GamepadProvider.cpp) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/GamepadProvider.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+#include "config.h"
+#include "GamepadProvider.h"
+
+#if ENABLE(GAMEPAD)
+
+#include "EmptyGamepadProvider.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+static GamepadProvider* sharedProvider = nullptr;
+
+GamepadProvider& GamepadProvider::singleton()
+{
+ if (!sharedProvider) {
+ static NeverDestroyed<EmptyGamepadProvider> defaultProvider;
+ sharedProvider = &defaultProvider.get();
+ }
+
+ return *sharedProvider;
+}
+
+void GamepadProvider::setSharedProvider(GamepadProvider& newProvider)
+{
+ sharedProvider = &newProvider;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadGamepadProviderhfromrev204177trunkSourceWebCoreplatformGamepadProviderh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/GamepadProvider.h (from rev 204177, trunk/Source/WebCore/platform/GamepadProvider.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/GamepadProvider.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/GamepadProvider.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class GamepadProviderClient;
+class PlatformGamepad;
+
+class GamepadProvider {
+public:
+ virtual ~GamepadProvider() { }
+
+ WEBCORE_EXPORT static GamepadProvider& singleton();
+ WEBCORE_EXPORT static void setSharedProvider(GamepadProvider&);
+
+ virtual void startMonitoringGamepads(GamepadProviderClient*) = 0;
+ virtual void stopMonitoringGamepads(GamepadProviderClient*) = 0;
+ virtual const Vector<PlatformGamepad*>& platformGamepads() = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadGamepadProviderClienthfromrev204177trunkSourceWebCoreplatformGamepadProviderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h (from rev 204177, trunk/Source/WebCore/platform/GamepadProviderClient.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/GamepadProviderClient.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+namespace WebCore {
+
+class PlatformGamepad;
+
+class GamepadProviderClient {
+public:
+ virtual ~GamepadProviderClient() { }
+
+ virtual void platformGamepadConnected(PlatformGamepad&) = 0;
+ virtual void platformGamepadDisconnected(PlatformGamepad&) = 0;
+ virtual void platformGamepadInputActivity() = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadPlatformGamepadhfromrev204177trunkSourceWebCoreplatformPlatformGamepadh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/PlatformGamepad.h (from rev 204177, trunk/Source/WebCore/platform/PlatformGamepad.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/PlatformGamepad.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/PlatformGamepad.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class PlatformGamepad {
+public:
+ virtual ~PlatformGamepad() { }
+
+ const String& id() const { return m_id; }
+ unsigned index() const { return m_index; }
+ double lastUpdateTime() const { return m_lastUpdateTime; }
+ double connectTime() const { return m_connectTime; }
+ virtual const Vector<double>& axisValues() const = 0;
+ virtual const Vector<double>& buttonValues() const = 0;
+
+protected:
+ explicit PlatformGamepad(unsigned index)
+ : m_index(index)
+ , m_lastUpdateTime(0.0)
+ , m_connectTime(0.0)
+ {
+ }
+
+ String m_id;
+ unsigned m_index;
+ double m_lastUpdateTime;
+ double m_connectTime;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepaddeprecatedGamepadshfromrev204177trunkSourceWebCoreplatformGamepadsh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/deprecated/Gamepads.h (from rev 204177, trunk/Source/WebCore/platform/Gamepads.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/deprecated/Gamepads.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/deprecated/Gamepads.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2011, Google 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.
+ */
+
+#ifndef Gamepads_h
+#define Gamepads_h
+
+#if ENABLE(GAMEPAD_DEPRECATED)
+
+namespace WebCore {
+
+class GamepadList;
+
+void sampleGamepads(GamepadList* into);
+
+}
+
+#endif // ENABLE(GAMEPAD_DEPRECATED)
+
+#endif // Gamepads_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadeflGamepadsEflcppfromrev204177trunkSourceWebCoreplatformeflGamepadsEflcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/efl/GamepadsEfl.cpp (from rev 204177, trunk/Source/WebCore/platform/efl/GamepadsEfl.cpp) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/efl/GamepadsEfl.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/efl/GamepadsEfl.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,241 @@
</span><ins>+/*
+ * Copyright (C) 2012 Intel Corporation. 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.
+ */
+
+#include "config.h"
+#include "Gamepads.h"
+
+#if ENABLE(GAMEPAD_DEPRECATED)
+
+#include "GamepadDeviceLinux.h"
+#include "GamepadList.h"
+#include "Logging.h"
+#include <Ecore.h>
+#include <Eeze.h>
+#include <Eina.h>
+#include <unistd.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+static const char joystickPrefix[] = "/dev/input/js";
+
+class GamepadDeviceEfl : public GamepadDeviceLinux {
+public:
+ explicit GamepadDeviceEfl(const String& deviceFile);
+ ~GamepadDeviceEfl();
+ void resetFdHandler() { m_fdHandler = 0; }
+ const String& deviceFile() const { return m_deviceFile; }
+
+private:
+ static Eina_Bool readCallback(void* userData, Ecore_Fd_Handler*);
+
+ Ecore_Fd_Handler* m_fdHandler;
+ String m_deviceFile;
+};
+
+GamepadDeviceEfl::GamepadDeviceEfl(const String& deviceFile)
+ : GamepadDeviceLinux(deviceFile)
+ , m_fdHandler(0)
+ , m_deviceFile(deviceFile)
+{
+ if (m_fileDescriptor < 0)
+ return;
+
+ m_fdHandler = ecore_main_fd_handler_add(m_fileDescriptor, ECORE_FD_READ, readCallback, this, 0, 0);
+ if (!m_fdHandler)
+ LOG_ERROR("Failed to create the Ecore_Fd_Handler.");
+}
+
+GamepadDeviceEfl::~GamepadDeviceEfl()
+{
+ if (m_fdHandler)
+ ecore_main_fd_handler_del(m_fdHandler);
+}
+
+Eina_Bool GamepadDeviceEfl::readCallback(void* userData, Ecore_Fd_Handler* fdHandler)
+{
+ GamepadDeviceEfl* gamepadDevice = static_cast<GamepadDeviceEfl*>(userData);
+
+ if (ecore_main_fd_handler_active_get(fdHandler, ECORE_FD_ERROR)) {
+ LOG_ERROR("An error occurred while watching the joystick file descriptor at %s, aborting.", gamepadDevice->deviceFile().utf8().data());
+ gamepadDevice->resetFdHandler();
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ int fdDevice = ecore_main_fd_handler_fd_get(fdHandler);
+ struct js_event event;
+ const ssize_t len = read(fdDevice, &event, sizeof(event));
+
+ if (len <= 0) {
+ LOG_ERROR("Failed to read joystick file descriptor at %s, aborting.", gamepadDevice->deviceFile().utf8().data());
+ gamepadDevice->resetFdHandler();
+ return ECORE_CALLBACK_CANCEL;
+ }
+ if (len != sizeof(event)) {
+ LOG_ERROR("Wrong js_event size read on file descriptor at %s, ignoring.", gamepadDevice->deviceFile().utf8().data());
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ gamepadDevice->updateForEvent(event);
+ return ECORE_CALLBACK_RENEW;
+}
+
+class GamepadsEfl {
+ friend class NeverDestroyed<GamepadsEfl>;
+public:
+ GamepadsEfl(size_t length);
+
+ void registerDevice(const String& syspath);
+ void unregisterDevice(const String& syspath);
+
+ void updateGamepadList(GamepadList*);
+
+private:
+ ~GamepadsEfl();
+ static void onGamePadChange(const char* syspath, Eeze_Udev_Event, void* userData, Eeze_Udev_Watch* watcher);
+
+ Vector<std::unique_ptr<GamepadDeviceEfl>> m_slots;
+ HashMap<String, GamepadDeviceEfl*> m_deviceMap;
+
+ Eeze_Udev_Watch* m_gamepadsWatcher;
+};
+
+void GamepadsEfl::onGamePadChange(const char* syspath, Eeze_Udev_Event event, void* userData, Eeze_Udev_Watch*)
+{
+ GamepadsEfl* gamepadsEfl = static_cast<GamepadsEfl*>(userData);
+
+ switch (event) {
+ case EEZE_UDEV_EVENT_ADD:
+ gamepadsEfl->registerDevice(String::fromUTF8(syspath));
+ break;
+ case EEZE_UDEV_EVENT_REMOVE:
+ gamepadsEfl->unregisterDevice(String::fromUTF8(syspath));
+ break;
+ default:
+ break;
+ }
+}
+
+GamepadsEfl::GamepadsEfl(size_t length)
+ : m_slots(length)
+ , m_gamepadsWatcher(0)
+{
+ if (eeze_init() < 0) {
+ LOG_ERROR("Failed to initialize eeze library.");
+ return;
+ }
+
+ // Watch for gamepads additions / removals.
+ m_gamepadsWatcher = eeze_udev_watch_add(EEZE_UDEV_TYPE_JOYSTICK, (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE), onGamePadChange, this);
+
+ // List available gamepads.
+ Eina_List* gamepads = eeze_udev_find_by_type(EEZE_UDEV_TYPE_JOYSTICK, 0);
+ void* data;
+ EINA_LIST_FREE(gamepads, data) {
+ char* syspath = static_cast<char*>(data);
+ registerDevice(String::fromUTF8(syspath));
+ eina_stringshare_del(syspath);
+ }
+}
+
+GamepadsEfl::~GamepadsEfl()
+{
+ if (m_gamepadsWatcher)
+ eeze_udev_watch_del(m_gamepadsWatcher);
+ eeze_shutdown();
+}
+
+void GamepadsEfl::registerDevice(const String& syspath)
+{
+ if (m_deviceMap.contains(syspath))
+ return;
+
+ // Make sure it is a valid joystick.
+ const char* deviceFile = eeze_udev_syspath_get_devpath(syspath.utf8().data());
+ if (!deviceFile || !eina_str_has_prefix(deviceFile, joystickPrefix))
+ return;
+
+ LOG(Gamepad, "Registering gamepad at %s", deviceFile);
+
+ const size_t slotCount = m_slots.size();
+ for (size_t index = 0; index < slotCount; ++index) {
+ if (!m_slots[index]) {
+ m_slots[index] = std::make_unique<GamepadDeviceEfl>(String::fromUTF8(deviceFile));
+ LOG(Gamepad, "Gamepad device name is %s", m_slots[index]->id().utf8().data());
+ m_deviceMap.add(syspath, m_slots[index].get());
+ break;
+ }
+ }
+}
+
+void GamepadsEfl::unregisterDevice(const String& syspath)
+{
+ if (!m_deviceMap.contains(syspath))
+ return;
+
+ GamepadDeviceEfl* gamepadDevice = m_deviceMap.take(syspath);
+ LOG(Gamepad, "Unregistering gamepad at %s", gamepadDevice->deviceFile().utf8().data());
+ const size_t index = m_slots.find(std::make_unique<GamepadDeviceEfl>(gamepadDevice->deviceFile()));
+ ASSERT(index != notFound);
+
+ m_slots[index] = nullptr;
+}
+
+void GamepadsEfl::updateGamepadList(GamepadList* into)
+{
+ ASSERT(m_slots.size() == into->length());
+
+ const size_t slotCount = m_slots.size();
+ for (size_t i = 0; i < slotCount; ++i) {
+ if (m_slots[i].get() && m_slots[i]->connected()) {
+ GamepadDeviceEfl* gamepadDevice = m_slots[i].get();
+ RefPtr<Gamepad> gamepad = into->item(i);
+ if (!gamepad)
+ gamepad = Gamepad::create();
+
+ gamepad->index(i);
+ gamepad->id(gamepadDevice->id());
+ gamepad->timestamp(gamepadDevice->timestamp());
+ gamepad->axes(gamepadDevice->axesCount(), gamepadDevice->axesData());
+ gamepad->buttons(gamepadDevice->buttonsCount(), gamepadDevice->buttonsData());
+
+ into->set(i, gamepad);
+ } else
+ into->set(i, 0);
+ }
+}
+
+void sampleGamepads(GamepadList* into)
+{
+ static NeverDestroyed<GamepadsEfl> gamepadsEfl(into->length());
+ gamepadsEfl.get().updateGamepadList(into);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD_DEPRECATED)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadglibGamepadsGlibcppfromrev204177trunkSourceWebCoreplatformglibGamepadsGlibcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/glib/GamepadsGlib.cpp (from rev 204177, trunk/Source/WebCore/platform/glib/GamepadsGlib.cpp) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/glib/GamepadsGlib.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/glib/GamepadsGlib.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,219 @@
</span><ins>+/*
+ * Copyright (C) 2012 Zan Dobersek <zandobersek@gmail.com>
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "Gamepads.h"
+
+#if ENABLE(GAMEPAD_DEPRECATED)
+
+#include "GamepadDeviceLinux.h"
+#include "GamepadList.h"
+#include "Logging.h"
+#include <gio/gunixinputstream.h>
+#include <gudev/gudev.h>
+#include <wtf/HashMap.h>
+#include <wtf/glib/GRefPtr.h>
+#include <wtf/glib/GUniquePtr.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class GamepadDeviceGlib : public GamepadDeviceLinux {
+public:
+ explicit GamepadDeviceGlib(String deviceFile);
+ ~GamepadDeviceGlib();
+
+private:
+ static gboolean readCallback(GObject* pollableStream, gpointer data);
+ GRefPtr<GInputStream> m_inputStream;
+ GRefPtr<GSource> m_source;
+};
+
+GamepadDeviceGlib::GamepadDeviceGlib(String deviceFile)
+ : GamepadDeviceLinux(deviceFile)
+{
+ if (m_fileDescriptor == -1)
+ return;
+
+ m_inputStream = adoptGRef(g_unix_input_stream_new(m_fileDescriptor, FALSE));
+ m_source = adoptGRef(g_pollable_input_stream_create_source(G_POLLABLE_INPUT_STREAM(m_inputStream.get()), 0));
+ g_source_set_callback(m_source.get(), reinterpret_cast<GSourceFunc>(readCallback), this, 0);
+ g_source_attach(m_source.get(), 0);
+}
+
+GamepadDeviceGlib::~GamepadDeviceGlib()
+{
+ if (m_source)
+ g_source_destroy(m_source.get());
+}
+
+gboolean GamepadDeviceGlib::readCallback(GObject* pollableStream, gpointer data)
+{
+ GamepadDeviceGlib* gamepadDevice = reinterpret_cast<GamepadDeviceGlib*>(data);
+ GUniqueOutPtr<GError> error;
+ struct js_event event;
+
+ gssize len = g_pollable_input_stream_read_nonblocking(G_POLLABLE_INPUT_STREAM(pollableStream),
+ &event, sizeof(event), 0, &error.outPtr());
+
+ // FIXME: Properly log the error.
+ // In the case of G_IO_ERROR_WOULD_BLOCK error return TRUE to wait until
+ // the source becomes readable again and FALSE otherwise.
+ if (error)
+ return g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK);
+
+ ASSERT_UNUSED(len, len == sizeof(event));
+ gamepadDevice->updateForEvent(event);
+ return TRUE;
+}
+
+class GamepadsGlib {
+public:
+ explicit GamepadsGlib(unsigned length);
+
+ void registerDevice(String deviceFile);
+ void unregisterDevice(String deviceFile);
+
+ void updateGamepadList(GamepadList*);
+
+private:
+ ~GamepadsGlib();
+ static void onUEventCallback(GUdevClient*, gchar* action, GUdevDevice*, gpointer data);
+ static gboolean isGamepadDevice(GUdevDevice*);
+
+ Vector<std::unique_ptr<GamepadDeviceGlib> > m_slots;
+ HashMap<String, GamepadDeviceGlib*> m_deviceMap;
+
+ GRefPtr<GUdevClient> m_gudevClient;
+};
+
+GamepadsGlib::GamepadsGlib(unsigned length)
+ : m_slots(length)
+{
+ static const char* subsystems[] = { "input", 0 };
+ m_gudevClient = adoptGRef(g_udev_client_new(subsystems));
+ g_signal_connect(m_gudevClient.get(), "uevent", G_CALLBACK(onUEventCallback), this);
+
+ GUniquePtr<GList> devicesList(g_udev_client_query_by_subsystem(m_gudevClient.get(), subsystems[0]));
+ for (GList* listItem = devicesList.get(); listItem; listItem = g_list_next(listItem)) {
+ GUdevDevice* device = G_UDEV_DEVICE(listItem->data);
+ String deviceFile = String::fromUTF8(g_udev_device_get_device_file(device));
+ if (isGamepadDevice(device))
+ registerDevice(deviceFile);
+ g_object_unref(device);
+ }
+}
+
+GamepadsGlib::~GamepadsGlib()
+{
+ g_signal_handlers_disconnect_matched(m_gudevClient.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+}
+
+void GamepadsGlib::registerDevice(String deviceFile)
+{
+ LOG(Gamepad, "GamepadsGlib::registerDevice %s", deviceFile.ascii().data());
+ ASSERT(!m_deviceMap.contains(deviceFile));
+
+ for (unsigned index = 0; index < m_slots.size(); index++) {
+ if (!m_slots[index]) {
+ m_slots[index] = std::make_unique<GamepadDeviceGlib>(deviceFile);
+ m_deviceMap.add(deviceFile, m_slots[index].get());
+ break;
+ }
+ }
+}
+
+void GamepadsGlib::unregisterDevice(String deviceFile)
+{
+ LOG(Gamepad, "GamepadsGlib::unregisterDevice %s", deviceFile.ascii().data());
+ ASSERT(m_deviceMap.contains(deviceFile));
+
+ GamepadDeviceGlib* gamepadDevice = m_deviceMap.take(deviceFile);
+ size_t index = m_slots.find(gamepadDevice);
+ ASSERT(index != notFound);
+
+ m_slots[index] = nullptr;
+}
+
+void GamepadsGlib::updateGamepadList(GamepadList* into)
+{
+ ASSERT(m_slots.size() == into->length());
+
+ for (unsigned i = 0; i < m_slots.size(); i++) {
+ if (m_slots[i].get() && m_slots[i]->connected()) {
+ GamepadDeviceGlib* gamepadDevice = m_slots[i].get();
+ RefPtr<Gamepad> gamepad = into->item(i);
+ if (!gamepad)
+ gamepad = Gamepad::create();
+
+ gamepad->index(i);
+ gamepad->id(gamepadDevice->id());
+ gamepad->timestamp(gamepadDevice->timestamp());
+ gamepad->axes(gamepadDevice->axesCount(), gamepadDevice->axesData());
+ gamepad->buttons(gamepadDevice->buttonsCount(), gamepadDevice->buttonsData());
+
+ into->set(i, gamepad);
+ } else
+ into->set(i, 0);
+ }
+}
+
+void GamepadsGlib::onUEventCallback(GUdevClient*, gchar* action, GUdevDevice* device, gpointer data)
+{
+ if (!isGamepadDevice(device))
+ return;
+
+ GamepadsGlib* gamepadsGlib = reinterpret_cast<GamepadsGlib*>(data);
+ String deviceFile = String::fromUTF8(g_udev_device_get_device_file(device));
+
+ if (!g_strcmp0(action, "add"))
+ gamepadsGlib->registerDevice(deviceFile);
+ else if (!g_strcmp0(action, "remove"))
+ gamepadsGlib->unregisterDevice(deviceFile);
+}
+
+gboolean GamepadsGlib::isGamepadDevice(GUdevDevice* device)
+{
+ const gchar* deviceFile = g_udev_device_get_device_file(device);
+ const gchar* sysfsPath = g_udev_device_get_sysfs_path(device);
+ if (!deviceFile || !sysfsPath)
+ return FALSE;
+
+ if (!g_udev_device_has_property(device, "ID_INPUT") || !g_udev_device_has_property(device, "ID_INPUT_JOYSTICK"))
+ return FALSE;
+
+ return g_str_has_prefix(deviceFile, "/dev/input/js");
+}
+
+void sampleGamepads(GamepadList* into)
+{
+ DEPRECATED_DEFINE_STATIC_LOCAL(GamepadsGlib, gamepadsGlib, (into->length()));
+ gamepadsGlib.updateGamepadList(into);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD_DEPRECATED)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadlinuxGamepadDeviceLinuxcppfromrev204177trunkSourceWebCoreplatformlinuxGamepadDeviceLinuxcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.cpp (from rev 204177, trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.cpp) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,99 @@
</span><ins>+/*
+ * Copyright (C) 2012 Zan Dobersek <zandobersek@gmail.com>
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "GamepadDeviceLinux.h"
+
+#if ENABLE(GAMEPAD_DEPRECATED)
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+GamepadDeviceLinux::GamepadDeviceLinux(String deviceFile)
+ : m_fileDescriptor(-1)
+ , m_connected(false)
+ , m_lastTimestamp(0)
+{
+ // FIXME: Log errors when returning early.
+ m_fileDescriptor = open(deviceFile.utf8().data(), O_RDONLY | O_NONBLOCK);
+ if (m_fileDescriptor == -1)
+ return;
+
+ char deviceName[1024];
+ if (ioctl(m_fileDescriptor, JSIOCGNAME(sizeof(deviceName)), deviceName) < 0)
+ return;
+ m_deviceName = String(deviceName).simplifyWhiteSpace();
+
+ uint8_t numberOfAxes;
+ uint8_t numberOfButtons;
+ if (ioctl(m_fileDescriptor, JSIOCGAXES, &numberOfAxes) < 0 || ioctl(m_fileDescriptor, JSIOCGBUTTONS, &numberOfButtons) < 0)
+ return;
+ m_axes.fill(0.0, numberOfAxes);
+ m_buttons.fill(0.0, numberOfButtons);
+}
+
+GamepadDeviceLinux::~GamepadDeviceLinux()
+{
+ if (m_fileDescriptor != -1)
+ close(m_fileDescriptor);
+}
+
+void GamepadDeviceLinux::updateForEvent(struct js_event event)
+{
+ if (!(event.type & JS_EVENT_AXIS || event.type & JS_EVENT_BUTTON))
+ return;
+
+ // Mark the device as connected only if it is not yet connected, the event is not an initialization
+ // and the value is not 0 (indicating a genuine interaction with the device).
+ if (!m_connected && !(event.type & JS_EVENT_INIT) && event.value)
+ m_connected = true;
+
+ if (event.type & JS_EVENT_AXIS)
+ m_axes[event.number] = normalizeAxisValue(event.value);
+ else if (event.type & JS_EVENT_BUTTON)
+ m_buttons[event.number] = normalizeButtonValue(event.value);
+
+ m_lastTimestamp = event.time;
+}
+
+float GamepadDeviceLinux::normalizeAxisValue(short value)
+{
+ // Normalize from range [-32767, 32767] into range [-1.0, 1.0]
+ return value / 32767.0f;
+}
+
+float GamepadDeviceLinux::normalizeButtonValue(short value)
+{
+ // Normalize from range [0, 1] into range [0.0, 1.0]
+ return value / 1.0f;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD_DEPRECATED)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadlinuxGamepadDeviceLinuxhfromrev204177trunkSourceWebCoreplatformlinuxGamepadDeviceLinuxh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.h (from rev 204177, trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/linux/GamepadDeviceLinux.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+/*
+ * Copyright (C) 2012 Zan Dobersek <zandobersek@gmail.com>
+ *
+ * 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.
+ */
+
+#ifndef GamepadDeviceLinux_h
+#define GamepadDeviceLinux_h
+
+#if ENABLE(GAMEPAD_DEPRECATED)
+
+#include <linux/joystick.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class GamepadDeviceLinux {
+public:
+ bool connected() { return m_connected; };
+
+ String id() { return m_deviceName; }
+ unsigned long long timestamp() { return m_lastTimestamp; }
+
+ unsigned axesCount() { return m_axes.size(); }
+ float* axesData() { return m_axes.data(); }
+
+ unsigned buttonsCount() { return m_buttons.size(); }
+ float* buttonsData() { return m_buttons.data(); }
+
+protected:
+ GamepadDeviceLinux(String deviceFile);
+ ~GamepadDeviceLinux();
+
+ void updateForEvent(struct js_event);
+ int m_fileDescriptor;
+
+private:
+ float normalizeAxisValue(short value);
+ float normalizeButtonValue(short value);
+
+ bool m_connected;
+ String m_deviceName;
+ unsigned long long m_lastTimestamp;
+
+ Vector<float> m_axes;
+ Vector<float> m_buttons;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD_DEPRECATED)
+
+#endif // GamepadDeviceLinux_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadmacHIDGamepadcppfromrev204177trunkSourceWebCoreplatformmacHIDGamepadcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp (from rev 204177, trunk/Source/WebCore/platform/mac/HIDGamepad.cpp) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,190 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+#include "HIDGamepad.h"
+
+#if ENABLE(GAMEPAD)
+
+#include <IOKit/hid/IOHIDElement.h>
+#include <IOKit/hid/IOHIDUsageTables.h>
+#include <IOKit/hid/IOHIDValue.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+HIDGamepad::HIDGamepad(IOHIDDeviceRef hidDevice, unsigned index)
+ : PlatformGamepad(index)
+ , m_hidDevice(hidDevice)
+{
+ m_connectTime = m_lastUpdateTime = monotonicallyIncreasingTime();
+
+ CFNumberRef cfVendorID = (CFNumberRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey));
+ CFNumberRef cfProductID = (CFNumberRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey));
+
+ int vendorID, productID;
+ CFNumberGetValue(cfVendorID, kCFNumberIntType, &vendorID);
+ CFNumberGetValue(cfProductID, kCFNumberIntType, &productID);
+
+ CFStringRef cfProductName = (CFStringRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductKey));
+ String productName(cfProductName);
+
+ // Currently the spec has no formatting for the id string.
+ // This string formatting matches Firefox.
+ m_id = String::format("%x-%x-%s", vendorID, productID, productName.utf8().data());
+
+ initElements();
+}
+
+void HIDGamepad::getCurrentValueForElement(const HIDGamepadElement& gamepadElement)
+{
+ IOHIDElementRef element = gamepadElement.iohidElement.get();
+ IOHIDValueRef value;
+ if (IOHIDDeviceGetValue(IOHIDElementGetDevice(element), element, &value) == kIOReturnSuccess)
+ valueChanged(value);
+}
+
+void HIDGamepad::initElements()
+{
+ RetainPtr<CFArrayRef> elements = adoptCF(IOHIDDeviceCopyMatchingElements(m_hidDevice.get(), NULL, kIOHIDOptionsTypeNone));
+ initElementsFromArray(elements.get());
+
+ // Buttons are specified to appear highest priority first in the array.
+ std::sort(m_buttons.begin(), m_buttons.end(), [](auto& a, auto& b) {
+ return a->priority < b->priority;
+ });
+
+ m_axisValues.resize(m_axes.size());
+ m_buttonValues.resize(m_buttons.size());
+
+ for (auto& button : m_buttons)
+ getCurrentValueForElement(*button);
+
+ for (auto& axis : m_axes)
+ getCurrentValueForElement(*axis);
+}
+
+void HIDGamepad::initElementsFromArray(CFArrayRef elements)
+{
+ for (CFIndex i = 0, count = CFArrayGetCount(elements); i < count; ++i) {
+ IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
+ if (CFGetTypeID(element) != IOHIDElementGetTypeID())
+ continue;
+
+ // As a physical element can appear in the device twice (in different collections) and can be
+ // represented by different IOHIDElementRef objects, we look at the IOHIDElementCookie which
+ // is meant to be unique for each physical element.
+ IOHIDElementCookie cookie = IOHIDElementGetCookie(element);
+ if (m_elementMap.contains(cookie))
+ continue;
+
+ IOHIDElementType type = IOHIDElementGetType(element);
+
+ if ((type == kIOHIDElementTypeInput_Misc || type == kIOHIDElementTypeInput_Button) && maybeAddButton(element))
+ continue;
+
+ if ((type == kIOHIDElementTypeInput_Misc || type == kIOHIDElementTypeInput_Axis) && maybeAddAxis(element))
+ continue;
+
+ if (type == kIOHIDElementTypeCollection)
+ initElementsFromArray(IOHIDElementGetChildren(element));
+ }
+}
+
+bool HIDGamepad::maybeAddButton(IOHIDElementRef element)
+{
+ uint32_t usagePage = IOHIDElementGetUsagePage(element);
+ if (usagePage != kHIDPage_Button)
+ return false;
+
+ uint32_t usage = IOHIDElementGetUsage(element);
+ if (!usage)
+ return false;
+
+ CFIndex min = IOHIDElementGetLogicalMin(element);
+ CFIndex max = IOHIDElementGetLogicalMax(element);
+
+ m_buttons.append(std::make_unique<HIDGamepadButton>(usage, min, max, element));
+
+ IOHIDElementCookie cookie = IOHIDElementGetCookie(element);
+ m_elementMap.set(cookie, m_buttons.last().get());
+
+ return true;
+}
+
+bool HIDGamepad::maybeAddAxis(IOHIDElementRef element)
+{
+ uint32_t usagePage = IOHIDElementGetUsagePage(element);
+ if (usagePage != kHIDPage_GenericDesktop)
+ return false;
+
+ uint32_t usage = IOHIDElementGetUsage(element);
+ // This range covers the standard axis usages.
+ if (usage < kHIDUsage_GD_X || usage > kHIDUsage_GD_Rz)
+ return false;
+
+ CFIndex min = IOHIDElementGetPhysicalMin(element);
+ CFIndex max = IOHIDElementGetPhysicalMax(element);
+
+ m_axes.append(std::make_unique<HIDGamepadAxis>(min, max, element));
+
+ IOHIDElementCookie cookie = IOHIDElementGetCookie(element);
+ m_elementMap.set(cookie, m_axes.last().get());
+
+ return true;
+}
+
+void HIDGamepad::valueChanged(IOHIDValueRef value)
+{
+ IOHIDElementCookie cookie = IOHIDElementGetCookie(IOHIDValueGetElement(value));
+ HIDGamepadElement* element = m_elementMap.get(cookie);
+
+ // This might be an element we don't currently handle as input so we can skip it.
+ if (!element)
+ return;
+
+ element->rawValue = IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical);
+
+ if (element->isButton()) {
+ for (unsigned i = 0; i < m_buttons.size(); ++i) {
+ if (m_buttons[i].get() == element)
+ m_buttonValues[i] = element->normalizedValue();
+ }
+ } else if (element->isAxis()) {
+ for (unsigned i = 0; i < m_axes.size(); ++i) {
+ if (m_axes[i].get() == element)
+ m_axisValues[i] = element->normalizedValue();
+ }
+ } else
+ ASSERT_NOT_REACHED();
+
+ m_lastUpdateTime = monotonicallyIncreasingTime();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadmacHIDGamepadhfromrev204177trunkSourceWebCoreplatformmacHIDGamepadh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.h (from rev 204177, trunk/Source/WebCore/platform/mac/HIDGamepad.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepad.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,126 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include "PlatformGamepad.h"
+#include <IOKit/hid/IOHIDDevice.h>
+#include <wtf/HashMap.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+struct HIDGamepadElement {
+ HIDGamepadElement(double theMin, double theMax, IOHIDElementRef element)
+ : min(theMin)
+ , max(theMax)
+ , rawValue(theMin)
+ , iohidElement(element)
+ {
+ }
+
+ virtual ~HIDGamepadElement()
+ {
+ }
+
+ double min;
+ double max;
+ double rawValue;
+ RetainPtr<IOHIDElementRef> iohidElement;
+
+ virtual bool isButton() const { return false; }
+ virtual bool isAxis() const { return false; }
+
+ virtual double normalizedValue() = 0;
+};
+
+struct HIDGamepadButton : HIDGamepadElement {
+ HIDGamepadButton(uint32_t thePriority, double min, double max, IOHIDElementRef element)
+ : HIDGamepadElement(min, max, element)
+ , priority(thePriority)
+ {
+ }
+
+ uint32_t priority;
+
+ bool isButton() const override { return true; }
+
+ // Buttons normalize to the range (0.0) - (1.0)
+ double normalizedValue() override
+ {
+ return (rawValue - min) / (max - min);
+ }
+};
+
+struct HIDGamepadAxis : HIDGamepadElement {
+ HIDGamepadAxis(double min, double max, IOHIDElementRef element)
+ : HIDGamepadElement(min, max, element)
+ {
+ }
+
+ bool isAxis() const override { return true; }
+
+ // Axes normalize to the range (-1.0) - (1.0)
+ double normalizedValue() override
+ {
+ return (((rawValue - min) / (max - min)) * 2) - 1;
+ }
+};
+
+class HIDGamepad : public PlatformGamepad {
+public:
+ HIDGamepad(IOHIDDeviceRef, unsigned index);
+
+ IOHIDDeviceRef hidDevice() const { return m_hidDevice.get(); }
+
+ void valueChanged(IOHIDValueRef);
+
+ const Vector<double>& axisValues() const final { return m_axisValues; }
+ const Vector<double>& buttonValues() const final { return m_buttonValues; }
+
+private:
+ void initElements();
+ void initElementsFromArray(CFArrayRef);
+
+ bool maybeAddButton(IOHIDElementRef);
+ bool maybeAddAxis(IOHIDElementRef);
+
+ void getCurrentValueForElement(const HIDGamepadElement&);
+
+ RetainPtr<IOHIDDeviceRef> m_hidDevice;
+
+ HashMap<IOHIDElementCookie, HIDGamepadElement*> m_elementMap;
+
+ Vector<std::unique_ptr<HIDGamepadButton>> m_buttons;
+ Vector<std::unique_ptr<HIDGamepadAxis>> m_axes;
+ Vector<double> m_buttonValues;
+ Vector<double> m_axisValues;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadmacHIDGamepadProvidercppfromrev204177trunkSourceWebCoreplatformmacHIDGamepadProvidercpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp (from rev 204177, trunk/Source/WebCore/platform/mac/HIDGamepadProvider.cpp) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,254 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+#include "HIDGamepadProvider.h"
+
+#if ENABLE(GAMEPAD)
+
+#include "GamepadProviderClient.h"
+#include "Logging.h"
+#include "PlatformGamepad.h"
+
+namespace WebCore {
+
+static const double ConnectionDelayInterval = 0.5;
+static const double InputNotificationDelay = 0.05;
+
+static RetainPtr<CFDictionaryRef> deviceMatchingDictionary(uint32_t usagePage, uint32_t usage)
+{
+ ASSERT(usagePage);
+ ASSERT(usage);
+
+ RetainPtr<CFNumberRef> pageNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usagePage));
+ RetainPtr<CFNumberRef> usageNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage));
+
+ CFStringRef keys[] = { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) };
+ CFNumberRef values[] = { pageNumber.get(), usageNumber.get() };
+
+ return adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+}
+
+static void deviceAddedCallback(void* context, IOReturn, void*, IOHIDDeviceRef device)
+{
+ HIDGamepadProvider* listener = static_cast<HIDGamepadProvider*>(context);
+ listener->deviceAdded(device);
+}
+
+static void deviceRemovedCallback(void* context, IOReturn, void*, IOHIDDeviceRef device)
+{
+ HIDGamepadProvider* listener = static_cast<HIDGamepadProvider*>(context);
+ listener->deviceRemoved(device);
+}
+
+static void deviceValuesChangedCallback(void* context, IOReturn result, void*, IOHIDValueRef value)
+{
+ // A non-zero result value indicates an error that we can do nothing about for input values.
+ if (result)
+ return;
+
+ HIDGamepadProvider* listener = static_cast<HIDGamepadProvider*>(context);
+ listener->valuesChanged(value);
+}
+
+HIDGamepadProvider& HIDGamepadProvider::singleton()
+{
+ static NeverDestroyed<HIDGamepadProvider> sharedListener;
+ return sharedListener;
+}
+
+HIDGamepadProvider::HIDGamepadProvider()
+ : m_shouldDispatchCallbacks(false)
+ , m_connectionDelayTimer(*this, &HIDGamepadProvider::connectionDelayTimerFired)
+ , m_inputNotificationTimer(*this, &HIDGamepadProvider::inputNotificationTimerFired)
+{
+ m_manager = adoptCF(IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone));
+
+ RetainPtr<CFDictionaryRef> joystickDictionary = deviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
+ RetainPtr<CFDictionaryRef> gamepadDictionary = deviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
+
+ CFDictionaryRef devices[] = { joystickDictionary.get(), gamepadDictionary.get() };
+
+ RetainPtr<CFArrayRef> matchingArray = adoptCF(CFArrayCreate(kCFAllocatorDefault, (const void**)devices, 2, &kCFTypeArrayCallBacks));
+
+ IOHIDManagerSetDeviceMatchingMultiple(m_manager.get(), matchingArray.get());
+ IOHIDManagerRegisterDeviceMatchingCallback(m_manager.get(), deviceAddedCallback, this);
+ IOHIDManagerRegisterDeviceRemovalCallback(m_manager.get(), deviceRemovedCallback, this);
+ IOHIDManagerRegisterInputValueCallback(m_manager.get(), deviceValuesChangedCallback, this);
+}
+
+unsigned HIDGamepadProvider::indexForNewlyConnectedDevice()
+{
+ unsigned index = 0;
+ while (index < m_gamepadVector.size() && m_gamepadVector[index])
+ ++index;
+
+ return index;
+}
+
+void HIDGamepadProvider::connectionDelayTimerFired()
+{
+ m_shouldDispatchCallbacks = true;
+}
+
+void HIDGamepadProvider::openAndScheduleManager()
+{
+ LOG(Gamepad, "HIDGamepadProvider opening/scheduling HID manager");
+
+ ASSERT(m_gamepadVector.isEmpty());
+ ASSERT(m_gamepadMap.isEmpty());
+
+ m_shouldDispatchCallbacks = false;
+
+ IOHIDManagerScheduleWithRunLoop(m_manager.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
+ IOHIDManagerOpen(m_manager.get(), kIOHIDOptionsTypeNone);
+
+ // Any connections we are notified of within the ConnectionDelayInterval of listening likely represent
+ // devices that were already connected, so we suppress notifying clients of these.
+ m_connectionDelayTimer.startOneShot(ConnectionDelayInterval);
+}
+
+void HIDGamepadProvider::closeAndUnscheduleManager()
+{
+ LOG(Gamepad, "HIDGamepadProvider closing/unscheduling HID manager");
+
+ IOHIDManagerUnscheduleFromRunLoop(m_manager.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
+ IOHIDManagerClose(m_manager.get(), kIOHIDOptionsTypeNone);
+
+ m_gamepadVector.clear();
+ m_gamepadMap.clear();
+
+ m_connectionDelayTimer.stop();
+}
+
+void HIDGamepadProvider::startMonitoringGamepads(GamepadProviderClient* client)
+{
+ bool shouldOpenAndScheduleManager = m_clients.isEmpty();
+
+ ASSERT(!m_clients.contains(client));
+ m_clients.add(client);
+
+ if (shouldOpenAndScheduleManager)
+ openAndScheduleManager();
+}
+void HIDGamepadProvider::stopMonitoringGamepads(GamepadProviderClient* client)
+{
+ ASSERT(m_clients.contains(client));
+
+ bool shouldCloseAndUnscheduleManager = m_clients.remove(client) && m_clients.isEmpty();
+
+ if (shouldCloseAndUnscheduleManager)
+ closeAndUnscheduleManager();
+}
+
+void HIDGamepadProvider::deviceAdded(IOHIDDeviceRef device)
+{
+ ASSERT(!m_gamepadMap.get(device));
+
+ LOG(Gamepad, "HIDGamepadProvider device %p added", device);
+
+ unsigned index = indexForNewlyConnectedDevice();
+ std::unique_ptr<HIDGamepad> gamepad = std::make_unique<HIDGamepad>(device, index);
+
+ if (m_gamepadVector.size() <= index)
+ m_gamepadVector.resize(index + 1);
+
+ m_gamepadVector[index] = gamepad.get();
+ m_gamepadMap.set(device, WTFMove(gamepad));
+
+ if (!m_shouldDispatchCallbacks) {
+ // This added device is the result of us starting to monitor gamepads.
+ // We'll get notified of all connected devices during this current spin of the runloop
+ // and we don't want to tell the client about any of them.
+ // The m_connectionDelayTimer fires in a subsequent spin of the runloop after which
+ // any connection events are actual new devices.
+ m_connectionDelayTimer.startOneShot(0);
+
+ LOG(Gamepad, "Device %p was added while suppressing callbacks, so this should be an 'already connected' event", device);
+
+ return;
+ }
+
+ for (auto& client : m_clients)
+ client->platformGamepadConnected(*m_gamepadVector[index]);
+}
+
+void HIDGamepadProvider::deviceRemoved(IOHIDDeviceRef device)
+{
+ LOG(Gamepad, "HIDGamepadProvider device %p removed", device);
+
+ std::unique_ptr<HIDGamepad> removedGamepad = removeGamepadForDevice(device);
+ ASSERT(removedGamepad);
+
+ // Any time we get a device removed callback we know it's a real event and not an 'already connected' event.
+ // We should always stop suppressing callbacks when we receive such an event.
+ m_shouldDispatchCallbacks = true;
+
+ for (auto& client : m_clients)
+ client->platformGamepadDisconnected(*removedGamepad);
+}
+
+void HIDGamepadProvider::valuesChanged(IOHIDValueRef value)
+{
+ IOHIDDeviceRef device = IOHIDElementGetDevice(IOHIDValueGetElement(value));
+
+ HIDGamepad* gamepad = m_gamepadMap.get(device);
+
+ // When starting monitoring we might get a value changed callback before we even know the device is connected.
+ if (!gamepad)
+ return;
+
+ gamepad->valueChanged(value);
+
+ // This isActive check is necessary as we want to delay input notifications from the time of the first input,
+ // and not push the notification out on every subsequent input.
+ if (!m_inputNotificationTimer.isActive())
+ m_inputNotificationTimer.startOneShot(InputNotificationDelay);
+}
+
+void HIDGamepadProvider::inputNotificationTimerFired()
+{
+ if (!m_shouldDispatchCallbacks)
+ return;
+
+ for (auto& client : m_clients)
+ client->platformGamepadInputActivity();
+}
+
+std::unique_ptr<HIDGamepad> HIDGamepadProvider::removeGamepadForDevice(IOHIDDeviceRef device)
+{
+ std::unique_ptr<HIDGamepad> result = m_gamepadMap.take(device);
+ ASSERT(result);
+
+ auto i = m_gamepadVector.find(result.get());
+ if (i != notFound)
+ m_gamepadVector[i] = nullptr;
+
+ return result;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgamepadmacHIDGamepadProviderhfromrev204177trunkSourceWebCoreplatformmacHIDGamepadProviderh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h (from rev 204177, trunk/Source/WebCore/platform/mac/HIDGamepadProvider.h) (0 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h         (rev 0)
+++ trunk/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include "GamepadProvider.h"
+#include "HIDGamepad.h"
+#include "Timer.h"
+#include <IOKit/hid/IOHIDManager.h>
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class GamepadProviderClient;
+
+class HIDGamepadProvider : public GamepadProvider {
+ WTF_MAKE_NONCOPYABLE(HIDGamepadProvider);
+ friend class NeverDestroyed<HIDGamepadProvider>;
+public:
+ WEBCORE_EXPORT static HIDGamepadProvider& singleton();
+
+ virtual void startMonitoringGamepads(GamepadProviderClient*);
+ virtual void stopMonitoringGamepads(GamepadProviderClient*);
+ virtual const Vector<PlatformGamepad*>& platformGamepads() { return m_gamepadVector; }
+
+ void deviceAdded(IOHIDDeviceRef);
+ void deviceRemoved(IOHIDDeviceRef);
+ void valuesChanged(IOHIDValueRef);
+
+private:
+ HIDGamepadProvider();
+
+ std::unique_ptr<HIDGamepad> removeGamepadForDevice(IOHIDDeviceRef);
+
+ void openAndScheduleManager();
+ void closeAndUnscheduleManager();
+
+ void connectionDelayTimerFired();
+ void inputNotificationTimerFired();
+
+ unsigned indexForNewlyConnectedDevice();
+
+ Vector<PlatformGamepad*> m_gamepadVector;
+ HashMap<IOHIDDeviceRef, std::unique_ptr<HIDGamepad>> m_gamepadMap;
+
+ RetainPtr<IOHIDManagerRef> m_manager;
+
+ HashSet<GamepadProviderClient*> m_clients;
+ bool m_shouldDispatchCallbacks;
+
+ Timer m_connectionDelayTimer;
+ Timer m_inputNotificationTimer;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GAMEPAD)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformglibGamepadsGlibcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/glib/GamepadsGlib.cpp (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/glib/GamepadsGlib.cpp        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/glib/GamepadsGlib.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,219 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Zan Dobersek <zandobersek@gmail.com>
- *
- * 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.
- */
-
-#include "config.h"
-#include "Gamepads.h"
-
-#if ENABLE(GAMEPAD_DEPRECATED)
-
-#include "GamepadDeviceLinux.h"
-#include "GamepadList.h"
-#include "Logging.h"
-#include <gio/gunixinputstream.h>
-#include <gudev/gudev.h>
-#include <wtf/HashMap.h>
-#include <wtf/glib/GRefPtr.h>
-#include <wtf/glib/GUniquePtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-
-namespace WebCore {
-
-class GamepadDeviceGlib : public GamepadDeviceLinux {
-public:
- explicit GamepadDeviceGlib(String deviceFile);
- ~GamepadDeviceGlib();
-
-private:
- static gboolean readCallback(GObject* pollableStream, gpointer data);
- GRefPtr<GInputStream> m_inputStream;
- GRefPtr<GSource> m_source;
-};
-
-GamepadDeviceGlib::GamepadDeviceGlib(String deviceFile)
- : GamepadDeviceLinux(deviceFile)
-{
- if (m_fileDescriptor == -1)
- return;
-
- m_inputStream = adoptGRef(g_unix_input_stream_new(m_fileDescriptor, FALSE));
- m_source = adoptGRef(g_pollable_input_stream_create_source(G_POLLABLE_INPUT_STREAM(m_inputStream.get()), 0));
- g_source_set_callback(m_source.get(), reinterpret_cast<GSourceFunc>(readCallback), this, 0);
- g_source_attach(m_source.get(), 0);
-}
-
-GamepadDeviceGlib::~GamepadDeviceGlib()
-{
- if (m_source)
- g_source_destroy(m_source.get());
-}
-
-gboolean GamepadDeviceGlib::readCallback(GObject* pollableStream, gpointer data)
-{
- GamepadDeviceGlib* gamepadDevice = reinterpret_cast<GamepadDeviceGlib*>(data);
- GUniqueOutPtr<GError> error;
- struct js_event event;
-
- gssize len = g_pollable_input_stream_read_nonblocking(G_POLLABLE_INPUT_STREAM(pollableStream),
- &event, sizeof(event), 0, &error.outPtr());
-
- // FIXME: Properly log the error.
- // In the case of G_IO_ERROR_WOULD_BLOCK error return TRUE to wait until
- // the source becomes readable again and FALSE otherwise.
- if (error)
- return g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK);
-
- ASSERT_UNUSED(len, len == sizeof(event));
- gamepadDevice->updateForEvent(event);
- return TRUE;
-}
-
-class GamepadsGlib {
-public:
- explicit GamepadsGlib(unsigned length);
-
- void registerDevice(String deviceFile);
- void unregisterDevice(String deviceFile);
-
- void updateGamepadList(GamepadList*);
-
-private:
- ~GamepadsGlib();
- static void onUEventCallback(GUdevClient*, gchar* action, GUdevDevice*, gpointer data);
- static gboolean isGamepadDevice(GUdevDevice*);
-
- Vector<std::unique_ptr<GamepadDeviceGlib> > m_slots;
- HashMap<String, GamepadDeviceGlib*> m_deviceMap;
-
- GRefPtr<GUdevClient> m_gudevClient;
-};
-
-GamepadsGlib::GamepadsGlib(unsigned length)
- : m_slots(length)
-{
- static const char* subsystems[] = { "input", 0 };
- m_gudevClient = adoptGRef(g_udev_client_new(subsystems));
- g_signal_connect(m_gudevClient.get(), "uevent", G_CALLBACK(onUEventCallback), this);
-
- GUniquePtr<GList> devicesList(g_udev_client_query_by_subsystem(m_gudevClient.get(), subsystems[0]));
- for (GList* listItem = devicesList.get(); listItem; listItem = g_list_next(listItem)) {
- GUdevDevice* device = G_UDEV_DEVICE(listItem->data);
- String deviceFile = String::fromUTF8(g_udev_device_get_device_file(device));
- if (isGamepadDevice(device))
- registerDevice(deviceFile);
- g_object_unref(device);
- }
-}
-
-GamepadsGlib::~GamepadsGlib()
-{
- g_signal_handlers_disconnect_matched(m_gudevClient.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
-}
-
-void GamepadsGlib::registerDevice(String deviceFile)
-{
- LOG(Gamepad, "GamepadsGlib::registerDevice %s", deviceFile.ascii().data());
- ASSERT(!m_deviceMap.contains(deviceFile));
-
- for (unsigned index = 0; index < m_slots.size(); index++) {
- if (!m_slots[index]) {
- m_slots[index] = std::make_unique<GamepadDeviceGlib>(deviceFile);
- m_deviceMap.add(deviceFile, m_slots[index].get());
- break;
- }
- }
-}
-
-void GamepadsGlib::unregisterDevice(String deviceFile)
-{
- LOG(Gamepad, "GamepadsGlib::unregisterDevice %s", deviceFile.ascii().data());
- ASSERT(m_deviceMap.contains(deviceFile));
-
- GamepadDeviceGlib* gamepadDevice = m_deviceMap.take(deviceFile);
- size_t index = m_slots.find(gamepadDevice);
- ASSERT(index != notFound);
-
- m_slots[index] = nullptr;
-}
-
-void GamepadsGlib::updateGamepadList(GamepadList* into)
-{
- ASSERT(m_slots.size() == into->length());
-
- for (unsigned i = 0; i < m_slots.size(); i++) {
- if (m_slots[i].get() && m_slots[i]->connected()) {
- GamepadDeviceGlib* gamepadDevice = m_slots[i].get();
- RefPtr<Gamepad> gamepad = into->item(i);
- if (!gamepad)
- gamepad = Gamepad::create();
-
- gamepad->index(i);
- gamepad->id(gamepadDevice->id());
- gamepad->timestamp(gamepadDevice->timestamp());
- gamepad->axes(gamepadDevice->axesCount(), gamepadDevice->axesData());
- gamepad->buttons(gamepadDevice->buttonsCount(), gamepadDevice->buttonsData());
-
- into->set(i, gamepad);
- } else
- into->set(i, 0);
- }
-}
-
-void GamepadsGlib::onUEventCallback(GUdevClient*, gchar* action, GUdevDevice* device, gpointer data)
-{
- if (!isGamepadDevice(device))
- return;
-
- GamepadsGlib* gamepadsGlib = reinterpret_cast<GamepadsGlib*>(data);
- String deviceFile = String::fromUTF8(g_udev_device_get_device_file(device));
-
- if (!g_strcmp0(action, "add"))
- gamepadsGlib->registerDevice(deviceFile);
- else if (!g_strcmp0(action, "remove"))
- gamepadsGlib->unregisterDevice(deviceFile);
-}
-
-gboolean GamepadsGlib::isGamepadDevice(GUdevDevice* device)
-{
- const gchar* deviceFile = g_udev_device_get_device_file(device);
- const gchar* sysfsPath = g_udev_device_get_sysfs_path(device);
- if (!deviceFile || !sysfsPath)
- return FALSE;
-
- if (!g_udev_device_has_property(device, "ID_INPUT") || !g_udev_device_has_property(device, "ID_INPUT_JOYSTICK"))
- return FALSE;
-
- return g_str_has_prefix(deviceFile, "/dev/input/js");
-}
-
-void sampleGamepads(GamepadList* into)
-{
- DEPRECATED_DEFINE_STATIC_LOCAL(GamepadsGlib, gamepadsGlib, (into->length()));
- gamepadsGlib.updateGamepadList(into);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD_DEPRECATED)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformlinuxGamepadDeviceLinuxcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.cpp (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.cpp        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,99 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Zan Dobersek <zandobersek@gmail.com>
- *
- * 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.
- */
-
-#include "config.h"
-#include "GamepadDeviceLinux.h"
-
-#if ENABLE(GAMEPAD_DEPRECATED)
-
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-GamepadDeviceLinux::GamepadDeviceLinux(String deviceFile)
- : m_fileDescriptor(-1)
- , m_connected(false)
- , m_lastTimestamp(0)
-{
- // FIXME: Log errors when returning early.
- m_fileDescriptor = open(deviceFile.utf8().data(), O_RDONLY | O_NONBLOCK);
- if (m_fileDescriptor == -1)
- return;
-
- char deviceName[1024];
- if (ioctl(m_fileDescriptor, JSIOCGNAME(sizeof(deviceName)), deviceName) < 0)
- return;
- m_deviceName = String(deviceName).simplifyWhiteSpace();
-
- uint8_t numberOfAxes;
- uint8_t numberOfButtons;
- if (ioctl(m_fileDescriptor, JSIOCGAXES, &numberOfAxes) < 0 || ioctl(m_fileDescriptor, JSIOCGBUTTONS, &numberOfButtons) < 0)
- return;
- m_axes.fill(0.0, numberOfAxes);
- m_buttons.fill(0.0, numberOfButtons);
-}
-
-GamepadDeviceLinux::~GamepadDeviceLinux()
-{
- if (m_fileDescriptor != -1)
- close(m_fileDescriptor);
-}
-
-void GamepadDeviceLinux::updateForEvent(struct js_event event)
-{
- if (!(event.type & JS_EVENT_AXIS || event.type & JS_EVENT_BUTTON))
- return;
-
- // Mark the device as connected only if it is not yet connected, the event is not an initialization
- // and the value is not 0 (indicating a genuine interaction with the device).
- if (!m_connected && !(event.type & JS_EVENT_INIT) && event.value)
- m_connected = true;
-
- if (event.type & JS_EVENT_AXIS)
- m_axes[event.number] = normalizeAxisValue(event.value);
- else if (event.type & JS_EVENT_BUTTON)
- m_buttons[event.number] = normalizeButtonValue(event.value);
-
- m_lastTimestamp = event.time;
-}
-
-float GamepadDeviceLinux::normalizeAxisValue(short value)
-{
- // Normalize from range [-32767, 32767] into range [-1.0, 1.0]
- return value / 32767.0f;
-}
-
-float GamepadDeviceLinux::normalizeButtonValue(short value)
-{
- // Normalize from range [0, 1] into range [0.0, 1.0]
- return value / 1.0f;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD_DEPRECATED)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformlinuxGamepadDeviceLinuxh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/linux/GamepadDeviceLinux.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,73 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012 Zan Dobersek <zandobersek@gmail.com>
- *
- * 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.
- */
-
-#ifndef GamepadDeviceLinux_h
-#define GamepadDeviceLinux_h
-
-#if ENABLE(GAMEPAD_DEPRECATED)
-
-#include <linux/joystick.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class GamepadDeviceLinux {
-public:
- bool connected() { return m_connected; };
-
- String id() { return m_deviceName; }
- unsigned long long timestamp() { return m_lastTimestamp; }
-
- unsigned axesCount() { return m_axes.size(); }
- float* axesData() { return m_axes.data(); }
-
- unsigned buttonsCount() { return m_buttons.size(); }
- float* buttonsData() { return m_buttons.data(); }
-
-protected:
- GamepadDeviceLinux(String deviceFile);
- ~GamepadDeviceLinux();
-
- void updateForEvent(struct js_event);
- int m_fileDescriptor;
-
-private:
- float normalizeAxisValue(short value);
- float normalizeButtonValue(short value);
-
- bool m_connected;
- String m_deviceName;
- unsigned long long m_lastTimestamp;
-
- Vector<float> m_axes;
- Vector<float> m_buttons;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD_DEPRECATED)
-
-#endif // GamepadDeviceLinux_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacHIDGamepadcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/HIDGamepad.cpp (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/HIDGamepad.cpp        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/mac/HIDGamepad.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,190 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#include "config.h"
-#include "HIDGamepad.h"
-
-#if ENABLE(GAMEPAD)
-
-#include <IOKit/hid/IOHIDElement.h>
-#include <IOKit/hid/IOHIDUsageTables.h>
-#include <IOKit/hid/IOHIDValue.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-HIDGamepad::HIDGamepad(IOHIDDeviceRef hidDevice, unsigned index)
- : PlatformGamepad(index)
- , m_hidDevice(hidDevice)
-{
- m_connectTime = m_lastUpdateTime = monotonicallyIncreasingTime();
-
- CFNumberRef cfVendorID = (CFNumberRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey));
- CFNumberRef cfProductID = (CFNumberRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey));
-
- int vendorID, productID;
- CFNumberGetValue(cfVendorID, kCFNumberIntType, &vendorID);
- CFNumberGetValue(cfProductID, kCFNumberIntType, &productID);
-
- CFStringRef cfProductName = (CFStringRef)IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductKey));
- String productName(cfProductName);
-
- // Currently the spec has no formatting for the id string.
- // This string formatting matches Firefox.
- m_id = String::format("%x-%x-%s", vendorID, productID, productName.utf8().data());
-
- initElements();
-}
-
-void HIDGamepad::getCurrentValueForElement(const HIDGamepadElement& gamepadElement)
-{
- IOHIDElementRef element = gamepadElement.iohidElement.get();
- IOHIDValueRef value;
- if (IOHIDDeviceGetValue(IOHIDElementGetDevice(element), element, &value) == kIOReturnSuccess)
- valueChanged(value);
-}
-
-void HIDGamepad::initElements()
-{
- RetainPtr<CFArrayRef> elements = adoptCF(IOHIDDeviceCopyMatchingElements(m_hidDevice.get(), NULL, kIOHIDOptionsTypeNone));
- initElementsFromArray(elements.get());
-
- // Buttons are specified to appear highest priority first in the array.
- std::sort(m_buttons.begin(), m_buttons.end(), [](auto& a, auto& b) {
- return a->priority < b->priority;
- });
-
- m_axisValues.resize(m_axes.size());
- m_buttonValues.resize(m_buttons.size());
-
- for (auto& button : m_buttons)
- getCurrentValueForElement(*button);
-
- for (auto& axis : m_axes)
- getCurrentValueForElement(*axis);
-}
-
-void HIDGamepad::initElementsFromArray(CFArrayRef elements)
-{
- for (CFIndex i = 0, count = CFArrayGetCount(elements); i < count; ++i) {
- IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
- if (CFGetTypeID(element) != IOHIDElementGetTypeID())
- continue;
-
- // As a physical element can appear in the device twice (in different collections) and can be
- // represented by different IOHIDElementRef objects, we look at the IOHIDElementCookie which
- // is meant to be unique for each physical element.
- IOHIDElementCookie cookie = IOHIDElementGetCookie(element);
- if (m_elementMap.contains(cookie))
- continue;
-
- IOHIDElementType type = IOHIDElementGetType(element);
-
- if ((type == kIOHIDElementTypeInput_Misc || type == kIOHIDElementTypeInput_Button) && maybeAddButton(element))
- continue;
-
- if ((type == kIOHIDElementTypeInput_Misc || type == kIOHIDElementTypeInput_Axis) && maybeAddAxis(element))
- continue;
-
- if (type == kIOHIDElementTypeCollection)
- initElementsFromArray(IOHIDElementGetChildren(element));
- }
-}
-
-bool HIDGamepad::maybeAddButton(IOHIDElementRef element)
-{
- uint32_t usagePage = IOHIDElementGetUsagePage(element);
- if (usagePage != kHIDPage_Button)
- return false;
-
- uint32_t usage = IOHIDElementGetUsage(element);
- if (!usage)
- return false;
-
- CFIndex min = IOHIDElementGetLogicalMin(element);
- CFIndex max = IOHIDElementGetLogicalMax(element);
-
- m_buttons.append(std::make_unique<HIDGamepadButton>(usage, min, max, element));
-
- IOHIDElementCookie cookie = IOHIDElementGetCookie(element);
- m_elementMap.set(cookie, m_buttons.last().get());
-
- return true;
-}
-
-bool HIDGamepad::maybeAddAxis(IOHIDElementRef element)
-{
- uint32_t usagePage = IOHIDElementGetUsagePage(element);
- if (usagePage != kHIDPage_GenericDesktop)
- return false;
-
- uint32_t usage = IOHIDElementGetUsage(element);
- // This range covers the standard axis usages.
- if (usage < kHIDUsage_GD_X || usage > kHIDUsage_GD_Rz)
- return false;
-
- CFIndex min = IOHIDElementGetPhysicalMin(element);
- CFIndex max = IOHIDElementGetPhysicalMax(element);
-
- m_axes.append(std::make_unique<HIDGamepadAxis>(min, max, element));
-
- IOHIDElementCookie cookie = IOHIDElementGetCookie(element);
- m_elementMap.set(cookie, m_axes.last().get());
-
- return true;
-}
-
-void HIDGamepad::valueChanged(IOHIDValueRef value)
-{
- IOHIDElementCookie cookie = IOHIDElementGetCookie(IOHIDValueGetElement(value));
- HIDGamepadElement* element = m_elementMap.get(cookie);
-
- // This might be an element we don't currently handle as input so we can skip it.
- if (!element)
- return;
-
- element->rawValue = IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical);
-
- if (element->isButton()) {
- for (unsigned i = 0; i < m_buttons.size(); ++i) {
- if (m_buttons[i].get() == element)
- m_buttonValues[i] = element->normalizedValue();
- }
- } else if (element->isAxis()) {
- for (unsigned i = 0; i < m_axes.size(); ++i) {
- if (m_axes[i].get() == element)
- m_axisValues[i] = element->normalizedValue();
- }
- } else
- ASSERT_NOT_REACHED();
-
- m_lastUpdateTime = monotonicallyIncreasingTime();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacHIDGamepadh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/HIDGamepad.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/HIDGamepad.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/mac/HIDGamepad.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,128 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#ifndef HIDGamepad_h
-#define HIDGamepad_h
-
-#if ENABLE(GAMEPAD)
-
-#include "PlatformGamepad.h"
-#include <IOKit/hid/IOHIDDevice.h>
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-struct HIDGamepadElement {
- HIDGamepadElement(double theMin, double theMax, IOHIDElementRef element)
- : min(theMin)
- , max(theMax)
- , rawValue(theMin)
- , iohidElement(element)
- {
- }
-
- virtual ~HIDGamepadElement()
- {
- }
-
- double min;
- double max;
- double rawValue;
- RetainPtr<IOHIDElementRef> iohidElement;
-
- virtual bool isButton() const { return false; }
- virtual bool isAxis() const { return false; }
-
- virtual double normalizedValue() = 0;
-};
-
-struct HIDGamepadButton : HIDGamepadElement {
- HIDGamepadButton(uint32_t thePriority, double min, double max, IOHIDElementRef element)
- : HIDGamepadElement(min, max, element)
- , priority(thePriority)
- {
- }
-
- uint32_t priority;
-
- bool isButton() const override { return true; }
-
- // Buttons normalize to the range (0.0) - (1.0)
- double normalizedValue() override
- {
- return (rawValue - min) / (max - min);
- }
-};
-
-struct HIDGamepadAxis : HIDGamepadElement {
- HIDGamepadAxis(double min, double max, IOHIDElementRef element)
- : HIDGamepadElement(min, max, element)
- {
- }
-
- bool isAxis() const override { return true; }
-
- // Axes normalize to the range (-1.0) - (1.0)
- double normalizedValue() override
- {
- return (((rawValue - min) / (max - min)) * 2) - 1;
- }
-};
-
-class HIDGamepad : public PlatformGamepad {
-public:
- HIDGamepad(IOHIDDeviceRef, unsigned index);
-
- IOHIDDeviceRef hidDevice() const { return m_hidDevice.get(); }
-
- void valueChanged(IOHIDValueRef);
-
- const Vector<double>& axisValues() const final { return m_axisValues; }
- const Vector<double>& buttonValues() const final { return m_buttonValues; }
-
-private:
- void initElements();
- void initElementsFromArray(CFArrayRef);
-
- bool maybeAddButton(IOHIDElementRef);
- bool maybeAddAxis(IOHIDElementRef);
-
- void getCurrentValueForElement(const HIDGamepadElement&);
-
- RetainPtr<IOHIDDeviceRef> m_hidDevice;
-
- HashMap<IOHIDElementCookie, HIDGamepadElement*> m_elementMap;
-
- Vector<std::unique_ptr<HIDGamepadButton>> m_buttons;
- Vector<std::unique_ptr<HIDGamepadAxis>> m_axes;
- Vector<double> m_buttonValues;
- Vector<double> m_axisValues;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
-#endif // HIDGamepad_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacHIDGamepadProvidercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/HIDGamepadProvider.cpp (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/HIDGamepadProvider.cpp        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/mac/HIDGamepadProvider.cpp        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,254 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#include "config.h"
-#include "HIDGamepadProvider.h"
-
-#if ENABLE(GAMEPAD)
-
-#include "GamepadProviderClient.h"
-#include "Logging.h"
-#include "PlatformGamepad.h"
-
-namespace WebCore {
-
-static const double ConnectionDelayInterval = 0.5;
-static const double InputNotificationDelay = 0.05;
-
-static RetainPtr<CFDictionaryRef> deviceMatchingDictionary(uint32_t usagePage, uint32_t usage)
-{
- ASSERT(usagePage);
- ASSERT(usage);
-
- RetainPtr<CFNumberRef> pageNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usagePage));
- RetainPtr<CFNumberRef> usageNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage));
-
- CFStringRef keys[] = { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) };
- CFNumberRef values[] = { pageNumber.get(), usageNumber.get() };
-
- return adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-}
-
-static void deviceAddedCallback(void* context, IOReturn, void*, IOHIDDeviceRef device)
-{
- HIDGamepadProvider* listener = static_cast<HIDGamepadProvider*>(context);
- listener->deviceAdded(device);
-}
-
-static void deviceRemovedCallback(void* context, IOReturn, void*, IOHIDDeviceRef device)
-{
- HIDGamepadProvider* listener = static_cast<HIDGamepadProvider*>(context);
- listener->deviceRemoved(device);
-}
-
-static void deviceValuesChangedCallback(void* context, IOReturn result, void*, IOHIDValueRef value)
-{
- // A non-zero result value indicates an error that we can do nothing about for input values.
- if (result)
- return;
-
- HIDGamepadProvider* listener = static_cast<HIDGamepadProvider*>(context);
- listener->valuesChanged(value);
-}
-
-HIDGamepadProvider& HIDGamepadProvider::singleton()
-{
- static NeverDestroyed<HIDGamepadProvider> sharedListener;
- return sharedListener;
-}
-
-HIDGamepadProvider::HIDGamepadProvider()
- : m_shouldDispatchCallbacks(false)
- , m_connectionDelayTimer(*this, &HIDGamepadProvider::connectionDelayTimerFired)
- , m_inputNotificationTimer(*this, &HIDGamepadProvider::inputNotificationTimerFired)
-{
- m_manager = adoptCF(IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone));
-
- RetainPtr<CFDictionaryRef> joystickDictionary = deviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
- RetainPtr<CFDictionaryRef> gamepadDictionary = deviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
-
- CFDictionaryRef devices[] = { joystickDictionary.get(), gamepadDictionary.get() };
-
- RetainPtr<CFArrayRef> matchingArray = adoptCF(CFArrayCreate(kCFAllocatorDefault, (const void**)devices, 2, &kCFTypeArrayCallBacks));
-
- IOHIDManagerSetDeviceMatchingMultiple(m_manager.get(), matchingArray.get());
- IOHIDManagerRegisterDeviceMatchingCallback(m_manager.get(), deviceAddedCallback, this);
- IOHIDManagerRegisterDeviceRemovalCallback(m_manager.get(), deviceRemovedCallback, this);
- IOHIDManagerRegisterInputValueCallback(m_manager.get(), deviceValuesChangedCallback, this);
-}
-
-unsigned HIDGamepadProvider::indexForNewlyConnectedDevice()
-{
- unsigned index = 0;
- while (index < m_gamepadVector.size() && m_gamepadVector[index])
- ++index;
-
- return index;
-}
-
-void HIDGamepadProvider::connectionDelayTimerFired()
-{
- m_shouldDispatchCallbacks = true;
-}
-
-void HIDGamepadProvider::openAndScheduleManager()
-{
- LOG(Gamepad, "HIDGamepadProvider opening/scheduling HID manager");
-
- ASSERT(m_gamepadVector.isEmpty());
- ASSERT(m_gamepadMap.isEmpty());
-
- m_shouldDispatchCallbacks = false;
-
- IOHIDManagerScheduleWithRunLoop(m_manager.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
- IOHIDManagerOpen(m_manager.get(), kIOHIDOptionsTypeNone);
-
- // Any connections we are notified of within the ConnectionDelayInterval of listening likely represent
- // devices that were already connected, so we suppress notifying clients of these.
- m_connectionDelayTimer.startOneShot(ConnectionDelayInterval);
-}
-
-void HIDGamepadProvider::closeAndUnscheduleManager()
-{
- LOG(Gamepad, "HIDGamepadProvider closing/unscheduling HID manager");
-
- IOHIDManagerUnscheduleFromRunLoop(m_manager.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
- IOHIDManagerClose(m_manager.get(), kIOHIDOptionsTypeNone);
-
- m_gamepadVector.clear();
- m_gamepadMap.clear();
-
- m_connectionDelayTimer.stop();
-}
-
-void HIDGamepadProvider::startMonitoringGamepads(GamepadProviderClient* client)
-{
- bool shouldOpenAndScheduleManager = m_clients.isEmpty();
-
- ASSERT(!m_clients.contains(client));
- m_clients.add(client);
-
- if (shouldOpenAndScheduleManager)
- openAndScheduleManager();
-}
-void HIDGamepadProvider::stopMonitoringGamepads(GamepadProviderClient* client)
-{
- ASSERT(m_clients.contains(client));
-
- bool shouldCloseAndUnscheduleManager = m_clients.remove(client) && m_clients.isEmpty();
-
- if (shouldCloseAndUnscheduleManager)
- closeAndUnscheduleManager();
-}
-
-void HIDGamepadProvider::deviceAdded(IOHIDDeviceRef device)
-{
- ASSERT(!m_gamepadMap.get(device));
-
- LOG(Gamepad, "HIDGamepadProvider device %p added", device);
-
- unsigned index = indexForNewlyConnectedDevice();
- std::unique_ptr<HIDGamepad> gamepad = std::make_unique<HIDGamepad>(device, index);
-
- if (m_gamepadVector.size() <= index)
- m_gamepadVector.resize(index + 1);
-
- m_gamepadVector[index] = gamepad.get();
- m_gamepadMap.set(device, WTFMove(gamepad));
-
- if (!m_shouldDispatchCallbacks) {
- // This added device is the result of us starting to monitor gamepads.
- // We'll get notified of all connected devices during this current spin of the runloop
- // and we don't want to tell the client about any of them.
- // The m_connectionDelayTimer fires in a subsequent spin of the runloop after which
- // any connection events are actual new devices.
- m_connectionDelayTimer.startOneShot(0);
-
- LOG(Gamepad, "Device %p was added while suppressing callbacks, so this should be an 'already connected' event", device);
-
- return;
- }
-
- for (auto& client : m_clients)
- client->platformGamepadConnected(*m_gamepadVector[index]);
-}
-
-void HIDGamepadProvider::deviceRemoved(IOHIDDeviceRef device)
-{
- LOG(Gamepad, "HIDGamepadProvider device %p removed", device);
-
- std::unique_ptr<HIDGamepad> removedGamepad = removeGamepadForDevice(device);
- ASSERT(removedGamepad);
-
- // Any time we get a device removed callback we know it's a real event and not an 'already connected' event.
- // We should always stop suppressing callbacks when we receive such an event.
- m_shouldDispatchCallbacks = true;
-
- for (auto& client : m_clients)
- client->platformGamepadDisconnected(*removedGamepad);
-}
-
-void HIDGamepadProvider::valuesChanged(IOHIDValueRef value)
-{
- IOHIDDeviceRef device = IOHIDElementGetDevice(IOHIDValueGetElement(value));
-
- HIDGamepad* gamepad = m_gamepadMap.get(device);
-
- // When starting monitoring we might get a value changed callback before we even know the device is connected.
- if (!gamepad)
- return;
-
- gamepad->valueChanged(value);
-
- // This isActive check is necessary as we want to delay input notifications from the time of the first input,
- // and not push the notification out on every subsequent input.
- if (!m_inputNotificationTimer.isActive())
- m_inputNotificationTimer.startOneShot(InputNotificationDelay);
-}
-
-void HIDGamepadProvider::inputNotificationTimerFired()
-{
- if (!m_shouldDispatchCallbacks)
- return;
-
- for (auto& client : m_clients)
- client->platformGamepadInputActivity();
-}
-
-std::unique_ptr<HIDGamepad> HIDGamepadProvider::removeGamepadForDevice(IOHIDDeviceRef device)
-{
- std::unique_ptr<HIDGamepad> result = m_gamepadMap.take(device);
- ASSERT(result);
-
- auto i = m_gamepadVector.find(result.get());
- if (i != notFound)
- m_gamepadVector[i] = nullptr;
-
- return result;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacHIDGamepadProviderh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/HIDGamepadProvider.h (204177 => 204178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/HIDGamepadProvider.h        2016-08-05 17:43:45 UTC (rev 204177)
+++ trunk/Source/WebCore/platform/mac/HIDGamepadProvider.h        2016-08-05 18:27:49 UTC (rev 204178)
</span><span class="lines">@@ -1,87 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 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.
- */
-
-#ifndef HIDGamepadProvider_h
-#define HIDGamepadProvider_h
-
-#if ENABLE(GAMEPAD)
-
-#include "GamepadProvider.h"
-#include "HIDGamepad.h"
-#include "Timer.h"
-#include <IOKit/hid/IOHIDManager.h>
-#include <wtf/Deque.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-class GamepadProviderClient;
-
-class HIDGamepadProvider : public GamepadProvider {
- WTF_MAKE_NONCOPYABLE(HIDGamepadProvider);
- friend class NeverDestroyed<HIDGamepadProvider>;
-public:
- WEBCORE_EXPORT static HIDGamepadProvider& singleton();
-
- virtual void startMonitoringGamepads(GamepadProviderClient*);
- virtual void stopMonitoringGamepads(GamepadProviderClient*);
- virtual const Vector<PlatformGamepad*>& platformGamepads() { return m_gamepadVector; }
-
- void deviceAdded(IOHIDDeviceRef);
- void deviceRemoved(IOHIDDeviceRef);
- void valuesChanged(IOHIDValueRef);
-
-private:
- HIDGamepadProvider();
-
- std::unique_ptr<HIDGamepad> removeGamepadForDevice(IOHIDDeviceRef);
-
- void openAndScheduleManager();
- void closeAndUnscheduleManager();
-
- void connectionDelayTimerFired();
- void inputNotificationTimerFired();
-
- unsigned indexForNewlyConnectedDevice();
-
- Vector<PlatformGamepad*> m_gamepadVector;
- HashMap<IOHIDDeviceRef, std::unique_ptr<HIDGamepad>> m_gamepadMap;
-
- RetainPtr<IOHIDManagerRef> m_manager;
-
- HashSet<GamepadProviderClient*> m_clients;
- bool m_shouldDispatchCallbacks;
-
- Timer m_connectionDelayTimer;
- Timer m_inputNotificationTimer;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(GAMEPAD)
-#endif // HIDGamepadProvider_h
</del></span></pre>
</div>
</div>
</body>
</html>