I was wondering if there's a method on MacOS to have my application hide a hid device such as a game controller and instead have the receiving game/application see my app's virtual controller? Is this possible via DriverKit or some other form of kernel level coding?
On Windows we have a tool known as HidHide that hids a game controller from all other applications. Is it possible to implement such behavior into an app or is that system level?
I was wondering if there's a method on macOS to have my application hide a hid device such as a game controller and instead have the receiving game/application see my app's virtual controller? Is this possible via DriverKit or some other form of kernel-level coding?
Yes, and it doesn't require DriverKit or any kernel-level code. The basic flow here is:
-
Your app discovers the device using CoreHID.
-
You use seizeDevice() to take control of the accessory. Strictly speaking, the device would still be visible to other apps, but they can't receive events from it or otherwise interact.
-
Your app then emits events to the system, either by using CoreHID to create a virtual HID device or by using CGEventTap to directly submit higher-level events to the system.
Expanding on that last point, the choice here depends on what you're actually trying to do. Using virtual HID allows you to emulate a specific accessory, but that assumes that some other app/process is "looking" for that accessory and is ready to interpret that HID device. On the other hand, CGEvent is the entry point into the system event system, which makes it much easier to ensure you're generating exactly what the rest of the system is "expecting".
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware