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
48unsafe impl NSObjectProtocol for GCDeviceBattery {}
49
50impl GCDeviceBattery {
51 extern_methods!(
52 /// This is the battery level for controller.
53 /// Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged) and defaults to 0
54 #[unsafe(method(batteryLevel))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn batteryLevel(&self) -> c_float;
57
58 /// A battery state for controller, defaults to GCControllerBatteryStateUnknown
59 ///
60 ///
61 /// Note: This property might be useful if you display the information about currently connected controller for player's convenience
62 #[unsafe(method(batteryState))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn batteryState(&self) -> GCDeviceBatteryState;
65
66 #[unsafe(method(init))]
67 #[unsafe(method_family = init)]
68 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
69 );
70}
71
72/// Methods declared on superclass `NSObject`.
73impl GCDeviceBattery {
74 extern_methods!(
75 #[unsafe(method(new))]
76 #[unsafe(method_family = new)]
77 pub unsafe fn new() -> Retained<Self>;
78 );
79}