234 comments

[ 4.7 ms ] story [ 260 ms ] thread
I use the IOGear switch between windows/pc and like 1/5 times it doesn't switch correctly (it'll end up holding the option key down or something.)

are there any keyboard switches that emulate a keyboard correctly instead of just unplugging and replugging the usb connection?

I've given up finding a KVM that has this support for emulation. I've got a Kinesis Freestyle Edge RGB and even for the better ConnectPRO KVMs, there are just too many USB endpoints.

I found that X-Keys make a range of keypads that are specifically designed for KVMs. I have it setup for KVM switching and the remaining keys have other macros. I'm glad I got it, but it's expensive compared to DIY kits.

> are there any keyboard switches that emulate a keyboard correctly instead of just unplugging and replugging the usb connection?

StarTech's KVMs have a rather robust USB stack which handles this situation very well.

thank you! any particular products you have experience with?
This is awesome!

I've often dreamed about doing this with a keyboard shortcut ala switching layouts in a tiling WM (or 'real' kvm switches from the CRT + ps2 era).

Is there a good usb hub that supports switching outputs via software?

Some of the IOGear KVMs do provide hotkey functionality.
Neat!

I use a similar setup where I literally have a single USB cable that gives me access to everything: monitor, keyboard, mouse, lighting, camera, microphone.

I just need to plug the cable in the computer I want to use. However, I do need to change the input on the monitor as one of the them is connected via HDMI.

You must in the USBC world!
USB connectors have a terrible plug/unplug lifespan.. I have a few computers where the USB ports can't be used because they have been unplugged too often.

Might just be USB-A, I haven't looked at the other specs

I like it! Thank you for sharing the code!

By the way, I have that same USB switch. I have tried a number of them, and that is the fastest I've found. The only major flaw is the status lights -- they are too hard to see from far away.

To fix that issue, I drilled a hole in the top of the case, over the lights, about the same size as the adjacent power button. I put a small piece of foam inside to separate the two lights, and covered it with tape. It works perfectly now and it's so much easier to see the status from a typical usage angle.

The whole modification took maybe 15 minutes, and I didn't even bother disassembling it first.

This is an interesting hack, thanks for sharing! I agree the status lights are hard to see...
> I wrote some software.

And my heart sank.

Zero chance of getting that past corporate laptops that are way too locked down for actual code anything beyond VBA

Then just have corporate buy you a real KVM switch?
ive done the same on Linux using udev rules and a simple usb switch. i use it for a VM with a physical GPU attached and it worked great ever since.
To paraphrase the internet. Sample configs or it didn't happen!

Seriously, I'd love to see this. I have had mixed results with udev and no idea where to start to send an input switch command to my monitor.

I was searching for it couple weeks ago. The cheapest KVM for two monitors at ebay starts from $80. So, good job.
I have similar setup without the software to automatically switch inputs. I use the physical buttons on the monitor to switch input. Not efficient but I get a better resolution than pushing display through a cheap KVM switch. Will be trying software in article. Anyone know of software that runs on Linux to switch display the input? OP lists Windows and Mac OS support.
that's one monitor
This fails at two criteria presented in the second paragraph:

- it only supports one 4K monitor, not two,

- it doesn't support USB-C.

That's USB 2 and one monitor. He is looking for USB 3.

Also, I can tell you it's harder than you'd think to find good hardware in this area, so I don't think the software effort is wasted.

Interesting image descriptions. The 6th one says "Suport operate system" with a Windows 7, 8 and Vista icons.
This is great! I did something very similar using AutoHotKey and Synergy : https://moshen.net/posts/virtual_kvm/
That looks nice! But there are two downsides:

- Your solution requires Synergy. In my experience, Synergy has been buggy--or at least extremely finicky--every time I've tried it since release circa 2001. When it comes to input devices, I want things to be basically flawless. So I like this very simple fix better.

- The posted solution is cross-platform between Mac and Windows, which is a common use case. Yours relies on Autohotkey, which is awesome on Windows but, last I checked, terrible on Mac OS.

Yeah, fair points. Every now and then I have to stop/start Synergy for it to work. Since my mouse/keyboard remain connected to my Windows machine, it can act as the "server" and issue the DCC to the monitor to switch when my key combo is hit. So I only ever run it on the Windows box.
The other thing about Synergy is that it's a bit of a question mark in terms of security, even with encryption enabled (at least that I've seen — would be happy to be corrected!)
Please support Barrier[0] (FOSS) or, perhaps, just buy ShareMouse[1] or download Input Director[2] (free but closed source) rather than supporting Synergy.

I worked for Symless for 2 years and I can tell you first hand that the owner had little interest in fixing or improving the core functionality, the code for which has remained largely unchanged for 12-15 years.

