#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern "C" {
pub static GCControllerDidConnectNotification: &'static NSString;
}
extern "C" {
pub static GCControllerDidDisconnectNotification: &'static NSString;
}
extern "C" {
pub static GCControllerDidBecomeCurrentNotification: &'static NSString;
}
extern "C" {
pub static GCControllerDidStopBeingCurrentNotification: &'static NSString;
}
extern "C" {
pub static GCControllerUserCustomizationsDidChangeNotification: &'static NSString;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GCControllerPlayerIndex(pub NSInteger);
impl GCControllerPlayerIndex {
#[doc(alias = "GCControllerPlayerIndexUnset")]
pub const Unset: Self = Self(-1);
pub const GCControllerPlayerIndex1: Self = Self(0);
pub const GCControllerPlayerIndex2: Self = Self(1);
pub const GCControllerPlayerIndex3: Self = Self(2);
pub const GCControllerPlayerIndex4: Self = Self(3);
}
unsafe impl Encode for GCControllerPlayerIndex {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for GCControllerPlayerIndex {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GCController;
unsafe impl ClassType for GCController {
type Super = NSObject;
type Mutability = InteriorMutable;
}
);
#[cfg(feature = "GCDevice")]
unsafe impl GCDevice for GCController {}
unsafe impl NSObjectProtocol for GCController {}
extern_methods!(
unsafe impl GCController {
#[cfg(feature = "block2")]
#[deprecated = "controllerPausedHandler has been deprecated. Use the Menu button found on the controller's profile, if it exists."]
#[method(controllerPausedHandler)]
pub unsafe fn controllerPausedHandler(&self) -> *mut Block<dyn Fn(NonNull<GCController>)>;
#[cfg(feature = "block2")]
#[deprecated = "controllerPausedHandler has been deprecated. Use the Menu button found on the controller's profile, if it exists."]
#[method(setControllerPausedHandler:)]
pub unsafe fn setControllerPausedHandler(
&self,
controller_paused_handler: Option<&Block<dyn Fn(NonNull<GCController>)>>,
);
#[method_id(@__retain_semantics Other current)]
pub unsafe fn current() -> Option<Id<GCController>>;
#[method(shouldMonitorBackgroundEvents)]
pub unsafe fn shouldMonitorBackgroundEvents() -> bool;
#[method(setShouldMonitorBackgroundEvents:)]
pub unsafe fn setShouldMonitorBackgroundEvents(should_monitor_background_events: bool);
#[method(isAttachedToDevice)]
pub unsafe fn isAttachedToDevice(&self) -> bool;
#[method(isSnapshot)]
pub unsafe fn isSnapshot(&self) -> bool;
#[method(playerIndex)]
pub unsafe fn playerIndex(&self) -> GCControllerPlayerIndex;
#[method(setPlayerIndex:)]
pub unsafe fn setPlayerIndex(&self, player_index: GCControllerPlayerIndex);
#[cfg(feature = "GCControllerInput")]
#[method_id(@__retain_semantics Other input)]
pub unsafe fn input(&self) -> Id<GCControllerLiveInput>;
#[cfg(feature = "GCDeviceBattery")]
#[method_id(@__retain_semantics Other battery)]
pub unsafe fn battery(&self) -> Option<Id<GCDeviceBattery>>;
#[cfg(feature = "GCPhysicalInputProfile")]
#[method_id(@__retain_semantics Other physicalInputProfile)]
pub unsafe fn physicalInputProfile(&self) -> Id<GCPhysicalInputProfile>;
#[cfg(all(feature = "GCGamepad", feature = "GCPhysicalInputProfile"))]
#[deprecated]
#[method_id(@__retain_semantics Other gamepad)]
pub unsafe fn gamepad(&self) -> Option<Id<GCGamepad>>;
#[cfg(all(feature = "GCMicroGamepad", feature = "GCPhysicalInputProfile"))]
#[method_id(@__retain_semantics Other microGamepad)]
pub unsafe fn microGamepad(&self) -> Option<Id<GCMicroGamepad>>;
#[cfg(all(feature = "GCExtendedGamepad", feature = "GCPhysicalInputProfile"))]
#[method_id(@__retain_semantics Other extendedGamepad)]
pub unsafe fn extendedGamepad(&self) -> Option<Id<GCExtendedGamepad>>;
#[cfg(feature = "GCMotion")]
#[method_id(@__retain_semantics Other motion)]
pub unsafe fn motion(&self) -> Option<Id<GCMotion>>;
#[cfg(feature = "GCDeviceLight")]
#[method_id(@__retain_semantics Other light)]
pub unsafe fn light(&self) -> Option<Id<GCDeviceLight>>;
#[cfg(feature = "GCDeviceHaptics")]
#[method_id(@__retain_semantics Other haptics)]
pub unsafe fn haptics(&self) -> Option<Id<GCDeviceHaptics>>;
#[method_id(@__retain_semantics Other capture)]
pub unsafe fn capture(&self) -> Id<GCController>;
#[method_id(@__retain_semantics Other controllers)]
pub unsafe fn controllers() -> Id<NSArray<GCController>>;
#[cfg(feature = "block2")]
#[method(startWirelessControllerDiscoveryWithCompletionHandler:)]
pub unsafe fn startWirelessControllerDiscoveryWithCompletionHandler(
completion_handler: Option<&Block<dyn Fn()>>,
);
#[method(stopWirelessControllerDiscovery)]
pub unsafe fn stopWirelessControllerDiscovery();
#[method_id(@__retain_semantics Other controllerWithMicroGamepad)]
pub unsafe fn controllerWithMicroGamepad() -> Id<GCController>;
#[method_id(@__retain_semantics Other controllerWithExtendedGamepad)]
pub unsafe fn controllerWithExtendedGamepad() -> Id<GCController>;
}
);
extern_methods!(
unsafe impl GCController {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new() -> Id<Self>;
}
);