OLD | NEW |
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 Loading... |
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.) | 41 , value(0.) |
44 #else | |
45 , value(0.f) | |
46 #endif | |
47 { | 42 { |
48 } | 43 } |
49 #if defined(ENABLE_NEW_GAMEPAD_API) | |
50 WebGamepadButton(bool pressed, double value) | 44 WebGamepadButton(bool pressed, double value) |
51 #else | |
52 WebGamepadButton(bool pressed, float value) | |
53 #endif | |
54 : pressed(pressed) | 45 : pressed(pressed) |
55 , value(value) | 46 , value(value) |
56 { | 47 { |
57 } | 48 } |
58 bool pressed; | 49 bool pressed; |
59 #if defined(ENABLE_NEW_GAMEPAD_API) | |
60 double value; | 50 double value; |
61 #else | |
62 float value; | |
63 #endif | |
64 }; | 51 }; |
65 | 52 |
66 // This structure is intentionally POD and fixed size so that it can be shared | 53 // This structure is intentionally POD and fixed size so that it can be shared |
67 // memory between hardware polling threads and the rest of the browser. See | 54 // memory between hardware polling threads and the rest of the browser. See |
68 // also WebGamepads.h. | 55 // also WebGamepads.h. |
69 class WebGamepad { | 56 class WebGamepad { |
70 public: | 57 public: |
71 static const size_t idLengthCap = 128; | 58 static const size_t idLengthCap = 128; |
72 static const size_t mappingLengthCap = 16; | 59 static const size_t mappingLengthCap = 16; |
73 static const size_t axesLengthCap = 16; | 60 static const size_t axesLengthCap = 16; |
(...skipping 16 matching lines...) Expand all Loading... |
90 WebUChar id[idLengthCap]; | 77 WebUChar id[idLengthCap]; |
91 | 78 |
92 // Monotonically increasing value referring to when the data were last | 79 // Monotonically increasing value referring to when the data were last |
93 // updated. | 80 // updated. |
94 unsigned long long timestamp; | 81 unsigned long long timestamp; |
95 | 82 |
96 // Number of valid entries in the axes array. | 83 // Number of valid entries in the axes array. |
97 unsigned axesLength; | 84 unsigned axesLength; |
98 | 85 |
99 // Normalized values representing axes, in the range [-1..1]. | 86 // Normalized values representing axes, in the range [-1..1]. |
100 #if defined(ENABLE_NEW_GAMEPAD_API) | |
101 double axes[axesLengthCap]; | 87 double axes[axesLengthCap]; |
102 #else | |
103 float axes[axesLengthCap]; | |
104 #endif | |
105 | 88 |
106 // Number of valid entries in the buttons array. | 89 // Number of valid entries in the buttons array. |
107 unsigned buttonsLength; | 90 unsigned buttonsLength; |
108 | 91 |
109 // Button states | 92 // Button states |
110 WebGamepadButton buttons[buttonsLengthCap]; | 93 WebGamepadButton buttons[buttonsLengthCap]; |
111 | 94 |
112 // Mapping type (for example "standard") | 95 // Mapping type (for example "standard") |
113 WebUChar mapping[mappingLengthCap]; | 96 WebUChar mapping[mappingLengthCap]; |
114 }; | 97 }; |
115 | 98 |
116 #if BLINK_IMPLEMENTATION | 99 #if BLINK_IMPLEMENTATION |
117 #if defined(ENABLE_NEW_GAMEPAD_API) | |
118 COMPILE_ASSERT(sizeof(WebGamepad) == 721, WebGamepad_has_wrong_size); | 100 COMPILE_ASSERT(sizeof(WebGamepad) == 721, WebGamepad_has_wrong_size); |
119 #else | |
120 COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size); | |
121 #endif | |
122 #endif | 101 #endif |
123 | 102 |
124 #pragma pack(pop) | 103 #pragma pack(pop) |
125 | 104 |
126 } | 105 } |
127 | 106 |
128 #endif // WebGamepad_h | 107 #endif // WebGamepad_h |
OLD | NEW |