objc2_game_controller/generated/GCControllerAxisInput.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/// Set this block if you want to be notified when the value on this axis changes.
10///
11///
12/// Parameter `axis`: the element that has been modified.
13///
14/// Parameter `value`: the value the axis was set to at the time the valueChangedHandler fired.
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrolleraxisvaluechangedhandler?language=objc)
17#[cfg(all(feature = "GCControllerElement", feature = "block2"))]
18pub type GCControllerAxisValueChangedHandler =
19 *mut block2::Block<dyn Fn(NonNull<GCControllerAxisInput>, c_float)>;
20
21extern_class!(
22 /// [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gccontrolleraxisinput?language=objc)
23 #[unsafe(super(GCControllerElement, NSObject))]
24 #[derive(Debug, PartialEq, Eq, Hash)]
25 #[cfg(feature = "GCControllerElement")]
26 pub struct GCControllerAxisInput;
27);
28
29#[cfg(feature = "GCControllerElement")]
30unsafe impl NSObjectProtocol for GCControllerAxisInput {}
31
32#[cfg(feature = "GCControllerElement")]
33impl GCControllerAxisInput {
34 extern_methods!(
35 #[cfg(feature = "block2")]
36 #[unsafe(method(valueChangedHandler))]
37 #[unsafe(method_family = none)]
38 pub unsafe fn valueChangedHandler(&self) -> GCControllerAxisValueChangedHandler;
39
40 #[cfg(feature = "block2")]
41 /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
42 #[unsafe(method(setValueChangedHandler:))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn setValueChangedHandler(
45 &self,
46 value_changed_handler: GCControllerAxisValueChangedHandler,
47 );
48
49 /// A normalized value for the input, between -1 and 1 for axis inputs. The values are deadzoned and saturated before they are returned
50 /// so there is no value ouside the range. Deadzoning does not remove values from the range, the full 0 to 1 magnitude of values
51 /// are possible from the input.
52 ///
53 /// As an axis is often used in a digital sense, you can rely on a value of 0 meaning the axis is inside the deadzone.
54 /// Any value greater than or less than zero is not in the deadzone.
55 #[unsafe(method(value))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn value(&self) -> c_float;
58
59 /// Sets the normalized value for the input.
60 ///
61 ///
62 /// Parameter `value`: the value to set the input to.
63 ///
64 /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
65 ///
66 /// See: value
67 #[unsafe(method(setValue:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn setValue(&self, value: c_float);
70 );
71}
72
73/// Methods declared on superclass `NSObject`.
74#[cfg(feature = "GCControllerElement")]
75impl GCControllerAxisInput {
76 extern_methods!(
77 #[unsafe(method(init))]
78 #[unsafe(method_family = init)]
79 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
80
81 #[unsafe(method(new))]
82 #[unsafe(method_family = new)]
83 pub unsafe fn new() -> Retained<Self>;
84 );
85}