objc2_game_controller/generated/
GCKeyboardInput.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 a value of a key changed. If multiple keys have changed this block will be called
10/// cd  for each key that changed.
11///
12///
13/// Parameter `keyboard`: this keyboard that is being used to map the raw input data into logical values on keyboard keys.
14///
15/// Parameter `key`: the key that has been modified
16///
17/// Parameter `pressed`: the state of the key at the moment of block calling
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gckeyboardvaluechangedhandler?language=objc)
20#[cfg(all(
21    feature = "GCControllerButtonInput",
22    feature = "GCControllerElement",
23    feature = "GCKeyCodes",
24    feature = "GCPhysicalInputProfile",
25    feature = "block2",
26    feature = "objc2-core-foundation"
27))]
28pub type GCKeyboardValueChangedHandler = *mut block2::DynBlock<
29    dyn Fn(NonNull<GCKeyboardInput>, NonNull<GCControllerButtonInput>, GCKeyCode, Bool),
30>;
31
32extern_class!(
33    /// Keyboard profile. Contains the current state of buttons specified in GCKeyCodes.h.
34    ///
35    /// GCKeyboardInput is designed primarly for input polling. For the best text input experience, UIKit/AppKit usage is recommended.
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gckeyboardinput?language=objc)
38    #[unsafe(super(GCPhysicalInputProfile, NSObject))]
39    #[derive(Debug, PartialEq, Eq, Hash)]
40    #[cfg(feature = "GCPhysicalInputProfile")]
41    pub struct GCKeyboardInput;
42);
43
44#[cfg(feature = "GCPhysicalInputProfile")]
45extern_conformance!(
46    unsafe impl NSObjectProtocol for GCKeyboardInput {}
47);
48
49#[cfg(feature = "GCPhysicalInputProfile")]
50impl GCKeyboardInput {
51    extern_methods!(
52        #[cfg(all(
53            feature = "GCControllerButtonInput",
54            feature = "GCControllerElement",
55            feature = "GCKeyCodes",
56            feature = "block2",
57            feature = "objc2-core-foundation"
58        ))]
59        #[unsafe(method(keyChangedHandler))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn keyChangedHandler(&self) -> GCKeyboardValueChangedHandler;
62
63        #[cfg(all(
64            feature = "GCControllerButtonInput",
65            feature = "GCControllerElement",
66            feature = "GCKeyCodes",
67            feature = "block2",
68            feature = "objc2-core-foundation"
69        ))]
70        /// Setter for [`keyChangedHandler`][Self::keyChangedHandler].
71        #[unsafe(method(setKeyChangedHandler:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setKeyChangedHandler(
74            &self,
75            key_changed_handler: GCKeyboardValueChangedHandler,
76        );
77
78        /// Before querying any key for a value it might be useful to check if any key is actually pressed
79        #[unsafe(method(isAnyKeyPressed))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn isAnyKeyPressed(&self) -> bool;
82
83        #[cfg(all(
84            feature = "GCControllerButtonInput",
85            feature = "GCControllerElement",
86            feature = "GCKeyCodes",
87            feature = "objc2-core-foundation"
88        ))]
89        /// Alongside general subscript notation of GCPhysicalInputProfile keys can be accessed using this method.
90        ///
91        ///
92        ///
93        /// Parameter `code`: is a low level key code that can be used for accessing a keyboard button.
94        ///
95        /// Note: Full list of supported key constants can be found in GCKeyCodes.h and GCKeyNames.h
96        #[unsafe(method(buttonForKeyCode:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn buttonForKeyCode(
99            &self,
100            code: GCKeyCode,
101        ) -> Option<Retained<GCControllerButtonInput>>;
102    );
103}
104
105/// Methods declared on superclass `NSObject`.
106#[cfg(feature = "GCPhysicalInputProfile")]
107impl GCKeyboardInput {
108    extern_methods!(
109        #[unsafe(method(init))]
110        #[unsafe(method_family = init)]
111        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113        #[unsafe(method(new))]
114        #[unsafe(method_family = new)]
115        pub unsafe fn new() -> Retained<Self>;
116    );
117}