Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/io_message.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// exports from <IOKit/IOMessage.h>

#![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;
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +32,7 @@ mod usb;
mod io_hid_keys;
mod io_hid_base;
mod io_hid_manager;
mod io_message;

// exports from <IOKit/IOKitLib.h>

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}