iokit

Cocoa get Power Adapter Status

点点圈 提交于 2019-12-09 23:36:19
问题 I'm currently working on a Backup Application, and I have received a lot of requests for features to be added recently, and the top one of them is adding a checkbox like "Back Up when on Battery Power" like Time Machine has. So, is there a way I can get the status of the Power Adapter (plugged in and plugged in)? I assume that if one had a Desktop Mac, like iMac, etc, I would probably just get Plugged In all the time. Therefore, I need means of detecting if the computer is a portable or not.

How to get device descriptor and configuration descriptor of usb device in Mac?

吃可爱长大的小学妹 提交于 2019-12-07 17:50:50
问题 I have minimum exposure to xcode and I/Okit framework. I have seen device descriptor and configuration descriptor of a usb device in USB prober. I have written an xcode program using I/O kit framework which gives the usb device name as output, when we give product id and vendor id of that device as input. /*Take the vendor and product id from console*/ printf("\nEnter the vendor id : "); scanf("%lx",&usbVendor); printf("\nEnter the product id :"); scanf("%lx",&usbProduct); /* Set up a

Monitor changes on Thunderbolt port connection

丶灬走出姿态 提交于 2019-12-06 13:18:56
I am working on a requirement where i need to monitor changes in Thunderbolt port connection. (When Thunderbolt cable is connected or disconnected). I tried to use IOServiceMatching(kIOUSBInterfaceClassName) from IOKit framework but i cannot monitor changes on Thunderbolt port. Is there any way i can achieve it? Any help is appreciated. Thunderbolt devices (except displays that use the DisplayPort portion of the Thunderbolt port) are PCI devices, not USB, so they will show up in the IOService registry as IOPCIDevice s. They will however also show up as IOThunderboltPort objects in the

Programmatically trigger “detect displays.”

六眼飞鱼酱① 提交于 2019-12-06 11:43:59
问题 I’m trying to trigger the same thing that the system does when you click on “Detect Displays” in the “Displays” System Preferences pane. Is there a way to do this programmatically? My goal is to create a LaunchAgent that does this at login to reset the display resolution in case a user messes with it. 回答1: You will need to use a private CoreGraphics routine to get the list of all displays including inactive ones, and then request a rescan of the bus. Try it like this: #include <IOKit/IOKitLib

How to get device descriptor and configuration descriptor of usb device in Mac?

谁说我不能喝 提交于 2019-12-06 01:46:53
I have minimum exposure to xcode and I/Okit framework. I have seen device descriptor and configuration descriptor of a usb device in USB prober. I have written an xcode program using I/O kit framework which gives the usb device name as output, when we give product id and vendor id of that device as input. /*Take the vendor and product id from console*/ printf("\nEnter the vendor id : "); scanf("%lx",&usbVendor); printf("\nEnter the product id :"); scanf("%lx",&usbProduct); /* Set up a matching dictionary for the class */ matchingDict = IOServiceMatching(kIOUSBDeviceClassName); if (matchingDict

Mac Mouse/Trackpad Speed Programmatically

泄露秘密 提交于 2019-12-05 21:48:44
I'm trying to change the mouse tracking speed (Notice: Not acceleration) for an application I'm working on. I've searched everywhere for a way to do this, but couldn't find anything. I suspect that has to do with the value I give in this function on the IOKit/hidsystem Framework: IOHIDSetAccelerationWithKey(handle, CFSTR(kIOHIDMouseAccelerationType), mouseAcceleration); Being mouseAcceleration the value, I suspect there is a hex value that defines both acceleration and speed. Does anyone came across this problem and could help me? Thanks in advance Working example in swift: func

How to get list of HID devices in a Swift/Cocoa application?

不羁岁月 提交于 2019-12-05 20:01:36
The following code works perfectly to get a list of connected HID devices: import Foundation import IOKit import IOKit.usb import IOKit.hid private func createDeviceMatchingDictionary( usagePage: Int, usage: Int) -> CFMutableDictionary { let dict = [ kIOHIDDeviceUsageKey: usage, kIOHIDDeviceUsagePageKey: usagePage ] as NSDictionary return dict.mutableCopy() as! NSMutableDictionary; } let manager = IOHIDManagerCreate(kCFAllocatorDefault, IOOptionBits(kIOHIDOptionsTypeNone)); let keyboard = createDeviceMatchingDictionary(usagePage: kHIDPage_GenericDesktop, usage: kHIDUsage_GD_Keyboard)

how to get Device id, vendor id and product id of a mounted usb device in Mac OS cocoa

人走茶凉 提交于 2019-12-05 02:29:29
问题 I am trying to write a Cocoa program which detects iPods connected to Mac OS. I am listening to NSWorkspaceDidMountNotification and NSWorkspaceDidUnmountNotification for the USB device mount and unmount notifications. I can get the device path of the mounted device using NSString *path = [[notif userInfo] objectForKey:@"NSDevicePath"]; but I also need t know the Device Id, Vendor Id, Product Id etc to check whether the mounted device is an iPod. I think the way forward is IOKit. But I have a

Cocoa get Power Adapter Status

試著忘記壹切 提交于 2019-12-04 20:01:00
I'm currently working on a Backup Application, and I have received a lot of requests for features to be added recently, and the top one of them is adding a checkbox like "Back Up when on Battery Power" like Time Machine has. So, is there a way I can get the status of the Power Adapter (plugged in and plugged in)? I assume that if one had a Desktop Mac, like iMac, etc, I would probably just get Plugged In all the time. Therefore, I need means of detecting if the computer is a portable or not. I assume IOKit would be a library to look at, but I simply could not find anything in the docs, that

Using IOKit to return Mac's Serial number returns 4 extra characters

南楼画角 提交于 2019-12-04 18:30:41
I'm playing with IOKit and have the following code, the general idea is to pass a platformExpert key to this small core foundation command line application and have it print the decoded string. The test case is "serial-number". The code below when run like: ./compiled serial-number Almost works but returns the last 4 characters of the serial number at the beginning of the string i.e. for an example serial such as C12D2JMPDDQX it would return DDQXC12D2JMPDDQX Any ideas? #include <CoreFoundation/CoreFoundation.h> #include <IOKit/IOKitLib.h> int main (int argc, const char * argv[]) { CFStringRef