Gain user-space access to hardware devices and drivers using IOKit.

IOKit Documentation

Posts under IOKit tag

49 Posts
Sort by:
Post not yet marked as solved
0 Replies
496 Views
Using IOHIDManagerCopyDevices to get a list of keyboards and mice attached to Mac, triggers the user facing "Input Monitoring" request. Because I'm NOT monitoring the users input, the result of the user selection makes no difference to the result, but the privacy warning dialog makes my app look suspicious. All it is doing is checking to make sure that the customer has a non-Bluetooth keyboard or mouse, before they click the button to disable Bluetooth. Is there a way a safe way (no private API please) to enumerate HID devices without this warning, or should I file a feedback asking Apple to reconsider what triggers this dialog?
Posted
by rowlands.
Last updated
.
Post not yet marked as solved
0 Replies
405 Views
macOS, really, so there are a bunch of things that may be running during various types of sleep. I know I can get notifications from IOKit about the system going to sleep or waking up, but if I've got a daemon that crashed, and is then relaunched automatically, can I tell whether the machine is awake, or in some sort of sleep state other than hibernation?
Posted
by kithrup.
Last updated
.
Post not yet marked as solved
2 Replies
459 Views
Hello, I try to get notifications when the display is turned off (not the screensaver). I've tried the following code (part of it), but it don't work at all (the callback is never called).. I don't get where I did something wrong. Any help or relevant documentation link would be very appreciated .. Thank, volfo io_object_t disp_notifierObject; void* disp_refCon = NULL; kern_return_t disp_registerCode; notifyPortRef = IONotificationPortCreate(kIOMainPortDefault); display_wrangler = IOServiceGetMatchingService( kIOMainPortDefault, IOServiceNameMatching("IODisplayWrangler")); // register to receive display sleep notifications disp_registerCode = IOServiceAddInterestNotification( notifyPortRef, display_wrangler, kIOGeneralInterest, CBDisplaySleep, NULL, &disp_notifierObject); if ( disp_registerCode != kIOReturnSuccess ) { printf("IOServiceAddInterestNotification failed\n"); return 2; } CFRunLoopAddSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes ); IOObjectRelease (display_wrangler);
Posted
by volfoni69.
Last updated
.
Post not yet marked as solved
2 Replies
911 Views
IOPSCopyPowerSourcesInfo → kIOPSBatteryHealthKey returning incorrect value Background: I write software to monitor computer system health. I'm having problems getting battery health information on my new M2 notebook. Given the following Objective-C program: #include <Foundation/NSObjCRuntime.h> #include <IOKit/ps/IOPSKeys.h> #include <IOKit/ps/IOPowerSources.h> #include <assert.h> int main() { CFTypeRef psInfo = IOPSCopyPowerSourcesInfo(); assert(psInfo != NULL); CFArrayRef list = IOPSCopyPowerSourcesList(psInfo); assert(list != NULL); long count = CFArrayGetCount(list); for(long i = 0; i < count; i++) { CFDictionaryRef ps = IOPSGetPowerSourceDescription( psInfo, CFArrayGetValueAtIndex(list, i)); assert(ps != NULL); CFStringRef deviceName = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSNameKey)); assert(deviceName != NULL); CFStringRef serialNumber = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSHardwareSerialNumberKey)); assert(serialNumber != NULL); CFStringRef health = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSBatteryHealthKey)); assert(health != NULL); NSLog(@"\nName=\"%@\"\nSerialNumber=\"%@\"\n" "BatteryHealth=\"%@\"\n", (__bridge NSString*)deviceName, (__bridge NSString*)serialNumber, (__bridge NSString*)health); } CFRelease(list); CFRelease(psInfo); return 0; } and looking at the IOPSKeys.h header, I expect to get one of "Poor", "Fair", or "Good" for the value of kIOPSBatteryHealthKey. https://opensource.apple.com/source/IOKitUser/IOKitUser-1845.81.1/ps.subproj/IOPSKeys.h.auto.html Instead, on my 2022 M2 Macbook Air running 13.2.1 (22D68), I get the following output: Name="InternalBattery-0" SerialNumber="F8Y2422145S10X2A7" BatteryHealth="Check Battery" At the same time, the "System Information app says "Condition: Normal". Am I missing something? This seems to be a bug, right? Should I look into filing a Technical Support Incident?
Posted Last updated
.
Post marked as solved
3 Replies
1.4k Views
Hi, I am developping an app for IOS using React Native. I want to write a native modules in Swift and use Objective C to bridge the React Native JS functions with native component. In particular, i want to use IOKit framework to access such information as Battery Temperature and Battery Level. I read in many stackoverflow articles and in ChatGPT that the usage of IOS Private APIs are forbidden andd Apple will reject the app from AppStore and block the account. Is it true? Is there any legal way to use low level APIs and avoid to be rejected or blocked by Apple? The official Apple Technical Support is not responding me. I would really appreciate your help and support. Best Regards, Kamran
Posted Last updated
.
Post marked as solved
5 Replies
710 Views
Hi. I have a class-compliant usb device which announces its serial number as m4121095, as per its kUSBSerialNumberString property. However, the file name it is provided is tty.usbmodemm41210951 – it's the serial number with an additional 1 at the end. What is the meaning of this appendage? (I'm tempted to believe that the 1 at the end is there in the unlikely case another device with the same SN is connected, but there's no way to test this possibility). In the end, I would like to obtain a filename that is guaranteed to be representing a connection to exactly this device. Can I assume that the filename of a device that follows the same protocol of serial numbering will be consistently appended with a number that can in some way be inferred? Thank you.
Posted
by plaukiu.
Last updated
.
Post not yet marked as solved
3 Replies
614 Views
Hi everyone, I am fairly new to Apple development. I have been working on a project where I need Mac to interface with an HID device (custom device). I have successfully communicated with the device using IOKit, Core Foundation and Driver Kit frameworks by simply importing these frameworks in the project and making use of their APIs. However, my client is now asking that I develop the communication explicitly using HID Driver Kit. Bear in mind that I have not purchased the apple developer certificate nor do I have any provisional signing certificates and without any of these, Xcode was allowing me to use frameworks like IOKit, DriverKit etc. Now, when I tried importing HIDDriverKit into the project, I am not able to find this framework in the "Frameworks and Libraries" tab. How do I import this framework into my project? Do I have to purchase apple developer ID or get the provisional signing certificates or any other formalities are required? Please let me know what can be done. Any pointers or suggestions are welcome. Best, Vishnu
Posted
by Vishnu93.
Last updated
.
Post not yet marked as solved
1 Replies
630 Views
In Apple Developer Documentation / DriverKit, Notes that "The base DriverKit framework is available ... and iPadOS for devices with an M1 processor.", There is no mention of the M2 and subsequent Apple Silicon chipsets, Does DriverKit work on iPads with M2 and subsequent Apple Silicon chipsets? Apple Developer Documentation / DriverKit : https://developer.apple.com/documentation/driverkit
Posted
by KhKwak.
Last updated
.
Post not yet marked as solved
14 Replies
4.2k Views
I'm interested in exploring the idea of connecting an iPhone to a Mac/PC. The initial idea is to allow a computer to access/use the iPhones camera and microphone, but I guess I would also be interested in knowing more about how the communication between an iPhone and Mac/PC could work in a general sense too. There are many posts talking about an iPhone integrating with external hardware devices and MFI is mentioned as well as Redpark cables - but I'm not sure if these same things apply when working with a Mac/PC. So, some questions: What protocols, technologies or frameworks would I use send audio and video from an iPhone and a Mac using a USB cable (if the type of cable matters or makes a difference (ie USB-C vs USB-A), please call it out - but I think it's very likely the type of cable wouldn't make any difference) What protocols, technologies or frameworks would I use to send commands from a Mac to the iPhone using USB so that it can be handled by the iOS app It appears that developers are not able to send raw USB protocol/messages/packets unless the developer is a part of MFI, is that correct? Is there another way to achieve this communication? E.g. with some type of "middle-man" (ie a Redpark cable? some other device?) I've seen iOS applications that turn your phone into a webcam (they usually offer connectivity over USB and over the network (NDI)) - these applications require additional downloads on the Mac/PC. My assumption is that the iOS application is sending messages/packets to the Mac/PC application, and the Mac/PC application is then handling all the work to expose that video/auidio stream as a "camera" device to the system. Would this be the only way to achieve this functionality? Could you expose an iOS application as a camera to a Mac (ignoring PC for now) in a native way, so that it would work the same way it does when you plug in a webcam? Is this possible with MFI alone, or is this possible with a third party device (cable/hardware) in between the iPhone and Mac?
Posted
by jmurphyau.
Last updated
.