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::DynBlock<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")]
30extern_conformance!(
31    unsafe impl NSObjectProtocol for GCControllerAxisInput {}
32);
33
34#[cfg(feature = "GCControllerElement")]
35impl GCControllerAxisInput {
36    extern_methods!(
37        #[cfg(feature = "block2")]
38        /// # Safety
39        ///
40        /// The returned block's argument 1 must be a valid pointer.
41        #[unsafe(method(valueChangedHandler))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn valueChangedHandler(&self) -> GCControllerAxisValueChangedHandler;
44
45        #[cfg(feature = "block2")]
46        /// Setter for [`valueChangedHandler`][Self::valueChangedHandler].
47        ///
48        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
49        ///
50        /// # Safety
51        ///
52        /// `value_changed_handler` must be a valid pointer or null.
53        #[unsafe(method(setValueChangedHandler:))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn setValueChangedHandler(
56            &self,
57            value_changed_handler: GCControllerAxisValueChangedHandler,
58        );
59
60        /// A normalized value for the input, between -1 and 1 for axis inputs. The values are deadzoned and saturated before they are returned
61        /// so there is no value ouside the range. Deadzoning does not remove values from the range, the full 0 to 1 magnitude of values
62        /// are possible from the input.
63        ///
64        /// 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.
65        /// Any value greater than or less than zero is not in the deadzone.
66        #[unsafe(method(value))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn value(&self) -> c_float;
69
70        /// Sets the normalized value for the input.
71        ///
72        ///
73        /// Parameter `value`: the value to set the input to.
74        ///
75        /// Note: If the controller's snapshot flag is set to NO, this method has no effect.
76        ///
77        /// See: value
78        #[unsafe(method(setValue:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setValue(&self, value: c_float);
81    );
82}
83
84/// Methods declared on superclass `NSObject`.
85#[cfg(feature = "GCControllerElement")]
86impl GCControllerAxisInput {
87    extern_methods!(
88        #[unsafe(method(init))]
89        #[unsafe(method_family = init)]
90        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
91
92        #[unsafe(method(new))]
93        #[unsafe(method_family = new)]
94        pub unsafe fn new() -> Retained<Self>;
95    );
96}