Virtual Controllers on Mac via the Game Controller Framework

Hi fellow devs, I have a quick question is it possible to have virtual controllers on Mac. For instance can my app exclusively manage the controller and output it into the Game Controller framework? And create a virtual controller to allow for features such as controller emulation, haptic control, and others.

Answered by Frameworks Engineer in 872628022

Hi David

Not really.

can my app exclusively manage the controller

I don't believe you can take exclusive ownership of the source game controller device such that the OS game controller support won't see it too. Possibly with some clever use of USB DriverKit - though that's going to be source-device specific and would only work for wired connections.

create a virtual controller

This may be technically possible today using DriverKit or IOHIDUserDevice to fake a game controller device that is supported natively by macOS. But we can't guarantee this won't break in the future - the OS game controller support is designed and tested for real (physical) game controllers. There are some existing checks in the OS game controller support to ignore virtual HID devices, specifically to prevent issues arising from looping game controller input back into the OS.

What are you trying to do? It would be helpful to capture your use case in a feedback issue (to the Game Controllers feedback area).

-- Justin

Accepted Answer

Hi David

Not really.

can my app exclusively manage the controller

I don't believe you can take exclusive ownership of the source game controller device such that the OS game controller support won't see it too. Possibly with some clever use of USB DriverKit - though that's going to be source-device specific and would only work for wired connections.

create a virtual controller

This may be technically possible today using DriverKit or IOHIDUserDevice to fake a game controller device that is supported natively by macOS. But we can't guarantee this won't break in the future - the OS game controller support is designed and tested for real (physical) game controllers. There are some existing checks in the OS game controller support to ignore virtual HID devices, specifically to prevent issues arising from looping game controller input back into the OS.

What are you trying to do? It would be helpful to capture your use case in a feedback issue (to the Game Controllers feedback area).

-- Justin

Hi Justin, we're trying to allow for more support for primarily the DualSense controllers. One core feature that's already implemented in our Windows version is controller emulation. We allow for the DualSense to pretend to be a DualShock or Xbox controller for more capability with older and unsupported games. On Windows, we use low-level APIs such as HIDHide to hide the DualSense from the system, use the Windows equivalent of IOKit to grab exclusive access to it, and then Windows’s virtual controller framework to create a virtual controller that games see. Unfortunately, even with a custom DriverKit, we would be unable to feed the controller data exclusively or hide the controller from the Game Controller framework as it is too low-level and inaccessible for developers. And macOS simply does not currently have a virtual controller framework. If Apple were to add those features, we would love to update our app to feature these improvements.

  • David

Interestingly System Settings is able to control how the Game Controller framework maps buttons through the Game Controller tab on MacOS. If Apple could at least expose those for developers it would allow us to do so much more. The best would be the ability to fake controller via VID:PID as on Windows.

The only thing we've been able to do is allow user to map controller buttons to keyboard and mouse and allowing them to use their controller in games that don't support controller input. But since we can't hide the controller from games that support controller input this feature can only work on games that don't support controller or can disable them.

Ok I've submitted a suggestion via Feedback Assist.

I've submitted a suggestion via Feedback Assist.

Thanks!

What was the bug number?

Share and Enjoy

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

The feedback number is FB21643623. Thanks Quinn the Eskimo.

Virtual Controllers on Mac via the Game Controller Framework
 
 
Q