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

Unified Diff: public/platform/WebGamepad.h

Issue 170993002: Updating Blink-side WebGamepad interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Scaled back Blink changes, only contains WebGamepad interface update Created 6 years, 10 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: public/platform/WebGamepad.h
diff --git a/public/platform/WebGamepad.h b/public/platform/WebGamepad.h
index 93df8a28b67adaa5022aa13843b26a0908fe5a67..db1fa1c012da5eaa2279c9f0454a9c2c530f236d 100644
--- a/public/platform/WebGamepad.h
+++ b/public/platform/WebGamepad.h
@@ -34,12 +34,31 @@ namespace blink {
#pragma pack(push, 1)
+#if defined(ENABLE_NEW_GAMEPAD_API)
+class WebGamepadButton {
+public:
+ WebGamepadButton()
+ : pressed(false)
+ , value(0.f)
+ {
+ }
+ WebGamepadButton(bool pressed, float value)
+ : pressed(pressed)
+ , value(value)
+ {
+ }
+ bool pressed;
+ float value;
+};
+#endif
+
// 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 mappingLengthCap = 16;
static const size_t axesLengthCap = 16;
static const size_t buttonsLengthCap = 32;
@@ -50,6 +69,9 @@ public:
, buttonsLength(0)
{
id[0] = 0;
+#if defined(ENABLE_NEW_GAMEPAD_API)
+ mapping[0] = 0;
+#endif
}
// Is there a gamepad connected at this index?
@@ -71,13 +93,24 @@ public:
// Number of valid entries in the buttons array.
unsigned buttonsLength;
- // Normalized values representing buttons, in the range [0..1].
+#if defined(ENABLE_NEW_GAMEPAD_API)
+ // Button states
+ WebGamepadButton buttons[buttonsLengthCap];
+
+ // Mapping type (for example "standard")
+ WebUChar mapping[mappingLengthCap];
+#else
float buttons[buttonsLengthCap];
+#endif
};
#if BLINK_IMPLEMENTATION
+#if defined(ENABLE_NEW_GAMEPAD_API)
+COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size);
+#else
COMPILE_ASSERT(sizeof(WebGamepad) == 465, WebGamepad_has_wrong_size);
#endif
+#endif
abarth-chromium 2014/02/20 06:12:45 What's the point of these COMPILE_ASSERTs if we're
bajones 2014/02/20 17:03:24 Truthfully I'm not sure. The class must be a stati
#pragma pack(pop)

Powered by Google App Engine
This is Rietveld 408576698