Bug 1863873 - Block ability to perform audio decoding outside of Utility on release...
[gecko.git] / dom / gamepad / GamepadPoseState.h
blob2272b84c76d804c04a2c7d66fbc32a45e58bf165
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/. */
7 #ifndef mozilla_dom_gamepad_GamepadPoseState_h_
8 #define mozilla_dom_gamepad_GamepadPoseState_h_
10 namespace mozilla::dom {
12 enum class GamepadCapabilityFlags : uint16_t {
13 Cap_None = 0,
14 /**
15 * Cap_Position is set if the Gamepad is capable of tracking its position.
17 Cap_Position = 1 << 1,
18 /**
19 * Cap_Orientation is set if the Gamepad is capable of tracking its
20 * orientation.
22 Cap_Orientation = 1 << 2,
23 /**
24 * Cap_AngularAcceleration is set if the Gamepad is capable of tracking its
25 * angular acceleration.
27 Cap_AngularAcceleration = 1 << 3,
28 /**
29 * Cap_LinearAcceleration is set if the Gamepad is capable of tracking its
30 * linear acceleration.
32 Cap_LinearAcceleration = 1 << 4,
33 /**
34 * Cap_GripSpacePosition is set if the Gamepad has a grip space position.
36 Cap_GripSpacePosition = 1 << 5,
37 /**
38 * Cap_PositionEmulated is set if the VRDisplay is capable of setting a
39 * emulated position (e.g. neck model) even if still doesn't support 6DOF
40 * tracking.
42 Cap_PositionEmulated = 1 << 6,
43 /**
44 * Cap_All used for validity checking during IPC serialization
46 Cap_All = (1 << 7) - 1
49 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(GamepadCapabilityFlags)
51 struct GamepadPoseState {
52 GamepadCapabilityFlags flags;
53 float orientation[4];
54 float position[3];
55 float angularVelocity[3];
56 float angularAcceleration[3];
57 float linearVelocity[3];
58 float linearAcceleration[3];
59 bool isPositionValid;
60 bool isOrientationValid;
62 GamepadPoseState()
63 : flags(GamepadCapabilityFlags::Cap_None),
64 orientation{0, 0, 0, 0},
65 position{0, 0, 0},
66 angularVelocity{0, 0, 0},
67 angularAcceleration{0, 0, 0},
68 linearVelocity{0, 0, 0},
69 linearAcceleration{0, 0, 0},
70 isPositionValid(false),
71 isOrientationValid(false) {}
73 bool operator==(const GamepadPoseState& aPose) const {
74 return flags == aPose.flags && orientation[0] == aPose.orientation[0] &&
75 orientation[1] == aPose.orientation[1] &&
76 orientation[2] == aPose.orientation[2] &&
77 orientation[3] == aPose.orientation[3] &&
78 position[0] == aPose.position[0] &&
79 position[1] == aPose.position[1] &&
80 position[2] == aPose.position[2] &&
81 angularVelocity[0] == aPose.angularVelocity[0] &&
82 angularVelocity[1] == aPose.angularVelocity[1] &&
83 angularVelocity[2] == aPose.angularVelocity[2] &&
84 angularAcceleration[0] == aPose.angularAcceleration[0] &&
85 angularAcceleration[1] == aPose.angularAcceleration[1] &&
86 angularAcceleration[2] == aPose.angularAcceleration[2] &&
87 linearVelocity[0] == aPose.linearVelocity[0] &&
88 linearVelocity[1] == aPose.linearVelocity[1] &&
89 linearVelocity[2] == aPose.linearVelocity[2] &&
90 linearAcceleration[0] == aPose.linearAcceleration[0] &&
91 linearAcceleration[1] == aPose.linearAcceleration[1] &&
92 linearAcceleration[2] == aPose.linearAcceleration[2] &&
93 isPositionValid == aPose.isPositionValid &&
94 isOrientationValid == aPose.isOrientationValid;
97 bool operator!=(const GamepadPoseState& aPose) const {
98 return !(*this == aPose);
101 void Clear() {
102 memset(&flags, 0,
103 reinterpret_cast<char*>(&isOrientationValid) +
104 sizeof(isOrientationValid) - reinterpret_cast<char*>(&flags));
108 } // namespace mozilla::dom
110 #endif // mozilla_dom_gamepad_GamepadPoseState_h_