4
1
I'm using a KVM-switch like setup to share my keyboard and mouse between a Windows machine and a Linux machine.
I have a Logitech Mouse and Corsair (K95-RGB) Keyboard (ironically both devices made and optimized for windows with only windows-side official driver support...) and the problem is that when I switch the devices from Windows (or offline) to Linux, Linux picks up that the devices are plugged in and activates them immediately, I can use the devices within 1 second no matter how recently I last switched or which state the devices were in previously.
When I switch from Linux (or offline) to Windows, Windows can take an awful amount of time to first detect the devices, and another awful lot of time to actually enable them...
According to my Windows clock (I counted), roughly 38 seconds for device detection (powering on), and another 17 seconds (update: on a re-test later on I found the mouse activating in ~15s and keyboard 5 secs later, or in ~20s) for device activation (e.g. for the driver to kick in properly, so from the time I switch to windows I waited 55 seconds before I could use the devices) this time was the same for both my Keyboard and Mouse despite using separate driver software and being completely different devices.
So what takes Linux effectively around 1 second to do, windows takes up to 1 minute to do, usually in the range of 40-60 seconds based on my experience over roughly half a month.
To further clarify things. The first 35-40 seconds that Windows takes to power on/detect the devices only happens if the devices were recently disconnected. Basically what is happening is that when I disconnect the devices (switch away from Windows) windows takes 35-40 seconds to acknowledge that the devices have been disconnected (making the device disconnected sound). If I switch back to windows after this point, the devices are detected/powered on immediately, but still take a good 15-20 seconds to be usable (for the drivers to work).
Question #1 is whether I can somehow hasten the driver enablement for the devices after they have been detected and powered on? (Maybe somehow prevent the drivers from being unloaded completely in the first place? Or offload them to a RAMDisk for faster load? Something else?)
Question #2. Can I somehow reduce the time(out?) before Windows disconnects the devices after they have been unplugged (switched to another computer)? I'd prefer this to be as close to instant as possible.
Extra Info:
My setup is as follows (from computer to devices)
- USB 2.0 Port
- USB 1.X USB Switch
- USB 2.0, 4 Port Manhattan Powered USB Hub
- Corsair K95-RGB Keyboard (uses 2 USB Ports, one for extra power)
- Logitech G402 Hyperion Fury Mouse
- Wacom CTH-680 Tablet.
Tests:
I tested the same switch/hub setup on Linux and in the UEFI BIOS, none of the issues on Windows were observed (except that the keyboard and keyboard alone takes a few seconds to be re-detected by the ckb driver, what this means is that macro/extra keys don't work until after a few seconds on Linux for the keyboard. Otherwise everything works perfectly in <1s)
I decided to test plugging my mouse alone directly in since it's the easiest and on the first connect it exhibited a similar behavior of a roughly ~50 second wait before the mouse was usable (much of this time was again waiting for it to be detected and powered in the first place). If I repeated this test afterwards by unplugging the mouse and plugging it back in, it was instantly activated/usable, and similarly if I unplugged it then and plugged it into the already active USB hub, it was again instantly activated. But if I used the switch to turn the devices off/on it reverts to the same pattern as before. (Plug and play works best if you are not disconnecting/reconnecting an entire hub with several devices connected)
I tried switching the usb switch off of windows, waiting for Windows to disconnect the devices (~40s) and playing the device disconnect sound, at which point I switched back to windows, device detection was instant but driver load still took 15-20 seconds. (Wacom untested) mouse and keyboard become usable at the exact same time despite the keyboard driver being seemingly more complex and should probably be taking longer to load than the mouse (it's kind of like no device can work until all the devices connected to the hub have had their drivers loaded, may just be coincidence though).
I tried booting in safe mode (generic drivers only), in here the device disconnect still took ~40s but the driver activation after detection took <1s for the mouse and <5s for the keyboard (much faster than the ~17s for both; but in light of this I decided to re-test the activation time after detection for both devices after booting out of safe mode, and true enough, this time the keyboard took around 5 seconds longer than the mouse to load the drivers (mouse ~15s, keyboard ~20s).
I ran another test after uninstalling the Corsair Utility Engine (keyboard drivers) the keyboard did not initialize any faster (still took ~20s). After a restart, the keyboard would activate almost as fast as it did in safe mode. I then re-installed the Corsair Utility Engine and tried again, and with the corsair drivers active it was fast again. I rebooted, and things went back to the way they were before. I uninstalled the corsair utility engine again, and despite it being uninstalled, the keyboard does not initialize fast anymore. Further testing lead me to conclude that I can uninstall the corsair specific keyboard drivers and use the generic ones instead (with the corsair utility engine still running and activating the leds) and this gives me enough speed boost so that driver enablement takes 5s (mouse) and ~10s (keyboard), however this solution is not an option for me since it means my keyboard would not function correctly.
If you plug them directly into the PC, into the same ports the KVM is plugged into, does this behavior still exhibit itself? – Ramhound – 2016-04-13T17:23:34.170
@Ramhound I should probably clarify my setup, I have a USB (1.0) switch which I connected to a USB (2.0, 4 port, powered) hub which my devices (USB 2.0) are connected to. I decided to test plugging my mouse alone directly in since it's the easiest (keyboard uses 2 ports) and it exhibited a similar behavior of a roughly 40 second wait before the mouse was usable. I wouldn't be surprised if the duration this is taking windows is partly because it may be trying to first detect and activate the USB Hub before it goes on activating the HIDs I've got plugged into it (extending the time by like 20s) – Cestarian – 2016-04-13T17:30:14.580
Your keyboard uses 2 USB ports? Once you did this initial test, did you repeat the test, Windows is suppose to create a catalog of USB devices based on the port. – Ramhound – 2016-04-13T17:33:50.840
@Ramhound yes, I have a Corsair K95-RGB keyboard, it needs one port for power, one port for HID, the plugs are interchangeable (e.g. either one can act as input and power or just power based on the order in which they are plugged in) I did not repeat the test, but let me do so now... Yes, I plugged the mouse (this time into another port) and it was activated almost instantly this time (<2s).
Funny thing, afterwards I plug it back into the hub, and it is again activated almost instantly, we might be on to a solution... Or on the right path anyways. – Cestarian – 2016-04-13T17:40:00.603
@Ramhound I tried again switching the USB on and off via the switch, after plugging the mouse back in, but this time the mouse took just as long to activate as before (just as long as the keyboard). I notice that for the largest part of this duration though (e.g. the 38 seconds in my first post) the devices aren't even powered on, which must be the duration Windows is taking to detect and activate the Hub before it proceeds to the devices which are activating faster. – Cestarian – 2016-04-13T17:43:05.463
3I suspect the problem is the Switch itself not the keyboard and mouse. The delay is to be expected, but it sounds like, the switch is behaving like an entirely new device each time you switch between the connected PCs Alternative is very the problem with just the mouse, I suspect the keyboard, is causing the problems with relation to mouse taking 60 seconds to internalize. – Ramhound – 2016-04-13T17:47:11.340
@Ramhound this may be, but it sounds like a problem that could potentially be worked around somehow. I don't mind having a delay, just... preferably under 10 seconds. (Linux never gives me any delay, so it's not like it's impossible) – Cestarian – 2016-04-13T17:50:05.607
@Ramhound wait I actually noticed something just now. As I said earlier, more than half the time I wait the devices are powered off.This happens if I switch the devices off, then back on. However if I switch off, and wait for Windows to detect the device disconnect (i.e. make that "disconnect" sound notification) then turn back on, the devices power on (e.g. get detected) instantly leaving only the much more tolerable (but still kinda slow) 15-20 seconds for the driver to activate. Is there any way I can optimize this? (Make Windows detect USB disconnection faster?) – Cestarian – 2016-04-13T18:16:02.680
If you take this fancy keyboard with a processor out of the equation. Does anything change. I have concerns its either the switch itself or (now that I looked it up) the keyboard is causing the delay. If the mouse does not have a delay, with the switch, then you have confirmed the problem. – Ramhound – 2016-04-13T18:42:58.980
@Ramhound with the keyboard unplugged, the same test as above (i.e. quick off/on switch with the USB switch) took just upwards of 30 seconds with the mouse (and also a wacom tablet which is connected to the hubs 4th port, I have not tested it's detections speeds, it may be faster than the others) plugged keyboard back in, got a speed of roughly the same 55s as earlier, it seems that windows takes longer to detect the disconnect of the corsair keyboard which in turn adds a seemingly 20-25 second delay in this test scenario (minimal delay if the device disconnect already detected) 30s is 2 slow. – Cestarian – 2016-04-13T19:27:46.217
Try booting Windows in Safe mode, to see if this is caused by a third-party driver. – harrymc – 2016-04-16T12:51:00.160
@harrymc tried this, got very nice results for driver load time on the generic drivers (<1s for mouse <5s for keyboard, within a very acceptable range for me) but the device disconnect took just as long (~40s). Since the uefi bios only has generic drivers, that's probably why it has no problems, and I think Linux loads generic keyboard driver first for the keyboard before offloading it to my userspace driver (or the userspace driver interfaces with the generic keyboard driver) which would be why it activates so fast there as well. – Cestarian – 2016-04-16T16:40:52.757
Have a look at which drivers are installed for these devices. However, this can also be caused by some other installed third-party driver that is not connected to the KVM. – harrymc – 2016-04-16T17:17:48.407
@harrymc look how? The keyboard has the official drivers installed, mouse using generic drivers, wacom has no drivers installed yet. I have other HIDs plugged in though (always in) that is a logitech mx master and a razer blackwidow, they have drivers of their own. – Cestarian – 2016-04-16T18:14:55.090
You can see the driver of the problematic device(s) in Device Manager. If the performance in Safe mode is acceptable, this means that the device uses a third-party driver. Delete the driver from the computer to force using the Microsoft generic one. – harrymc – 2016-04-16T19:09:59.703
@harrymc that's tough... I have many HIDs plugged in, and all except for one (an unrelated one at that) have generic names in the device manager... – Cestarian – 2016-04-16T19:16:04.807
You do that only for the one or two problematic devices, not all the connected devices. See the article Using Device Manager to Uninstall Devices and Driver Packages where you want "Deleting a Driver Package from the Driver Store". Ensure you have the media for re-installing the 3rd-party driver in case of problems with the generic one.
– harrymc – 2016-04-16T19:24:11.510@harrymc It seems that only my keyboard has a specific driver, Mouse is using generic driver. I deleted it's driver successfully, the devices are initializing noticably faster (mouse less than 5s, keyboard 10s) but not as fast as in safe mode. I tried reinstalling driver after that, and (without reboot) it remains faster. – Cestarian – 2016-04-16T20:00:15.613
@harrymc It seems that only my keyboard has a specific driver, Mouse is using generic driver. I deleted it's driver successfully, the devices are initializing noticably faster (mouse less than 5s, keyboard 10s) but not as fast as in safe mode. I tried reinstalling driver after that, and (without reboot) it remains faster; however still uses generic drivers (as such keyboard extra keys do not work). So from this I think we can easily gather that my corsair keyboard drivers are taking a while to initialize and holding up the mouse while doing it. – Cestarian – 2016-04-16T20:08:33.397
Are you using the latest Corsair Utility Engine from March 2016? (Does this "engine" contain a driver?) You may also ask the Corsair’s Customer Service.
– harrymc – 2016-04-17T08:03:05.267@harrymc yes I am, yes it does and yeah I'll ask them (doubt I'll get much out of it though, this could just be bad code) – Cestarian – 2016-04-17T10:10:43.083
Until then, you could use the generic driver. For the special keys, you could use programs such as SharpKeys and/or AutoHotkey to map them to useful functions.
– harrymc – 2016-04-17T11:03:16.263@harrymc Corsair support was a bust, they said this "Please connect the keyboard directly to the computer as it is meant to." Not gonna buy products from those assholes again, I at the very least expect a more polite refusal of service than this... – Cestarian – 2016-04-18T23:40:09.693
Have you tried Disabling Searching Windows Update for Device Drivers? The option is in the Hardware tab of the System Properties window.
– Atoadaso – 2016-04-22T11:42:17.447@Atoadaso was already off. – Cestarian – 2016-04-22T18:35:14.257