| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2011, Google Inc. All rights reserved. | |
| 2 // | |
| 3 // Redistribution and use in source and binary forms, with or without | |
| 4 // modification, are permitted provided that the following conditions are met: | |
| 5 // | |
| 6 // 1. Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // 2. Redistributions in binary form must reproduce the above copyright | |
| 9 // notice, this list of conditions and the following disclaimer in the | |
| 10 // documentation and/or other materials provided with the distribution. | |
| 11 // | |
| 12 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND | |
| 13 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 14 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 15 // ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE | |
| 16 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 17 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 18 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 19 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 20 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 21 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
| 22 // DAMAGE. | |
| 23 | |
| 24 #ifndef WebGamepad_h | |
| 25 #define WebGamepad_h | |
| 26 | |
| 27 #include "WebCommon.h" | |
| 28 | |
| 29 namespace blink { | |
| 30 | |
| 31 #pragma pack(push, 4) | |
| 32 | |
| 33 class WebGamepadButton { | |
| 34 public: | |
| 35 WebGamepadButton() : pressed(false), touched(false), value(0.) {} | |
| 36 WebGamepadButton(bool pressed, bool touched, double value) | |
| 37 : pressed(pressed), touched(touched), value(value) {} | |
| 38 bool pressed; | |
| 39 bool touched; | |
| 40 double value; | |
| 41 }; | |
| 42 | |
| 43 class WebGamepadVector { | |
| 44 public: | |
| 45 WebGamepadVector() : not_null(false) {} | |
| 46 | |
| 47 bool not_null; | |
| 48 float x, y, z; | |
| 49 }; | |
| 50 | |
| 51 class WebGamepadQuaternion { | |
| 52 public: | |
| 53 WebGamepadQuaternion() : not_null(false) {} | |
| 54 | |
| 55 bool not_null; | |
| 56 float x, y, z, w; | |
| 57 }; | |
| 58 | |
| 59 class WebGamepadPose { | |
| 60 public: | |
| 61 WebGamepadPose() : not_null(false) {} | |
| 62 | |
| 63 bool not_null; | |
| 64 | |
| 65 bool has_orientation; | |
| 66 bool has_position; | |
| 67 | |
| 68 WebGamepadQuaternion orientation; | |
| 69 WebGamepadVector position; | |
| 70 WebGamepadVector angular_velocity; | |
| 71 WebGamepadVector linear_velocity; | |
| 72 WebGamepadVector angular_acceleration; | |
| 73 WebGamepadVector linear_acceleration; | |
| 74 }; | |
| 75 | |
| 76 enum WebGamepadHand { | |
| 77 kGamepadHandNone = 0, | |
| 78 kGamepadHandLeft = 1, | |
| 79 kGamepadHandRight = 2 | |
| 80 }; | |
| 81 | |
| 82 // This structure is intentionally POD and fixed size so that it can be shared | |
| 83 // memory between hardware polling threads and the rest of the browser. See | |
| 84 // also WebGamepads.h. | |
| 85 class WebGamepad { | |
| 86 public: | |
| 87 static const size_t kIdLengthCap = 128; | |
| 88 static const size_t kMappingLengthCap = 16; | |
| 89 static const size_t kAxesLengthCap = 16; | |
| 90 static const size_t kButtonsLengthCap = 32; | |
| 91 | |
| 92 WebGamepad() | |
| 93 : connected(false), | |
| 94 timestamp(0), | |
| 95 axes_length(0), | |
| 96 buttons_length(0), | |
| 97 display_id(0) { | |
| 98 id[0] = 0; | |
| 99 mapping[0] = 0; | |
| 100 } | |
| 101 | |
| 102 // Is there a gamepad connected at this index? | |
| 103 bool connected; | |
| 104 | |
| 105 // Device identifier (based on manufacturer, model, etc.). | |
| 106 WebUChar id[kIdLengthCap]; | |
| 107 | |
| 108 // Monotonically increasing value referring to when the data were last | |
| 109 // updated. | |
| 110 unsigned long long timestamp; | |
| 111 | |
| 112 // Number of valid entries in the axes array. | |
| 113 unsigned axes_length; | |
| 114 | |
| 115 // Normalized values representing axes, in the range [-1..1]. | |
| 116 double axes[kAxesLengthCap]; | |
| 117 | |
| 118 // Number of valid entries in the buttons array. | |
| 119 unsigned buttons_length; | |
| 120 | |
| 121 // Button states | |
| 122 WebGamepadButton buttons[kButtonsLengthCap]; | |
| 123 | |
| 124 // Mapping type (for example "standard") | |
| 125 WebUChar mapping[kMappingLengthCap]; | |
| 126 | |
| 127 WebGamepadPose pose; | |
| 128 | |
| 129 WebGamepadHand hand; | |
| 130 | |
| 131 unsigned display_id; | |
| 132 }; | |
| 133 | |
| 134 #pragma pack(pop) | |
| 135 } | |
| 136 | |
| 137 #endif // WebGamepad_h | |
| OLD | NEW |