Most of the input bugs in the software are a decade old, and unless a community patch comes along that can be merged, the owner only has interest in keeping it working on new OS versions, and tarting up the UI/UX to support Symless as a lifestyle business.

In the 2 years since I left I've seen exactly 3 bugfix releases, one of which broke TLS, and none of which seemed to contain any significant original work.

Supposedly Synergy 3 is in the works, after Synergy 2 (which I worked on) was scrapped, but this will almost certainly only be a proprietary Electron UI for the FOSS CLI instead of a Qt/QML UI for the FOSS CLI (as v2 was).

Major versions of Input Director (v2.0) and ShareMouse (v5.0) have been announced in the last few months, and it looks like significant work has taken place on both projects. Both of these products need better marketing.

Unfortunately none of the alternatives to Barrier/Synergy seem to want to support Linux, which remains its moat. The days for that are numbered due to Wayland though (Synergy uses the X11 XTest extension to inject input).

[0] https://github.com/debauchee/barrier

[1] https://www.sharemouse.com/

[2] https://www.inputdirector.com

That's good to know. I certainly haven't seen progress made on Synergy in the years I've been using it. Barrier wasn't forked when I initially made and wrote about my setup either, but I think I will make the switch and write a follow up.

The issue I repeatedly ran into with these solutions is that they want to have a "hot" edge and both systems up on independent screens at the same time. I really only want a hot key and one system on my single monitor at a time. Which I could configure with Synergy 1 (not 2).

Thanks for this, I have completely switched over to Barrier. It was painless as I was just able to point it at my old Synergy configuration.

I also updated my post with the recommendation to use Barrier.

Hah, I use a low tech solution: I have a HDMI extension cable that reaches the front of the monitor that I just plug the device I want active into (and a usb splitter similar to what he uses for keyboard and mouse). It’s not quite as seamless as the solution described here but it took no time to set up.
You can get a physical HDMI button so you don't even have to unplug anything: https://www.amazon.com/gp/product/B01L8LLP2G/
"4Kx2K@30hz resolution"

The issue is 4k@60.

Yeah, I did use a switcher before I upgraded my resolution.
Does something like this exist for USB-C devices? I have to plug and unplug a certain device to change it between machines.

Not full emulation and remaining "connected" - just the ability to press a button and change what the device is plugged into.

I have been looking for the same thing. I want to connect my 2 laptops to the same dell monitor via one usb-c port, charge them, use the mouse and keyboard attached to the monitor. Now I have to move the usb-c cable from one laptop to the other, which already started to leave a mark on the port enclosure.
If you get some short extension cables, then most of the wear will be on the cable instead of your devices.
That's basically what I have: extension cable from monitor to front of monitor and HDMI cable from device to extension cable. So worst case is I have to replace either the extension cable or the HDMI cable. Either way, no biggy. I guess I wasn't clear that when I said "I plug my devices in", I meant a HDMI cable that then stretches to the actual devices, so they don't need to be at the monitor (eg my PS4).
I have monitor with TB3 input. I'm switching cables to that slot between laptop (TB3) and desktop (USB-C). Any idea if this prevents extension cable as if I've understood correctly TB3 requires a specific active cable?
We were talking about extension cables to protect the connector on your most expensive equipment. And while there do appear to be TB3 male to female cables, I confess that TB is a problem I haven’t solved yet, and it’s getting bigger.

Generally I’ve only been unlugging my work laptop from my desk about three times a week but for work-life hygiene I should probably unplug it at 5pm 5 days a week. Since it’s mostly split across 2 laptops and occasionally a third, I know the cable will go but haven’t thought too hard about the laptops so far.

TB monitors mostly means I’m wearing out one connector instead of three (can you wear out MagSafe?) so it’s an improvement.

You seem to be asking about a solution where you don’t have to move any cables? I’m not sure I have enough TB3 ports anywhere to do that. Someone with a complete TB3 system might be able to put one computer at each end of a chain, but I think you’re right that they won’t play nice, and you could never go to three. Docking station or KVM switch are probably it.

No, I'm interested in having a short male-female extension cable plugged into my monitor so I can use that slot when I switch between my computers. Currently I have to change the TB3/USB-C cable directly to the monitor twice a day: once in the morning to plug in work laptop, and again in the evening to switch to my private desktop after work day.

I wouldn't want to wear out the slot in the expensive monitor, but rather have a short extension permanently attached just for manual cable plugging purposes.

