briankendall/devreorder

Shuffle order with the same VID and PID numbers devices

lesliehu16 opened this issue · 16 comments

Hi all,

First of all, I would like to thank you for sharing this amazing program. I did not have any issue at all until I used 4 joystick controllers with the same VID and PID.

The GUID stays in order but maybe when I restart my PC, whoever the joystick power up first will receive the first GUID in devreorder.ini and so on. That is why my joystick shuffles.

In act of desperation, I tried using Device Instance path enclosed with { } with no luck. I know its not included in the features yet but that is the only option I noticed which stays the same order no matter what.

Aside from my idea due to desperation, is there any other way to keep my joysticks in order? I'm using system wide setting by the way.

It doesn't surprise me that the device's GUID switches around. 😞 Those numbers are supposed to remain the same for a specific physical device, but Windows seems to get nearly everything wrong about how it orders controllers.

Adding a feature to devreorder that allows you to pick a device by its full instance ID would be a good idea for use cases like yours. If I have the time I'll see about adding it, though these days I barely have the time!

In the meantime, there is something you can do as a stopgap that might work. This method is what I used to reorder my controllers before I wrote devreorder:

What I did was I wrote a batch script that would run every time the system started up where it simulated unplugging and reconnecting my controllers. Since reconnecting the controller would cause it to jump up to the top of the order of DirectInput devices, it allowed me to keep everything in the right order, for the most part.

The batch script used the command devcon remove to remove any devices I wanted to move to the top of the list, then devcon rescan to force Windows to redetect and reinstall them. So you might try something like this:

devcon remove "< device instance ID of controller #4 >"
timeout /T 5
devcon rescan
devcon remove "< device instance ID of controller #3 >"
timeout /T 5
devcon rescan
devcon remove "< device instance ID of controller #2 >"
timeout /T 5
devcon rescan
devcon remove "< device instance ID of controller #1 >"
timeout /T 5
devcon rescan

You can use wildcard characters like * when writing out the device instance ID, but you might want to use the device's full ID. I'm not sure if five seconds is long enough to wait between removing and rescanning, but play around with it and see what works. If you can manage to get it to work when calling devcon remove for everything and then doing just one rescan afterwards, all the better.

The batch script needs to be run with elevated permissions. You can do this manually by running in an administrator command prompt, but if you want it to happen automatically, especially when Windows boots up, you can use a Scheduled Task with the "start a program" action and set it to run with the highest privileges.

The pitfalls of this approach though are that you're actually telling Windows to "uninstall" the devices rather than simply treating them like they were unplugged. Sometimes Windows gets into a state where it thinks it needs to reboot before the devices will work again. And sometimes it would still manage to get the devices in the wrong order. (In fact the whole reason I wrote devreorder is because I got fed up with this not working consistently!) But your use case is different than mine, so you might be able to finagle this into working for you.

I'll leave this issue open for now since the real solution would be adding support for device instance IDs to devreorder.

Hi briankendall,

Thank you for this very informative reply. I tried the script that you showed. So far so good, hope they won't shuffle anymore. The only downside to that which is very minor I believe is first, I need to wait before everything is done as I placed the batch script in windows startup folder and second is the ding sound, does not sound so neat as I'm polishing a dedicated Windows just for games. But this will do for now, I will keep my eye on any update to your program. Thanks again for the remedy. :)

I'm having exactly the same problem. It looks like devcon is not standard on windows anymore, but pnputil should work. Thank you Brian for the info, I think I can work around this now.

@briankendall - This project is so awesome; well done!
I would vote for adding a feature that allows you to pick a device by its full instance ID. I too am running into the issue where multiple controllers will use the same id depending on the order in which they are turned on (my controllers use bluetooth). With the ability to specify full instance IDs, I think this problem goes away entirely. Is this a relatively straight-forward feature or more complicated? I totally get the demands of time; I've had to push so many hobby projects to the backlog. I would be happy to pay for a resource on Upwork or similar to add this feature if you thought it was a relatively low lift and could provide some guidance that I could pass along. This is a space I am completely unfamiliar with. Thank you!

This would be a relatively straight forward feature so long as there's a reasonable way to get the full instance ID of a device given its DIDEVICEINSTANCE structure that's provided when enumerating DirectInput devices. Given that, I could set up a new format for specifying the instance ID in devreorder.ini (say putting the entry in parenthesis or something) so that it would know to compare to the instance ID. So far though I haven't found a way to get the full instance ID. There's surely a way to do it, but after some cursory searching I haven't found an answer.

Sounds good! I've posted a question on Stack Overflow hoping that someone there might be able to help, though I've been finding that site to be of limited usefulness lately. Do let me know if you find anything. I think that is the hardest aspect of implementing this feature.

Thanks for posting that; I was going to start with SO! Agreed; SO isn't what it used to be. Like why was this question downvoted?? Anyways, this might still be the best place for us to start. I upvoted and when enough time has passed (I think it's 2 days) I can add a fat bounty to the question and coordinate with you on which answer you think is the best. If we don't get traction using this route then I'll look for someone on Upwork.

I've placed a bounty on the question. Hopefully that'll get us closer to an answer. I'm not sure if it's possible to add to an existing bounty, but if it is feel free to do so.

You beat me to it! It doesn't look like I can add another bounty. Let's monitor and reassess based on answers.

I think I've figured out how to get at the devices' full instance ID. I'm going to try and make an experimental build of devreorder that allows ordering devices using that, but I'm insanely busy this month and I don't know when I'll have a chance to finish it. If I can't do it in the next week I might not have another chance until July. But I do intend to get to this without letting it languish much longer.

That's great news! I sincerely appreciate all the time you are putting into this.

Hi @briankendall ! Just checking-in to see if you've had some time to work on this?

Thanks for checking in. Sadly I've had very little time these last couple of months to work on it. I might be able to finally get something done in August though since my schedule will be more clear.

Appreciate it!

Hey @briankendall - Just checking-in on this...