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 /// # Safety
60 ///
61 /// - The returned block's argument 1 must be a valid pointer.
62 /// - The returned block's argument 2 must be a valid pointer.
63 #[unsafe(method(keyChangedHandler))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn keyChangedHandler(&self) -> GCKeyboardValueChangedHandler;
66
67 #[cfg(all(
68 feature = "GCControllerButtonInput",
69 feature = "GCControllerElement",
70 feature = "GCKeyCodes",
71 feature = "block2",
72 feature = "objc2-core-foundation"
73 ))]
74 /// Setter for [`keyChangedHandler`][Self::keyChangedHandler].
75 ///
76 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
77 ///
78 /// # Safety
79 ///
80 /// `key_changed_handler` must be a valid pointer or null.
81 #[unsafe(method(setKeyChangedHandler:))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn setKeyChangedHandler(
84 &self,
85 key_changed_handler: GCKeyboardValueChangedHandler,
86 );
87
88 /// Before querying any key for a value it might be useful to check if any key is actually pressed
89 #[unsafe(method(isAnyKeyPressed))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn isAnyKeyPressed(&self) -> bool;
92
93 #[cfg(all(
94 feature = "GCControllerButtonInput",
95 feature = "GCControllerElement",
96 feature = "GCKeyCodes",
97 feature = "objc2-core-foundation"
98 ))]
99 /// Alongside general subscript notation of GCPhysicalInputProfile keys can be accessed using this method.
100 ///
101 ///
102 ///
103 /// Parameter `code`: is a low level key code that can be used for accessing a keyboard button.
104 ///
105 /// Note: Full list of supported key constants can be found in GCKeyCodes.h and GCKeyNames.h
106 #[unsafe(method(buttonForKeyCode:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn buttonForKeyCode(
109 &self,
110 code: GCKeyCode,
111 ) -> Option<Retained<GCControllerButtonInput>>;
112 );
113}
114
115/// Methods declared on superclass `NSObject`.
116#[cfg(feature = "GCPhysicalInputProfile")]
117impl GCKeyboardInput {
118 extern_methods!(
119 #[unsafe(method(init))]
120 #[unsafe(method_family = init)]
121 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
122
123 #[unsafe(method(new))]
124 #[unsafe(method_family = new)]
125 pub unsafe fn new() -> Retained<Self>;
126 );
127}