I have another solution to the same problem using a monitor which has both HDMI and DVI. The HDMI port is used for the 'main' machine which the DVI is connected through a DVI-HDMI connector to any secondary machine which I may want to connect. Switching between the two is either automatic - when there is no signal on the DVI input - or through the monitor source selector. The monitor also has a few analog inputs which I have used on occasion with older laptops, extending the scheme even further. Of course this only switches the monitor, not the keyboard so it is not a complete replacement for a KVM switch.
This would probably work great for running VMs with a hardware pass-through GPU. Can't wait to try this out.
(comment deleted)
for those who have less time than money, https://store.level1techs.com/?category=Hardware
Both of the KVMs meeting his criteria on that page are sold out (and one is a pre-order as well as being sold out).
Another option is the Aten CS1944DP - 4 input dual 4K60 USB3 KVM switch - I have it and it's rather wonderful given I now have my work laptop here due to covid - not cheap, but it's really, really good.
Not cheap is quite the understatement. I could easily just get another screen for less money.
Depends on your use-case - I already have two screens but I need them switching between multiple computers - there are very few options for dual display multiple input KVMs which can support 4K60 and USB3
Would somebody like to help me understand why KVM switches are so sophisticated? A DisplayPort cable has 20 pins, so why can't it just be a 20 pole switch? (Or 30 pole for two USBs and a headphone jack, etc.)
Signal integrity. High speed signals degrade with even slightest mismatch in trace length or stubs. For high-speed signals you use a chip which is essentially an electrical repeater to redirect the output to port A or B.
It can be, eBay has HDMI physical switches for like $8. Your computers will see it as a monitor unplug, though, and do fun things with adjusting windows/icons/resolutions, and then have to re-handshake on every switch. Not a blocker, just a pain.

I'm also not 100% sure if it'll freak HDCP out.

I bought a HDMI switch and a USB switch. Total cost was under $30. I now have to press two buttons instead of one but that's about it. However, I don't know how to scale that for two monitors. I prefer a single monitor setup so it works for me.
iirc most of this switches (and cheap chinese capture cards) work around this problem by "breaking" HDCP. Problem solved.
At the multi-gigabit speeds of a modern video signal, the components of a normal mechanical switch are antennas.
So are the pins in cable connectors, but cables are (relatively) cheap and switching signals by replugging connectors works just fine.
In my experience displayport and DVI cables of all brands and prices are incredibly fragile and definitely stop working well soon if you plug/unplug them once too often.

Too often is something like 20-30 times.

No, cables and connectors these days are shielded and extremely tightly controlled. The amount of work that goes into designing them is staggering. (and that's before considering active cables)
A lot of it has to do with the electrical properties of such a switch. Even older versions of DisplayPort have massive data rates, meaning each electrical signal switches many millions of times a second. Also, each signal may have to switch states close to the same time as the other signals, meaning there needs to be some sort of matching between the different signal paths.

Add in noise sources from the power supplies, your cell phone, and other sources, and it becomes a challenging physics problem. Not to mention, you don't want those signals leaking out either. At these data rates, wires are both transmitting and receiving antennas.

Switches are inherently very mechanical devices, so designing one that can operate in these conditions reliably would be both complex and expensive. Much easier to have some silicon do it for you.

Isn't this what SPDT and other RF switches are designed to do?

Obviously impractical for a KVM switch, but I wonder if you could build one out of 20 of these.

RF switches are fairly expensive and aren't likely to meet the electrical spec anyway. If they're SPDT, you'll probably need at least 10 of them. What's the motivation for using them?
But I can just pull the plug on any USB 3.0/HDMI/DP cable without any warning to the devices and nothing breaks, why can't a rudimentary switch do the same?
These standards are robust to step-function changes like unplugging and plugging in, through smart electrical, mechanical, and software design. There's a ton of detail here, so if you're interested feel free to DM me.

However, the challenges I am referring to above mostly have to do with the steady state operation of the bus, after it has negotiated it's final data rate and is transmitting at full-blast. That's when you run into the transmission problems (eg. radiation of your signals), or your setup just won't allow you to reach the full data rate due to interference.

In addition to the signal issues outlined in sibling comments, a good KVM switch presents the HID devices full-time, so instead of the computers seeing USB disconnect/reconnects, they don't see any difference at all. This requires a complete USB implementation including HID protocols and something to translate real-keyboard and real-mouse signals into the virtual USB devices.

There are similar considerations regarding DDC passthrough on monitors for resolution negotiation and so forth.

A bad KVM presents to the computer as though the user is disconnecting all the input devices and the monitors every time you switch. These are indeed much simpler and cheaper devices but they cause all kinds of quality-of-life issues when you use them regularly.

Why shouldn't a computer be able to handle reconnection of peripherals without quality of life issues? It's pretty silly if this pure software issue is the reason KVM hardware has to be so complex and expensive.
Some peripherals require configuration after connection. Waiting for this can suck. I'm including monitors here -- a bad implementation will present, as an example, monitors out of order. Another problem you run into is inadvertently cycling through connections too quickly, which can show as devices being disconnected during initialization, causing some systems to flag the device as malfunctioning and refuse to initialize it next connection.

Of course it's easy to say that these are silly problems that should have pure software fixes, but Microsoft and Apple don't exactly accept patches. Let's not pretend that software is optimal.

You can see for yourself by disconnecting your monitor in a multi monitor setup or opening your laptop lid if you use the laptop on a dock. Computer windowing systems seem to take a moment to reposition all the windows and might not remember to redistribute your windows when the monitor count changes.
For many years I was happy with my multi-monitor setups. I'd use multiple screens for work, and turn all off except the center one for watching movies or playing games (because the backlight bleeding of the other screens was annoying, even with a 100 % black image).

That's not possible any more. Microsoft, VESA, nVidia say no. This mustn't be possible. (Actually it used to be possible to add a registry key in Windows 7 that disabled all of this bullshit, but Microsoft wisely decided in Windows 10 to remove that. It must not be done.)

Turning compliant DisplayPort devices off while using a compliant operating system must always garble all windows and shuffle desktop icons around. The spec says so. So it must be. The will of the ancients.

(nVidia will allow you to turn this off, if you are using a Quadro card - then you can use EDID emulation even on display-ports, which causes the OS to think the display is always connected - and more importantly - turned on. One of these areas where Linux is ahead -- although Linux is back to garbling windows like the rest in case you do actually decide, as an individual with agency, not a compliant operating system, to change the arrangement of displays.)

To be honest it probably comes down to being a non trivial problem to get it to be perceptually seamless and a rare enough event that people don't have the incentive to fix it.

Most people aren't plugging/unplugging monitors often

Seems pretty standard in tech offices to a) have one or two external monitors on your desk, and b) disconnect/reconnect them from your Macbook every time you get up for a meeting.

