objc2_game_controller/generated/
GCDeviceBattery.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/// This is the battery status and it's represented by one of the following values:
10/// GCControllerBatteryStateUnknown means that the current state of battery is unknown or cannot be determined
11/// GCControllerBatteryStateDischarging means that controller is on battery and discharging at this moment
12/// GCControllerBatteryStateCharging means that controller is plugged in, but it's battery level is less than 100%
13/// GCControllerBatteryStateFull means that controller is plugged in and it's battery level is 100%
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdevicebatterystate?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct GCDeviceBatteryState(pub NSInteger);
20impl GCDeviceBatteryState {
21    #[doc(alias = "GCDeviceBatteryStateUnknown")]
22    pub const Unknown: Self = Self(-1);
23    #[doc(alias = "GCDeviceBatteryStateDischarging")]
24    pub const Discharging: Self = Self(0);
25    #[doc(alias = "GCDeviceBatteryStateCharging")]
26    pub const Charging: Self = Self(1);
27    #[doc(alias = "GCDeviceBatteryStateFull")]
28    pub const Full: Self = Self(2);
29}
30
31unsafe impl Encode for GCDeviceBatteryState {
32    const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for GCDeviceBatteryState {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40    /// A controller battery is an abstract representation of the battery level and battery status of a GCController instance.
41    ///
42    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamecontroller/gcdevicebattery?language=objc)
43    #[unsafe(super(NSObject))]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    pub struct GCDeviceBattery;
46);
47
48extern_conformance!(
49    unsafe impl NSObjectProtocol for GCDeviceBattery {}
50);
51
52impl GCDeviceBattery {
53    extern_methods!(
54        #[unsafe(method(init))]
55        #[unsafe(method_family = init)]
56        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
57
58        /// This is the battery level for controller.
59        /// Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged) and defaults to 0
60        #[unsafe(method(batteryLevel))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn batteryLevel(&self) -> c_float;
63
64        /// A battery state for controller, defaults to GCControllerBatteryStateUnknown
65        ///
66        ///
67        /// Note: This property might be useful if you display the information about currently connected controller for player's convenience
68        #[unsafe(method(batteryState))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn batteryState(&self) -> GCDeviceBatteryState;
71    );
72}
73
74/// Methods declared on superclass `NSObject`.
75impl GCDeviceBattery {
76    extern_methods!(
77        #[unsafe(method(new))]
78        #[unsafe(method_family = new)]
79        pub unsafe fn new() -> Retained<Self>;
80    );
81}