Index: Source/modules/gamepad/Gamepad.cpp |
diff --git a/Source/modules/gamepad/Gamepad.cpp b/Source/modules/gamepad/Gamepad.cpp |
index c83ccaf90a457ce81bcf3bc81f7680410dfefc00..0c82a833a4f7e75b92c8eec369b9a85acc29c43c 100644 |
--- a/Source/modules/gamepad/Gamepad.cpp |
+++ b/Source/modules/gamepad/Gamepad.cpp |
@@ -28,6 +28,8 @@ |
namespace WebCore { |
+const float ButtonPressedThreshold = 0.1f; |
scottmg
2014/02/18 23:46:31
As noted in the chromium-side review, I think this
|
+ |
DEFINE_GC_INFO(Gamepad); |
Gamepad::Gamepad() |
@@ -46,9 +48,16 @@ void Gamepad::axes(unsigned count, float* data) |
void Gamepad::buttons(unsigned count, float* data) |
{ |
- m_buttons.resize(count); |
- if (count) |
- std::copy(data, data + count, m_buttons.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]); |
+ m_buttons[i]->pressed(data[i] >= ButtonPressedThreshold); |
+ } |
} |
Gamepad::~Gamepad() |