They still handle it horribly though. My favorite is how macOS used to assign the logical displays randomly, so I'd have to fix the arrangement in Displays preferences several times every day.

I have one of those bad KVM switches. How do I know which one to buy to have a good one?
Level1 sells KVM switches that are said to be quite good for their money.
Definitely didn't imagine that KVM switches could actually be that good when I asked the question. (I've obviously never used one.) Thanks!
I have one that's in-between. The monitor is always "present", only the keyboard and mouse get (dis)connected. It works fine, since it avoids the biggest problem of adjusting the screen resolution which can reposition desktop icons, etc. The only drawback is a 3-4 delay as USB mouse/keyboard is reconnected.

The price was around $50 IIRC.

I think KVMs provide the illusion of the monitor still being there when you switch away from that machine? So it doesn't think you just yanked the cable.
Using a literal switch or multiplexer would have the link disappear, so switching causes ~5-10 seconds of delay, assuming the machine doesn't crash or hang because somehow that's okay behavior for computers in 2020...?!

Additionally: The DisplayPort spec mandates that operating systems have to throw a huge temper tantrum and garble your desktop and windows when you disconnect or turn off a display. (Yes, nVidia and Microsoft consistently deny implementing an option to turn this utterly braindead behavior off, saying that it's not a bug, but intended behavior because DisplayPort and VESA say so).

What KVMs instead contain is similar to the rescaler ASICs found in a monitor, they receive multiple streams of display data and mix/forward/scale one of these. But since they constantly receive all of the streams, switching can be instant, or at least as quick the monitor can modeswitch (which, for some reason, takes screens at least a second).

Can you provide more information about the details of DisplayPort you're referring to, and what actual spec-required behavior you're referencing?
This (monitor being removed from the system if I turn it off) must be the most braindead idea I've seen in a while. This is why don't turn off my monitor after work day any more, but leave it on and let it go to power saving sleep when it wants so.

Until I figured out what the hell was going I was pulling my hair every morning when I turned on my work monitor (40-something inch 4k display) and found all program windows in the top-left corner of the monitor, stacked on top of each other and resized to some svga-resolution.

Be happy it only happens when you turn off the display. A display on one of my computers triggers this when it goes to sleep, which is about 20 times a day; even worse, it causes every single window to then shift to the "newly discovered" monitor when it wakes up. Almost makes multiple monitors pointless because you have to constantly rearrange the windows back to how they were.
> What KVMs instead contain is similar to the rescaler ASICs found in a monitor, they receive multiple streams of display data and mix/forward/scale one of these. But since they constantly receive all of the streams, switching can be instant, or at least as quick the monitor can modeswitch (which, for some reason, takes screens at least a second).

Do you know of a DisplayPort KVM switch that actually does that? I tried one a few years ago (it was one of the first ones I saw for a reasonable price), but I returned it immediately because I got the brain-dead window-rearranging behavior you described whenever I switched. I've been reluctant to try another until I know it solves that issue.

I still use one of these HDMI switches (https://www.iogear.com/product/GCS62HU/), because it's EDID support actually does make it transparent to the PCs, so I can switch instantly like I want to.

I haven't used them myself, but I've heard the KVM switches sold by level1tech don't trigger that.
A year ago, I considered their product...then I saw this commentary[1] straight from the cow's mouth:

> Most of the support on (their DisplayPort 1.2 KVM offering) have been down to bad or dodgy DisplayPort cables. Seriously, it's like sort of nuts. Like you go on Amazon, you order a DisplayPort cable, it doesn't work, and it's like, "Well, I have two DisplayPort cables that work independently, but when I plug both of them into the KVM, it doesn't work." The KVM doesn't have a repeater. So if you've got two 6-ft cables that pass through the KVM, it is like as if you have one 12-ft cable, and while one 6-ft cable might work, 1 12-ft cable will not because...(Jedi hand gestures)...repeater. So use good quality cables, you'll be fine.

Ignoring the "repeater" terminology wank, that soundbite disclosed enough about the white label device's internal architecture for me to infer with confidence that even if EDID was properly implemented (the easiest part), the video interface is skimp and doesn't actually buffer frames in realtime...which means that on switch, the monitor's receiving ASIC will detect frame interruption as it starts to receive its new stream and blank for a second or two while it tries to reacquire...which is definitely not the instantaneous performance I was looking for.

[1] https://youtu.be/0b0_yz-oDjQ?t=74

I’m using a TESmart HDMI KVM that behaves well, at least with my monitors. My USB peripherals sometimes need a reset though.
ConnectPRO claims that their switches pass EDID information to all systems. They have some examples of it being in use in Youtube https://www.youtube.com/user/rexwu168/videos

I finally ordered one a while ago after I couldn't find anything cheaper with similar functionality, but it's currently on backorder so it will take some time to arrive & see how well it works in reality.

I have a ConnectPro UDP2-12AP, and can confirm that systems connected to it do not see the monitor go away on switch.

There is an interruption if you press the KVM reset button, but that's not something you should often do.

> The DisplayPort spec mandates that operating systems have to throw a huge temper tantrum and garble your desktop and windows when you disconnect or turn off a display.

Sounds colorful. Can you cite the requirement and revision of the standard referenced? I'd like to read the actual verbiage for myself.

...and I now see your response[1] to an equivalent question.

[1] https://news.ycombinator.com/item?id=24359220

Looking at the normative language of the early DP v1.1a § 3.3 Hot Plug/Unplug Detect Circuitry:

> The HPD signal is asserted by the DisplayPort Sink whenever the Sink is connected to either its main power supply or “trickle” power. HPD signal specification is shown in Table 3-2.

To be sure, HPD assertion on "trickle" power is the monitor's requirement.

Looking closer at Table 3-2 (empty Nom col removed, Comments col separated for clarity):

  | Parameter                          | Min  | Max | Units | Comments |
  | ---------------------------------- | ---- | --- | ----- | -------- |
  | HPD Voltage                        | 2.25 | 3.6 | Volt  | (a)      |
  | Hot Plug Detection Threshold       | 2.0  |     | Volt  | (b)      |
  | Hot Unplug Detection Threshold     | 0.8  |     | Volt  | (b)      |
  | HPD source termination             | 100  |     | kΩ    | (c)      |
  | HPD sink termination               | 100  |     | kΩ    | (d)      |
  | IRQ HPD Pulse Width Driven by Sink | 0.5  | 1.0 | ms    | (e)      |
  | IRQ HPD Pulse Detection Threshold  | 2.0  |     | ms    | (f)      |
> Comments:

> (a) HPD signal to be driven by the Sink Device

> (b) HPD signal to be detected by the Source Device

> (c) Source Device must pull down its HPD input with a ≥ 100kΩ resistor.

> (d) When a Sink Device is off, it must pull down its HPD output with ≥ 100kΩ resistor.

> (e) Sink generates a low going pulse within this range for IRQ (interrupt request) to the Source

> (f) When the pulse width is narrower than this threshold, the Source must read the link / sink status field of the DPCD first and take corrective action. When the pulse width is wider than this threshold, it is likely to be actual cable unplug / re-plug event. Upon detecting HPD high, the Source must read the link / sink status field, and if the link is unstable, read the link / sink capability field of the DPCD before initiating Link Training.

Then just below Table 3-2:

> The voltage level of the HPD pin is monitored by the Source Device. TTL levels must be used for the detection.

> The Sink Device may detect the presence of the Source Device by monitoring the DC voltage level of the AUX CH lines. Source detection is an optional feature of a Sink Device.

Based on this language and description of noted workarounds, color me unconvinced that DP spec ambiguity was the root cause of this issue.

Where is "trickle power" supposed to come from? DisplayPort also mandates that DP_PWR not be connected by cables (only intended for adapters / dongles, see § 4.2.1.1 and Figure 4-23). Note that EC demands that electronics put in stand-by / "off-mode" may not consume more than 0.5 W of wall power.

So I think what might be going on behind the curtains is that 1) DP requiring handling of hot plug 2) DP forbidding "trickle power" being sourced from the DP port 3) monitors perhaps not being able to meet 0.5 W standby if they'd entertain the DP interface 4) Operating systems handling display hotplug disgracefully combine into one heck of a bad user experience.

