1
\$\begingroup\$

As there is more choice in DPDT switches than there is for 4PDT switches I am wondering which TWO connections are the best to disconnect to disable a USB mouse?

I need an easy to use switch that allows the mouse to be 'disconnected' without pulling the USB connector out of a laptop so I want to use a DPDT rocker or paddle switch.

From what I have found so far the pin-out is:

  1. VCC (+5V)
  2. Data -ve
  3. Data +ve
  4. GND

If my switch only allows two of these to be disconnected is it better/safer to disconnect both data lines, both power lines or one of each?

(Note: I've attempted to do the disabling programmatically in Windows but unfortunately Windows APIs identify the multiple input devices on the machine all as 'Generic HID' (Human Input Device) so it's not easy to determine the correct one to disable.)

(Note 2 - added in response to some comments and answers: The reason for this question is that I need to supply a solution to a user in a user-friendly manner. To this end registry hacks, Device Manager etc are not user-friendly enough. A simple toggle switch is easy to understand and, so long as it doesn't fry the MoBo or the USB hub, then is safer than sending a user into system settings.)

\$\endgroup\$
  • \$\begingroup\$ Simple question - why would you want to do this? \$\endgroup\$ – Andy aka Jan 5 '17 at 15:43
  • \$\begingroup\$ Also, even if it's a 'Generic HID' in Windows, it will likely have a unique manufacturer/device ID that you can use instead, assuming you want to disable the same mouse every time. \$\endgroup\$ – Shamtam Jan 5 '17 at 15:51
  • 2
    \$\begingroup\$ @Andyaka It's an odd one. A user with a physical mouse and a 'head-mouse' (actually a tracking webcam that presents to the OS as a generic mouse) wants to be able to temporarily disable the head-mouse in order to use the physical mouse. Unfortunately as the head-mouse presents as a generic mouse to the OS and just uses the generic mouse driver (quite clever in that sense) there is no way to distinguish the two that I can find. \$\endgroup\$ – Fat Monk Jan 5 '17 at 16:04
  • \$\begingroup\$ In windows you can disable it in device manager. In Linux you can show and disable it using xinput command. Or you can get a usb hub with VBUS switch. \$\endgroup\$ – user3528438 Feb 8 '17 at 13:24
  • \$\begingroup\$ I'd think disconnecting Vcc alone would do the trick, but why not just use a usb hub such as this (amazon.com/Sabrent-4-Port-Individual-Switches-HB-UMLS/dp/…) with a built in switch rather than building your own switch? \$\endgroup\$ – ks0ze Feb 8 '17 at 17:44
5
\$\begingroup\$

My first reflex was to say that you should disconnect D+ and D- lines. Leaving VCC and GND connected is obviously safe for both the mouse and the host: VCC and GND leads in USB connectors are even made longer to insure this safe state is reached before D+ and D- are connected.

However, disconnecting VCC alone may be enough, and even if not, it should at least be safe. Take a look at this figure from USB specification:

enter image description here

The host will only communicate with the device when it sees D- line pulled up. However, once VCC is disconnected, Rpu is effectively eliminated from the circuit, leaving both D+ and D- at ground potential. As a result, no further communication will take place.

Once you reconnect the VCC line, the host will again see D- line pulled high, and will react as if a new USB device was just plugged in. In the best case, your mouse will just work. In the unlikely worst case scenario, the mouse won't have enough time to initialize (since normally VCC is connected before D- and the device has more time to start) and will fail to reply to the host within the allotted time. In that case, you'll have to keep VCC and GND connected and put a DPST switch on D+ and D-.

\$\endgroup\$
  • \$\begingroup\$ I do not think that separating the D- and D+ is a usefull method. In my case this results in the detection of an unknown device in Windows. \$\endgroup\$ – auoa Feb 8 '17 at 17:57
  • 2
    \$\begingroup\$ @auoa Could you provide details? According to USB spec, this should not happen. I also own a charge cable (without D+/D- lines), and Windows says nothing when I connect a phone to it. \$\endgroup\$ – Dmitry Grigoryev Mar 8 '17 at 12:05
  • 1
    \$\begingroup\$ @DmitryGrigoryev I presume that the problem is that abruptly disconnecting the data lines without disconnecting power leaves the slave end in a weird state, and reconnecting them without power cycling results in an incorrect response from the slave. \$\endgroup\$ – jms Mar 10 '17 at 16:55
1
\$\begingroup\$

The safest way is to disconnect the Vbus line. This powers off the device but keeps the Ground connected for RFI shielding and ESD protection.

If the ground is disconnected then the mouse becomes an antenna connected to the D+ and D- lines radiating as the host initiates a USB training sequence.

There is no problem if the data lines are connected as long as the ground is not disconnected all USB PHYs are designed for this because some devices are not bus powered. But there is a problem if the Vbus line is connected while the ground is disconnected because the data lines D+ and D- have ESD devices connected to the substrate in the die and this may originate latch-up or stress the ESD devices above the specifications.

\$\endgroup\$
  • 1
    \$\begingroup\$ A comment from @kbro on this reply electronics.stackexchange.com/a/55447/135081 to another post suggests that leaving D+ and D- connected while VCC is connected is not a good idea... \$\endgroup\$ – Fat Monk Jan 5 '17 at 17:20
  • \$\begingroup\$ @FatMonk. That post makes no sense at all. If you connect an externally powered USB hub or device to a computer you can either plug in the power supply or not ..in the case of a Hub it'll still work ..and it won't under any circumstances damage the PC. It may shutdown because you draw too much current from the upstream port but there is no likelihood of damage. If you do plug in the power supply then the standard says you need to control current feedback to the upstream host. ....again, no damage. \$\endgroup\$ – Jack Creasey Jan 6 '17 at 0:21
0
\$\begingroup\$

As Tony Stewart commented you can use the registry directly ....you can use Device manager to find the VID/PID for the particular mouse: enter image description here

You can also just manually disable the mouse directly in Device Manager by right clicking and 'Disable' the device or run a Regedit macro, WMI or Powershell script to toggle the registry values.

\$\endgroup\$
-2
\$\begingroup\$

Probably most reliable if you disconnect VCC and GND. Putting a switch in the D+/- lines may interfere with their operation.

For the programmatic approach, it ought to say "Mouse" somewhere in the WMI information, or alternatively if you can get hold of its HID descriptor table you can find out what a device really is.

\$\endgroup\$
  • \$\begingroup\$ Yup, the WMI info identifies it as a mouse, but identically to the other real mouse on the system. If it was always guaranteed to be plugged into the same USB socket I could possibly use that address info, but I don't want to have to rely on that. \$\endgroup\$ – Fat Monk Jan 5 '17 at 16:06
  • 4
    \$\begingroup\$ @pjc50. Disconnecting both VCC and Ground while leaving D+/- connected is a nightmare static scenario....don't do it. If you must disconnected anything....disconnect VCC only. Look at the connectors for the vast majority of USB cables and you will see the VCC and Ground connect first for the very same reason. \$\endgroup\$ – Jack Creasey Jan 5 '17 at 16:17
  • \$\begingroup\$ @FatMonk What control methods are easy to do for you? Software script switch? Hardware toggle switch? USB devices connect power first before data to avoid latchup and disconnect data first before power for similar reasons. So USB data disconnect is the logical choice and for a USB1 speed device, not too hard. \$\endgroup\$ – Sunnyskyguy EE75 Jan 5 '17 at 16:23
  • \$\begingroup\$ To disable the mouse all you need to know is the USB port number. Disable the port and you disable the mouse. Read up on scripts to deactivate devices or Local Group Policy. \$\endgroup\$ – Jack Creasey Jan 5 '17 at 16:27
  • \$\begingroup\$ @JackCreasey I cannot guarantee that the device will always be plugged into the same USB port every time / all of the time so using the port number is not an option unfortunately. \$\endgroup\$ – Fat Monk Jan 5 '17 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.