Question about removing a USB controller.

Post Reply
rednecked_crake
Posts: 4
Joined: May 4th, 2020, 12:17 pm

Question about removing a USB controller.

Post by rednecked_crake »

This is a bit of a niche request, so I'd understand if no-one can really answer it.

I have 2 game controllers (one is an arcade stick using XInput, the other is a DualShock4). Because a lot of games require 'player 1' to be the controller, and because either the stick or the pad can randomly be assigned #1 or #2 when the PC is booted up, I have to unplug and replug either controller depending on what game I'm playing. It's a bit of a hassle, so I made a batch file that called on Devcon.exe and disabled one and enabled the other with just a click, until it stopped working.

Trying out this program, it works perfectly for disabling the DualShock4. But when trying to disable the arcade stick, it seems as though the DWM (dwm.exe) is hooking into it somehow and preventing it from being disabled. Any ideas for getting around this? Disabling DWM on Windows 10 isn't really feasible (and causes BSOD's from what I've read) and some googling just gives pages of results about Xbox and so on.

Great program either way, might just buy it just to disable the DualShock4. Cheers.
Attachments
1.png
1.png (3.63 KiB) Viewed 85070 times
2.png
2.png (16.12 KiB) Viewed 85070 times
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Re: Question about removing a USB controller.

Post by Igor »

Hi rednecked_crake,
Have you tried to use the "Forced Stop" button? If yes, and that didn't help, please send me the report from the program.

In order to send the report you should right click to the system tray icon of the program, choose Help -> Report a bug", and in the opened dialog enter your e-mail and a short description of the problem.
rednecked_crake
Posts: 4
Joined: May 4th, 2020, 12:17 pm

Re: Question about removing a USB controller.

Post by rednecked_crake »

Igor wrote: May 5th, 2020, 9:52 am Hi rednecked_crake,
Have you tried to use the "Forced Stop" button? If yes, and that didn't help, please send me the report from the program.

In order to send the report you should right click to the system tray icon of the program, choose Help -> Report a bug", and in the opened dialog enter your e-mail and a short description of the problem.
It does work, but it completely shuts off the Desktop Window Manager (dwm.exe) which I'd rather not do.

I did find a workaround, for anyone who ever stumbles on this with a google search. It looks like DWM hooks into any XInput device on startup, and won't let it be disabled normally. To get around it, you can go into device manager and disable the controllers directly. I just used a utility called DevManView and made a batch file;

Code: Select all


@ECHO OFF

echo.
echo Shutting down...
echo.

:: Disabling hitbox & arcade stick prior to shutdown.

F:\Apps\devmanview-x64\DevManView.exe /disable "USB\VID_1BAD&PID_F03A\114ADCAB"
F:\Apps\devmanview-x64\DevManView.exe /disable "USB\VID_2C22&PID_2303\8730F4EA"

:: Shutting down

shutdown.exe /s /t 00
If you then go into your Group Policy Editor (gpedit.exe), you can go to Windows Settings - Scripts - Shutdown, and have that batch file run whenever you shutdown or restart. Your controllers get disabled and DWM won't hook into them and stop them from being disabled, you can then pick what controller you want to use with a click on next bootup. I have 2 XInput controllers and a DualShock that doesn't get hooked by DWM (because it's a DirectInput device I'm guessing), so it's really neat that I don't have to keep reaching around the PC to swap out USB cables every day now.

I'll keep using this for a week or so to make sure there's no problems and then I'll buy it, cheers!
Attachments
Clipboard01.png
Clipboard01.png (13.79 KiB) Viewed 85059 times
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Re: Question about removing a USB controller.

Post by Igor »

rednecked_crake wrote: May 5th, 2020, 10:36 pm It does work, but it completely shuts off the Desktop Window Manager (dwm.exe) which I'd rather not do.
No, the Forced Stop doesn't shut off the processes. It just closes the file connections that a process made to the device. It's that same as if the device is disconnected. So I'd suggest you to try it and if that works you probably do not need the tricks you described. Besides with USB Safely Remove you do not need to use devcon at all, since you can disable (and then enable) a device directly in the menu. Just right click to the device and choose "Disable device":
2020-05-06_12-29-28.png
2020-05-06_12-29-28.png (16.42 KiB) Viewed 85054 times
rednecked_crake
Posts: 4
Joined: May 4th, 2020, 12:17 pm

Re: Question about removing a USB controller.

Post by rednecked_crake »

Hi, I tried to 'Force Stop' and right-click disable device, but I don't think either option does anything. I don't really want to try it with DWN again because it made my desktop flash a few times and Windows explorer didn't work properly afterwards, so I tested it with Steam (it also seems to hook into a controller like DWM does). It just shows this window over and over, I think it's trying to close Steam or the connection but it can't.

It's not a big deal, the batch file works fine really. I don't know if there's any way to close this file connection between an XInput controller and Steam or DWM otherwise.
Attachments
Clipboard01.png
Clipboard01.png (15.2 KiB) Viewed 85014 times
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Re: Question about removing a USB controller.

Post by Igor »

rednecked_crake wrote: May 6th, 2020, 10:53 pm I tested it with Steam (it also seems to hook into a controller like DWM does). It just shows this window over and over, I think it's trying to close Steam or the connection but it can't.
rednecked_crake, can you send us the report from the program so that I can investigate why the program cannot forcibly stop the Hitbox device?

In order to send the report you should right click to the system tray icon of the program, choose Help -> Report a bug", and in the opened dialog enter your e-mail and a short description of the problem.
rednecked_crake
Posts: 4
Joined: May 4th, 2020, 12:17 pm

Re: Question about removing a USB controller.

Post by rednecked_crake »

I sent the report.
User avatar
Igor
Developer
Posts: 602
Joined: Nov 1st, 2007, 12:44 pm
Location: Saint Petersburg
Contact:

Re: Question about removing a USB controller.

Post by Igor »

rednecked_crake, thank you!

I've investigated the log files and I can see that the program was able to successfully unlock dwm.exe and stop the device. steam.exe was also unlocked successfully but this program immediately opens a new connection to the device so that USB Safely Remove is not in time to stop the device. We will think what we can do with this in future, and now you if you need you can either add "steam.exe" to automatically terminate\restart the app before and after device removal or just terminate it manually from this dialog:

2020-05-08_18-54-21.png
2020-05-08_18-54-21.png (10.1 KiB) Viewed 84854 times
Post Reply