Things actually start to align now, because this issue started to happen en-masse around 2013-2014. And that's precisely when the more stringent standby power requirements came into force. For example, the Dell U2713H doesn't do this, while the later U2715H does. Both of these are DP 1.2 monitors, so any new mandates in the non-publicly available DP 1.3/1.4 specs shouldn't matter.

> Where is "trickle power" supposed to come from? DisplayPort also mandates that DP_PWR not be connected by cables (only intended for adapters / dongles, see § 4.2.1.1 and Figure 4-23).

The answer seems to me unambiguous when considering the normative language in § 4.2.1.1:

> The standard external cable connector assembly must not have a wire on pin 20, DP_PWR.

...in conjunction with the normative definition of trickle power per § 1.4 (my emphasis):

> Power for Sink Device that is sufficient to let the Source Device read EDID via the AUX CH, but insufficient to enable Main Link and other sink functions. For sink to drive the HPD signal high, at least the trickle power must be present. The amount of power needed for the trickle power is sink implementation specific.

(To be sure, Figure 4-23 per DP v1.1a is single-slot PCI "Panel Cut Out Reference Dimensions", so unsure what was meant to be conveyed there).

> Note that EC demands that electronics put in stand-by / "off-mode" may not consume more than 0.5 W of wall power.

...which is ~150 mA at 3.3 V nominal. Even generously derating 30% to account for ballpark efficiency losses, we're still talking > 100 mA budget to support an explicitly constrained requirement. I mean asserting HPD in the worst case is apparently a 36 uA affair.

