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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #ifndef WebGamepad_h | 24 #ifndef WebGamepad_h |
25 #define WebGamepad_h | 25 #define WebGamepad_h |
26 | 26 |
27 #include "WebCommon.h" | 27 #include "WebCommon.h" |
28 | 28 |
29 #if BLINK_IMPLEMENTATION | 29 #if BLINK_IMPLEMENTATION |
30 #include "wtf/Assertions.h" | 30 #include "wtf/Assertions.h" |
31 #endif | 31 #endif |
32 | 32 |
33 // FIXME(cdumez): Remove once the Chromium side has been updated. | |
34 #define ENABLE_NEW_GAMEPAD_API 1 | |
35 | |
36 namespace blink { | 33 namespace blink { |
37 | 34 |
38 #pragma pack(push, 1) | 35 #pragma pack(push, 1) |
39 | 36 |
40 class WebGamepadButton { | 37 class WebGamepadButton { |
41 public: | 38 public: |
42 WebGamepadButton() | 39 WebGamepadButton() |
43 : pressed(false) | 40 : pressed(false) |
44 , value(0.) | 41 , value(0.f) |
45 { | 42 { |
46 } | 43 } |
47 WebGamepadButton(bool pressed, double value) | 44 WebGamepadButton(bool pressed, float value) |
48 : pressed(pressed) | 45 : pressed(pressed) |
49 , value(value) | 46 , value(value) |
50 { | 47 { |
51 } | 48 } |
52 bool pressed; | 49 bool pressed; |
53 double value; | 50 float value; |
54 }; | 51 }; |
55 | 52 |
56 // 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 |
57 // 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 |
58 // also WebGamepads.h. | 55 // also WebGamepads.h. |
59 class WebGamepad { | 56 class WebGamepad { |
60 public: | 57 public: |
61 static const size_t idLengthCap = 128; | 58 static const size_t idLengthCap = 128; |
62 static const size_t mappingLengthCap = 16; | 59 static const size_t mappingLengthCap = 16; |
63 static const size_t axesLengthCap = 16; | 60 static const size_t axesLengthCap = 16; |
(...skipping 16 matching lines...) Expand all Loading... |
80 WebUChar id[idLengthCap]; | 77 WebUChar id[idLengthCap]; |
81 | 78 |
82 // Monotonically increasing value referring to when the data were last | 79 // Monotonically increasing value referring to when the data were last |
83 // updated. | 80 // updated. |
84 unsigned long long timestamp; | 81 unsigned long long timestamp; |
85 | 82 |
86 // Number of valid entries in the axes array. | 83 // Number of valid entries in the axes array. |
87 unsigned axesLength; | 84 unsigned axesLength; |
88 | 85 |
89 // Normalized values representing axes, in the range [-1..1]. | 86 // Normalized values representing axes, in the range [-1..1]. |
90 double axes[axesLengthCap]; | 87 float axes[axesLengthCap]; |
91 | 88 |
92 // Number of valid entries in the buttons array. | 89 // Number of valid entries in the buttons array. |
93 unsigned buttonsLength; | 90 unsigned buttonsLength; |
94 | 91 |
95 // Button states | 92 // Button states |
96 WebGamepadButton buttons[buttonsLengthCap]; | 93 WebGamepadButton buttons[buttonsLengthCap]; |
97 | 94 |
98 // Mapping type (for example "standard") | 95 // Mapping type (for example "standard") |
99 WebUChar mapping[mappingLengthCap]; | 96 WebUChar mapping[mappingLengthCap]; |
100 }; | 97 }; |
101 | 98 |
102 #if BLINK_IMPLEMENTATION | 99 #if BLINK_IMPLEMENTATION |
103 COMPILE_ASSERT(sizeof(WebGamepad) == 721, WebGamepad_has_wrong_size); | 100 COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size); |
104 #endif | 101 #endif |
105 | 102 |
106 #pragma pack(pop) | 103 #pragma pack(pop) |
107 | 104 |
108 } | 105 } |
109 | 106 |
110 #endif // WebGamepad_h | 107 #endif // WebGamepad_h |
OLD | NEW |