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"))]
143unsafe impl NSObjectProtocol for GCDualSenseAdaptiveTrigger {}
144
145#[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
146impl GCDualSenseAdaptiveTrigger {
147 extern_methods!(
148 /// 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.
149 /// It does not update immediately after calling -[GCDualSenseAdaptiveTrigger setMode...].
150 ///
151 ///
152 /// See: GCDualSenseAdaptiveTriggerMode
153 #[unsafe(method(mode))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn mode(&self) -> GCDualSenseAdaptiveTriggerMode;
156
157 /// 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.
158 ///
159 ///
160 /// See: GCDualSenseAdaptiveTriggerStatus
161 #[unsafe(method(status))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn status(&self) -> GCDualSenseAdaptiveTriggerStatus;
164
165 /// A normalized float from [0-1], with 0 representing the lowest possible trigger arm position and 1 representing the maximum trigger arm position.
166 ///
167 ///
168 /// See: GCDualSenseAdaptiveTriggerStatus
169 #[unsafe(method(armPosition))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn armPosition(&self) -> c_float;
172
173 /// 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.
174 /// 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.
175 ///
176 ///
177 /// 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.
178 ///
179 /// 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.
180 ///
181 /// 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.
182 ///
183 /// 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.
184 #[unsafe(method(setModeSlopeFeedbackWithStartPosition:endPosition:startStrength:endStrength:))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn setModeSlopeFeedbackWithStartPosition_endPosition_startStrength_endStrength(
187 &self,
188 start_position: c_float,
189 end_position: c_float,
190 start_strength: c_float,
191 end_strength: c_float,
192 );
193
194 /// 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
195 /// constant degree of feedback whenever it is depressed further than the start position.
196 ///
197 ///
198 /// Parameter `startPosition`: - A normalized float from [0-1], with 0 representing the smallest possible trigger depression and 1 representing the maximum trigger depression.
199 ///
200 /// Parameter `resistiveStrength`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
201 #[unsafe(method(setModeFeedbackWithStartPosition:resistiveStrength:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setModeFeedbackWithStartPosition_resistiveStrength(
204 &self,
205 start_position: c_float,
206 resistive_strength: c_float,
207 );
208
209 /// 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.
210 ///
211 ///
212 /// Parameter `positionalResistiveStrengths`: - Positional normalized floats from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
213 #[unsafe(method(setModeFeedbackWithResistiveStrengths:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn setModeFeedbackWithResistiveStrengths(
216 &self,
217 positional_resistive_strengths: GCDualSenseAdaptiveTriggerPositionalResistiveStrengths,
218 );
219
220 /// 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.
221 /// 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
222 /// 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.
223 ///
224 ///
225 /// 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.
226 ///
227 /// 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.
228 ///
229 /// Parameter `resistiveStrength`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
230 #[unsafe(method(setModeWeaponWithStartPosition:endPosition:resistiveStrength:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setModeWeaponWithStartPosition_endPosition_resistiveStrength(
233 &self,
234 start_position: c_float,
235 end_position: c_float,
236 resistive_strength: c_float,
237 );
238
239 /// 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
240 /// the trigger whenever it is depressed further than the start position, providing a "sense of vibration".
241 ///
242 ///
243 /// 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.
244 ///
245 /// Parameter `amplitude`: - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
246 ///
247 /// Parameter `frequency`: - A normalized float from [0-1], with 0 representing the minimum frequency and 1 representing the maximum frequency of the vibration effect.
248 #[unsafe(method(setModeVibrationWithStartPosition:amplitude:frequency:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setModeVibrationWithStartPosition_amplitude_frequency(
251 &self,
252 start_position: c_float,
253 amplitude: c_float,
254 frequency: c_float,
255 );
256
257 /// 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".
258 ///
259 ///
260 /// Parameter `positionalAmplitudes`: - Positional normalized floats from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
261 ///
262 /// Parameter `frequency`: - A normalized float from [0-1], with 0 representing the minimum frequency and 1 representing the maximum frequency of the vibration effect.
263 #[unsafe(method(setModeVibrationWithAmplitudes:frequency:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn setModeVibrationWithAmplitudes_frequency(
266 &self,
267 positional_amplitudes: GCDualSenseAdaptiveTriggerPositionalAmplitudes,
268 frequency: c_float,
269 );
270
271 /// Sets the adaptive trigger to off mode. This turns off the adaptive trigger effect.
272 #[unsafe(method(setModeOff))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn setModeOff(&self);
275 );
276}
277
278/// Methods declared on superclass `NSObject`.
279#[cfg(all(feature = "GCControllerButtonInput", feature = "GCControllerElement"))]
280impl GCDualSenseAdaptiveTrigger {
281 extern_methods!(
282 #[unsafe(method(init))]
283 #[unsafe(method_family = init)]
284 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
285
286 #[unsafe(method(new))]
287 #[unsafe(method_family = new)]
288 pub unsafe fn new() -> Retained<Self>;
289 );
290}