Anecdotally, I haven't encountered the issue despite a bias towards DP (on advise from a friend in compliance test over a random beer discussion on radiated emissions performance); all my setups discriminate to either dual U2415 or dual U2412M as a matter of personal preference.

Just thought I'd remark in passing because VESA specs never really struck me as being technically egregious in its ambiguity.

I was referring to DP 1.2, where Figure 4-23 shows the exact pin connections of a cable.

> ...which is ~150 mA at 3.3 V nominal.

Small power supplies become very inefficient due to relatively fixed losses relative to output power. The 0.5 W spec is wall power, so if you fully use the 0.5 W, you might get 0.1-0.2 W worth of output.

> Anecdotally, I haven't encountered the issue despite a bias towards DP (on advise from a friend in compliance test over a random beer discussion on radiated emissions performance); all my setups discriminate to either dual U2415 or dual U2412M as a matter of personal preference.

I'm using a Dell U2415 connected by DisplayPort to Intel graphics right now, and if I turn it off (using the soft buttons) my desktop and windows are garbled because it "disappears" from the system despite not being disconnected.

Compare this to the DVI days where I could literally switch the outlet strip powering my screens off and nothing would get garbled, and the system would never hang or crash. I'm pretty sure it's impossible for DisplayPort to support that, since the display has to be powered to avoid being un-detected by the system. So I'm not asking for that to work. Obviously a good standard would support this usage, but DP never will, so okay, fair enough. I'm just asking for the insanity of "disconnecting" monitors sent to stand-by / "soft button off" and subsequent garbling of my workspace to stop. And while they're at it, maybe fix crashes and hangs on monitor re/disconnects. Y'know, it's not really "plug and play" if I plug it in and have to hit the reset button to get my machine back.

Real world analogy: A standard for desks that dump everything on the floor as soon as you turn your back to them would never fly. But somehow the equivalent is acceptable for computers.

PS: A Japenese entrepeneur sells DPHPDMA devices, which are little dongles plugged directly into a Displayport output and contain a microcontroller powered by DP_PWR, which intercepts the EDID communication etc. and essentially performs EDID emulation in hardware (since GPU manufacturers disable software EDID emulation for consumer cards). They're like 50 bucks plus international shipping each.

Another question is why does it take so very long in human scale for all these things to happen? You'd think scanning for a valid data frame and flinging bits onto the glass would take under one frame, so 0.01s?
With respect to HPD, one contributing factor per DP 1.1a § 5.1.4:

