modernizing legacy IOKit Driver code: IOKit/usb/IOUSBLib.h

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

Answered by DTS Engineer in 707120022

I’m not a USB expert but I can comment on this:

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 framework headers, but Kernel framework headers

Right. IOKit framework is for building user space code and Kernel framework is for building kernel code, and importing the former into a kext will not work.

What “symbols utilised by the driver” are you talking about here?


I picked up an old Opensource project from github which is a driver for the Xbox 360 controller.

You’re aware that Game Controller framework supports Xbox controllers out of the box, right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

I’m not a USB expert but I can comment on this:

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 framework headers, but Kernel framework headers

Right. IOKit framework is for building user space code and Kernel framework is for building kernel code, and importing the former into a kext will not work.

What “symbols utilised by the driver” are you talking about here?


I picked up an old Opensource project from github which is a driver for the Xbox 360 controller.

You’re aware that Game Controller framework supports Xbox controllers out of the box, right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

:/ I just forked that and was wrestling with Xcode to get it to use user-mode IOKit headers, and after hours of searching for ways to do it by fumbling around through build settings, I happened upon this post. Epic! You end up finding a way to do this, or just use GameController? I still haven't gotten this thing to build, although I'm getting closer lol.

modernizing legacy IOKit Driver code: IOKit/usb/IOUSBLib.h
 
 
Q