macOS gamepad support#756
macOS gamepad support#756kotleni wants to merge 18 commits intoLizardByte:nightlyfrom kotleni:macos-gamepad-support
Conversation
cgutman
left a comment
There was a problem hiding this comment.
Kexts require some special signing entitlements, right?
|
|
||
| // Map triggers | ||
| if(gamepad_state.lt > 0) gamepad.buttons |= GAMEPAD_BTN_LT; | ||
| if(gamepad_state.rt > 0) gamepad.buttons |= GAMEPAD_BTN_RT; |
There was a problem hiding this comment.
Is it possible to emulate these with analog axes? Digital triggers are problematic for driving games and other games where precise trigger control is required.
There was a problem hiding this comment.
I'm not sure that now I can implement analog support. Maybe I might do it in the future.
There was a problem hiding this comment.
And, I don't have device with analog trigger, for testing.
| } | ||
|
|
||
| // Fill up the input arguments. | ||
| virtgamepad_input[0] = (uint64_t)strdup(VIRTGAMEPAD_NAME); // device name |
There was a problem hiding this comment.
It looks like your driver is identifying the gamepads by name. Can we concatenate the nr parameter to the hardcoded name or something to support multiple gamepads?
There was a problem hiding this comment.
This name can be changed, it's dynamic. (It's not a inditifier)
Yes, you need be identified developer (100$ per year), but it's needed only for building. |
|
Analog triggers don't work (I just emulate digital triggers). I will make another PR in the future with support for analog triggers. |
|
Thank you for this PR! It might take me a few days to get this merged. In the meantime can you update the documentation?
In your other repo, please improve the installation instructions for someone who would install the release version. I'd like to have a few macOS users test this as well before it's merged. |
|
@ReenigneArcher Due to the complexity of installing kernel extensions, this will be a problem for normal users. |
|
What kind of game compatibility do you expect from this? When I looked at adding controller support previously it seemed like games either had to 1) explicitly look for your controller (so needed to emulate something popular like 360/ps4 controllers) or 2) use GCController (which we can’t provide a source input for). I know very little about this space but would like to learn. Awesome work though, I’ll take it for a spin this weekend! |
|
@brad-richardson It needs testing by other users. |
ReenigneArcher
left a comment
There was a problem hiding this comment.
Can you also add:
notes-append "For gamepad support, install VirtualHID from 'https://github.com/kotleni/VirtualHID-macOS/releases/latest'
to the Portfile, just before the final note with the documentation link.
|
@ReenigneArcher |
|
I tried this out and wasn't able to get it working. I only see "Gamepad: Unable to open IOService" when I run sunshine. I took a couple of additional steps that I suspect are unique to M1 macs or macOS 13:
Even after "enabling" the extension and restarting as prompted it seems to not have taken effect - eg I think this is fine to ship as is for a first pass, especially if you think this could be a known problem for arm macs or the new OS. I would be interested in debugging further though |
I tested on the same configuration. The second point is normal behavior, macOS says about it - that's why I did not write about it in the instructions. Have you tried re-running the installer after the system has restarted? Did the Apple logo flicker a couple of times on reboot? |
|
@ReenigneArcher Done. |
|
Okay |
|
@kotleni Your release Is it not properly signed? Did I do something bad with the permissions? |
|
@brad-richardson |
|
Try it: |
|
@brad-richardson |
|
Yeah my bad, I missed the format below. I fixed the file permission issues by just copying into I'm able to load the extension then enable and reboot like it instructs, but the extension is still just not there after I login. Any other ideas? |
|
I don't want to derail this PR, are you in the LizardByte discord? I'm interested in your thoughts on https://support.apple.com/guide/deployment/system-and-kernel-extensions-in-macos-depa5fb8376f/web. It seems like Apple is headed for removal of kexts entirely but I wonder if it would be possible to package your kext as part of the Sunshine install |
|
@brad-richardson Yes, I joined to server now, find me in off topic channel. |
|
@brad-richardson Try |
This comment was marked as outdated.
This comment was marked as outdated.
|
I can add that switching away from using a kext and to DriverKit system extension would allow users of modern macOS to install the driver without needing to disable SIP, rebooting, or otherwise change the security settings of their mac. The only thing they'd need to do is authorize loading the system extension in the System Preferences / Settings app. Unfortunately this is Apple, so of course there are developer-hostile restrictions to doing this. It requires a paid developer account on top of having to ask for special permission from Apple to use the entitlement that grants an app permission to load a dext. The dext also needs to be bundled with a specific app, even if it's intended to be used across multiple apps. But getting over these hurdles will make it much more accessible to normal users. |
Commit 0457407
* Changed service provider to foohid * Changed gamepad data to DualShock4 * Fixed wrong allocation size
|
This PR is stale because it has been open for 90 days with no activity. Comment or remove the stale label, otherwise this will be closed in 10 days. |
|
@kotleni hi,did the kext support x64 gamepad? i install the kext,but not work |
|
@classicalwow It never worked out for me, my implementation doesn't work properly, I stopped trying to implement it. P.S. Special thanks to Apple. 💩 |
@kotleni excuse me, I really want to use this feature,i install the kexts and build kotleni:macos-gamepad-support from source,but got wrong,help me,plz.
kextstat | grep -v com.apple 64 0 0xffffff8005d0f000 0x16000 0x16000 it.kotleni.virthid (1.0.0d1) 0270B242-FC62-3136-9873-64DBB4E19075 <63 7 6 3> |
|
@classicalwow Yes, this is main problem with my implementation. |
|
Is there another option to implement gamepad support for sunshine? |
|
@iMonZ Idk. Maybe we can use Steam Input (but it's not documented). :o |
|
@kotleni Could it be that kext were deprecated by macOS? |
Hey. Idk what is "System extension", but my kext was very unstable. So, maybe u need to recheck it? 🤔 |
|
is this something that still exists? I would love to test it! |
|
No, but it might be easier to implement this now: https://developer.apple.com/documentation/gamecontroller/gcvirtualcontroller?language=objc |
Seems to be targetted to creating a controller in iOS. Wouldn't necessarily be able to give us a controller on mac. |


Description
Implemented gamepad support on macOS. This works with my driver for virtual HID devices (you can copy this repository for yourself, the code is not licensed). Vibration not supported. I also added the IOKit dependency (shipped with Xcode).
Sunshine host tested on Macbook Air M1 (2020).
Tested on two clients (Moonlight-nx (Nintendo Switch), and Moonlight (iOS)).
Screenshot
Issues Fixed or Closed
Type of Change
.github/...)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.