> There is no mandatory time constraint on the Source Device’s response to a plug / re-plug event, but a Source Device vendor may want to impose a voluntary constraint similar to that for HPD IRQ events (for example, 100 ms) to ensure a good user experience via prompt discovery and configuration of newly attached devices.

There's a lot more going on behind the scenes than mere "scanning for a valid data frame and flinging bits onto the glass", and much of it has nothing to do with approaching technical limits, e.g. the dynamic of multiple product vendors finding incentive to reach consensus in standards development despite naturally seeking to cut each other's throats in the open market.

You wouldn't happen to know how to prevent the tantrum from happening? It's been driving me nuts
Disable all power saving / standby features and never turn the screens off manually or cut their power while the PC is on.
And perhaps a little unpaid ad:

> PS: A Japenese entrepeneur sells DPHPDMA devices, which are little dongles plugged directly into a Displayport output and contain a microcontroller powered by DP_PWR, which intercepts the EDID communication etc. and essentially performs EDID emulation in hardware (since GPU manufacturers disable software EDID emulation for consumer cards). They're like 50 bucks plus international shipping each.

Check out a DisplayPort cable teardown. I was surprised how complicated they are! Long gone are the days of simple 'copper only' cables. These high bandwidth cables have electronics on both sides to negotiate with the devices they connect to and to optimise data throughput from one end of the cable to the other.
USB is a differential signal, not a digital one (like a GPIO square wave), and once you lose the training the connection is lost: it's basically a replug, but you can't do it too quickly, so you need to build a circuit to switch it; or just have a smart hub that electrically switches it by maintaining all of the connections (phy links).
There isn’t a tb3 kvm switch available on the market, that would do what I need. So I’m just re-plugging the tb-3/usb-c docking station downlink cable between two laptops. All the peripherals are connected to the docking station so I don’t need to switch them.

Probably could build a mechanical contraption to do that on a lever push. So that’s what I’m curious about too: why yet no mechanical switch if I’m literally doing it manually already?

Back in the old days (early 90s), they actually were many-pole switches. If you opened one up, it looked like a stack of washers with a bunch of wires coming out of it, more like a variable capacitor than a normal switch.

They were very expensive and very unreliable. If something was weird, click it back and forth a few times and maybe it fixes itself.

Nowadays the signaling is too fast to go through a physical switch and most devices would be unhappy to be plugged/unplugged so rapidly.

> A DisplayPort cable has 20 pins, so why can't it just be a 20 pole switch?

I use magnetic 20-pin USB C adapters to connect laptop thunderbolt and usb c to a DisplayPort headset and misc. Less worry about yanks; easy dis/re-connect; simplified cable and headset handling. No issues so far. I like them. Though I've not been pushing the DP bandwidth hard. And because they disconnect much more easily than a plug, I can't for instance move the laptop around and expect the cabling to simply follow.

But to use them for frequent hot swap, compared with a real switch, I'd be worried about duty cycle lifetime. And the dis/connect isn't hidden from the environment, which might be inconvenient.

Haha, this is clever and I like it. You turned what is usually solved on the physical layer to something solved on the logical layer - which is almost always better because you can express conceptual changes much better when you don't need hardware.

It's a small taste of the stuff that software-defined networks have added to networking.

I have an MX Keys keyboard that can connect to up to three devices (with three special keys). Unfortunately, the operating system does not see the key pressed. But if it was, I could activate the display input switching using your app (thanks!). I have filled a support request at Logitech, maybe one day...
Are other keys (e.g. Fn) mappable to the special keys? Maybe you could work around it by setting e.g. F1-3 to F1-3 + Special1-3, and then input switching on F1-3.
Or the other way around? Map the special keys to F13 or something. (Normal keyboard only have up to F12, but I believe the standard allows up to F24.)
Reminds me of a similar post in HN in order to switch inputs on a single monitor, between mac and PC, via software only. Ideally a shortcut on the mac desktop in order to switch to HDMI and another shortcut on the PC desktop to switch to DisplayPort. For sure I’m going to give a go at the code of this soft/hard KVM.
Very cool. Will this only work over HDMI?
I imagine it will work on any input your display supports
I hoped for the actual switch schematics :) .

Offtopic: I wanted to buy this USB switch, but it's hard to get on the current market in my country (or available for an absurd price). So I started trying to build my own... which was fun, but then I understood I need a some USB/MAX chips that are also hard to find, and started to cause me frustration instead of fun, because I'm not really that good with low-level electronics, university was a long time ago. And I was still without my switch/hub. So at the end I just chose a 3-pole double-throw toggle switch and a couple of USB connectors and wired them up. I only need to switch my keyboard, because my mouse is multi-device. If I need more, I'll just wire a hub to it. Work is in progress, but it can't get simpler than that.

