TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How I built a keyboard/video/mouse switch for my two 4k monitors

458 点作者 car超过 4 年前

44 条评论

ohazi超过 4 年前
Okay, let&#x27;s talk about that USB switch [1], because I was looking for one a few days ago and discovered something ghastly about the majority of the ones available on Amazon:<p>Most of them use a USB Type-A to Type-A cable for the link between the switch and PC.<p>This cable violates the USB spec, and is the moral equivalent of an electrical cord with prongs on both ends. It should never, ever be made or used, because plugging one of the ends into the wrong receptacle can destroy both USB ports.<p>The correct cable to use here would be a standard Type-A to Type-B or Type-A to Micro-B cable, but for some reason a very small minority of these switches do that [2].<p>WTF is going on here?<p>[1] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;B01N6GD9JO&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;B01N6GD9JO&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;B083JKDNRJ&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;B083JKDNRJ&#x2F;</a>
评论 #24360716 未加载
评论 #24360103 未加载
评论 #24360104 未加载
评论 #24360130 未加载
评论 #24360511 未加载
评论 #24360008 未加载
评论 #24360558 未加载
评论 #24360030 未加载
评论 #24360134 未加载
评论 #24359977 未加载
评论 #24360559 未加载
评论 #24364989 未加载
ElCapitanMarkla超过 4 年前
I know this isn’t the same but if you don’t need to switch the monitor inputs and only need mouse &#x2F; keyboard support. I’ve been using <a href="https:&#x2F;&#x2F;github.com&#x2F;debauchee&#x2F;barrier" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;debauchee&#x2F;barrier</a> for the last few years.<p>It works surprisingly well, no noticeable lag even when gaming.
评论 #24359768 未加载
评论 #24360501 未加载
评论 #24361705 未加载
评论 #24359453 未加载
评论 #24359369 未加载
评论 #24361390 未加载
zachrose超过 4 年前
Would somebody like to help me understand why KVM switches are so sophisticated? A DisplayPort cable has 20 pins, so why can&#x27;t it just be a 20 pole switch? (Or 30 pole for two USBs and a headphone jack, etc.)
评论 #24358548 未加载
评论 #24358971 未加载
评论 #24358760 未加载
评论 #24358540 未加载
评论 #24358801 未加载
评论 #24358542 未加载
评论 #24358524 未加载
评论 #24359303 未加载
评论 #24363726 未加载
评论 #24362627 未加载
评论 #24361692 未加载
评论 #24359027 未加载
评论 #24359629 未加载
zargon超过 4 年前
The disadvantage of this arrangement, which may not be obvious until you try it, is the delay in switching time. You have to wait for the monitor to re-sync on the new signal and for the USB to enumerate on the new host. I guess most people can tolerate this? For me that delay is intolerable. Quality KVMs (ConnectPRO is the one I remember off the top of my head) maintain both connections at all times and switching is instantaneous.
评论 #24360874 未加载
评论 #24362945 未加载
D13Fd超过 4 年前
I like it! Thank you for sharing the code!<p>By the way, I have that same USB switch. I have tried a number of them, and that is the fastest I&#x27;ve found. The only major flaw is the status lights -- they are too hard to see from far away.<p>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&#x27;s so much easier to see the status from a typical usage angle.<p>The whole modification took maybe 15 minutes, and I didn&#x27;t even bother disassembling it first.
评论 #24358530 未加载
nkrisc超过 4 年前
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&#x27;ve been manually changing the input on my monitor like a caveman.
评论 #24362284 未加载
doctorhandshake超过 4 年前
There was a comment here yesterday[1] about DDC&#x2F;CI writes being finite on some hardware — is that a concern with this approach?<p>[1] top comment - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24344045" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24344045</a>
评论 #24360897 未加载
dkersten超过 4 年前
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.
评论 #24358633 未加载
评论 #24358393 未加载
评论 #24359498 未加载
评论 #24358268 未加载
salex89超过 4 年前
I hoped for the actual switch schematics :) .<p>Offtopic: I wanted to buy this USB switch, but it&#x27;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&#x2F;MAX chips that are also hard to find, and started to cause me frustration instead of fun, because I&#x27;m not really that good with low-level electronics, university was a long time ago. And I was still without my switch&#x2F;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&#x27;ll just wire a hub to it. Work is in progress, but it can&#x27;t get simpler than that.<p>If you&#x27;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&#x27;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&#x27;s it.
评论 #24360483 未加载
Fannon超过 4 年前
The Dell U3219Q monitor has a (rather rare) feature that gets rid of the need for a KVM switch for me entirely.<p>It has both an USB-C input and an USB3 upstream that can be combined with either DisplayPort or HDMI. It also has signal auto detection.<p>When I&#x27;m starting up my PC, it will use the USB connection from my PC via USB3 upstream. When I power up my work laptop, it will take USB from its USB-C connection.<p>That even eliminates the need to push a button to switch. I&#x27;m really happy with this setup.
评论 #24362141 未加载
评论 #24361701 未加载
justaguy88超过 4 年前
for those who have less time than money, <a href="https:&#x2F;&#x2F;store.level1techs.com&#x2F;?category=Hardware" rel="nofollow">https:&#x2F;&#x2F;store.level1techs.com&#x2F;?category=Hardware</a>
评论 #24361817 未加载
评论 #24358376 未加载
renewiltord超过 4 年前
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&#x27;t need hardware.<p>It&#x27;s a small taste of the stuff that software-defined networks have added to networking.
dasloop超过 4 年前
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...
评论 #24358982 未加载
bijant超过 4 年前
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: <a href="https:&#x2F;&#x2F;de.aliexpress.com&#x2F;item&#x2F;1005001274095928.html" rel="nofollow">https:&#x2F;&#x2F;de.aliexpress.com&#x2F;item&#x2F;1005001274095928.html</a> USB 2 is more than enough for mouse and keyboard and it has the additional advantage of having an extension button to switch.
评论 #24359536 未加载
voltagex_超过 4 年前
DDC&#x2F;CI seems like an absolute crapshoot - I&#x27;ve got some 10 year old Dell monitors that don&#x27;t seem to support it at all, but someone with the same monitors reported brightness control.<p>I just checked my 2019 Acer XB27HU, which reports brightness control but it doesn&#x27;t seem to work - it then got stuck in Factory Test mode. It doesn&#x27;t support input selection and doesn&#x27;t do any kind of hotplug detection. I&#x27;ve never seen a monitor review mention these kind of features, either.
评论 #24360347 未加载
评论 #24360741 未加载
mmsimanga超过 4 年前
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.
评论 #24358420 未加载
cellular超过 4 年前
There are full software solutions that just show the screen over the network and relay your mouse&#x2F;keyboard to whichever machine is on focus.<p>It worked well enough that I&#x27;d forget which pc the kvm s were actually connected to. But I was only programming, not gaming, so maybe the 60Hz would be a problem. no hurt to try. It was free and there were a couple software solutions.
评论 #24359328 未加载
评论 #24360396 未加载
PiMaker超过 4 年前
Did something similar a while back in C#. Registers itself as a system service so it can even switch displays when no user is logged in (i.e. you&#x27;re on the Windows login screen). Also has a web GUI for configuration.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;PiMaker&#x2F;DDCKVM" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;PiMaker&#x2F;DDCKVM</a>
globular-toast超过 4 年前
Since working from home I&#x27;ve had the exact same use case. I thought a KVM would be perfect, but was really surprised that they are incredibly expensive and don&#x27;t really seem very good anyway. It&#x27;s odd because switching the keyboard&#x2F;mouse seems easy, while switching the monitor inputs is something that is done by AVR receivers which can be found for less than a KVM.<p>I&#x27;ve resorted to having both machines plugged into my monitors and switching inputs using the monitor front panel. Not ideal. For the keyboard&#x2F;mouse I currently just have two of each on my desk. Also not ideal, although I must admit it provides some semblance of work&#x2F;life separation. I&#x27;m going to look into one of the software solutions for switching the keyboard&#x2F;mouse.
vaillancourtmax超过 4 年前
Neat!<p>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.<p>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.
评论 #24363444 未加载
评论 #24358169 未加载
desdiv超过 4 年前
While we&#x27;re on the subject on KVMs, what do you guys do about audio?<p>Currently I have one computer connected to the AV receiver via TOSLINK (optical audio). The other computer is connected to the receiver via coaxial S&#x2F;PDIF. When I switch computers I have to physically go to the receiver and switch between the two input channels. This presents two problems:<p>P1: Manual action required<p>P2: Only one computer can play sound at any given time<p>Ideally, I would want a S&#x2F;PDIF mixer that can decode the two S&#x2F;PDIF streams, add each constituent channel together, and then output that as a single S&#x2F;PDIF stream to the receiver. But I can&#x27;t seem to find this anywhere.<p>Most mixers I&#x27;ve found are:<p>1. Analog mixers<p>2. Pro audio mixing consoles that have a dozen input channels and 50 dials on it, with a price tag to match
评论 #24360348 未加载
评论 #24360410 未加载
评论 #24364361 未加载
m0shen超过 4 年前
This is great! I did something very similar using AutoHotKey and Synergy : <a href="https:&#x2F;&#x2F;moshen.net&#x2F;posts&#x2F;virtual_kvm&#x2F;" rel="nofollow">https:&#x2F;&#x2F;moshen.net&#x2F;posts&#x2F;virtual_kvm&#x2F;</a>
评论 #24361500 未加载
评论 #24358276 未加载
AntiRush超过 4 年前
This is awesome!<p>I&#x27;ve often dreamed about doing this with a keyboard shortcut ala switching layouts in a tiling WM (or &#x27;real&#x27; kvm switches from the CRT + ps2 era).<p>Is there a good usb hub that supports switching outputs via software?
评论 #24358092 未加载
yfiapo超过 4 年前
That&#x27;s cool. As another alternative, this is the one I bought at start of lockdown which does everything but the USB-C: <a href="https:&#x2F;&#x2F;smile.amazon.com&#x2F;gp&#x2F;product&#x2F;B0851CMHP2&#x2F;" rel="nofollow">https:&#x2F;&#x2F;smile.amazon.com&#x2F;gp&#x2F;product&#x2F;B0851CMHP2&#x2F;</a><p>Not particularly cheap but at least no longer back-ordered. I&#x27;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.
评论 #24360423 未加载
narrowtux超过 4 年前
I had the same problem, and one of my displays is insanely picky when it comes to switching sources. It seems like it will only attempt a handshake once, and when the source is not ready for it, it will switch back.<p>I bought HDMI&#x2F;DisplayPort switches which are capable of 4k60 and are very cheap. Only these combined KVMs have outrageous prices, but if you&#x27;re fine with using multiple switches it can be achieved quite cheaply.
mercora超过 4 年前
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.
评论 #24358727 未加载
aloer超过 4 年前
I recently bought a Philips 346b1c (34&quot; UWQHD with built-in USB C hub + KVM) and the use of DDC&#x2F;CI to tell the monitor what input to switch to could come in super handy here.<p>The display is very good at automatically switching KVM based on the selected input, but the selection still has to be done with the little buttons underneath the screen
trissylegs超过 4 年前
Thanks for this. I was thinking about doing something like this. Because:<p>1. I have 4k 144hz monitor. Not many devices or even display protocals can handle that (I won&#x27;t be able to even fully utilize it until I upgrade my desktops graphics card).<p>2. The amount of cambes I have for my current KVM swicth (for my second, 1080p, monitor). Is getting unweildy.
NKosmatos超过 4 年前
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&#x2F;hard KVM.
TehCorwiz超过 4 年前
This would probably work great for running VMs with a hardware pass-through GPU. Can&#x27;t wait to try this out.
car超过 4 年前
The author of this project is on HN. I hope he reads this and makes a top-level post, in case anyone has a question, suggestion or thanks for him.<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;user?id=haimgel" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;user?id=haimgel</a>
joshu超过 4 年前
I use the IOGear switch between windows&#x2F;pc and like 1&#x2F;5 times it doesn&#x27;t switch correctly (it&#x27;ll end up holding the option key down or something.)<p>are there any keyboard switches that emulate a keyboard correctly instead of just unplugging and replugging the usb connection?
评论 #24358057 未加载
评论 #24358412 未加载
milofeynman超过 4 年前
I have been using a KM switch and manually switching the monitor for the last few months. I was wishing there were a way to programmatically change the input, and apparently there is! But I assume this is only supported by some monitors. I will try it out tonight. Thank you
brian_herman超过 4 年前
<a href="https:&#x2F;&#x2F;store.level1techs.com&#x2F;products&#x2F;kvm-switch-dual-monitor-model" rel="nofollow">https:&#x2F;&#x2F;store.level1techs.com&#x2F;products&#x2F;kvm-switch-dual-monit...</a> A little more expensive. But gets the job done!
c0smic超过 4 年前
Big fan of the Level 1 Tech KVMs, both the hardware and support are quite good. You&#x27;re way more likely to run into issues with docks&#x2F;monitors&#x2F;usb devices etc than something actually wrong with the KVM itself.
dugmartin超过 4 年前
I use a combination of a cheap USB switch and the remote for my 4K monitor (really a 43&quot; TV) to switch inputs. Not as nice as one button press but much cheaper than a high end KVM.
评论 #24359347 未加载
crisopolis超过 4 年前
Wow, I use this same USB switch and also use two monitors for everything. Right now I manually switch my main monitor and just gave up on switching the monitor above it.<p>But this is friggin awesome.
mandeepj超过 4 年前
I was searching for it couple weeks ago. The cheapest KVM for two monitors at ebay starts from $80. So, good job.
j45超过 4 年前
It would be great if it was possible to extend this into a kvm over ip.
keithnz超过 4 年前
depending what you are doing, I find remote desktop solutions to be pretty good. However, multi monitor can be problematic.
评论 #24360359 未加载
评论 #24361876 未加载
Splendor超过 4 年前
Very cool. Will this only work over HDMI?
评论 #24358623 未加载
thefz超过 4 年前
&gt; for my two 4k monitors<p>Weird flex, but okay.
haram_masala超过 4 年前
<a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;aw&#x2F;d&#x2F;B0817YFJKW" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;aw&#x2F;d&#x2F;B0817YFJKW</a><p>$60 shipped.
评论 #24358144 未加载
评论 #24358465 未加载
评论 #24358142 未加载
评论 #24358131 未加载
Havoc超过 4 年前
&gt; I wrote some software.<p>And my heart sank.<p>Zero chance of getting that past corporate laptops that are way too locked down for actual code anything beyond VBA
评论 #24358191 未加载