OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ |
6 #define PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ | 6 #define PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "ppapi/c/ppb_gamepad.h" | 10 #include "ppapi/c/ppb_gamepad.h" |
11 #include "ppapi/shared_impl/ppapi_shared_export.h" | 11 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 12 #include "third_party/WebKit/public/platform/WebGamepads.h" |
12 | 13 |
13 namespace ppapi { | 14 namespace ppapi { |
14 | 15 |
15 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this | 16 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this |
16 // code should all move into the GamepadResource. | 17 // code should all move into the GamepadResource. |
17 | 18 |
18 #pragma pack(push, 1) | 19 #pragma pack(push, 1) |
19 | 20 |
20 struct WebKitGamepadButton { | 21 struct WebKitGamepadButton { |
21 bool pressed; | 22 bool pressed; |
| 23 #if defined(ENABLE_NEW_GAMEPAD_API) |
| 24 double value; |
| 25 #else |
22 float value; | 26 float value; |
| 27 #endif |
23 }; | 28 }; |
24 | 29 |
25 // This must match the definition of blink::Gamepad. The GamepadHost unit test | 30 // This must match the definition of blink::Gamepad. The GamepadHost unit test |
26 // has some compile asserts to validate this. | 31 // has some compile asserts to validate this. |
27 struct WebKitGamepad { | 32 struct WebKitGamepad { |
28 static const size_t kIdLengthCap = 128; | 33 static const size_t kIdLengthCap = 128; |
29 static const size_t kMappingLengthCap = 16; | 34 static const size_t kMappingLengthCap = 16; |
30 static const size_t kAxesLengthCap = 16; | 35 static const size_t kAxesLengthCap = 16; |
31 static const size_t kButtonsLengthCap = 32; | 36 static const size_t kButtonsLengthCap = 32; |
32 | 37 |
33 // Is there a gamepad connected at this index? | 38 // Is there a gamepad connected at this index? |
34 bool connected; | 39 bool connected; |
35 | 40 |
36 // Device identifier (based on manufacturer, model, etc.). | 41 // Device identifier (based on manufacturer, model, etc.). |
37 base::char16 id[kIdLengthCap]; | 42 base::char16 id[kIdLengthCap]; |
38 | 43 |
39 // Monotonically increasing value referring to when the data were last | 44 // Monotonically increasing value referring to when the data were last |
40 // updated. | 45 // updated. |
41 unsigned long long timestamp; | 46 unsigned long long timestamp; |
42 | 47 |
43 // Number of valid entries in the axes array. | 48 // Number of valid entries in the axes array. |
44 unsigned axes_length; | 49 unsigned axes_length; |
45 | 50 |
46 // Normalized values representing axes, in the range [-1..1]. | 51 // Normalized values representing axes, in the range [-1..1]. |
| 52 #if defined(ENABLE_NEW_GAMEPAD_API) |
| 53 double axes[kAxesLengthCap]; |
| 54 #else |
47 float axes[kAxesLengthCap]; | 55 float axes[kAxesLengthCap]; |
| 56 #endif |
48 | 57 |
49 // Number of valid entries in the buttons array. | 58 // Number of valid entries in the buttons array. |
50 unsigned buttons_length; | 59 unsigned buttons_length; |
51 | 60 |
52 // Normalized values representing buttons, in the range [0..1]. | 61 // Normalized values representing buttons, in the range [0..1]. |
53 WebKitGamepadButton buttons[kButtonsLengthCap]; | 62 WebKitGamepadButton buttons[kButtonsLengthCap]; |
54 | 63 |
55 // Mapping type (for example "standard") | 64 // Mapping type (for example "standard") |
56 base::char16 mapping[kMappingLengthCap]; | 65 base::char16 mapping[kMappingLengthCap]; |
57 }; | 66 }; |
(...skipping 20 matching lines...) Expand all Loading... |
78 | 87 |
79 #pragma pack(pop) | 88 #pragma pack(pop) |
80 | 89 |
81 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData( | 90 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData( |
82 const WebKitGamepads& webkit_data, | 91 const WebKitGamepads& webkit_data, |
83 PP_GamepadsSampleData* output_data); | 92 PP_GamepadsSampleData* output_data); |
84 | 93 |
85 } // namespace ppapi | 94 } // namespace ppapi |
86 | 95 |
87 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ | 96 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ |
OLD | NEW |