diff --git a/src/io_message.rs b/src/io_message.rs new file mode 100644 index 0000000..939c77c --- /dev/null +++ b/src/io_message.rs @@ -0,0 +1,18 @@ +// exports from + +#![allow(non_upper_case_globals)] + +pub const kIOMessageDeviceWillPowerOff: u32 = 0xe0000210; +pub const kIOMessageDeviceHasPoweredOn: u32 = 0xe0000230; +pub const kIOMessageSystemWillPowerOff: u32 = 0xe0000250; +pub const kIOMessageSystemWillRestart: u32 = 0xe0000310; +pub const kIOMessageSystemPagingOff: u32 = 0xe0000255; +pub const kIOMessageCanSystemSleep: u32 = 0xe0000270; +pub const kIOMessageSystemWillNotSleep: u32 = 0xe0000290; +pub const kIOMessageSystemWillSleep: u32 = 0xe0000280; +pub const kIOMessageSystemWillPowerOn: u32 = 0xe0000320; +pub const kIOMessageSystemHasPoweredOn: u32 = 0xe0000300; +pub const kIOMessageCanDevicePowerOff: u32 = 0xe0000200; +pub const kIOMessageDeviceWillNotPowerOff: u32 = 0xe0000260; +pub const kIOMessageDeviceWillPowerOn: u32 = 0xe0000215; +pub const kIOMessageDeviceHasPoweredOff: u32 = 0xe0000225; diff --git a/src/lib.rs b/src/lib.rs index 5ae964c..63c7e30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,7 @@ pub use usb::*; pub use io_hid_keys::*; pub use io_hid_base::*; pub use io_hid_manager::*; +pub use io_message::*; mod io_return; mod keys; @@ -31,6 +32,7 @@ mod usb; mod io_hid_keys; mod io_hid_base; mod io_hid_manager; +mod io_message; // exports from @@ -64,6 +66,7 @@ extern "C" { pub fn IONotificationPortCreate(masterPort: mach_port_t) -> IONotificationPortRef; pub fn IONotificationPortDestroy(notify: IONotificationPortRef); pub fn IONotificationPortGetMachPort(notify: IONotificationPortRef) -> mach_port_t; + pub fn IONotificationPortGetRunLoopSource(notify: IONotificationPortRef) -> *mut c_void; pub fn IOCreateReceivePort(msgType: u32, recvPort: *mut mach_port_t) -> kern_return_t; @@ -168,4 +171,10 @@ extern "C" { pub fn IOServiceNameMatching(name: *const c_char) -> CFMutableDictionaryRef; pub fn IOBSDNameMatching(masterPort: mach_port_t, options: u32, bsdName: *const c_char) -> CFMutableDictionaryRef; pub fn IORegistryEntryIDMatching(entryID: u64) -> CFMutableDictionaryRef; + + // IO System Power Notifications + pub fn IOAllowPowerChange(kernelPort: io_connect_t, notification_id: isize) -> kern_return_t; + pub fn IOCancelPowerChange(kernel_port: io_connect_t, notification_id: isize) -> kern_return_t; + pub fn IORegisterForSystemPower(refcon: *mut c_void, port: *mut IONotificationPortRef, callback: IOServiceInterestCallback, notifier: *mut io_object_t) -> kern_return_t; + pub fn IODeregisterForSystemPower(notifier: *mut io_object_t) -> kern_return_t; }