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