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

Side by Side Diff: ppapi/shared_impl/ppb_gamepad_shared.h

Issue 289423004: Turn on ENABLE_NEW_GAMEPAD_API flag so that the new gamepad code is used (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add bug number Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 12
14 namespace ppapi { 13 namespace ppapi {
15 14
16 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this 15 // TODO(brettw) when we remove the non-IPC-based gamepad implementation, this
17 // code should all move into the GamepadResource. 16 // code should all move into the GamepadResource.
18 17
19 #pragma pack(push, 1) 18 #pragma pack(push, 1)
20 19
21 #if defined(ENABLE_NEW_GAMEPAD_API)
22 typedef double buttonValueType;
23 typedef double axisValueType;
24 #else
25 typedef float buttonValueType;
26 typedef float axisValueType;
27 #endif
28
29 struct WebKitGamepadButton { 20 struct WebKitGamepadButton {
30 bool pressed; 21 bool pressed;
31 buttonValueType value; 22 double value;
32 }; 23 };
33 24
34 // This must match the definition of blink::Gamepad. The GamepadHost unit test 25 // This must match the definition of blink::Gamepad. The GamepadHost unit test
35 // has some compile asserts to validate this. 26 // has some compile asserts to validate this.
36 struct WebKitGamepad { 27 struct WebKitGamepad {
37 static const size_t kIdLengthCap = 128; 28 static const size_t kIdLengthCap = 128;
38 static const size_t kMappingLengthCap = 16; 29 static const size_t kMappingLengthCap = 16;
39 static const size_t kAxesLengthCap = 16; 30 static const size_t kAxesLengthCap = 16;
40 static const size_t kButtonsLengthCap = 32; 31 static const size_t kButtonsLengthCap = 32;
41 32
42 // Is there a gamepad connected at this index? 33 // Is there a gamepad connected at this index?
43 bool connected; 34 bool connected;
44 35
45 // Device identifier (based on manufacturer, model, etc.). 36 // Device identifier (based on manufacturer, model, etc.).
46 base::char16 id[kIdLengthCap]; 37 base::char16 id[kIdLengthCap];
47 38
48 // Monotonically increasing value referring to when the data were last 39 // Monotonically increasing value referring to when the data were last
49 // updated. 40 // updated.
50 unsigned long long timestamp; 41 unsigned long long timestamp;
51 42
52 // Number of valid entries in the axes array. 43 // Number of valid entries in the axes array.
53 unsigned axes_length; 44 unsigned axes_length;
54 45
55 // Normalized values representing axes, in the range [-1..1]. 46 // Normalized values representing axes, in the range [-1..1].
56 axisValueType axes[kAxesLengthCap]; 47 double axes[kAxesLengthCap];
57 48
58 // Number of valid entries in the buttons array. 49 // Number of valid entries in the buttons array.
59 unsigned buttons_length; 50 unsigned buttons_length;
60 51
61 // Normalized values representing buttons, in the range [0..1]. 52 // Normalized values representing buttons, in the range [0..1].
62 WebKitGamepadButton buttons[kButtonsLengthCap]; 53 WebKitGamepadButton buttons[kButtonsLengthCap];
63 54
64 // Mapping type (for example "standard") 55 // Mapping type (for example "standard")
65 base::char16 mapping[kMappingLengthCap]; 56 base::char16 mapping[kMappingLengthCap];
66 }; 57 };
(...skipping 20 matching lines...) Expand all
87 78
88 #pragma pack(pop) 79 #pragma pack(pop)
89 80
90 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData( 81 PPAPI_SHARED_EXPORT void ConvertWebKitGamepadData(
91 const WebKitGamepads& webkit_data, 82 const WebKitGamepads& webkit_data,
92 PP_GamepadsSampleData* output_data); 83 PP_GamepadsSampleData* output_data);
93 84
94 } // namespace ppapi 85 } // namespace ppapi
95 86
96 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_ 87 #endif // PPAPI_SHARED_IMPL_PPB_GAMEPAD_SHARED_H_
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698