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.) |
| 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 Loading... |
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 |
OLD | NEW |