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

Side by Side Diff: public/platform/WebGamepad.h

Issue 280393004: Update Gamepad.axes / GamepadButton.value to match the latest specification (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add back #ifdefs 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 | « Source/modules/gamepad/GamepadCommon.cpp ('k') | public/platform/WebGamepads.h » ('j') | 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) 2011, Google Inc. All rights reserved. 1 // Copyright (C) 2011, Google Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met: 4 // modification, are permitted provided that the following conditions are met:
5 // 5 //
6 // 1. Redistributions of source code must retain the above copyright 6 // 1. Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright 8 // 2. Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the 9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution. 10 // documentation and/or other materials provided with the distribution.
(...skipping 20 matching lines...) Expand all
31 #endif 31 #endif
32 32
33 namespace blink { 33 namespace blink {
34 34
35 #pragma pack(push, 1) 35 #pragma pack(push, 1)
36 36
37 class WebGamepadButton { 37 class WebGamepadButton {
38 public: 38 public:
39 WebGamepadButton() 39 WebGamepadButton()
40 : pressed(false) 40 : pressed(false)
41 // FIXME(cdumez): Remove #ifdefs once chromium-side has been updated.
42 #if defined(ENABLE_NEW_GAMEPAD_API)
43 , value(0.)
44 #else
41 , value(0.f) 45 , value(0.f)
46 #endif
42 { 47 {
43 } 48 }
49 #if defined(ENABLE_NEW_GAMEPAD_API)
50 WebGamepadButton(bool pressed, double value)
51 #else
44 WebGamepadButton(bool pressed, float value) 52 WebGamepadButton(bool pressed, float value)
53 #endif
45 : pressed(pressed) 54 : pressed(pressed)
46 , value(value) 55 , value(value)
47 { 56 {
48 } 57 }
49 bool pressed; 58 bool pressed;
59 #if defined(ENABLE_NEW_GAMEPAD_API)
60 double value;
61 #else
50 float value; 62 float value;
63 #endif
51 }; 64 };
52 65
53 // This structure is intentionally POD and fixed size so that it can be shared 66 // This structure is intentionally POD and fixed size so that it can be shared
54 // memory between hardware polling threads and the rest of the browser. See 67 // memory between hardware polling threads and the rest of the browser. See
55 // also WebGamepads.h. 68 // also WebGamepads.h.
56 class WebGamepad { 69 class WebGamepad {
57 public: 70 public:
58 static const size_t idLengthCap = 128; 71 static const size_t idLengthCap = 128;
59 static const size_t mappingLengthCap = 16; 72 static const size_t mappingLengthCap = 16;
60 static const size_t axesLengthCap = 16; 73 static const size_t axesLengthCap = 16;
(...skipping 16 matching lines...) Expand all
77 WebUChar id[idLengthCap]; 90 WebUChar id[idLengthCap];
78 91
79 // Monotonically increasing value referring to when the data were last 92 // Monotonically increasing value referring to when the data were last
80 // updated. 93 // updated.
81 unsigned long long timestamp; 94 unsigned long long timestamp;
82 95
83 // Number of valid entries in the axes array. 96 // Number of valid entries in the axes array.
84 unsigned axesLength; 97 unsigned axesLength;
85 98
86 // Normalized values representing axes, in the range [-1..1]. 99 // Normalized values representing axes, in the range [-1..1].
100 #if defined(ENABLE_NEW_GAMEPAD_API)
101 double axes[axesLengthCap];
102 #else
87 float axes[axesLengthCap]; 103 float axes[axesLengthCap];
104 #endif
88 105
89 // Number of valid entries in the buttons array. 106 // Number of valid entries in the buttons array.
90 unsigned buttonsLength; 107 unsigned buttonsLength;
91 108
92 // Button states 109 // Button states
93 WebGamepadButton buttons[buttonsLengthCap]; 110 WebGamepadButton buttons[buttonsLengthCap];
94 111
95 // Mapping type (for example "standard") 112 // Mapping type (for example "standard")
96 WebUChar mapping[mappingLengthCap]; 113 WebUChar mapping[mappingLengthCap];
97 }; 114 };
98 115
99 #if BLINK_IMPLEMENTATION 116 #if BLINK_IMPLEMENTATION
117 #if defined(ENABLE_NEW_GAMEPAD_API)
118 COMPILE_ASSERT(sizeof(WebGamepad) == 721, WebGamepad_has_wrong_size);
119 #else
100 COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size); 120 COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size);
101 #endif 121 #endif
122 #endif
102 123
103 #pragma pack(pop) 124 #pragma pack(pop)
104 125
105 } 126 }
106 127
107 #endif // WebGamepad_h 128 #endif // WebGamepad_h
OLDNEW
« no previous file with comments | « Source/modules/gamepad/GamepadCommon.cpp ('k') | public/platform/WebGamepads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698