Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Unified Diff: Source/modules/gamepad/Gamepad.cpp

Issue 183313003: Added non-prefixed navigator.getGamepads() with updated API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added LayoutTests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/gamepad/Gamepad.cpp
diff --git a/Source/modules/gamepad/Gamepad.cpp b/Source/modules/gamepad/Gamepad.cpp
index 8fbe47c17946f3d38b21769ef387a9da8b966497..aea6a9ff3976bdcb8fc4c5ac5c9411baa4c225ea 100644
--- a/Source/modules/gamepad/Gamepad.cpp
+++ b/Source/modules/gamepad/Gamepad.cpp
@@ -28,42 +28,26 @@
namespace WebCore {
-Gamepad::Gamepad()
- : m_index(0)
- , m_timestamp(0)
+Gamepad::Gamepad() : GamepadBase()
{
ScriptWrappable::init(this);
}
-void Gamepad::axes(unsigned count, float* data)
+void Gamepad::buttons(unsigned count, const blink::WebGamepadButton* data)
{
- m_axes.resize(count);
- if (count)
- std::copy(data, data + count, m_axes.begin());
+ if (m_buttons.size() != count) {
+ m_buttons.resize(count);
+ for (unsigned i = 0; i < count; ++i)
+ m_buttons[i] = GamepadButton::create();
+ }
+ for (unsigned i = 0; i < count; ++i) {
+ m_buttons[i]->value(data[i].value);
+ m_buttons[i]->pressed(data[i].pressed);
+ }
}
-#if defined(ENABLE_NEW_GAMEPAD_API)
-void Gamepad::buttons(unsigned count, blink::WebGamepadButton* data)
-{
- m_buttons.resize(count);
- for (unsigned i = 0; i < count; ++i)
- m_buttons[i] = data[i].value;
-}
-#else
-void Gamepad::buttons(unsigned count, float* data)
-{
- m_buttons.resize(count);
- if (count)
- std::copy(data, data + count, m_buttons.begin());
-}
-#endif
-
Gamepad::~Gamepad()
{
}
-void Gamepad::trace(Visitor* visitor)
-{
-}
-
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698