-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(macos): virtual HID gamepad emulating Razer Serval #5171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
1baaf4f
4b77caa
9b54b80
c01a0ab
a4994b8
9078d5f
48b1fd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,53 @@ ninja -C build | |
| }} | ||
| } | ||
|
|
||
| ### macOS code signing & entitlements | ||
| The macOS virtual gamepad publishes a virtual HID device via `IOHIDUserDeviceCreate`, | ||
| which requires the `com.apple.hid.manager.user-access-device` entitlement. Without it, | ||
| AMFI terminates Sunshine the moment a controller is first connected. | ||
|
|
||
| The entitlements are defined in `src_assets/macos/build/sunshine.entitlements` and are | ||
| applied automatically when the `.app` is signed (when `SHOULD_SIGN=true`). | ||
|
|
||
| This is an Apple-**restricted** entitlement, which has two consequences: | ||
|
|
||
| - **Official / distributed builds:** the Developer ID signing identity must be authorized | ||
| by Apple for this entitlement, otherwise notarization (and AMFI at runtime) will reject | ||
| the build. | ||
| - **Local development (ad-hoc signed) builds:** ad-hoc signatures are not trusted to carry | ||
| restricted entitlements, so AMFI will still kill the process. To test the gamepad locally, | ||
| first sign the built `.app` with the entitlements: | ||
| ```bash | ||
| codesign --force --deep --sign - \ | ||
| --entitlements src_assets/macos/build/sunshine.entitlements \ | ||
| ./build/Sunshine.app | ||
| ``` | ||
| Then relax AMFI enforcement so the ad-hoc binary is allowed to use the restricted | ||
| entitlement. AMFI is controlled by the `amfi_get_out_of_my_way=0x1` boot argument (there is | ||
| no `csrutil` switch for it), and setting boot arguments requires SIP to be disabled. **This | ||
| weakens system security and is intended for development machines only.** | ||
|
|
||
| - **Intel:** boot into Recovery (⌘-R), open Terminal, then: | ||
| ```bash | ||
| csrutil disable | ||
| nvram boot-args="amfi_get_out_of_my_way=0x1" | ||
| ``` | ||
| Reboot back into macOS. | ||
| - **Apple Silicon:** boot into Recovery (hold the power button), set the startup disk to | ||
| *Reduced Security* with *"Allow user management of kernel extensions"* via Startup Security | ||
| Utility, then from a Recovery Terminal: | ||
| ```bash | ||
| csrutil disable | ||
| bputil -k # follow the prompts to allow boot-args | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, sorry to barge on this code review. First off thanks so much for doing this! I was so excited to be able to do this on my Tahoe M4 Mac, I built and ran this branch. Got Sunshine up and running, and then I made it to here, and realized: A) This command ran, but did not allow for the nvram update command below, due to permission issues from io/common. B) Realized that I was in very unsafe territory on my MacOs. I've worked in Software, and some in MacOs OS in virtualization before silicon, but I was not aware enough how quick I could break my whole computer until this didn't work. To try to solve A, I read through bputil documentation here: https://keith.github.io/xcode-man-pages/bputil.1.html and it looked like -a may also be needed, but when I tried it still failed. I pulled back and reset full security privileges for the time being. For B, wonder if there should be a good warning in the documentation before hand, or in the future an way to have a binary build with the developer key with a CI/CD pipeline. Sorry if this is to much. I really want this to work and come out! |
||
| nvram boot-args="amfi_get_out_of_my_way=0x1" | ||
| ``` | ||
| Reboot back into macOS. (Exact steps vary by macOS version — consult Apple's current | ||
| Startup Security Utility documentation.) | ||
|
|
||
| When you are done developing, **revert these changes**: clear the boot argument | ||
| (`sudo nvram -d boot-args`) and re-enable SIP from Recovery with `csrutil enable` (and | ||
| restore *Full Security* on Apple Silicon). | ||
|
|
||
| ### Remote Build | ||
| It may be beneficial to build remotely in some cases. This will enable easier building on different operating systems. | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.