Line data Source code
1 :
2 : #ifndef mozilla_dom_gamepad_GamepadPoseState_h_
3 : #define mozilla_dom_gamepad_GamepadPoseState_h_
4 :
5 : namespace mozilla{
6 : namespace dom{
7 :
8 : enum class GamepadCapabilityFlags : uint16_t {
9 : Cap_None = 0,
10 : /**
11 : * Cap_Position is set if the Gamepad is capable of tracking its position.
12 : */
13 : Cap_Position = 1 << 1,
14 : /**
15 : * Cap_Orientation is set if the Gamepad is capable of tracking its orientation.
16 : */
17 : Cap_Orientation = 1 << 2,
18 : /**
19 : * Cap_AngularAcceleration is set if the Gamepad is capable of tracking its
20 : * angular acceleration.
21 : */
22 : Cap_AngularAcceleration = 1 << 3,
23 : /**
24 : * Cap_LinearAcceleration is set if the Gamepad is capable of tracking its
25 : * linear acceleration.
26 : */
27 : Cap_LinearAcceleration = 1 << 4,
28 : /**
29 : * Cap_All used for validity checking during IPC serialization
30 : */
31 : Cap_All = (1 << 5) - 1
32 : };
33 :
34 0 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(GamepadCapabilityFlags)
35 :
36 : struct GamepadPoseState
37 : {
38 : GamepadCapabilityFlags flags;
39 : float orientation[4];
40 : float position[3];
41 : float angularVelocity[3];
42 : float angularAcceleration[3];
43 : float linearVelocity[3];
44 : float linearAcceleration[3];
45 : bool isPositionValid;
46 : bool isOrientationValid;
47 :
48 0 : GamepadPoseState()
49 0 : {
50 0 : Clear();
51 0 : }
52 :
53 0 : bool operator==(const GamepadPoseState& aPose) const
54 : {
55 0 : return flags == aPose.flags
56 0 : && orientation[0] == aPose.orientation[0]
57 0 : && orientation[1] == aPose.orientation[1]
58 0 : && orientation[2] == aPose.orientation[2]
59 0 : && orientation[3] == aPose.orientation[3]
60 0 : && position[0] == aPose.position[0]
61 0 : && position[1] == aPose.position[1]
62 0 : && position[2] == aPose.position[2]
63 0 : && angularVelocity[0] == aPose.angularVelocity[0]
64 0 : && angularVelocity[1] == aPose.angularVelocity[1]
65 0 : && angularVelocity[2] == aPose.angularVelocity[2]
66 0 : && angularAcceleration[0] == aPose.angularAcceleration[0]
67 0 : && angularAcceleration[1] == aPose.angularAcceleration[1]
68 0 : && angularAcceleration[2] == aPose.angularAcceleration[2]
69 0 : && linearVelocity[0] == aPose.linearVelocity[0]
70 0 : && linearVelocity[1] == aPose.linearVelocity[1]
71 0 : && linearVelocity[2] == aPose.linearVelocity[2]
72 0 : && linearAcceleration[0] == aPose.linearAcceleration[0]
73 0 : && linearAcceleration[1] == aPose.linearAcceleration[1]
74 0 : && linearAcceleration[2] == aPose.linearAcceleration[2]
75 0 : && isPositionValid == aPose.isPositionValid
76 0 : && isOrientationValid == aPose.isOrientationValid;
77 : }
78 :
79 0 : bool operator!=(const GamepadPoseState& aPose) const
80 : {
81 0 : return !(*this == aPose);
82 : }
83 :
84 0 : void Clear() {
85 0 : memset(this, 0, sizeof(GamepadPoseState));
86 0 : }
87 : };
88 :
89 : }// namespace dom
90 : }// namespace mozilla
91 :
92 : #endif // mozilla_dom_gamepad_GamepadPoseState_h_
|