Repository navigation
feat: add automatic peripheral switching on monitor input change - #207
Merged
MegaManSec merged 43 commits intoDec 2, 2026
Merged
Conversation
…/CI VCP 0x60) Add DDC/CI monitor input source (VESA MCCS VCP 0x60) detection and automatic peripheral switching for non-App-Store builds: - Add MonitorInputService (gated behind #if !APP_STORE) using IOAVService (DCPAVServiceProxy) to read VCP 0x60 from external displays on Apple Silicon, matching CGDirectDisplayID to its IOAVService via EDID vendor/model/serial with a single-external-display fallback. - Update Magic_Switch_Direct.entitlements to disable App Sandbox so local and Direct builds can access DCPAVServiceProxyUserClient for I2C DDC/CI reads (AppStore entitlements remain unchanged). - Extend DisplayMonitor with persisted input-switching settings (isInputSwitchingEnabled, sendOnInputSwitchAway, and per-display inputTriggers keyed by CoreGraphics display UUID), background polling on a dedicated queue while awake, and launch/wake seeding to avoid spurious switches. - Fire onTriggerDisplayInputSelected when VCP 0x60 transitions to the configured input (taking peripherals via takeAllPeripheralsIfAway) and optionally onTriggerDisplayInputDeselected when switching away to another valid input (sending peripherals to the trusted peer via performFullSetCommand(.send)), supporting monitors where only one Mac can read DDC/CI. - Add the Monitor Input Switching section in OtherSettingsView (#if !APP_STORE) with a master toggle, a 'Send peripherals to the other Mac when switching away' toggle, and per-display toggles that capture the live VCP 0x60 input.
MegaManSec
reviewed
Nov 29, 2026
MegaManSec
left a comment
Owner
There was a problem hiding this comment.
Notes on the original commit. Each is fixed in a later commit on this branch.
Owner
|
@sumanth1989 Thanks! I've made some signiificant changes in your changes; think you could test for me? |
Contributor
Author
|
Works perfectly with your changes @MegaManSec. |
Owner
|
Thanks, will merge and publish into the official brew/gh one soon. |
Contributor
Author
|
Thanks, you have built an amazing piece of software btw. |
|
🎉 This PR is included in version 3.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Adds Take Peripherals When a Monitor Switches Input to Settings → Other, for one monitor cabled to both Macs and switched with its input button. When the monitor switches to this Mac's input, this Mac takes the peripherals. Optionally, when it switches to the input chosen for the other Mac, this Mac sends them there.
It sits next to Take Peripherals When a Display Connects, which fires when a display connects to this Mac. A monitor that stays connected to both Macs never connects or disconnects when its input changes, so only the new section sees that switch.
Off by default. Apple silicon only, and not in the App Store build.
Settings
How it works
MonitorInputServicereads VCP0x60(input source) over DDC/CI through the privateIOAVServiceAPI, loaded withdlsym, on theDCPAVServiceProxyservices whose location isExternal. Each service is matched to its CoreGraphics display by EDID, read at I2C address0x50. Replies are checksum-checked.DisplayMonitorpolls every 1.5 s, only while the feature is on and a connected monitor has a trigger. Reads run on a serial background queue.Also changed
sendwith only some peripherals on this Mac used to show "Peripherals Split Between Macs". It now sends the ones that are here, each through the per-peripheral send with its own ping preflight and rollback, so a failed send can't pull back peripherals the other Mac holds.Limits
Permissions
The direct build's sandbox gets
com.apple.security.temporary-exception.iokit-user-client-classforDCPAVServiceProxyUserClient, whichIOAVServiceneeds to reach the display. The App Store build leaves the code out.Testing