[Chromium] gamepad changes to the public interface of Chromium port

https://bugs.webkit.org/show_bug.cgi?id=71518

Patch by Scott Graham <scottmg@chromium.org> on 2011-11-15
Reviewed by Darin Fisher.

Adds stubs for Chromium port, and defines shared memory structure to
be used between browser and WebKit.

Includes just the parts that touch the public interface so they can be
reviewed separately. See also:
https://bugs.webkit.org/show_bug.cgi?id=69451 and
http://codereview.chromium.org/8345027

* WebKit.gyp:
* public/WebGamepad.h: Added.
(WebKit::WebGamepad::WebGamepad):
* public/WebGamepads.h: Added.
(WebKit::WebGamepads::WebGamepads):
* public/WebKitPlatformSupport.h:
(WebKit::WebKitPlatformSupport::sampleGamepads):
* public/WebRuntimeFeatures.h:
* src/WebRuntimeFeatures.cpp:
(WebKit::WebRuntimeFeatures::enableGamepad):
(WebKit::WebRuntimeFeatures::isGamepadEnabled):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@100306 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d17fdc7d
2011-11-15 Scott Graham <scottmg@chromium.org>
[Chromium] gamepad changes to the public interface of Chromium port
https://bugs.webkit.org/show_bug.cgi?id=71518
Reviewed by Darin Fisher.
Adds stubs for Chromium port, and defines shared memory structure to
be used between browser and WebKit.
Includes just the parts that touch the public interface so they can be
reviewed separately. See also:
https://bugs.webkit.org/show_bug.cgi?id=69451 and
http://codereview.chromium.org/8345027
* WebKit.gyp:
* public/WebGamepad.h: Added.
(WebKit::WebGamepad::WebGamepad):
* public/WebGamepads.h: Added.
(WebKit::WebGamepads::WebGamepads):
* public/WebKitPlatformSupport.h:
(WebKit::WebKitPlatformSupport::sampleGamepads):
* public/WebRuntimeFeatures.h:
* src/WebRuntimeFeatures.cpp:
(WebKit::WebRuntimeFeatures::enableGamepad):
(WebKit::WebRuntimeFeatures::isGamepadEnabled):
2011-11-14 Anders Carlsson <andersca@apple.com>
HostWindow invalidation functions should use root view coordinates
......
......@@ -192,6 +192,8 @@
'public/WebFontCache.h',
'public/WebFormControlElement.h',
'public/WebFormElement.h',
'public/WebGamepad.h',
'public/WebGamepads.h',
'public/WebGeolocationClient.h',
'public/WebGeolocationClientMock.h',
'public/WebGeolocationController.h',
......
// 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 WebGamepad_h
#define WebGamepad_h
#include "WebCommon.h"
namespace WebKit {
// This structure is intentionally POD and fixed size so that it can be shared
// memory between hardware polling threads and the rest of the browser. See
// also WebGamepads.h.
class WebGamepad {
public:
static const size_t idLengthCap = 128;
static const size_t axesLengthCap = 16;
static const size_t buttonsLengthCap = 16;
WebGamepad()
: connected(false)
, timestamp(0)
, axesLength(0)
, buttonsLength(0)
{
id[0] = 0;
}
// Is there a gamepad connected at this index?
bool connected;
// Device identifier (based on manufacturer, model, etc.).
WebUChar id[idLengthCap];
// Monotonically increasing value referring to when the data were last
// updated.
unsigned long long timestamp;
// Number of valid entries in the axes array.
unsigned axesLength;
// Normalized values representing axes, in the range [-1..1].
float axes[axesLengthCap];
// Number of valid entries in the buttons array.
unsigned buttonsLength;
// Normalized values representing buttons, in the range [0..1].
float buttons[buttonsLengthCap];
};
}
#endif // WebGamepad_h
// 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 WebGamepads_h
#define WebGamepads_h
#include "WebGamepad.h"
namespace WebKit {
// This structure is intentionally POD and fixed size so that it can be stored
// in shared memory between hardware polling threads and the rest of the
// browser.
class WebGamepads {
public:
WebGamepads()
: length(0) { }
static const size_t itemsLengthCap = 4;
// Number of valid entries in the items array.
unsigned length;
// Gamepad data for N separate gamepad devices.
WebGamepad items[itemsLengthCap];
};
}
#endif // WebGamepads_h
......@@ -35,6 +35,7 @@
#include "WebAudioDevice.h"
#include "WebCommon.h"
#include "WebData.h"
#include "WebGamepads.h"
#include "WebLocalizedString.h"
#include "WebSerializedScriptValue.h"
#include "WebString.h"
......@@ -108,6 +109,11 @@ public:
const WebURL& url, bool isLocalStorage) { }
// Gamepad -------------------------------------------------------------
virtual void sampleGamepads(WebGamepads& into) { into.length = 0; }
// History -------------------------------------------------------------
// Returns the hash for the given canonicalized URL for use in visited
......
......@@ -118,6 +118,9 @@ public:
WEBKIT_EXPORT static void enableVideoTrack(bool);
WEBKIT_EXPORT static bool isVideoTrackEnabled();
WEBKIT_EXPORT static void enableGamepad(bool);
WEBKIT_EXPORT static bool isGamepadEnabled();
private:
WebRuntimeFeatures();
};
......
......@@ -414,4 +414,22 @@ bool WebRuntimeFeatures::isVideoTrackEnabled()
#endif
}
void WebRuntimeFeatures::enableGamepad(bool enable)
{
#if ENABLE(GAMEPAD)
RuntimeEnabledFeatures::setGamepadsEnabled(enable);
#else
UNUSED_PARAM(enable);
#endif
}
bool WebRuntimeFeatures::isGamepadEnabled()
{
#if ENABLE(GAMEPAD)
return RuntimeEnabledFeatures::gamepadsEnabled();
#else
return false;
#endif
}
} // namespace WebKit
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment