Post not yet marked as solved
Hello,
my goal is to port a virtual audio device written using CoreAudio and IOKit to DriverKit because it is mandatory for App Store distribution for macOS.
The driver can be easily installed in Library/Audio/Plug-Ins/HAL and has a .driver extension; it already works in user-space and it is a loopback interface for audio capturing and processing.
I have viewed other posts on this forum and the WWDC21 and WWDC22 videos regarding the uses of DriverKit.
My question is if it possible to port such driver to DriverKit and embed it in a macOS app for the app store. If yes, is there an example I can follow that allows me to fully embed the driver in an app and consume it from there or if I should still stick to using a separate installer distributing it elsewhere.I have viewed this: https://developer.apple.com/documentation/coreaudio/building_an_audio_server_plug-in_and_driver_extension and it seems that the .driver cannot be embedded in an app in anyway.
Thank you kindly for your help,
Best regards,
Chris
Post not yet marked as solved
I see that apple provides dynamic flags here: https://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-34.1.1/IOHIDSystem/IOKit/hidsystem/IOHIDUsageTables.h.auto.html
In page (0x07).
I can send a HID using appium for now, using this command in python:
self.driver.execute_script("mobile: performIoHidEvent", {"page": 0x07, "usage": 0xE0, "durationSeconds": 0.5})
But I cannot send dynamic flags to do a CMD.+ Combinations or shift + combinations.
I would like know if there is any other way I can do multi-key operations such as CMD + A, CMD + C etc.
Post not yet marked as solved
With the advertisement of enhanced IO support on iPadOS16 - Will developers be able to take advantage of IOKit aswell?
Post not yet marked as solved
I watched the session multiple times, but it just gives a high level overview that doesn't really say much about this very exciting and complex new feature. It only mentions actually talking to the driver in passing with a single sentence "apps use the IOKit framework to open user clients". Then the presenter says for an example of that we can check out "communicating between a driverkit extension and a client app", which is a macOS app that doesn't even use IOKit, and trying to import IOKit into an iPadOS target doesn't work anyway because the framework is not there.
Am I missing something, or is this simply not available in Xcode 14 seed 1? Release notes don't mention anything either, and docs are only updated to reflect that some of this stuff is now available on iPadOS 16...
Post not yet marked as solved
Hi there!
I'm currently new to Mac OS dev (coming from a history of Linux dev).
I have an external BT keyboard and a couple keys are mapped differently than my Mac keyboard (§ to ` for example). I'm wondering if it's possible to write a kernel extension that detects the key sent from the BT keyboard and remap the key code.
I don't really know whether this is possible and if it is, where to look in the ecosystem. It's a bit different from Linux.
Thank you!
Post not yet marked as solved
We are developing a Lighting keyboard(C78A) product that can charge apple devices, with the function of displaying the current power level of apple devices.
A problem was encountered during development.
When our keyboard is connected, the apple device is charged, let the apple device enter the lock screen status, the apple device will then sleep and the screen will go black. At this time, the iAP2 channel will be closed, causing our keyboard fail to communicate with Apple devices, but also cannot obtain real-time device power information. On the other hand, when the apple device wakes up from hibernation, the keyboard cannot initialize the iAP2 channel again because the keyboard has always been powered on, which makes it unable to be recognized by the apple device.
So, we want to know if there is a way to keep the iAP2 channel in hibernation when the apple device is connected to our keyboard and charged, so that the above problem can be solved.Thanks .
Post not yet marked as solved
Is it allowed for binaries to be signed with custom entitlements (e.g. com.flagers.xyz) for the purposes of determining the authenticity of an application using IOServiceOpen.
Post not yet marked as solved
we are developing USB hid library to interact with HID device, however we're facing on memory lacking when we calling IOCreatePlugInInterfaceForService then calling IODestroyPlugInInterface, the memory is not released and each time of calling it take about 0.3 MB Ram, after long time running, the program crash because runout of memory.
what should we do in this case to avoid memory leak?
// Create a device interface/HANDLE
static BOOL CreateHidDeviceInterface(io_object_t deviceObject, HANDLE* pHandle)
{
BOOL retVal = FALSE;
IOCFPlugInInterface** ppPluginInterface = NULL;
SInt32 score = 0;
IOReturn pluginResult;
HRESULT interfaceResult;
// Create a plugin so we can create an interface
pluginResult = IOCreatePlugInInterfaceForService(deviceObject, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &ppPluginInterface, &score);
if (pluginResult == kIOReturnSuccess)
{
// Create the interface (HANDLE)
interfaceResult = (*ppPluginInterface)->QueryInterface(ppPluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void**)pHandle);
if (interfaceResult == S_OK)
{
retVal = TRUE;
}
IODestroyPlugInInterface(ppPluginInterface);
}
return retVal;
}
Post not yet marked as solved
Hey there,
I'm freelancer on electronic circuits designer, and on my current project I want to design a hub that connects to iPhone and works as: 1. lightning to 3.5mm headphone jack, 2. a button to send a simple data as HID to iPhone and 3. has a lightning female port that enables to connection to charger to charge iPhone.
The company needs just a few of this device (actually 50) just for they're and they're few VIP costumers use.
I'm designing this gadget for iOS and Android devices. I don't have problem with USB and USB-c, but I there is some ambiguity. I searched web and Also Apple MFi program FAQ, I have some questions:
What kind of hardware-based considerations I should have in comparison to USB-c?
What is standards and protocols of data transfer of lightning port? Is it similar to USB interface?
Is USB hub controller ICs work on lightning as well as USB-c?
What is accessory identification chip? What is it's datasheet? Were and how to buy it?
For this amount of production (something about 50), is there necessary to get MFi certificate?
Is there a datasheet of accessory identification chip for me to complete the design and then enrolling to MFi program?
Thanks,
Hamidreza Hassanvand
Hi there forum,
I picked up an old Opensource project from github which is a driver for the Xbox 360 controller. I was going through and hoping to update the repo/build for Apple Silicon and learn some macOS Kernel driver dev along the way.
I have been scouring the Apple IOKit documentation archive making my 1/4 through the IOKit doc archive, but, currently, I have an issue with the header search paths.
I need to import IOKit/usb/IOUSBLib.h as it contains the symbols utilised by the driver, and it appears that by default Xcode does not use the IOKit Frameworkheaders, but Kernel.framework headers (if I search for definition of symbols that can be found, Xcode opens the Kernel.Framework IOKit path.).
Any idea how I can add the user-space IOKit to my driver? I saw that there's the kernel/kernlib, kernel/IOKit, and just IOKit. But a bit lost why this header file is not in the search path.
Thanks in advance,
If you're curious the code is here: https://github.com/VariableDeclared/360Controller/tree/pj/update-source-for-macos-12.0
Peter
Post not yet marked as solved
I get the following errors when running the code below in a sandboxed app (it works when not sandboxed) and I have the com.apple.security.device.usb entitlement enabled.
Error:Unable to open io_service_t object and create user client. with reason: IOServiceOpen failed.
Error Domain=IOUSBHostErrorDomain Code=-536870174 "Failed to create IOUSBHostObject." UserInfo={NSLocalizedRecoverySuggestion=, NSLocalizedDescription=Failed to create IOUSBHostObject., NSLocalizedFailureReason=IOServiceOpen failed.}
import Foundation
import IOKit
import IOKit.usb
import IOKit.usb.IOUSBLib
import IOKit.serial
import IOUSBHost
import IOUSBHost.IOUSBHostInterface
class USBService {
enum UsbError: Error {
case noDeviceMatched
case deviceCriteriaNotUnique
}
init() {
}
func getDevice(idVendor: Int?, idProduct: Int?) throws {
let deviceSearchPattern: [IOUSBHostMatchingPropertyKey : Int] = [
.vendorID : idVendor!,
.productID : idProduct!,
]
let deviceDomain = [ "IOProviderClass": "IOUSBHostDevice" ]
let searchRequest = (deviceSearchPattern as NSDictionary).mutableCopy() as! NSMutableDictionary
searchRequest.addEntries(from: deviceDomain)
let service = IOServiceGetMatchingService(kIOMasterPortDefault, searchRequest)
guard service != 0 else {
throw UsbError.noDeviceMatched
}
let device = try IOUSBHostDevice.init(__ioService: service, options: [], queue: nil, interestHandler: nil)
print(device.deviceDescriptor?.pointee.idProduct)
}
}
Post not yet marked as solved
Newer iPads come with USB-C ports.
Would it be possible to connect a USB-C CDC device (that is, a USB UART) and use it from an app? What would one need to supply to make this work?
Post not yet marked as solved
I read the doc of installing system extensions
https://developer.apple.com/documentation/systemextensions/installing_system_extensions_and_drivers?language=objc
, but actually our product is a framework and installed by .pkg.
I/O Kit kext is installed by script in .pkg.
So I meet a problem :how to install DriverKit dext by script?
Post not yet marked as solved
IOHIDDeviceSetReport blocks until the report is sent, and when you call it from the main thread in a situation where more than a couple bluetooth devices are connected (which is often, considering Apple's mice, keyboards and trackpads are all bluetooth) and the system can't keep up with the traffic the report rather frequently never makes it through, resulting in a hanged application and an unresponsive bluetooth HID device that will only respond after being disconnected and reconnected.
Is there any way around this situation? Ideally
IOHIDDeviceSetReport would timeout
An output report failing to get through would not make the HID device unresponsive
IOHIDDeviceSetReportWithCallback would work, but it seems under the hood it has simply never been implemented
There would be a way to set reports asynchronously
but it seems none of those are the case.
Does anyone have any light to shed on this matter?
macOS12 here.
Post not yet marked as solved
I am playing with IOI2CSendRequest and found a couple things I cannot do with it:
E-DDC read of EDIDs that are longer than 256 bytes. This requires a transaction with two sends (one for the segment pointer and one for the offset) with a start bit before each and then the reply preceded by a start bit and ended by a stop bit. IOI2CSendRequest can only do one send and one reply in a single transaction. The E-DDC transaction cannot be split because a second transaction would add an extra stop bit which would reset the segment pointer. A transaction without the offset part works with the GTX 680 or Intel UHD 630 but not with the AMD W5700.
DisplayPort DPCD read from DisplayPort device connected to a DisplayPort branch device. This requires a send to the sideband message down request buffer and a reply from the sideband message down reply buffer. This cannot be done with a single IOI2CSendRequest send and reply because the reply is not immediate. I don't think the reply can be polled because I think that is handled by a DisplayPort interrupt and the reply is probably read by the GPU driver and not passed to the user client.
Is there a special way to setup the IOI2CRequest to do the above?
In the E-DDC case, the i2c handler could maybe suppress the stop bit of the first send after it recognizes that the send is for the segment pointer.
In the DisplayPort sideband case, the i2c handler could recognize that the user client wants to get a reply from a sideband message by examining the request sent in the contents of the DisplayPort send buffer, and should therefore queue up the request and wait for the reply.
What about M1 Macs? I understand there are some undocumented APIs that people are using to do DDC/CI (MCCS) or to read the EDID but I don't know if they can get more than 256 bytes of the EDID.
Post not yet marked as solved
Hello
We have a USB camera. My Mac can recognize it and we can get frames with any software. There is a physical button on it and the vendor says the camera is UVC-compliant. But button doesn't work anyway.
I captured some USB traffic data and saw that it has two interfaces. One for streaming and other one for interrupting (like button click). I read UVC 1.5 standards to understand it and it is working like written in UVC 1.5. So, I can get a data with an interrupt transfer when clicking the button.
I checked these two interfaces, they use UVCAssistant for driver(System Extension). I tried to use libusb, I can get data from button click. But for frames I had to use libuvc, but it wasn't work for my camera (I think it is related with USB descriptor parsing in libuvc).
I thought that I should write a driver for single interface and so second interface will use same UVC assistant driver and first interface will use my driver.
I wrote a driver and it matches with first interface. But second interface is empty (unhandled by any driver). I want to load UVCAssistant for second interface of USB port.
How can I do this?
Output before loading my driver
After loading:
IOKitPersonalities that I used:
Post not yet marked as solved
Hi, I'm developing firmware for a USB audio device for which audio playback currently cuts off after about a second.
The normal system logs via Console do not seem to throw any error related to USB audio (and nor do kernel-only logs via log stream --process 0).
Is there a good way to dive deeper into what might be happening?
Looking into the AppleUSBAudio driver, it contains a bunch of verbose "USB Sound assertion (%s) in %s at line %d\n" logs via IOLog(). Are they supposed to end up in the system logs under normal conditions, or does this require setting IOKit debug verbosity in boot-args?
New to debugging Mac OS kernel things.. thanks for helping!
Post not yet marked as solved
Hi,
I am finding that network access is lost from my application when the computer goes to sleep.
When I receive kIOMessageSystemWillSleep, I want to send a message to another computer. But I am finding it does not always make it to the other end. Sometimes it only get sent when the computer wakes back up.
Post not yet marked as solved
We are implementing a Sample Partition Scheme driver.
this is the info.plist
<key>IOKitPersonalities</key>
<dict>
<key>SamplePartitionScheme</key>
<dict>
<key>IOKitDebug</key>
<integer>0</integer>
<key>IOProbeScore</key>
<integer>80000</integer>
....
<key>IOProviderClass</key>
<string>IOMedia</string>
<key>IOPropertyMatch</key>
<dict>
<key>Whole</key>
<true/>
</dict>
</dict>
</dict>
our driver match a whole disk IOMedia, If it's our disk, perform read/write on this disk.
When we test our driver in macOS12.
if the IOMedia is a blank RAW disk, our driver will be loaded at boot time.
if the IOMedia has partitions, system partition scheme driver will be loaded at boot time.
Pluging in a GUID partition disk on a booted Mac always load our kext.
how can our driver match GUID partition disks and load at boot time?
Post not yet marked as solved
We developed a bluetooth keyboard with classical bluetooth, and used usage page 0x01 and usage 0x03 for OTA firmware update, and I wrote an appliction on Windows 10 and everything works as expect.
I am trying to wrote same application on macOS Big Sur 11.6.1 with XCode 13.2.1, but I found that DeviceMatchingCallback was triggered only once with usage page 0x01 and usage 0x06, which is keyboard usage page/usage pairs, any other usage page/usage pairs such as 0x01/0x03, 0x0C/0x01 didn't trigger DeviceMatchingCallback.
So my question is: can customize usage page/usage of bluetooth hid be accessed by application?