objc2_game_controller/generated/
GCDualSenseAdaptiveTrigger.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// The number of discrete control positions supported by the DualSense adaptive triggers. Each of these positions can be configured separately in multi-position feedback and multi-position vibration modes.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetriggerdiscretepositioncount?language=objc)
12pub const GCDualSenseAdaptiveTriggerDiscretePositionCount: c_uint = 10;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetriggermode?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct GCDualSenseAdaptiveTriggerMode(pub NSInteger);
19impl GCDualSenseAdaptiveTriggerMode {
20    /// The adaptive trigger effect is disabled.
21    #[doc(alias = "GCDualSenseAdaptiveTriggerModeOff")]
22    pub const Off: Self = Self(0);
23    /// The adaptive trigger effect provides constant feedback from the start position onwards.
24    #[doc(alias = "GCDualSenseAdaptiveTriggerModeFeedback")]
25    pub const Feedback: Self = Self(1);
26    /// The adaptive trigger effect provides feedback from the start position to the end position, emulating the feeling of pulling the trigger on a weapon.
27    #[doc(alias = "GCDualSenseAdaptiveTriggerModeWeapon")]
28    pub const Weapon: Self = Self(2);
29    /// The adaptive trigger effect provides a constant vibration effect from the start position onwards.
30    #[doc(alias = "GCDualSenseAdaptiveTriggerModeVibration")]
31    pub const Vibration: Self = Self(3);
32    /// The adaptive trigger effect provides feedback from the start position to the end position, linearly interpolated between the start and end strengths.
33    #[doc(alias = "GCDualSenseAdaptiveTriggerModeSlopeFeedback")]
34    pub const SlopeFeedback: Self = Self(4);
35}
36
37unsafe impl Encode for GCDualSenseAdaptiveTriggerMode {
38    const ENCODING: Encoding = NSInteger::ENCODING;
39}
40
41unsafe impl RefEncode for GCDualSenseAdaptiveTriggerMode {
42    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
43}
44
45/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetriggerstatus?language=objc)
46// NS_ENUM
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct GCDualSenseAdaptiveTriggerStatus(pub NSInteger);
50impl GCDualSenseAdaptiveTriggerStatus {
51    /// The adaptive trigger status cannot be determined.
52    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusUnknown")]
53    pub const Unknown: Self = Self(-1);
54    /// The adaptive trigger is in feedback mode, and a resistive load has not been applied yet.
55    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusFeedbackNoLoad")]
56    pub const FeedbackNoLoad: Self = Self(0);
57    /// The adaptive trigger is in feedback mode, and a resistive load is applied.
58    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusFeedbackLoadApplied")]
59    pub const FeedbackLoadApplied: Self = Self(1);
60    /// The adaptive trigger is in weapon mode, the trigger is ready to fire, and a resistive load has not been applied yet.
61    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusWeaponReady")]
62    pub const WeaponReady: Self = Self(2);
63    /// The adaptive trigger is in weapon mode, the trigger is firing, and a resistive load is currently being applied.
64    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusWeaponFiring")]
65    pub const WeaponFiring: Self = Self(3);
66    /// The adaptive trigger is in weapon mode, the trigger has fired, and a resistive load is no longer being applied.
67    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusWeaponFired")]
68    pub const WeaponFired: Self = Self(4);
69    /// The adaptive trigger is in vibration mode, and the trigger is not vibrating.
70    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusVibrationNotVibrating")]
71    pub const VibrationNotVibrating: Self = Self(5);
72    /// The adaptive trigger is in vibration mode, and the trigger is currently vibrating.
73    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusVibrationIsVibrating")]
74    pub const VibrationIsVibrating: Self = Self(6);
75    /// The adaptive trigger is in slope feedback mode, the trigger is ready to apply a resistive load, but a resistive load has not been applied yet.
76    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusSlopeFeedbackReady")]
77    pub const SlopeFeedbackReady: Self = Self(7);
78    /// The adaptive trigger is in slope feedback mode, and a resistive load is currently being applied to the trigger.
79    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusSlopeFeedbackApplyingLoad")]
80    pub const SlopeFeedbackApplyingLoad: Self = Self(8);
81    /// The adaptive trigger is in slope feedback mode, a resistive load has previously been applied, but is no longer being applied.
82    #[doc(alias = "GCDualSenseAdaptiveTriggerStatusSlopeFeedbackFinished")]
83    pub const SlopeFeedbackFinished: Self = Self(9);
84}
85
86unsafe impl Encode for GCDualSenseAdaptiveTriggerStatus {
87    const ENCODING: Encoding = NSInteger::ENCODING;
88}
89
90unsafe impl RefEncode for GCDualSenseAdaptiveTriggerStatus {
91    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
92}
93
94/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetriggerpositionalamplitudes?language=objc)
95#[repr(C)]
96#[derive(Clone, Copy, Debug, PartialEq)]
97pub struct GCDualSenseAdaptiveTriggerPositionalAmplitudes {
98    /// An array of amplitudes associated with the GCDualSenseAdaptiveTriggerDiscretePositionCount control positions supported by the DualSense adaptive triggers.
99    pub values: [c_float; 10],
100}
101
102unsafe impl Encode for GCDualSenseAdaptiveTriggerPositionalAmplitudes {
103    const ENCODING: Encoding = Encoding::Struct("?", &[<[c_float; 10]>::ENCODING]);
104}
105
106unsafe impl RefEncode for GCDualSenseAdaptiveTriggerPositionalAmplitudes {
107    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
108}
109
110/// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetriggerpositionalresistivestrengths?language=objc)
111#[repr(C)]
112#[derive(Clone, Copy, Debug, PartialEq)]
113pub struct GCDualSenseAdaptiveTriggerPositionalResistiveStrengths {
114    /// An array of resistive strengths associated with the GCDualSenseAdaptiveTriggerDiscretePositionCount control positions supported by the DualSense adaptive triggers.
115    pub values: [c_float; 10],
116}
117
118unsafe impl Encode for GCDualSenseAdaptiveTriggerPositionalResistiveStrengths {
119    const ENCODING: Encoding = Encoding::Struct("?", &[<[c_float; 10]>::ENCODING]);
120}
121
122unsafe impl RefEncode for GCDualSenseAdaptiveTriggerPositionalResistiveStrengths {
123    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
124}
125
126extern_class!(
127    /// DualSense triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example.
128    ///
129    /// GCDualSenseAdaptiveTrigger represents an adaptive trigger on the Sony DualSense controller, allowing you to specify a dynamic resistance force
130    /// that is applied when pulling the trigger. This can, for example, be used to emulate the feeling of pulling back a bow string, firing a weapon, or pulling a lever.
131    ///
132    ///
133    /// See: GCDualSenseGamepad
134    ///
135    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetrigger?language=objc)
136    #[unsafe(super(GCControllerButtonInput, GCControllerElement, NSObject))]
137    #[derive(Debug, PartialEq, Eq, Hash)]
138    #[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
139    pub struct GCDualSenseAdaptiveTrigger;
140);
141
142#[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
143extern_conformance!(
144    unsafe impl NSObjectProtocol for GCDualSenseAdaptiveTrigger {}
145);
146
147#[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
148impl GCDualSenseAdaptiveTrigger {
149    extern_methods!(
150        /// The mode that the adaptive trigger is currently in. This property reflects the physical state of the triggers - and requires a response from the controller.
151        /// It does not update immediately after calling -[GCDualSenseAdaptiveTrigger setMode...].
152        ///
153        ///
154        /// See: GCDualSenseAdaptiveTriggerMode
155        #[unsafe(method(mode))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn mode(&self) -> GCDualSenseAdaptiveTriggerMode;
158
159        /// The current status of the adaptive trigger - whether it is ready to apply a load, is currently applying a load, or has finished applying a load.
160        ///
161        ///
162        /// See: GCDualSenseAdaptiveTriggerStatus
163        #[unsafe(method(status))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn status(&self) -> GCDualSenseAdaptiveTriggerStatus;
166
167        /// A normalized float from [0-1], with 0 representing the lowest possible trigger arm position and 1 representing the maximum trigger arm position.
168        ///
169        ///
170        /// See: GCDualSenseAdaptiveTriggerStatus
171        #[unsafe(method(armPosition))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn armPosition(&self) -> c_float;
174
175        /// Sets the adaptive trigger to slope feedback mode. The start position, end position, start strength, and end strength of the effect can be set arbitrarily; however the end position must be larger than the start position.
176        /// The trigger arm will provide a linearly interpolated degree of feedback whenever it is depressed between the start and end positions based on the starting and ending strengths.
177        ///
178        ///
179        /// Parameter `startPosition`: - A normalized float from [0-1], with 0 representing the smallest possible trigger depression and 1 representing the maximum trigger depression. The effect will begin once the trigger is depressed beyond this point.
180        ///
181        /// Parameter `endPosition`: - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. Must be greater than startPosition. The effect will end once the trigger is depressed beyond this point.
182        ///
183        /// Parameter `startStrength`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength. The effect will begin at startStrength once the trigger is depressed beyond startPosition.
184        ///
185        /// Parameter `endStrength`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength. The effect will end at endStrength once the trigger is depressed to endPosition.
186        #[unsafe(method(setModeSlopeFeedbackWithStartPosition:endPosition:startStrength:endStrength:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setModeSlopeFeedbackWithStartPosition_endPosition_startStrength_endStrength(
189            &self,
190            start_position: c_float,
191            end_position: c_float,
192            start_strength: c_float,
193            end_strength: c_float,
194        );
195
196        /// Sets the adaptive trigger to feedback mode. The start position and strength of the effect can be set arbitrarily. The trigger arm will continue to provide a
197        /// constant degree of feedback whenever it is depressed further than the start position.
198        ///
199        ///
200        /// Parameter `startPosition`: - A normalized float from [0-1], with 0 representing the smallest possible trigger depression and 1 representing the maximum trigger depression.
201        ///
202        /// Parameter `resistiveStrength`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
203        #[unsafe(method(setModeFeedbackWithStartPosition:resistiveStrength:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setModeFeedbackWithStartPosition_resistiveStrength(
206            &self,
207            start_position: c_float,
208            resistive_strength: c_float,
209        );
210
211        /// Sets the adaptive trigger to feedback mode. The strength of the effect can be set for each possible trigger position. The trigger arm will provide a degree of feedback based on the resistive strength for a given position.
212        ///
213        ///
214        /// Parameter `positionalResistiveStrengths`: - Positional normalized floats from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
215        #[unsafe(method(setModeFeedbackWithResistiveStrengths:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setModeFeedbackWithResistiveStrengths(
218            &self,
219            positional_resistive_strengths: GCDualSenseAdaptiveTriggerPositionalResistiveStrengths,
220        );
221
222        /// Sets the adaptive trigger to weapon mode. The start position, end position, and strength of the effect can be set arbitrarily; however the end position must be larger than the start position.
223        /// The trigger arm will continue to provide a constant degree of feedback whenever it is depressed further than the start position. Once the trigger arm has been depressed past the end
224        /// position, the strength of the effect will immediately fall to zero, providing a "sense of release" similar to that provided by pulling the trigger of a weapon.
225        ///
226        ///
227        /// Parameter `startPosition`: - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. The effect will begin once the trigger is depressed beyond this point.
228        ///
229        /// Parameter `endPosition`: - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. Must be greater than startPosition. The effect will end once the trigger is depressed beyond this point.
230        ///
231        /// Parameter `resistiveStrength`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
232        #[unsafe(method(setModeWeaponWithStartPosition:endPosition:resistiveStrength:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setModeWeaponWithStartPosition_endPosition_resistiveStrength(
235            &self,
236            start_position: c_float,
237            end_position: c_float,
238            resistive_strength: c_float,
239        );
240
241        /// Sets the adaptive trigger to vibration mode. The start position, amplitude, and frequency of the effect can be set arbitrarily. The trigger arm will continue to strike against
242        /// the trigger whenever it is depressed further than the start position, providing a "sense of vibration".
243        ///
244        ///
245        /// Parameter `startPosition`: - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. The effect will begin once the trigger is depressed beyond this point.
246        ///
247        /// Parameter `amplitude`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
248        ///
249        /// Parameter `frequency`: - A normalized float from [0-1], with 0 representing the minimum frequency and 1 representing the maximum frequency of the vibration effect.
250        #[unsafe(method(setModeVibrationWithStartPosition:amplitude:frequency:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setModeVibrationWithStartPosition_amplitude_frequency(
253            &self,
254            start_position: c_float,
255            amplitude: c_float,
256            frequency: c_float,
257        );
258
259        /// Sets the adaptive trigger to vibration mode. The amplitude of the effect can be set for each possible trigger position. The trigger arm will provide a degree of feedback based on the amplitude for a given position. The trigger arm will continue to strike against the trigger, providing a "sense of vibration".
260        ///
261        ///
262        /// Parameter `positionalAmplitudes`: - Positional normalized floats from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
263        ///
264        /// Parameter `frequency`: - A normalized float from [0-1], with 0 representing the minimum frequency and 1 representing the maximum frequency of the vibration effect.
265        #[unsafe(method(setModeVibrationWithAmplitudes:frequency:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn setModeVibrationWithAmplitudes_frequency(
268            &self,
269            positional_amplitudes: GCDualSenseAdaptiveTriggerPositionalAmplitudes,
270            frequency: c_float,
271        );
272
273        /// Sets the adaptive trigger to off mode. This turns off the adaptive trigger effect.
274        #[unsafe(method(setModeOff))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setModeOff(&self);
277    );
278}
279
280/// Methods declared on superclass `NSObject`.
281#[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
282impl GCDualSenseAdaptiveTrigger {
283    extern_methods!(
284        #[unsafe(method(init))]
285        #[unsafe(method_family = init)]
286        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
287
288        #[unsafe(method(new))]
289        #[unsafe(method_family = new)]
290        pub unsafe fn new() -> Retained<Self>;
291    );
292}