1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GCAcceleration {
    pub x: c_double,
    pub y: c_double,
    pub z: c_double,
}

unsafe impl Encode for GCAcceleration {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <c_double>::ENCODING,
            <c_double>::ENCODING,
            <c_double>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for GCAcceleration {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GCRotationRate {
    pub x: c_double,
    pub y: c_double,
    pub z: c_double,
}

unsafe impl Encode for GCRotationRate {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <c_double>::ENCODING,
            <c_double>::ENCODING,
            <c_double>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for GCRotationRate {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GCEulerAngles {
    pub pitch: c_double,
    pub yaw: c_double,
    pub roll: c_double,
}

unsafe impl Encode for GCEulerAngles {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <c_double>::ENCODING,
            <c_double>::ENCODING,
            <c_double>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for GCEulerAngles {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GCQuaternion {
    pub x: c_double,
    pub y: c_double,
    pub z: c_double,
    pub w: c_double,
}

unsafe impl Encode for GCQuaternion {
    const ENCODING: Encoding = Encoding::Struct(
        "GCQuaternion",
        &[
            <c_double>::ENCODING,
            <c_double>::ENCODING,
            <c_double>::ENCODING,
            <c_double>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for GCQuaternion {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "block2")]
pub type GCMotionValueChangedHandler = *mut Block<dyn Fn(NonNull<GCMotion>)>;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GCMotion;

    unsafe impl ClassType for GCMotion {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for GCMotion {}

extern_methods!(
    unsafe impl GCMotion {
        #[cfg(feature = "GCController")]
        #[method_id(@__retain_semantics Other controller)]
        pub unsafe fn controller(&self) -> Option<Id<GCController>>;

        #[cfg(feature = "block2")]
        #[method(valueChangedHandler)]
        pub unsafe fn valueChangedHandler(&self) -> GCMotionValueChangedHandler;

        #[cfg(feature = "block2")]
        #[method(setValueChangedHandler:)]
        pub unsafe fn setValueChangedHandler(
            &self,
            value_changed_handler: GCMotionValueChangedHandler,
        );

        #[method(sensorsRequireManualActivation)]
        pub unsafe fn sensorsRequireManualActivation(&self) -> bool;

        #[method(sensorsActive)]
        pub unsafe fn sensorsActive(&self) -> bool;

        #[method(setSensorsActive:)]
        pub unsafe fn setSensorsActive(&self, sensors_active: bool);

        #[method(hasGravityAndUserAcceleration)]
        pub unsafe fn hasGravityAndUserAcceleration(&self) -> bool;

        #[method(gravity)]
        pub unsafe fn gravity(&self) -> GCAcceleration;

        #[method(userAcceleration)]
        pub unsafe fn userAcceleration(&self) -> GCAcceleration;

        #[method(acceleration)]
        pub unsafe fn acceleration(&self) -> GCAcceleration;

        #[deprecated = "hasAttitudeAndRotationRate has been deprecated, use -hasAttitude and -hasRotationRate instead"]
        #[method(hasAttitudeAndRotationRate)]
        pub unsafe fn hasAttitudeAndRotationRate(&self) -> bool;

        #[method(hasAttitude)]
        pub unsafe fn hasAttitude(&self) -> bool;

        #[method(hasRotationRate)]
        pub unsafe fn hasRotationRate(&self) -> bool;

        #[method(attitude)]
        pub unsafe fn attitude(&self) -> GCQuaternion;

        #[method(rotationRate)]
        pub unsafe fn rotationRate(&self) -> GCRotationRate;

        #[method(setGravity:)]
        pub unsafe fn setGravity(&self, gravity: GCAcceleration);

        #[method(setUserAcceleration:)]
        pub unsafe fn setUserAcceleration(&self, user_acceleration: GCAcceleration);

        #[method(setAcceleration:)]
        pub unsafe fn setAcceleration(&self, acceleration: GCAcceleration);

        #[method(setAttitude:)]
        pub unsafe fn setAttitude(&self, attitude: GCQuaternion);

        #[method(setRotationRate:)]
        pub unsafe fn setRotationRate(&self, rotation_rate: GCRotationRate);

        #[method(setStateFromMotion:)]
        pub unsafe fn setStateFromMotion(&self, motion: &GCMotion);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl GCMotion {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);