   Dynamic DirectInput Controllers
  Ok, I'm doing some experimentation with handling controllers being removed during gameplay (by accident or whatever, I'm just trying to make my code robust).The way I'm dealing with this currently is by keeping track of all of the enumerated devices and then monitoring for WM_DEVICECHANGED messages. I then mark all of the devices as inactive and then re-enumerate, marking the remaining controllers as active, and adding any new ones to the list.All works lovely, except......I have 3 controllers, two of which are identical (two adaptiods, incidentally). Stupid DirectInput now has some questionable behaviour....now you would think that it would be easy to track which controller is which, given one of the members of the DIDEVICEINSTANCE structure is guidInstance, which is supposed to hold a unique GUID for the controller. Except it doesn't.It helpfully has a GUID for the first controller it finds, and then another one for the second controller it finds, and so on.So if you unplug controller one and mark it as inactive, the program dies, because of course, controller two is now controller one. Even stranger, if i swap a single controller between USB ports, it picks it up again ok (it will think its the same controller due to the silly GUID problem above), but will fail acquistion attempts with DIERR_UNPLUGGED. Which makes sense, but if it knows its in a different port, why can't it give controllers unique GUIDs? Grrr. Another annoyance....acording to MSDN, WM_DEVICECHANGED signals the application should rebuild its device lists, as some hardware has changed. So I dilligently rebuild my lists...but it sends me the message 3 times, one after the other, and all with identical w and l Params....why? - All this means is that I have to rebuild my list three times or code around this unspecified behaviour (and I think coding to something not guarenteed to stay consistent is bad, mmmkay?).Oh, well. Just a rant at some things that have been bugging me for a few days now. Any advice is appreciated, but I guss I'll just have to abandon this scheme.[edit] Just tidying up some typs and clarifying things [/edit][edited by - mr_jrt on February 4, 2004 8:12:25 PM]
  Ok, another angle on this then.How are you people handling identification of multiple controllers on a PC? I know there''s the tried-and-true system of monitor all the controllers and "player n push a button" to identify....but there surely must be a better way... 