Allow script to request durable storage permission (chrome side)
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_gamepad_shared.h
blob22b4df7a7be1477f698feb0f6c826904c4c571ef
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_
8 #include "base/atomicops.h"
9 #include "base/strings/string16.h"
10 #include "ppapi/c/ppb_gamepad.h"
11 #include "ppapi/shared_impl/ppapi_shared_export.h"
13 namespace ppapi {
15 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this
16 // code should all move into the GamepadResource.
18 #pragma pack(push, 1)
20 struct WebKitGamepadButton {
21 bool pressed;
22 double value;
25 // This must match the definition of blink::Gamepad. The GamepadHost unit test
26 // has some compile asserts to validate this.
27 struct WebKitGamepad {
28 static const size_t kIdLengthCap = 128;
29 static const size_t kMappingLengthCap = 16;
30 static const size_t kAxesLengthCap = 16;
31 static const size_t kButtonsLengthCap = 32;
33 // Is there a gamepad connected at this index?
34 bool connected;
36 // Device identifier (based on manufacturer, model, etc.).
37 base::char16 id[kIdLengthCap];
39 // Monotonically increasing value referring to when the data were last
40 // updated.
41 unsigned long long timestamp;
43 // Number of valid entries in the axes array.
44 unsigned axes_length;
46 // Normalized values representing axes, in the range [-1..1].
47 double axes[kAxesLengthCap];
49 // Number of valid entries in the buttons array.
50 unsigned buttons_length;
52 // Normalized values representing buttons, in the range [0..1].
53 WebKitGamepadButton buttons[kButtonsLengthCap];
55 // Mapping type (for example "standard")
56 base::char16 mapping[kMappingLengthCap];
59 // This must match the definition of blink::Gamepads. The GamepadHost unit
60 // test has some compile asserts to validate this.
61 struct WebKitGamepads {
62 static const size_t kItemsLengthCap = 4;
64 // Number of valid entries in the items array.
65 unsigned length;
67 // Gamepad data for N separate gamepad devices.
68 WebKitGamepad items[kItemsLengthCap];
71 // This is the structure store in shared memory. It must match
72 // content/common/gamepad_hardware_buffer.h. The GamepadHost unit test has
73 // some compile asserts to validate this.
74 struct ContentGamepadHardwareBuffer {
75 base::subtle::Atomic32 sequence;
76 WebKitGamepads buffer;
79 #pragma pack(pop)
81 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData(
82 const WebKitGamepads& webkit_data,
83 PP_GamepadsSampleData* output_data);
85 } // namespace ppapi
87 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_