Chromium Code Reviews| Index: Source/modules/gamepad/Gamepad.cpp |
| diff --git a/Source/modules/gamepad/Gamepad.cpp b/Source/modules/gamepad/Gamepad.cpp |
| index 8fbe47c17946f3d38b21769ef387a9da8b966497..d58311e094793d75aa81d18fa4cb26ffab9fc84e 100644 |
| --- a/Source/modules/gamepad/Gamepad.cpp |
| +++ b/Source/modules/gamepad/Gamepad.cpp |
| @@ -35,34 +35,39 @@ Gamepad::Gamepad() |
| ScriptWrappable::init(this); |
| } |
| -void Gamepad::axes(unsigned count, float* data) |
| +void Gamepad::setAxes(unsigned count, const float* data) |
| { |
| m_axes.resize(count); |
| if (count) |
| std::copy(data, data + count, m_axes.begin()); |
| } |
| -#if defined(ENABLE_NEW_GAMEPAD_API) |
| -void Gamepad::buttons(unsigned count, blink::WebGamepadButton* data) |
| +void Gamepad::setButtons(unsigned count, const blink::WebGamepadButton* data) |
| { |
| - m_buttons.resize(count); |
| - for (unsigned i = 0; i < count; ++i) |
| - m_buttons[i] = data[i].value; |
| + 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) { |
|
eseidel
2014/03/12 20:06:46
I'm not sure if it's simpler to do the copying int
Nils Barth (inactive)
2014/03/13 08:55:46
(This is from upstream; as noted, doesn't make muc
|
| + m_buttons[i]->setValue(data[i].value); |
| + m_buttons[i]->setPressed(data[i].pressed); |
| + } |
| } |
| -#else |
| -void Gamepad::buttons(unsigned count, float* data) |
| + |
| +void Gamepad::setWebkitButtons(unsigned count, const blink::WebGamepadButton* data) |
| { |
| - m_buttons.resize(count); |
| - if (count) |
| - std::copy(data, data + count, m_buttons.begin()); |
| + m_webkitButtons.resize(count); |
| + for (unsigned i = 0; i < count; ++i) |
| + m_webkitButtons[i] = data[i].value; |
| } |
| -#endif |
| -Gamepad::~Gamepad() |
| +void Gamepad::trace(Visitor* visitor) |
| { |
| + visitor->trace(m_buttons); |
| } |
| -void Gamepad::trace(Visitor* visitor) |
| +Gamepad::~Gamepad() |
| { |
| } |