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

Unified Diff: ppapi/shared_impl/ppb_gamepad_shared.h

Issue 10912062: Implement the gamepad API in the IPC proxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « ppapi/shared_impl/ppapi_permissions.cc ('k') | ppapi/shared_impl/ppb_gamepad_shared.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/ppb_gamepad_shared.h
diff --git a/ppapi/shared_impl/ppb_gamepad_shared.h b/ppapi/shared_impl/ppb_gamepad_shared.h
new file mode 100644
index 0000000000000000000000000000000000000000..b3ab8827f9fa84167dc85ed1eaa0b5d71a7e2d25
--- /dev/null
+++ b/ppapi/shared_impl/ppb_gamepad_shared.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_
+#define PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_
+
+#include "base/atomicops.h"
+#include "base/string16.h"
+#include "ppapi/c/ppb_gamepad.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+// TODO(brettw) when we remove the non-IPC-based gamepad implementation, this
+// code should all move into the GamepadResource.
+
+#pragma pack(push, 1)
+
+// This must match the definition of WebKit::Gamepad. The GamepadHost unit test
+// has some compile asserts to validate this.
+struct WebKitGamepad {
+ static const size_t kIdLengthCap = 128;
+ static const size_t kAxesLengthCap = 16;
+ static const size_t kButtonsLengthCap = 32;
+
+ // Is there a gamepad connected at this index?
+ bool connected;
+
+ // Device identifier (based on manufacturer, model, etc.).
+ char16 id[kIdLengthCap];
+
+ // Monotonically increasing value referring to when the data were last
+ // updated.
+ unsigned long long timestamp;
+
+ // Number of valid entries in the axes array.
+ unsigned axes_length;
+
+ // Normalized values representing axes, in the range [-1..1].
+ float axes[kAxesLengthCap];
+
+ // Number of valid entries in the buttons array.
+ unsigned buttons_length;
+
+ // Normalized values representing buttons, in the range [0..1].
+ float buttons[kButtonsLengthCap];
+};
+
+// This must match the definition of WebKit::Gamepads. The GamepadHost unit
+// test has some compile asserts to validate this.
+struct WebKitGamepads {
+ static const size_t kItemsLengthCap = 4;
+
+ // Number of valid entries in the items array.
+ unsigned length;
+
+ // Gamepad data for N separate gamepad devices.
+ WebKitGamepad items[kItemsLengthCap];
+};
+
+// This is the structure store in shared memory. It must match
+// content/common/gamepad_hardware_buffer.h. The GamepadHost unit test has
+// some compile asserts to validate this.
+struct ContentGamepadHardwareBuffer {
+ base::subtle::Atomic32 sequence;
+ WebKitGamepads buffer;
+};
+
+#pragma pack(pop)
+
+PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData(
+ const WebKitGamepads& webkit_data,
+ PP_GamepadsSampleData* output_data);
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_
« no previous file with comments | « ppapi/shared_impl/ppapi_permissions.cc ('k') | ppapi/shared_impl/ppb_gamepad_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698