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