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::Block<
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")]
45unsafe impl NSObjectProtocol for GCKeyboardInput {}
46
47#[cfg(feature = "GCPhysicalInputProfile")]
48impl GCKeyboardInput {
49    extern_methods!(
50        #[cfg(all(
51            feature = "GCControllerButtonInput",
52            feature = "GCControllerElement",
53            feature = "GCKeyCodes",
54            feature = "block2",
55            feature = "objc2-core-foundation"
56        ))]
57        #[unsafe(method(keyChangedHandler))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn keyChangedHandler(&self) -> GCKeyboardValueChangedHandler;
60
61        #[cfg(all(
62            feature = "GCControllerButtonInput",
63            feature = "GCControllerElement",
64            feature = "GCKeyCodes",
65            feature = "block2",
66            feature = "objc2-core-foundation"
67        ))]
68        /// Setter for [`keyChangedHandler`][Self::keyChangedHandler].
69        #[unsafe(method(setKeyChangedHandler:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn setKeyChangedHandler(
72            &self,
73            key_changed_handler: GCKeyboardValueChangedHandler,
74        );
75
76        /// Before querying any key for a value it might be useful to check if any key is actually pressed
77        #[unsafe(method(isAnyKeyPressed))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn isAnyKeyPressed(&self) -> bool;
80
81        #[cfg(all(
82            feature = "GCControllerButtonInput",
83            feature = "GCControllerElement",
84            feature = "GCKeyCodes",
85            feature = "objc2-core-foundation"
86        ))]
87        /// Alongside general subscript notation of GCPhysicalInputProfile keys can be accessed using this method.
88        ///
89        ///
90        ///
91        /// Parameter `code`: is a low level key code that can be used for accessing a keyboard button.
92        ///
93        /// Note: Full list of supported key constants can be found in GCKeyCodes.h and GCKeyNames.h
94        #[unsafe(method(buttonForKeyCode:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn buttonForKeyCode(
97            &self,
98            code: GCKeyCode,
99        ) -> Option<Retained<GCControllerButtonInput>>;
100    );
101}
102
103/// Methods declared on superclass `NSObject`.
104#[cfg(feature = "GCPhysicalInputProfile")]
105impl GCKeyboardInput {
106    extern_methods!(
107        #[unsafe(method(init))]
108        #[unsafe(method_family = init)]
109        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
110
111        #[unsafe(method(new))]
112        #[unsafe(method_family = new)]
113        pub unsafe fn new() -> Retained<Self>;
114    );
115}