/work/obj-fuzz/dist/include/mozilla/dom/GamepadPoseState.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_gamepad_GamepadPoseState_h_ |
8 | | #define mozilla_dom_gamepad_GamepadPoseState_h_ |
9 | | |
10 | | namespace mozilla{ |
11 | | namespace dom{ |
12 | | |
13 | | enum class GamepadCapabilityFlags : uint16_t { |
14 | | Cap_None = 0, |
15 | | /** |
16 | | * Cap_Position is set if the Gamepad is capable of tracking its position. |
17 | | */ |
18 | | Cap_Position = 1 << 1, |
19 | | /** |
20 | | * Cap_Orientation is set if the Gamepad is capable of tracking its orientation. |
21 | | */ |
22 | | Cap_Orientation = 1 << 2, |
23 | | /** |
24 | | * Cap_AngularAcceleration is set if the Gamepad is capable of tracking its |
25 | | * angular acceleration. |
26 | | */ |
27 | | Cap_AngularAcceleration = 1 << 3, |
28 | | /** |
29 | | * Cap_LinearAcceleration is set if the Gamepad is capable of tracking its |
30 | | * linear acceleration. |
31 | | */ |
32 | | Cap_LinearAcceleration = 1 << 4, |
33 | | /** |
34 | | * Cap_All used for validity checking during IPC serialization |
35 | | */ |
36 | | Cap_All = (1 << 5) - 1 |
37 | | }; |
38 | | |
39 | | MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(GamepadCapabilityFlags) |
40 | | |
41 | | struct GamepadPoseState |
42 | | { |
43 | | GamepadCapabilityFlags flags; |
44 | | float orientation[4]; |
45 | | float position[3]; |
46 | | float angularVelocity[3]; |
47 | | float angularAcceleration[3]; |
48 | | float linearVelocity[3]; |
49 | | float linearAcceleration[3]; |
50 | | bool isPositionValid; |
51 | | bool isOrientationValid; |
52 | | |
53 | | GamepadPoseState() |
54 | | : flags(GamepadCapabilityFlags::Cap_None) |
55 | | , orientation{ 0, 0, 0, 0 } |
56 | | , position{ 0, 0, 0} |
57 | | , angularVelocity{ 0, 0, 0} |
58 | | , angularAcceleration{ 0, 0, 0} |
59 | | , linearVelocity{ 0, 0, 0} |
60 | | , linearAcceleration{ 0, 0, 0} |
61 | | , isPositionValid(false) |
62 | | , isOrientationValid(false) |
63 | 0 | { |
64 | 0 | } |
65 | | |
66 | | bool operator==(const GamepadPoseState& aPose) const |
67 | 0 | { |
68 | 0 | return flags == aPose.flags |
69 | 0 | && orientation[0] == aPose.orientation[0] |
70 | 0 | && orientation[1] == aPose.orientation[1] |
71 | 0 | && orientation[2] == aPose.orientation[2] |
72 | 0 | && orientation[3] == aPose.orientation[3] |
73 | 0 | && position[0] == aPose.position[0] |
74 | 0 | && position[1] == aPose.position[1] |
75 | 0 | && position[2] == aPose.position[2] |
76 | 0 | && angularVelocity[0] == aPose.angularVelocity[0] |
77 | 0 | && angularVelocity[1] == aPose.angularVelocity[1] |
78 | 0 | && angularVelocity[2] == aPose.angularVelocity[2] |
79 | 0 | && angularAcceleration[0] == aPose.angularAcceleration[0] |
80 | 0 | && angularAcceleration[1] == aPose.angularAcceleration[1] |
81 | 0 | && angularAcceleration[2] == aPose.angularAcceleration[2] |
82 | 0 | && linearVelocity[0] == aPose.linearVelocity[0] |
83 | 0 | && linearVelocity[1] == aPose.linearVelocity[1] |
84 | 0 | && linearVelocity[2] == aPose.linearVelocity[2] |
85 | 0 | && linearAcceleration[0] == aPose.linearAcceleration[0] |
86 | 0 | && linearAcceleration[1] == aPose.linearAcceleration[1] |
87 | 0 | && linearAcceleration[2] == aPose.linearAcceleration[2] |
88 | 0 | && isPositionValid == aPose.isPositionValid |
89 | 0 | && isOrientationValid == aPose.isOrientationValid; |
90 | 0 | } |
91 | | |
92 | | bool operator!=(const GamepadPoseState& aPose) const |
93 | 0 | { |
94 | 0 | return !(*this == aPose); |
95 | 0 | } |
96 | | |
97 | 0 | void Clear() { |
98 | 0 | memset(&flags, |
99 | 0 | 0, |
100 | 0 | reinterpret_cast<char*>(&isOrientationValid) + |
101 | 0 | sizeof(isOrientationValid) - reinterpret_cast<char*>(&flags)); |
102 | 0 | } |
103 | | }; |
104 | | |
105 | | }// namespace dom |
106 | | }// namespace mozilla |
107 | | |
108 | | #endif // mozilla_dom_gamepad_GamepadPoseState_h_ |