0

Update Gamepad API to match the latest specification

Update Gamepad API to match the latest specification:
https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#widl-Gamepad-axes
https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#widl-GamepadButton-value

Namely, Gamepad.axes / GamepadButton.value should be of type double, not float.

R=bbudge@chromium.org, jam@chromium.org, scottmg@chromium.org
BUG=344556

Review URL: https://codereview.chromium.org/280713004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271775 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
ch.dumez@samsung.com
2014-05-20 22:04:06 +00:00
parent bccbfc9abe
commit 7106f33669
2 changed files with 14 additions and 7 deletions

@ -18,16 +18,14 @@ void ConvertWebKitGamepadData(const WebKitGamepads& webkit_data,
if (webkit_pad.connected) {
COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id),
id_size_does_not_match);
COMPILE_ASSERT(sizeof(output_pad.axes) == sizeof(webkit_pad.axes),
axes_size_does_not_match);
memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id));
output_pad.timestamp = webkit_pad.timestamp;
output_pad.axes_length = webkit_pad.axes_length;
memcpy(output_pad.axes, webkit_pad.axes, sizeof(output_pad.axes));
for (unsigned j = 0; j < webkit_pad.axes_length; ++j)
output_pad.axes[j] = static_cast<float>(webkit_pad.axes[j]);
output_pad.buttons_length = webkit_pad.buttons_length;
for (unsigned j = 0; j < webkit_pad.buttons_length; ++j)
output_pad.buttons[j] = webkit_pad.buttons[j].value;
output_pad.buttons[j] = static_cast<float>(webkit_pad.buttons[j].value);
}
}
}

@ -9,6 +9,7 @@
#include "base/strings/string16.h"
#include "ppapi/c/ppb_gamepad.h"
#include "ppapi/shared_impl/ppapi_shared_export.h"
#include "third_party/WebKit/public/platform/WebGamepads.h"
namespace ppapi {
@ -17,9 +18,17 @@ namespace ppapi {
#pragma pack(push, 1)
#if defined(ENABLE_NEW_GAMEPAD_API)
typedef double buttonValueType;
typedef double axisValueType;
#else
typedef float buttonValueType;
typedef float axisValueType;
#endif
struct WebKitGamepadButton {
bool pressed;
float value;
buttonValueType value;
};
// This must match the definition of blink::Gamepad. The GamepadHost unit test
@ -44,7 +53,7 @@ struct WebKitGamepad {
unsigned axes_length;
// Normalized values representing axes, in the range [-1..1].
float axes[kAxesLengthCap];
axisValueType axes[kAxesLengthCap];
// Number of valid entries in the buttons array.
unsigned buttons_length;