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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 : pressed(pressed) | 42 : pressed(pressed) |
43 , touched(touched) | 43 , touched(touched) |
44 , value(value) | 44 , value(value) |
45 { | 45 { |
46 } | 46 } |
47 bool pressed; | 47 bool pressed; |
48 bool touched; | 48 bool touched; |
49 double value; | 49 double value; |
50 }; | 50 }; |
51 | 51 |
| 52 class WebGamepadVector { |
| 53 public: |
| 54 WebGamepadVector() |
| 55 : notNull(false) |
| 56 { |
| 57 } |
| 58 |
| 59 bool notNull; |
| 60 float x, y, z; |
| 61 }; |
| 62 |
| 63 class WebGamepadQuaternion { |
| 64 public: |
| 65 WebGamepadQuaternion() |
| 66 : notNull(false) |
| 67 { |
| 68 } |
| 69 |
| 70 bool notNull; |
| 71 float x, y, z, w; |
| 72 }; |
| 73 |
| 74 class WebGamepadPose { |
| 75 public: |
| 76 WebGamepadPose() |
| 77 : notNull(false) |
| 78 { |
| 79 } |
| 80 |
| 81 bool notNull; |
| 82 |
| 83 bool hasOrientation; |
| 84 bool hasPosition; |
| 85 |
| 86 WebGamepadQuaternion orientation; |
| 87 WebGamepadVector position; |
| 88 WebGamepadVector angularVelocity; |
| 89 WebGamepadVector linearVelocity; |
| 90 WebGamepadVector angularAcceleration; |
| 91 WebGamepadVector linearAcceleration; |
| 92 }; |
| 93 |
52 // This structure is intentionally POD and fixed size so that it can be shared | 94 // This structure is intentionally POD and fixed size so that it can be shared |
53 // memory between hardware polling threads and the rest of the browser. See | 95 // memory between hardware polling threads and the rest of the browser. See |
54 // also WebGamepads.h. | 96 // also WebGamepads.h. |
55 class WebGamepad { | 97 class WebGamepad { |
56 public: | 98 public: |
57 static const size_t idLengthCap = 128; | 99 static const size_t idLengthCap = 128; |
58 static const size_t mappingLengthCap = 16; | 100 static const size_t mappingLengthCap = 16; |
59 static const size_t axesLengthCap = 16; | 101 static const size_t axesLengthCap = 16; |
60 static const size_t buttonsLengthCap = 32; | 102 static const size_t buttonsLengthCap = 32; |
61 | 103 |
(...skipping 24 matching lines...) Expand all Loading... |
86 double axes[axesLengthCap]; | 128 double axes[axesLengthCap]; |
87 | 129 |
88 // Number of valid entries in the buttons array. | 130 // Number of valid entries in the buttons array. |
89 unsigned buttonsLength; | 131 unsigned buttonsLength; |
90 | 132 |
91 // Button states | 133 // Button states |
92 WebGamepadButton buttons[buttonsLengthCap]; | 134 WebGamepadButton buttons[buttonsLengthCap]; |
93 | 135 |
94 // Mapping type (for example "standard") | 136 // Mapping type (for example "standard") |
95 WebUChar mapping[mappingLengthCap]; | 137 WebUChar mapping[mappingLengthCap]; |
| 138 |
| 139 WebGamepadPose pose; |
96 }; | 140 }; |
97 | 141 |
98 static_assert(sizeof(WebGamepad) == 753, "WebGamepad has wrong size"); | 142 static_assert(sizeof(WebGamepad) == 838, "WebGamepad has wrong size"); |
99 | 143 |
100 #pragma pack(pop) | 144 #pragma pack(pop) |
101 | 145 |
102 } | 146 } |
103 | 147 |
104 #endif // WebGamepad_h | 148 #endif // WebGamepad_h |
OLD | NEW |