If you're wondering what got complicated, well as far as I read and understood, actually breaking a USB connection with solid state logic is kind of a pain in the neck if you want to stay within the USB parameters, at least for an inexperienced designer like me. And you need to build the power supply for the circuit, and I didn't want to introduce an external power supply, I wanted to piggyback of the USB source. Something this ugreen product does not do. So I left this project for another time, when I freshen up on my perished knowledge. A mechanical switch just switches the lines and that's it.

I opened the same ugreen switch up and plan to attach some wires from the button pins to my RaspberryPI. This way I will be able to use my RaspberryPI to switch between the two USB hosts and use the RaspberryPI's built-in CEC support to switch between video inputs.

What the board looks like: https://imgur.com/lX1uZ7Q

That's cool. As another alternative, this is the one I bought at start of lockdown which does everything but the USB-C: https://smile.amazon.com/gp/product/B0851CMHP2/

Not particularly cheap but at least no longer back-ordered. I've been pretty happy with it switching 2x4K monitors, keyboard and mouse between a Mac and a PC laptop. Both corporate laptops where custom software is more difficult.

You like this one? I have been looking for a while, but didn't find one I felt was trustworthy in that price range. For instances 11 reviews on this one.
This is perfect. The software competent is exactly what I was missing from my setup. I use a USB switch to switch my peripherals but I've been manually changing the input on my monitor like a caveman.
I'll have to have a go at this DDC/CI stuff as well. I too have a USB switch that just works (click button, two seconds later other computer has keyboard and mouse, and whatever else is on it, click again, back to the other one). It's simple, it's foolproof, and I can do it with my eyes closed if I so wanted to.

Now, switching the monitor however…

This involves clicking the six buttons on the rear of the monitor in an arcane sequence (your fingers sort of curl around the side, the buttons have labels on the front of the monitor on the right-side bezel, and yes, that works as well as you can imagine). Which then switches the monitor:

* Button 1: activate menu

* 1 again: select input

* 2: move down list of three inputs

* 2: move down list of three inputs

* 3: select mini display port

A somewhat similar sequence exists for going back to its HDMI input.

But hold on! It gets better if you turn off the computer you have live at the moment. The monitor then goes blank, and until it throws its 'no signal found' message, it won't respond to anything. If you are lucky, you can switch inputs before the current computer is shut down completely and the monitor blanks itself.

I do feel like a caveman.

The software on modern displays is often abysmal, with the exception of Dell's in my experience.
It really is. All I want is one button that just cycles to the next active port connected.
Unfortunately it looks like my monitor does support DDC but does not support VPC Code 96 (0x60) meaning I can't programmatically change the input. What a bummer.

Monitor is ASUS PG348Q.

That's a shame. I had more luck it seems — BenQ PD2700Q:

    Feature: 60 (Input Source)
        Values:
           0f: DisplayPort-1
           10: DisplayPort-2
           11: HDMI-1

    sudo ddcutil setvcp 60 0x11 # To HDMI
    sudo ddcutil setvcp 60 0x10 # To DisplayPort 2
Nice! Installing ddcutil¹ was a breeze too. No extra configuration needed on Ubuntu Linux. Although a few tweaks are needed to give the local user access instead of root.

1: http://www.ddcutil.com/

My LG 38WN95C says it supports 0x60, but then doesn't nothing when I set it (whereas other controls work, such as volume and brightness).

I wonder if there's any hope of hacking a solution to this, as it seems unlikely the LG would actually fix it.

There was a comment here yesterday[1] about DDC/CI writes being finite on some hardware — is that a concern with this approach?

[1] top comment - https://news.ycombinator.com/item?id=24344045

100K switches is switching your input 4 times a day for 68 years. You'll probably want a new fancy 32K monitor by then anyways. ;)

Also, if your monitor stores the current input in EEPROM, changing it via the OSD will also write to EEPROM, so it's not like you're saving the EEPROM by doing it manually (buying a real KVM is another story, obviously).

The Headline hit me right in the stomach because it was just yesterday that I was pondering whether to build or to order a USB Switch. With much to do currently, I wussed out and just ordered it. I didnt pay 38$ though: https://de.aliexpress.com/item/1005001274095928.html USB 2 is more than enough for mouse and keyboard and it has the additional advantage of having an extension button to switch.
I don't always trust tech from Aliexpress but sometimes it's worth a gamble. I had a look at that brand and they also do a KVM (HDMI, 2 USB ports for K/M) for USD $16. That seems way too cheap but I don't really understand the tech enough to know for sure.